<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Patrick Pichler on Medium]]></title>
        <description><![CDATA[Stories by Patrick Pichler on Medium]]></description>
        <link>https://medium.com/@patrickpichler?source=rss-73a93ddc5720------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*atNQacDa1DCtqvuPqBK7Hw.jpeg</url>
            <title>Stories by Patrick Pichler on Medium</title>
            <link>https://medium.com/@patrickpichler?source=rss-73a93ddc5720------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:33:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patrickpichler/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[3 Typical Misconceptions About Developing LLM Applications]]></title>
            <link>https://medium.com/creative-data/3-typical-misconceptions-about-developing-llm-applications-60fa746847a7?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/60fa746847a7</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 08:08:48 GMT</pubDate>
            <atom:updated>2024-10-29T08:09:36.011Z</atom:updated>
            <content:encoded><![CDATA[<p>Clearing up three common misunderstandings to help you build successful LLM applications</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C0dS_OjlsCJRntaN" /><figcaption>Photo by <a href="https://unsplash.com/@omilaev?utm_source=medium&amp;utm_medium=referral">Igor Omilaev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The realm of Artificial Intelligence has reached a new era thanks to the latest developments in GenAI including LLMs. It’s a complete game-changer for many traditional approaches to applying Artificial Intelligence, whether it’s about making recommendation systems smarter, anomaly detection easier or synthetic data generation more realistic.</p><p>Nevertheless, the most common scenario for implementing LLM applications within organizations might involve intelligent agents to improve and automate business processes and decision making. Next, I would like to list three very common misconceptions I have encountered recently while designing and developing LLM applications.</p><h3><strong>Misconceptions</strong></h3><p>The following misconceptions are coming directly from practice by talking to different professionals across sectors and business domains.</p><h4><strong>1. We need to hire a Data Scientist</strong></h4><p><strong>WRONG</strong>.</p><p>This is probably the most common misconception. While it’s definitely true that Data Scientists and Deep Learning practitioners possess the most knowledge of how things work under the hood of LLMs, they are not strictly necessary to develop LLM applications. I would even say that, in most cases, applying proper software and data engineering practices to ensure the long-term success of an LLM application is more important than understanding the details of the LLM’s internals. They are already very advanced and we now have frameworks like LangChain and LlamaIndex that make developing LLM applications highly accessible. Yes, of course, it doesn’t hurt to know more about tokenizers, prompting, or the transformer architecture in general that has driven the significant advancements in GenAI, but it’s not required. You could say the same about using a data processing framework, it’s not necessary to understand the exact details of the query execution engine, though it can be helpful.</p><h4><strong>2. We need to retrain the model to incorporate our own data</strong></h4><p><strong>WRONG.</strong></p><p>I keep hearing that we don’t have access to the necessary computational resources to develop LLM applications or that it takes hours or even days to fine-tune pre-trained LLMs for incorporating our own data. I believe there seems to be a lack of knowledge about alternatives, especially RAG systems which allow you to integrate “external” data without retraining a model. RAG stands for “Retrieval Augmented Generation” and in simple terms, it works by storing your data in a vector database that searches for similar information based on the user query. The database searches and returns relevant data which are then given as context to your LLM together with the user’s original question. In most scenarios, the results are even better when using RAG systems as opposed to retraining LLMs. This is because by feeding the data directly into the conversation, the context for the LLM is very clear and specific resulting in increased accuracy and reduced hallucinations in the response. Apart from that, it’s very easy to keep data up-to-date.</p><h4>3. We need to deploy a dedicated back-end.</h4><p><strong>WRONG.</strong></p><p>Just to clarify, I am not referring to the LLM endpoint hosting the LLM here, but rather the surrounding application built around it. This is where most of the logic resides and ultimately makes LLMs so versatile and powerful, opening a wide range of applications across industries and use cases. As already mentioned, building such applications is now streamlined with advanced frameworks, especially the comprehensive LangChain ecosystem. Initially, it started to just simplify basic LLM interactions by abstracting logic and integrating with several technologies. Nowadays, the integration of tools and technologies is endless allowing for the creation of complex and robust agents including testing and monitoring capabilities, thanks to extensions like LangGraph and LangSmith. This makes LangChain a robust suite for building end-to-end LLM applications in both Python and JavaScript/TypeScript. This is also the key point here, it also supports building client-side applications, allowing sophisticated operations and agent processing directly in the browser with in-memory executions, all without a dedicated back-end.</p><h3>Conclusion</h3><p>The GenAI wave has undoubtedly elevated business automation and decision-support systems to the next level. LLM applications are highly versatile and can autonomously handle even very complex tasks. However, it’s important to supervise these applications initially as adjustments are often necessary. In many cases, using proper prompt templates can make a significant difference. Additionally, ethical and compliance considerations should be kept in mind throughout their deployment. The power of LLMs can also be directly integrated into data management and processing systems. Several platforms already offer extensions and functionalities that make this integration seamless such as <a href="https://github.com/pgvector/pgvector">open-source vector similarity search for Postgres</a> or <a href="http://built-in SQL functions for GenAI on Databricks">built-in SQL functions for GenAI on Databricks</a>. It will be exciting to see how Business Intelligence and Artificial Intelligence concepts continue to merge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60fa746847a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/3-typical-misconceptions-about-developing-llm-applications-60fa746847a7">3 Typical Misconceptions About Developing LLM Applications</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Warehouse (Polaris) vs. Data Lakehouse (Spark) in Microsoft Fabric]]></title>
            <link>https://medium.com/creative-data/data-warehouse-polaris-vs-data-lakehouse-spark-in-microsoft-fabric-37bd65525def?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/37bd65525def</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[microsoft-fabric]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 08:29:47 GMT</pubDate>
            <atom:updated>2023-11-09T08:35:57.938Z</atom:updated>
            <content:encoded><![CDATA[<p>A comparison from a data architecture and workload perspective</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ec1VkEa_HX0lR0-g" /><figcaption>Photo by <a href="https://unsplash.com/@patmcmanaman?utm_source=medium&amp;utm_medium=referral">Patrick McManaman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Introduction</strong></h3><p>It’s not a secret, the most part of Microsoft Fabric is a re-branding centered around Azure Synapse Analytics and Power BI. Numerous existing services have now been seamlessly consolidated, offering users a unified and streamlined experience. However, in addition to this powerful re-branding initiative, there have also been introduced some exciting enhancements and new features. One of it is the re-architecture of the SQL distributed engine <strong><em>Polaris</em></strong> powering the <strong><em>Fabric Data Warehouse</em></strong>. It now allows to fully operate on the <em>Delta</em> format stored in a Data Lake (OneLake on ADFS). As such, it’s the first engine providing full ACID compliant transactional workloads on top of an open table format, which is truly kind of revolutionary.</p><p>But wait, isn’t that what the Data Lakehouse architecture has been claiming for years and what’s actually the difference to the <strong><em>Fabric Data Lakehouse</em></strong> offering? It also operates on the same storage system and open table format? Why are there two offerings in the first place and which one should I choose?</p><p>This is exactly where this article will shed some light on. It also highlights the importance of focusing on data workloads when choosing between one over the other, not only personas and skill-sets.</p><blockquote>Don’t opt for the Data Warehouse just because your data team is only familiar with SQL.</blockquote><h3>Fabric Data Warehouse vs. Data Lakehouse</h3><p>To begin with, many available resources place significant emphasis on personas and skill sets when comparing the two offerings, also the high-level <a href="https://learn.microsoft.com/en-us/fabric/get-started/decision-guide-warehouse-lakehouse">decision guide</a> by Microsoft, which provides an excellent first overview though. However, while expertise is undeniably important and should factor into your decision-making, it should not overshadow the primary objective: establishing a robust and sustainable data architecture that guarantees data quality and aligns with internal SLAs. For this reason, it’s essential to compare the two offerings from a more data workload perspective and analyze the technological shortcomings and benefits of each tool. By doing this, most of it ultimately boils down to the computing engines used behind the scenes. This is Microsoft’s proprietary engine<strong><em> Polari</em></strong>s powering the<strong><em> Data Warehous</em></strong>e and the open-source<strong><em> Spar</em></strong>k engine is leveraged by the<strong><em> Data Lakehous</em></strong>e, possibly with some slight modifications by Microsoft. Comparing these underlying computing engines, gives you a better understanding of how each offering handles data workloads, what scalability and performance characteristics they offer, and how well they align with your specific use cases and requirements.</p><h3>POLARIS — Data Warehouse</h3><p>Let’s start with the Polaris distributed engine that has already been around for several years. In fact, it has been powering the Azure Synapse Analytics Serverless SQL Pool since the beginning. The roots of it might even go back to SQL Server 2016 when Microsoft began offering the data virtualization technology PolyBase. It was the first Microsoft proprietary technology that allowed to query data from files and object stores based on metadata definitions such as OPENROWSET. This was also the beginning of bringing data warehousing and big data workloads closer together. Though, until now, everything in Polaris worked in a kind of schema-on-read fashion, meaning you couldn’t WRITE data.</p><p>This has changed now, the Polaris engine has been re-architectured from the ground up to also support the above mentioned ACID compliant transactional workloads. It got enhanced by integrating the best of the Azure Synapse Analytics Dedicated SQL pool engine as well as SQL Server. This allows you to write T-SQL code containing multiple read/write statements across multiple <em>Delta</em> tables without fearing to introduce data inconsistency. Behind the scenes, it makes usage of ROLLBACK and COMMIT just like atomic transactions in relational databases, everything is either committed or rolled back in case of an error. The tables stored in the Data Warehouse can further only be MODIFIED by Polaris, not any other external tool or process, not even by yourself via the file system. It’s totally locked up to not corrupt any data, giving you a kind of more relational database feeling, even though you can have a look on the Delta table structure in the file system. It’s also technically possible to READ this data outside of the Data Warehouse by using any other tool supporting Delta format such as the<strong><em> </em></strong>Fabric Data Lakehouse<strong><em>.</em></strong></p><p>All these characteristics make the Data Warehouse a perfect fit for typical batch-oriented data warehousing workloads accommodated in Stored Procedures, requiring robustness and full ACID transactional guarantees. In this regard, you nowadays also often hear the term <em>multi-statement transaction</em> or <em>multi-table transaction</em>, also mentioned in the Microsoft documentation. This got somehow introduced with the Data Lakehouse architecture and open table formats, but it’s basically nothing more than the “A” in ACID standing for Atomicity, read more <a href="https://learn.microsoft.com/en-us/azure/databricks/lakehouse/acid">here</a> and in the next section. As the final point, POLARIS has also proven to outperform the SPARK engine in both reading and writing data, even though both engines leverage the V-ORDER compaction by default. Caution though, at the time of this writing, the Data Warehouse provides limited T-SQL functionality and certain T-SQL commands can cause warehouse corruption, read more <a href="https://learn.microsoft.com/en-us/fabric/data-warehouse/limitations">here</a>. Further, table constraints such as Primary or Foreign Keys cannot be enforced, they might just result in a better execution plan but don’t guarantee uniqueness or data integrity, read more <a href="https://learn.microsoft.com/en-us/fabric/data-warehouse/table-constraints">here</a>.</p><h4>Common scenario</h4><p>A very typical use-case for utilizing the Data Warehouse could involve the integration of just one or possibly two data sources from databases or cloud services at relatively small scale with infrequent data updates. In such a scenario, the Data Factory offers lots of built-in connectors allowing you to ingest data with ease directly in to the Data Warehouse “<em>Data Staging</em>” layer, potentially into a separate schema. Subsequently, still within this layer, you would normally merge the new data with the existing one and possibly establish historical records while maintaining the integrity of your raw data. This staging area should be a consistent layer from where you should always be able to recreate the entire logic downstream — requirements will definitely change over time. Moving forward, you would normally enrich and cleanse your data in the same step as you bring it into an analytical data model, the “<em>Data Warehouse</em>” layer. This is supposed to be a consolidated and permanent storage area for data in a rather denormalized format with most of the business logic already applied. Finally, you would proceed with creating business-ready views in your “<em>Data Marts</em>” layer, incorporating relevant security access measures and maybe even more business logic. In some cases, you might want to materialize the data into this last layer depending on the requirements.</p><figure><img alt="Data Warehouse in Microsoft Fabric" src="https://cdn-images-1.medium.com/max/747/1*5okyYURoRkezG98AEdTtdQ.png" /><figcaption>Image by Author</figcaption></figure><h4><strong>SPARK — Data Lakehouse</strong></h4><p>Let’s now switch over to the Spark engine behind the Fabric Data Lakehouse. It’s essentially the same as for Azure Synapse Analytics with the difference of having the key performance features turned on by default, especially with regards to Delta format and V-Order. It also auto-compacts when writing data, meaning no difference to the Data Warehouse in terms of storage format and structure. However, it is crucial to note that the desired level of Atomicity mentioned above is not entirely guaranteed within the Data Lakehouse when writing data, as one might typically expect. In fact, it’s also not supported by any other Spark-backed service available at the time of this writing, including Databricks. In these scenarios, transactions are solely managed at a table level, and the grouping of multiple operations into a single transaction is not possible. Consequently, these operations will always be committed in a serial fashion, completely separated from each other, even if they are written within a single SQL-based notebook cell and may appear as a single transaction. The only way to combine inserts, updates, and deletes into a single transaction is using the MERGE statement.</p><p>All right, now let’s set aside the negative aspects of Spark. Spark’s ecosystem is tremendous and it’s growing every day. You gain access to different programming languages (most importantly Python and R) along with their extensive list of libraries, and you can seamlessly blend them together with SQL. Additionally, Spark offers robust capabilities for data streaming and machine learning, one of the main reason for the DATA LAKEHOUSE classification as opposed to DATA WAREHOUSE. You can effortlessly transition between batch and streaming modes, and the MLflow integration gives you access to the industry-standard platform for managing complete machine learning lifecycles (MLOps). Spark has also proven to be production-ready over the last couple of years, especially in very large-scale scenarios. The Fabric Data Lakehouse further enhances data integration with so-called <a href="https://learn.microsoft.com/en-us/fabric/onelake/onelake-shortcuts">OneLake shortcuts</a>, complementing the already vast amount of Spark’s built-in connections, which brings me to the integration of Spark into the Fabric UI in general. It is very well done, especially the <a href="https://learn.microsoft.com/en-us/fabric/data-engineering/navigate-lakehouse-explorer">Lakehouse explorer</a>. It allows you navigate and preview your tables as well as files in the same view, streamlining the entire development process. It also scans your files and creates Delta tables automatically for you, known as <a href="https://learn.microsoft.com/en-us/fabric/data-engineering/lakehouse-overview#automatic-table-discovery-and-registration">automatic table discovery and registration</a>. Finally, you can query your Data Lakehouse tables either using the <a href="https://learn.microsoft.com/en-us/fabric/data-engineering/lakehouse-sql-endpoint">SQL endpoint</a> (exposed with a little <a href="https://learn.microsoft.com/en-us/fabric/data-warehouse/data-warehousing#automatically-generated-schema-in-the-sql-endpoint-of-the-lakehouse">delay</a>) or the <a href="https://learn.microsoft.com/en-us/power-bi/enterprise/directlake-overview">Direct Lake</a> mode (only supported by Data Lakehouse tables at the time of this writing). Former is backed by POLARIS giving you an improved read-performance compared to SPARK including advanced access control such as RLS. On the other hand, the latter is Power BI querying the Delta tables (parquet files) directly from the data lake giving you even more performance and also access to the most current data.</p><h4>Common scenario</h4><p>Considering all these factors, you should opt for the Data Lakehouse when your use-case requires more than just basic reporting and once-per night batch job. It allows you to write the most complex ETLs, switching seamlessly between streaming and batch mode, and tackle even the most advanced analytics use-cases, although it may pose some additional challenges in ensuring complete data accuracy. A typical use-case involves the Apache Spark Structured Streaming API alongside a dedicated “<em>Landing Zone</em>”. This design achieves a critical separation of concerns, effectively decoupling data integration from data processing. It gives you a unified, scalable, and central entry point for data arriving from diverse sources, including IoT devices, applications, databases, and other external systems. The Structured Streaming API then takes charge of managing incoming data stored in various file formats, including Delta tables. It incorporates an automated check-pointing mechanism with multiple trigger options. This flexibility empowers you to execute the same data pipeline, whether it’s coded in Python, SQL, or another language, in either streaming or batch mode. Think of it as a fault-tolerant data pipeline with built-in Change Data Capture (Delta CDF) that runs in the background or can be triggered at any time. Additionally, you can achieve nearly real-time analytics by using the Direct Lake mode or Power BI’s push dataset, in addition to the SQL endpoint.”</p><figure><img alt="Data Lakehouse in Microsoft Fabric" src="https://cdn-images-1.medium.com/max/890/1*G9DZz_HCQ3VnTiXTKmM8iw.png" /><figcaption>Image by Author</figcaption></figure><h3>Better together</h3><p>Well, now let’s just put two and two together. What if you want to combine both, providing near real-time analytics and machine learning functionality while ensuring the highest data accuracy, even involving numerous multi-statement transactions? In this case, your architectural blueprint would resemble the following. The only change here is the final step, transitioning from the SPARK engine to the POLARIS engine, which enables this enhanced robustness and transactional guarantees while maintaining the flexibility and scalability in the data integration process by using the SPARK engine. Of course, you might want to extend this architecture and also include the Data Factory for some parts of the data ingestion.</p><figure><img alt="Blending Data Warehouse and Data Lakehouse in Microsoft Fabric" src="https://cdn-images-1.medium.com/max/890/1*xR2JP7vALz7SfZGGGOtKiw.png" /><figcaption>Image by Author</figcaption></figure><h3>Conclusion</h3><p>In conclusion, I hope this article made its point that both engines have their benefits and that’s important to not get off the wrong foot when starting with Fabric. Otherwise, a migration or redesgin is just a matter of time. Therefore, opting for the Data Warehouse just because your data team is only familiar with SQL might not be the best approach. In fact, you can develop data pipelines in Spark with up to 90% of the code written in SQL. Besides, what’s wrong about learning a little bit of Python (PySpark) as it seems to accompany us for a very long time in our data and analytics journey. In the end, to maximize the potential of Fabric, a hybrid approach that combines the Data Warehouse and Data Lakehouse is likely the most effective solution. Moreover, we can even hope for seeing a unification of these two offerings soon, possibly with Polaris serving as a plug-in query execution engine for Spark.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37bd65525def" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/data-warehouse-polaris-vs-data-lakehouse-spark-in-microsoft-fabric-37bd65525def">Data Warehouse (Polaris) vs. Data Lakehouse (Spark) in Microsoft Fabric</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Headless BI vs. Self-service BI]]></title>
            <link>https://medium.com/creative-data/headless-power-bi-d48df653fac8?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/d48df653fac8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Tue, 10 Jan 2023 14:16:41 GMT</pubDate>
            <atom:updated>2023-03-06T09:16:24.287Z</atom:updated>
            <content:encoded><![CDATA[<p>Brief introduction to Headless BI and putting Power BI into its context</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ShM9H_57xuFz0LWP" /><figcaption>Photo by <a href="https://unsplash.com/es/@egorikftp?utm_source=medium&amp;utm_medium=referral">Yahor Urbanovich</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Over the last couple of years, we have seen various new terms and inventions coming up around data and analytics, Headless BI is doubtlessly one of them.</p><p>In this article, we will first briefly explore what Headless BI is all about followed by the conceptual comparison to self-service BI. In particular, we will check whether Power BI meets the requirements of the Headless BI category and when it’s better to choose one over the other.</p><h3><strong>Headless BI</strong></h3><p>To start with, Headless BI is essentially an architectural style that decouples your persistent backend storage, be it a database or data lake, from your user-facing frontend to consume data. The main idea here is to create a loosely coupled layer in-between that gives you access to all information incorporated into a single abstracted data model representing the business/use-case without being tied to any specific frontend. Instead, this so-called <strong>semantic layer </strong>is getting exposed via a rich set of <strong>standardized interfaces and protocols</strong> — making it “headless”. The primary focus is hence totally on data delivery by providing fast and easy access to a curated single source of truth rather than on any kind of data visualization. This data delivery usually consists of standardized dimensions, metrics, hierarchies, KPIs and includes features such as data access control (RLS), aggregation capabilities, caching mechanisms, etc.</p><p>In terms of use-cases, Headless BI gets very often mentioned in the context of <strong>embedded analytics</strong>. This has also always been the primary objective of one of the today’s most popular Headless BI technologies, called <a href="https://github.com/cube-js/cube.js"><em>Cube</em></a><em>, </em>which we will also use as a kind of benchmark throughout this article. <em>Cube</em> was initially even written entirely in JavaScript, THE programming language for building interactive web applications. Though, nowadays, lots of code has been rewritten in Rust, also to expand its functionalities towards the connection of self-service BI tools such as Power BI or Tableau. Anyway, its rich connectivity together with the seamless integration with modern development languages and frameworks (SDKs), makes it quite easy to embed analytics natively into (web) applications. Besides easing this embedding process, its centralized concept further ensures data consistency across multiple applications. Another very popular use-case is <strong>real-time</strong> <strong>analytics. </strong>Headless BI tools tend to facilitate the combination of streaming and batch data at query processing time, apart from mechanisms to automatically update the frontend with the most current data available.</p><h4>Traditional BI</h4><p>Now, if especially this decoupled central semantic layer concept of Headless BI sounds familiar to you, then you have probably been in touch with traditional BI architectures based on <strong>OLAP</strong> (cube)<strong> </strong>technologies such as Microsoft Analysis Services or IBM Cognos. While their centralized idea is truly very similar, those OLAP technologies use to come with its own analytical engines which are mostly limited to a few interfaces and frontends while Headless BI seeks to provide a kind of universal access without any dependencies.</p><p>However, this centralized semantic layer approach changed anyway quite a bit with the rise of <strong>self-service BI </strong>tools as the next generation back then. The semantic layer including the dedicated analytical engines started to get tightly coupled with the visualization layer. A trend which could be now a potential driver for the today’s popularity of Headless BI? Let’s find out.</p><h3><strong>Power BI</strong></h3><p>First things first — Power BI obviously falls under the category of self-service BI tools. It has everything you need for conducting BI packed into one single tool, even data integration capabilities. At first sight, this sounds indeed very tempting and organizations increasingly started to adopt such self-service BI tools to be more flexible and agile for new requirements rather than depending on central IT departments. Business users themselves were suddenly enabled to build and design their own reports including the semantic layer behind it or at least some parts of it. Of course, such a decentralized approach allows single domains to move much faster, but it also requires a set of rules to follow together with a certain sense of responsibility, otherwise things can get chaotic very quickly. A falling data quality is often just a matter of time due to emerging data inconsistencies and different interpretations or definitions. In the end, the decision-making process might be faster but also better?</p><p>Probably not, but anyway, here is the point, with Power BI you can still stick to the central semantic layer concept similar to the idea of Traditional and Headless BI architectures. You just need to follow a commonly known architectural development concept called <strong>Power BI Shared Datasets. </strong>In practice, this simply means to not always publish a new dataset attached to the report, but instead, you centrally host well-designed pre-built datasets with just empty reports attached. Business users can then live connect to these datasets and build multiple reports on top of them by always reusing the same semantics. This way, your Power BI reports (visualization layer) are totally decoupled from your Power BI dataset (semantic layer) which also makes your semantic layer basically “headless”. Nevertheless, even by following this development concept, it’s still often difficult to totally prevent users to create their own datasets (semantic layer) just because of the nature of how self-service BI tools work. That’s why you further have the option to certify and promote Power BI datasets. While <em>certifying</em> helps to highlight high quality content meeting organization’s standards, <em>promoting</em> datasets allows users to mark datasets as being valuable on their own.</p><p>All right, so far so good, but does this now mean that Power BI meets all the requirements of a Headless BI tool just because you can uphold the idea of this central semantic data model?</p><h4><strong>Headless Power BI</strong></h4><p>Not quite, since the main point of Headless BI is actually to be frontend-agnostic by providing universal compatibility for integrating with any tool or framework through easy query formats and a broad range of standardized APIs such as SQL, REST, GraphQL, WebSockets, etc. This is where Power BI cannot keep pace, it just supports the SOAP-based XMLA interface including a REST API for executing DAX queries. This REST API even comes with some throttling and size limitations if you are not using Power BI Premium. For this reason, its difficult to query the semantic layer of Power BI for rendering query results natively within (web) applications, instead you would rather end up embedding Power BI content directly (reports or tiles). This would also support real-time scenarios in case of embedding content based on Power BI real-time datasets. However, this embedding functionality not only comes with extra costs (Power BI Embedded or Power BI Premium) but also causes typical iframe usability issues making the entire look and feel kind of odd compared to a native integration.</p><p>At this point, it needs to be mentioned that we have just discussed arguments in favor of using a Headless BI tool compared to Power BI, but not the other way around. The capabilities of Power BI are tremendous and it is arguably the best self-service BI tool on the today’s market. For instance, just by comparing the performance for processing and returning query results, then the Power BI’s integrated <em>VertiPaq</em> engine is almost unbeatable. Headless BI tools, on the other hand, pass queries on the backend for processing (if not cached) followed by retrieving the results back via REST or GraphQL API which obviously doesn’t provide the same performance — but more flexibility. This is generally one of the main tradeoffs between tightly and loosely coupled systems.</p><h3>Conclusion</h3><p>To conclude, there is no question that we have to deal with an increasing amount of data each day. Organizations generally start to choose a more data-centric approach by modernizing or laying out their (enterprise) IT architectures. Further, analytics isn’t just reporting and BI anymore. Likewise, building applications isn’t just supporting transactional (OLTP) workloads anymore, and at the same time, also the demand for data streaming and real-time dashboards is on the rise. These are all plausible arguments for adapting such Headless BI tools, especially if the main focus is on embedding analytics natively into applications and to generally support multiple APIs/SDKs. On the contrary, if reporting and BI is of prime importance for your organization, then you should definitely choose a self-service BI tool such as Power BI — or maybe even running both side-by-side pointing to the same backend. In any case, if Power BI decides to generally reduce its REST API limitations together with providing a simple SQL-like interface on top of DAX, it would drastically improve its interoperability which also means coming another step closer to the Headless BI category. Let’s see what the future will bring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d48df653fac8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/headless-power-bi-d48df653fac8">Headless BI vs. Self-service BI</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Logging in Azure Data Factory and Azure Synapse Analytics]]></title>
            <link>https://medium.com/creative-data/custom-logging-in-azure-data-factory-and-azure-synapse-analytics-f084643a5489?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/f084643a5489</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 11:29:13 GMT</pubDate>
            <atom:updated>2022-11-09T11:30:36.917Z</atom:updated>
            <content:encoded><![CDATA[<p>How to implement a custom logger for Azure Data Factory and Azure Synapse Analytics by querying pipeline run information via REST API</p><h3><strong>Introduction</strong></h3><p>A proper and easily accessible logging around your data integration pipelines is the very first step towards data accuracy. With Azure Data Factory and Azure Synapse Analytics, you have the built-in functionality to integrate with Azure Log Analytics which is powerful if you want to have all your Azure logging at one place. However, it requires certain setup time and expertise which can cause quite an overhead for a simple pipeline logging. Further, you might want to add any additional information not available out-of-the-box in Log Analytics. This article shows you an alternative way of how to implement a logging solution on your own by retrieving pipeline runs via REST API and querying it afterwards using the Serverless SQL pool.</p><h3><strong>Pipeline Template</strong></h3><h4>Overview</h4><p>Both Azure Data Factory and Azure Synapse Analytics provide a REST API endpoint called <em>queryPipelineRuns </em>which allows you to query pipeline runs from your factory/workspace based on various input filter conditions. This is basically the same information you have available in the <em>Monitor</em> section under <em>Pipeline runs</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sjq5oIx_W_Vpl7MkB5NcVw.png" /><figcaption>Image by Author</figcaption></figure><p>This <a href="https://github.com/CreativeDataEU/adf_templates">pipeline template</a> will help you to retrieve this information as a part of your pipeline and store it in an attached Azure storage for querying it afterwards. It’s on purpose stored in JSON format to not alter the original response message coming from the REST API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*Zen7-o0XLGto69ETOd1iUg.png" /><figcaption>Image by Author</figcaption></figure><p>The logging pipeline itself basically contains a simple <em>Copy</em> task capturing always the latest information by taking the wrapper pipeline start timestamp as a filter criteria to make sure to always retrieve all information necessary from start to end of the actual pipeline. This is why it’s a good idea to build a wrapper pipeline around it in which you pass on the system variable <em>@pipeline().TriggerTime</em> to the template’s filter parameter <em>lastUpdateAfter </em>as you can see in the screenshot below. Any other potential filtering can still be done afterwards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7V2597zSKzpqPKrKqA5pMw.jpeg" /><figcaption>Image by Author</figcaption></figure><h4>Config</h4><p>The template comes with <strong>two linked services </strong>including<strong> </strong>two associated <strong>datasets. </strong>Firstly, the <em>Azure Data Lake Storage Gen2</em> with JSON format and secondly, the the <em>REST </em>API endpoint.</p><p>The <strong>Azure Data Lake Storage Gen2 </strong>can essentially be accessed in any way you like. Though, the simplest way would probably be to use the (System Assigned) Managed Identity from either Azure Data Factory or Azure Synapse Analytics, it just need to have the <em>Storage Blob Data Contributor</em> role assigned to have access to the linked Azure storage. This would also allow you to reuse the existing dataset properties provided in the template for FileSystem, Directory and FileName:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*AXTZHdMQEy8MCLZJ8K6AQg.png" /><figcaption>Image by Author</figcaption></figure><p>The configuration for the <strong>REST </strong>endpoint slightly varies between Azure Data Factory and Azure Synapse Analytics, choose one of the configs below when importing the template.</p><p><strong>Azure Data Factory:</strong></p><ul><li>Base URL: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns?api-version=2018-06-01</li><li>Authentication type: System Assigned Managed Identity</li><li>ADD resource: https://management.azure.com</li></ul><p><strong>Azure Synapse Analytics:</strong></p><ul><li>Base URL: {endpoint}/queryPipelineRuns?api-version=2020-12-01</li><li>Authentication type: System Assigned Managed Identity</li><li>ADD resource: https://dev.azuresynapse.net</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*RSsQhLGDyQU4wUZD4IcFgg.png" /><figcaption>Image by Author</figcaption></figure><p>Additionally, you can also adjust the <em>Request body</em> of the POST request to your needs. You will find more information regarding this in the official documentation of the corresponding REST API for either <a href="http://Azure Data Factory">Azure Data Factory</a> or <a href="https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/pipeline-run/query-pipeline-runs-by-workspace?tabs=HTTP">Azure Synapse Analytics</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*oTicahZbev8us2xQigRr-A.png" /><figcaption>Image by Author</figcaption></figure><h3><strong>Serverless SQL pool — Query runs</strong></h3><p>Once you have stored the JSON files in your Azure storage, the best and most efficient way to query them is using Azure Synapse Analytics Serverless SQL pool. You can reuse the following code which will give you a similar view as in the Monitor section within Azure, you just need to adjust the path in the BULK section in OPENROWSET. Feel free to make any other adjustments.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c11bc18ef31a094fe51821c1f9393532/href">https://medium.com/media/c11bc18ef31a094fe51821c1f9393532/href</a></iframe><h3><strong>Conclusion</strong></h3><p>This template can just be reused as it is to have a simple pipeline logging as well as extended and advanced to any complexity. The final view can then easily be integrated into a Power BI Report making it easily and always accessible without digging deeper into the Azure portal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f084643a5489" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/custom-logging-in-azure-data-factory-and-azure-synapse-analytics-f084643a5489">Custom Logging in Azure Data Factory and Azure Synapse Analytics</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boosting Databricks ODBC Driver Performance]]></title>
            <link>https://medium.com/creative-data/boosting-databricks-odbc-driver-be2cf08a7a4a?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/be2cf08a7a4a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 07:13:42 GMT</pubDate>
            <atom:updated>2024-02-19T12:45:25.696Z</atom:updated>
            <content:encoded><![CDATA[<p>The top 3 aspects to consider to get the most out of the Databricks ODBC driver by interacting with Delta Lake tables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y56LzPlj__NePWzg" /><figcaption>Photo by <a href="https://unsplash.com/@matthiasspeicher?utm_source=medium&amp;utm_medium=referral">Matthias Speicher</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>Low-latency queries has always been an important topic when it comes to data platforms, but in the last few years it has noticeably regained momentum. This is due to the growing amount of data together with the overwhelming cloud data platform offerings to cope with it.</p><p>While most of those new platforms certainly reduce query response times over LARGE data volumes, the technology for client applications to interact with them is still mostly dominated by over 25 years old standards such as JDBC or ODBC, originally designed without taking into account distributed systems, object stores or columnar (in-memory) storage formats. In its original form, they require expensive converting/serializing processes by exporting data from a system-specific columnar format via the JDBC/ODBC row format and then maybe even converting back again to the client’s columnar format¹.</p><p>The good news is now that we have lately been making some progress to establish new standard interfaces such as <a href="https://arrow.apache.org/blog/2022/02/16/introducing-arrow-flight-sql/">Apache Arrow Flight SQL</a>, exchanging data much more efficient by leveraging latest technologies. However, while we wait for them to be commonly used, some data platform providers have also come up with some other improvements around existing interfaces. For instance, Databricks around the ODBC interface that the Spark Thrift server provides, especially speeding up the extraction of large data volumes. In this article, we will take a look at how these improvements work and what to bear in mind to actually take advantage of it.</p><h4>1. ODBC Driver Setup and Config</h4><p>First and foremost, make sure that you always use the latest <a href="https://www.databricks.com/spark/odbc-drivers-download">Databricks ODBC diver</a> version available since it’s constantly being improved and updated. In this context, also the configuration of the driver can make quite a difference, especially playing around with the <a href="http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/win/content/odbc/hi/options/options-advanced.htm">Advanced Driver Configuration Options</a>. For instance, if you deal with long STRING columns make sure to keep an eye on the DefaultStringColumnLength setting otherwise it could lead to string truncation and hence also very poor performance — try to avoid long string columns in general. Another interesting setting to change could be MaxBytesPerFetchRequest depending on your network which specifies the maximum number of bytes to retrieve from the server for every FetchResults API call when using Apache Arrow for serialization, more regarding this in the next section. As a broad orientation, next are listed some of the default configuration settings used by Power BI to connect to Databricks via ODBC:</p><pre>Driver = “Simba Spark ODBC Driver”,<br>Host = ValidatedHost,<br>HTTPPath = httpPath,<br>Port = 443,<br>ThriftTransport = 2,<br>SparkServerType = 3,<br>SSL = 1,<br>UseNativeQuery = 0,<br>UserAgentEntry = “PowerBI”,<br>UseSystemTrustStore = 1,<br>RowsFetchedPerBlock = 200000,<br>LCaseSspKeyName = 0,<br>ApplySSPWithQueries = 0,<br>DefaultStringColumnLength=65535,<br>DecimalColumnScale = 10,<br>UseUnicodeSqlCharacterTypes = 1</pre><h4>2. Cloud Fetch and Apache Arrow</h4><p>As already mentioned, extracting/fetching the results is the most expensive part by querying large data volumes. This is due to data serving happening single-threaded together with the data serialization/deserialization processes happening along the way by using ODBC in its original form. This is where <a href="https://docs.databricks.com/integrations/bi/jdbc-odbc-bi.html#extract-large-query-results-in-odbc">Cloud Fetch and Apache Arrow</a> comes to rescue by fetching data in parallel via HTTP directly from the cloud storage through a set of URLs provided by the Databricks endpoint (e.g. Shared Access Signatures in Azure, presigned URLs in AWS). This way it can be taken advantage of parallelism for data serving as well as <a href="https://arrow.apache.org/docs/index.html">Apache Arrow</a> for providing the data in an optimized serialization format leading to an accelerated data interchange with very low overhead. For the ODBC interface to use it, you just need to make sure to have installed at least the ODBC driver version 2.6.17 and to use the Databricks Runtime 8.3 or above. If this is the case, everything should be installed and set up automatically. Just be careful with complex data types such as MapType, ArrayType or StructType since Apache Arrow doesn’t support these types at the time of this writing.</p><p>If you still have doubts about whether Cloud Fetch is really used, you can check the last element <em>mapPartitionsInternal</em> of the query execution DAG of your corresponding job, it should contain<em> CloudStoreCollector:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*VokaGHhWhXcpayJTPZ2MGQ.png" /><figcaption>Image by Author</figcaption></figure><p>You can also check the Databricks driver log <em>Log4j</em> output for events such <em>as HybridCloudStoreResultHandler</em> and <em>ArrowResultHandler</em>. This would be even more specific since Cloud Fetch is finally only used for query results larger than 1 megabyte and the DAG above would still tell you <em>CloudStoreCollector </em>even though the query just returns 5248 bytes with 10 rows as you can see in the next image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*iaF87bRNob1pA-QQYfq6Zg.png" /><figcaption>Image by Author</figcaption></figure><h4>3. Photon and Disk Caching</h4><p>Another very easy way to speed up queries without changing a single line of code is choosing instance types supporting the new Spark execution engine Photon written in C++ together with accelerated disk caching. Even though this is not directly related to the ODBC driver, you will immediately notice impressive performance improvements by using these two proprietary Databricks features, especially when data is already cached on the nodes’ local SSD volumes using a fast intermediate data format.</p><p>If activated, this caching mechanism happens automatically by creating a local copy whenever a remote Parquet data file (including Delta Lake tables) has to be fetched from a remote storage. However, you can also actively “warm up” the cache by using the <em>CACHE SELECT</em> command. In this case, all data files will be loaded to the local machines and any upcoming changes are synchronized automatically. To activate it, the following settings need to be configured:</p><pre>spark.databricks.io.cache.enabled true<br>spark.databricks.io.cache.maxDiskUsage 50g<br>spark.databricks.io.cache.maxMetaDataCache 1g<br>spark.databricks.io.cache.compression.enabled false</pre><p>The probably most important setting here is <em>maxDiskUsage </em>specifying the disk space reserved per node for caching, you can watch the current usage in the Storage section of the Spark Web UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*Kl8HHk_txiGy24QUVTWjQg.png" /><figcaption>Image by Author</figcaption></figure><p>To check whether your query is supported by Photon, just run the <a href="https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-explain.html">EXPLAIN</a> command returning you the execution plan. Towards the end of it, you can find a section called “Photon Explanation”. In this example, Photon is not kicking in since the query is just too small, but there could be other reasons:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*HwZkk1OsPX-46xAEKkSJew.png" /><figcaption>Image by Author</figcaption></figure><h4>Conclusion</h4><p>Of course, on a physical data layer, there are lots of other <a href="https://docs.databricks.com/optimizations/index.html">Databricks optimization</a> techniques and <a href="https://docs.databricks.com/delta/best-practices.html">Delta Lake best-practices</a> to improve performance, some of them even take place automatically. However, no matter how good your physical data layer may be optimized and work within Databricks, your client application still needs to extract/fetch the data results via some interface. This is why you should keep the 3 mentioned aspects above in mind to reduce this bottleneck to a minimum.</p><h4>Resources:</h4><p>[1]: Dremio. 2022. An Introduction to Apache Arrow Flight SQL. [ONLINE] Available at: <a href="https://www.dremio.com/subsurface/an-introduction-to-apache-arrow-flight-sql/">https://www.dremio.com/subsurface/an-introduction-to-apache-arrow-flight-sql/</a>. [Accessed 23 October 2022].</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be2cf08a7a4a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/boosting-databricks-odbc-driver-be2cf08a7a4a">Boosting Databricks ODBC Driver Performance</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending Emails natively from Azure Data Factory or Synapse Pipelines]]></title>
            <link>https://medium.com/creative-data/sending-emails-natively-from-azure-data-factory-or-synapse-pipelines-cbd860adc832?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbd860adc832</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 09:54:39 GMT</pubDate>
            <atom:updated>2022-11-09T11:16:15.780Z</atom:updated>
            <content:encoded><![CDATA[<p>How to send emails programmatically via the Microsoft Graph API instead of relying on any other service like Azure Logic Apps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*exeRFJ-hxnokkgYR" /><figcaption>Photo by <a href="https://unsplash.com/@campaign_creators?utm_source=medium&amp;utm_medium=referral">Campaign Creators</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>The recommended and documented way to send emails from Azure Data Factory or Synapse Pipelines is using a <a href="https://learn.microsoft.com/en-us/azure/data-factory/how-to-send-email">Logic App workflow</a>. While you can perfectly stick to this approach, you should bear in mind that this requires you to have another Azure resource including costs and also have parts of your business logic in different places making also version control a little bit more difficult. Further, it’s also quite inflexible when it comes to dynamically interacting with different (shared) mailboxes. Therefore, this article shows you a way to bypass these shortcomings by using the Microsoft Graph API together with <em>Web Activity </em>tasks to interact with the mailboxes directly.</p><h4><strong>Prerequisites</strong></h4><ol><li><strong>Azure App registration</strong> with required <a href="https://learn.microsoft.com/en-us/graph/permissions-reference">Microsoft Graph Application Permissions</a>, e.g. Mail.Send<strong>. </strong>Follow <a href="https://techjatinder.medium.com/send-email-using-microsoft-graph-api-using-c-a838d128bb27">this</a> article.</li></ol><p>2. (Optional): <a href="https://learn.microsoft.com/en-us/graph/auth-limit-mailbox-access"><strong>Application Access Policy</strong></a><strong> </strong>to limit Azure App registration to specific mailboxes otherwise it has access to any mailbox in an organization which might raise security concerns.</p><h4><strong>Pipeline Template</strong></h4><p>Once the Azure App is registered, you can make usage of this <a href="https://github.com/CreativeDataEU/adf_templates">pipeline template</a>. It consists of two tasks, one for retrieving a bearer token with the required scope and another one for sending the actual email by triggering a POST request.</p><p>You can integrate this pipeline into any of your existing pipelines and pass on certain parameters dynamically. For instance, by looping through a list of email senders and recipients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*wfFrWLeE8Z9wEuicUYed3g.png" /><figcaption>Image by Author</figcaption></figure><h4>Conclusion</h4><p>In contrast to using Logic Apps, this is a very dynamic and reusable pattern for any Azure Data Factory or Synapse Pipeline which is also more integrated and hence easier to “version control”. Further, the Azure registration could be set up centrally with just a one-time effort and any pipeline can dynamically make usage of it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd860adc832" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/sending-emails-natively-from-azure-data-factory-or-synapse-pipelines-cbd860adc832">Sending Emails natively from Azure Data Factory or Synapse Pipelines</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Export To File with Power BI Pro]]></title>
            <link>https://medium.com/creative-data/export-store-and-email-reports-like-a-power-bi-pro-ddf1f48edef5?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddf1f48edef5</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 13:30:10 GMT</pubDate>
            <atom:updated>2022-11-09T11:16:48.291Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automating Export To File With Power BI Pro</h3><p>How to export reports programmatically with a Power BI Pro license only and send it to an arbitrary number of users via email using Azure Data Factory or Synapse Pipelines</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kK4MMvaAz2jowo29BOCS7g.png" /><figcaption>Export, store and email Power BI report (Image by Author)</figcaption></figure><h4>Introduction</h4><p>Newest self-service Business Intelligence tools enable us to create very dynamic and interactive reports that are easily accessible. Yet, organizations often still prefer static reports for archiving purposes or to send an automated email including the report directly to the intended recipients after refreshing data.</p><p>In Power BI Service, programmatically exporting reports to a file is natively supported by using a <a href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to">dedicated REST API</a>. This method works as long as the report resides on a Power BI Premium or Power BI Embedded capacity, but not on a <a href="https://docs.microsoft.com/en-us/power-bi/admin/service-admin-manage-your-data-storage-in-power-bi#shared-capacity-limits">shared capacity</a> using Power BI Pro or Premium Per User licenses. The only supported alternative is using <a href="https://docs.microsoft.com/en-us/power-bi/consumer/end-user-subscribe?tabs=creator">Subscriptions</a> to send automated emails at set intervals with snapshots of the current report. However, the problem here is that this will never be precisely time aligned with the data refresh nor is it very flexible or customizable. It further requires all recipients to have a Power BI license.</p><p>On the other hand, developing the export and email distribution on your own, would allow you to make the distribution process actually part of the entire data pipeline which makes it perfectly time aligned and data would be always up-to-date when exporting and sending out reports. Further, recipients don’t necessarily need a Power BI license as well as any other additional content could be easily included. In this article, I will show you how you can achieve that with a Power BI Pro license only.</p><p>Before we jumping into it, I would just like to mention that this is not officially supported by Microsoft.</p><h4>Prerequisites</h4><ol><li>Azure AD User with Power BI Pro license and multi-factor authentication (MFA) turned off.</li><li>Power BI Workspace including a Power BI Report on a “normal” shared capacity with Admins rights assigned to the User above.</li><li>Azure App Registration including client secret and “<em>Allow public client flows</em>” set to allow your application to silently authenticate as the user above and use the Power BI REST APIs. There are no additional API permission required since those are taken from the user itself — unfortunately it doesn’t seem to work with a service principal.</li></ol><h4>Solution</h4><p>The idea to get this working is quite simple, we just reproduce the REST API calls happening behind the scenes when exporting a report via the graphical user-interface (GUI) within the Power BI service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*Vt8_CwIgdrYpH1QM.png" /><figcaption><a href="https://docs.microsoft.com/en-us/power-bi/consumer/end-user-pdf?tabs=powerbi-service#export-your-power-bi-report-to-pdf">Trigger Export from UI (Image by Microsoft)</a></figcaption></figure><p>By starting the export via the button click a series of REST API calls gets triggered including some custom parameters such as the export format (PDF or PPTX). First, is triggered a POST request starting the export, followed by a number of GET request checking the export status until the export is finished which finally triggers a single GET request to retrieve the actual file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/0*7E-y7JWFnJr0mGKn.png" /><figcaption><a href="https://docs.microsoft.com/en-us/power-bi/consumer/end-user-pdf?tabs=powerbi-service#export-your-power-bi-report-to-pdf">Get Export Status (Image by Microsoft)</a></figcaption></figure><p>This is what the pipeline looks like in Azure Data Factory bringing the same result and storing the exported report directly in an Azure Storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cochVL7yd796miG9ZZuJFQ.jpeg" /><figcaption>Azure Data Factory Pipeline (Image by Author)</figcaption></figure><ol><li>First, we need to request a token in order to communicate with the Power BI REST API. The authentication happens via the registered Azure App and the user credentials.</li><li>The Power BI REST API uses redirections behind the scenes depending on the region which we read out in this step.</li><li>This POST request triggers the actual export of the given report.</li><li>This loop gets the export status and goes on until the export is finished an ready to be downloaded.</li><li>This GET request downloads the actual file content and saves the file to a given directory in a linked Azure Storage.</li></ol><p>The entire process is very similar to the way how it works on a Premium or Embedded capacity. The exported report file you can then send out as an email attachment by triggering an <a href="https://docs.microsoft.com/en-us/azure/data-factory/how-to-send-email">email workflow built with Logic Apps</a> or <a href="https://medium.com/creative-data/sending-emails-natively-from-azure-data-factory-or-synapse-pipelines-cbd860adc832?sk=ae0ae3c4010438a72f2021a35af652c4">natively via the Microsoft Graph API</a>.</p><h4><strong>Template</strong></h4><p>You are very welcome to download this <a href="https://github.com/CreativeDataEU/adf_templates">pipeline template</a> and adjust it to your needs. You just need to select/create two linked services whereof one is a simple Azure Storage without any specific configuration and the other one is a HTTP Linked Service with the following configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*qzDq2IRvT37NMWZsA5c70g.png" /><figcaption>HTTP Linked Service (Image by Author)</figcaption></figure><p>The pipeline includes a set of parameters which also need to be populated to get it working. If you don’t want to include the password in plaintext, you can extend the pipeline to use Azure Key Vault instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MtXGu6Dmilm3JRccW2JFQw.png" /></figure><h4><strong>Conclusion</strong></h4><p>This method allows you automatically store and send reports to as many people as you want, from or outside your organization and whether or not having a Power BI Pro license. It can also serve for archiving report snapshots at any given time interval to preserve historical states.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddf1f48edef5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/export-store-and-email-reports-like-a-power-bi-pro-ddf1f48edef5">Automating Export To File with Power BI Pro</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Variables in Databricks Workflows]]></title>
            <link>https://medium.com/creative-data/using-variables-in-databricks-workflows-557549b19c2a?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/557549b19c2a</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Thu, 21 Jul 2022 08:34:19 GMT</pubDate>
            <atom:updated>2022-09-20T10:21:01.386Z</atom:updated>
            <content:encoded><![CDATA[<p>How to pass on values to downstream tasks in Databricks Workflows by leveraging Job Task Values</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8g8_U2_BSPXzJDUJiDEeg.png" /><figcaption>Image by Author</figcaption></figure><h4>Introduction</h4><p>Not so long ago, Databricks introduced their fully-managed orchestration service <em>Databricks Workflows. </em>It allows you to orchestrate any combination of Notebooks, SQL, Spark, ML models as well as to integrate with other tools/systems via web services. Before this, you mostly had to rely on 3rd party orchestration tools to implement more complex workflows or you implemented dependencies right into the notebook by using %run or dbutils.notebook.run() known as <a href="https://docs.databricks.com/notebooks/notebook-workflows.html">Notebook Workflows</a>.</p><h4>Problem</h4><p>In any case, it has always been kind of a challenge to use variables across notebooks/tasks and also <em>Databricks Workflows</em> doesn’t provide anything more streamlined at the time of this writing. You still mostly either persist values/data to storage and pick it up somewhere downstream or you use the mentioned <em>Notebook Workflows</em> which allows you to pass on values to input widgets from another notebook. However, building complex workflows entirely with notebooks gets messy very quickly. Firstly, it lacks in terms of visual representation of the workflow and secondly, there are no built-in monitoring or error-handling capabilities. Therefore, I will show you in this article how to leverage the <em>Databricks Workflows</em> experience while using variables across tasks at the same time.</p><h4>Solution</h4><p>The solution to this problem is called <a href="https://docs.databricks.com/dev-tools/databricks-utils.html#dbutils-jobs-taskvalues">job task values</a> as part of the Databricks Utilities for Jobs. The idea is quite simple but seems to be not yet widely used.</p><p>The utility we use is actually a sub-utility that is just available for Python which allows you to <strong><em>set </em></strong>and <strong><em>get</em> </strong>arbitrary values during a job. These values are called <strong><em>task values</em></strong><em> </em>within a job and are even visible in <em>Databricks Workflows</em> once set and a task is completed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*sXegOOyXgtqmcyReWsu9Iw.png" /><figcaption>Image by Author</figcaption></figure><p>A task value can be created by using the dbutils.jobs.taskValues.set() method and is basically identified by a unique key and the name of a task in <em>Databricks Workflows </em>where each task can set or get multiple task values. The dbutils.jobs.taskValues.get() method allows you to access those values in any downstream task during a job. For debugging reasons outside of <em>Databricks Workflows</em>, you also need to provide a debug value and optionally you can also define a default value if required.</p><p>set example:</p><pre>dbutils.jobs.taskValues.set(key   = &quot;variable-name&quot;, \<br>                            value = &quot;value&quot;)</pre><p>get example:</p><pre>dbutils.jobs.taskValues.get(taskKey    = &quot;task-name-dbx-workflow&quot;, \<br>                            key        = &quot;variable-name&quot;, \<br>                            default    = 7, \<br>                            debugValue = &quot;debug-value&quot;)</pre><p>You can set up to 250 task values for a job run and the task values must be able to represent the value internally in JSON format with a maximum size of 48 KiB.</p><h4>Conclusion</h4><p>This approach is especially interesting for passing values that are determined only at runtime such as any intermediate results. However, you could also use it in combination with static job task parameters by defining a widget only once in the first task/notebook and assign this value to such a task value for using it throughout a job without having to populate widget parameters manually for each task.</p><p>Altogether, <em>Databricks Workflows</em> already provides a great built-in orchestration experience, but it still lacks quite a few features compared to other dedicated orchestration tools. Personally, I believe another very basic feature missing is to control and specify conditions when downstream tasks should run in relation to one another. For instance, in Apache Airflow this concept is called <a href="https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html#concepts-trigger-rules">trigger rules</a> or in the SQL Server Integration Services (SSIS) this is known under <a href="https://docs.microsoft.com/en-us/sql/integration-services/control-flow/precedence-constraints?view=sql-server-ver16">precedence constraints</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=557549b19c2a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/using-variables-in-databricks-workflows-557549b19c2a">Using Variables in Databricks Workflows</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real-time Monitoring of Apache Spark Streaming Jobs with Power BI]]></title>
            <link>https://medium.com/creative-data/real-time-monitoring-of-apache-spark-streaming-jobs-with-power-bi-475ec873125c?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/475ec873125c</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[power-bi]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 16:16:22 GMT</pubDate>
            <atom:updated>2022-05-19T06:04:46.895Z</atom:updated>
            <content:encoded><![CDATA[<p>How to push Apache Spark’s streaming metrics into Power BI in real-time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJOZFEk9whjm8wcztWU-Xw.gif" /><figcaption>Real-time Dashboard Power BI (Image by Author)</figcaption></figure><h3>Introduction</h3><p>Real-time data streaming and integration is being increasingly demanded by organizations to improve their business and better serve their customers. By comparing the development with traditional batch data, real-time data integration pipelines usually require more up-front simulation and testing. Though, unified processing engines such as the Apache Spark’s Structured Streaming API already make it very easy to get started integrating and processing data in real-time. However, to also ensure reliability and that those pipelines also work for extended time periods under a high workload, a proper monitoring and alerting system is essential. For this reason, there already exist a bunch of existing integrations for monitoring Apache Spark streaming applications in addition to the monitoring functionalities of the Spark UI itself. Yet, situations might require something more flexible, for example, to monitor multiple streaming jobs at once or to make monitoring easier accessible to the business as well. In this article, we will take a look how to push data into Power BI in real-time for enabling further alerting and dash-boarding use cases.</p><h3>StreamingQueryListener</h3><p>If you have already worked with Structured Streaming jobs, you certainly came across the built-in monitoring feature once you kick-off a streaming job in Spark/Databricks. The “Raw Data” tab gives you access to the raw data in JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*CPp8B242jqbTOhHYGgdlAg.png" /><figcaption>Built-in Spark Streaming Metrics (Image by Author)</figcaption></figure><p>Further down we will capture exactly this streaming metrics in a continuous fashion by using the Apache Spark’s StreamingQueryListener class.</p><h4>Developing custom StreamingQueryListener class</h4><p>First, we need to extend this class and create our own sub-class to meet our requirements. By doing this, we actually tell it how to parse the streaming metrics and hence can at this point decide how the data structure should look like.</p><p>It’s also important to know that the original structure and data of an event might vary between streaming jobs depending on its source type and progress. In this example, we will take only fields that are consistent across all jobs. You can take the following Scala code and paste it into a new notebook’s cell, there doesn’t exist a Python/PySpark binding for this library at the time of this writing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b24ca27f7afde2231bf8e4a162e726bf/href">https://medium.com/media/b24ca27f7afde2231bf8e4a162e726bf/href</a></iframe><h4>Attaching custom StreamingQueryListener class</h4><p>The last line of code adds and registers the new listener to the current Spark Context. This allows us to simply attach this notebook to any other notebook starting a streaming job which then automatically monitors the associated query. Callbacks are getting received whenever a query is started, stopped or a progress is made. To be able to easily distinguish between the streaming jobs and to assign their metrics, you should further provide a query name <em>.queryName(queryName).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*ukkJgU6PAm7BcXGZv830kw.png" /><figcaption>Attaching StreamingQueryListener to Notebook (Image by Author)</figcaption></figure><h3>Power BI Push Dataset</h3><p>Now that we agreed upon the data structure we want to push, we can create our Power BI push dataset. In a further stage, this step also be done automatically as part of the <em>StreamingQueryListener’s OnQueryStarted</em> event via the Power BI REST APIs. However, in our example and to keep things short, we will create it per hand upfront with the schema listed below and <em>historical data analysis</em> turned on. This way, a new database is created behind the scenes that continues to store the pushed data as it comes in which allows us to create reports on top of the real-time data. These reports and their visuals are just like any other report visuals, which means you can use all of Power BI’s report building features to create visuals or alerts. Take a note of the provided “Push URL” after creating the dataset, we need to paste this information in our custom class from above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*HnakhXNHtksim4n0uJDf6Q.png" /><figcaption>Power BI Push Dataset (Image by Author)</figcaption></figure><p><em>Tipp: You can reset/empty a push dataset by simply disabling and re-enabling the historic data analysis feature.</em></p><h3>Starting streaming and monitoring queries</h3><p>Once everything is set up, we are finally ready to start our streaming jobs. In case no data arrives on the Power BI side, check the Databricks driver logs or try to manually debug your developed custom streaming listener class.</p><p>The example dashboard from above is a normal report based on the Power BI push dataset having enabled an automatic page refresh with 1 second interval.</p><h3>Conclusion</h3><p>Throughout this article, we explored how to monitor Databricks structured streaming jobs in Power BI which once again demonstrates how these two technologies perfectly complement each other. A proper monitoring strategy makes a huge part of building reliable data streaming applications. It not only allows to immediately respond to errors or get notified about any anomalies, but also reveals bottlenecks or room for performance optimizations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=475ec873125c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/real-time-monitoring-of-apache-spark-streaming-jobs-with-power-bi-475ec873125c">Real-time Monitoring of Apache Spark Streaming Jobs with Power BI</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interactive Analytics on Azure Event Hub with Trino]]></title>
            <link>https://medium.com/creative-data/interactive-analytics-on-azure-event-hub-with-trino-1b64cfda3f63?source=rss-73a93ddc5720------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b64cfda3f63</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[power-bi]]></category>
            <dc:creator><![CDATA[Patrick Pichler]]></dc:creator>
            <pubDate>Thu, 21 Apr 2022 07:22:50 GMT</pubDate>
            <atom:updated>2023-10-23T09:38:57.940Z</atom:updated>
            <content:encoded><![CDATA[<h4>How Trino enables you to run interactive SQL queries on top of Azure Event Hub streaming data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*KXHwiuSCzXy0VCrbRlyuOA.jpeg" /><figcaption>Example Architecture (Image by Author)</figcaption></figure><h3>Introduction</h3><p>Modern distributed messaging systems such as Apache Kafka or Microsoft Azure Event Hubs have quite matured over the last few years. They build upon distributed commit logs and allow you to publish and consume data in real-time in a very efficient and distributed manner. This design pattern is mostly used for streaming data into other downstream systems to enable low-latency follow-up analysis or design microservices or serverless architectures. This makes messaging systems act as a kind of middle layer to decouple data producer from data consumer systems.</p><p>While they serve very well for those use-cases, they aren’t really designed to deal with direct queries or to run heavy computations such as joins or aggregations. Yet, as they are getting increasingly integrated in today&#39;s data architectures, the demand for such database-like functionalities is rising. To facilitate this, some purpose-built technologies have also already been introduced such as ksqlDB for Apache Kafka. Though, those tools are mostly tied to its own ecosystem and don’t allow you to query data across disparate data sources. This is where Trino comes into play. In this article, we will explore how Trino enables fetching live data from Azure Event Hubs and allows joins across any other data source supported by Trino using simple SQL queries. Results can then be loaded into Power BI for further analysis or persisted to a cold storage for archiving purposes. This is especially interesting since most of the cloud based messaging services only support a few number of days as a maximum retention period before messages get dropped. Without further ado, lets get started.</p><h3>1. Setup</h3><ol><li>Docker Desktop on Windows or Docker Engine on Linux</li><li>Cloning or downloading the <a href="https://github.com/bitsondatadev/trino-getting-started/tree/main/kafka/trino-kafka">Kafka</a> connector example from the <a href="https://github.com/bitsondatadev/trino-getting-started">Trino Getting Started</a> series</li><li>Azure Subscription including a Azure Event Hub namespace in at least standard tier for supporting the Kafka endpoint which is enabled by default</li><li>Python runtime for data generation</li></ol><h3><strong>2. Configuring Trino’s Kafka connector</strong></h3><p>The provided Kafka connector example includes everything required to locally load data into Kafka topics and query live data with Trino. However, since we take this tutorial just as a starting point to query our Azure Event Hub, we first need to make some configuration adjustments to get everything working.</p><p>First of all, we need to make the Azure Event Hub known to Trino which is defined in a catalog properties file etc/catalog/kafka.properties. You can take the following code snippet and make your adjustments:</p><pre>connector.name=kafka<br><strong>kafka.nodes=EVENTHUBNAMESPACENAME.servicebus.windows.net:9093<br>kafka.table-names=EVENTHUBNAMES</strong><br>kafka.hide-internal-columns=false<br><strong>kafka.config.resources=PATHCONFIG</strong></pre><p><strong>EVENTHUBNAMESPACE</strong>: The name of the created Azure Event Hub namespace. Example: trinoazureeventhub</p><p><strong>EVENTHUBNAMES</strong>: The name of the Azure Event Hubs you want to query, multiple names can be listed separated by a comma. If you name a non-existent Azure Event Hub, then this will be created automatically thanks to Kafka’s <em>auto.create.topics.enable</em> configuration which we will do in this example. The prefix defines the schema in which the Azure Event Hub will occur in Trino and the catalog/database is derived from the config file name, in our case this will be <em>kafka</em> (kafka.properties). Each Azure Event Hub will be represented as a single table in Trino. Example: azure.trinoazureeventhub</p><p><strong>PATHCONFIG</strong>: Path to reference another Kafka config file which we need to create manually for providing further Kafka properties. This is required for the SASL authentication. Example: etc/catalog/kafka-configuration.properties</p><p>You can copy the following code snippet and add it as a content to your just created and referenced file and make your adjustments.</p><pre><strong>security.protocol=SASL_SSL<br>sasl.mechanism=PLAIN<br>sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \<br> username=</strong><strong>&quot;$ConnectionString&quot; \<br> password=</strong><strong>&quot;EVENTHUBSCONNECTIONSTRING&quot;;</strong></pre><p><strong>EVENTHUBSCONNECTIONSTRING</strong>: A connection string from the Azure Event Hub namespace which includes the name of the shared access policy and its key value, among other information. Example: Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXX</p><h3>3. Configuring Trino’s Kafka connector description file</h3><p>As you might know, data in messaging systems is basically unstructured and self contained. If you haven&#39;t configured any schema registry, it has also no metadata to describe the format of the messages. Nevertheless, Trino’s Kafka connector would already be able to query data in its raw form holding the actual data in a column named “_message” among other Kafka specific columns. However, we want to have the messages decoded into separated columns which can be achieved in two ways. We can either create a view and parse the message on the fly by using the <em>json_extract_scalar()</em> function or we can tell Trino how to parse the message data upfront by providing it a description file.</p><p>In this example, we will further down feed our Azure Event Hub with messages in JSON format. We will now tell Trino the structure of those messages to be able to automatically transform the data into a table format. This description file needs to be located in the etc/kafka folder and must end with .json. One file for each table and it is recommended that the file name matches the table name, but this is not necessary. For our use case, we will create a file named azure.trinoazureeventhub.json with the following content:</p><pre>{<br> “tableName”: “trinoazureeventhub”,<br> “schemaName”: “azure”,<br> “topicName”: “azure.trinoazureeventhub”,<br> “message”: {<br> “dataFormat”: “json”,<br> “fields”: [<br> {<br> “name”: “deviceId”,<br> “mapping”: “deviceId”,<br> “type”: “VARCHAR”<br> },<br> {<br> “name”: “temperature”,<br> “mapping”: “temperature”,<br> “type”: “DOUBLE”<br> },<br> {<br> “name”: “pressure”,<br> “mapping”: “pressure”,<br> “type”: “DOUBLE”<br> },<br> {<br> “name”: “ts”,<br> “mapping”: “ts”,<br> “type”: “TIMESTAMP”,<br> “dataFormat”: “custom-date-time”,<br> “formatHint”: “yyyy-MM-dd HH:mm:ss.SSS”<br> },<br> {<br> “name”: “source”,<br> “mapping”: “source”,<br> “type”: “VARCHAR”<br> }<br> ]<br> }<br>}</pre><h3>4. Starting up Trino and its CLI</h3><p>Now we are ready to finally run the docker-compose command as outlined in the tutorial. The Kafka specific services will fail, don&#39;t worry, this is due to our configuration changes. It’s just the Trino coordinator which is required for us to go on since this actually runs Trino including its CLI.</p><p>Once we are connected to the it, the CLI allows us to run interactive SQL queries in Trino. If you have just created the Azure Event Hub namespace without an Azure Event Hub itself, then running the first query would automatically create one for you — as mentioned above without returning any data yet. For instance, the query for the given example would look like this:</p><pre>SELECT * FROM kafka.azure.trinoazureeventhub;</pre><h3>5. Publishing data to Azure Event Hub</h3><p>To finally test our setup, we will use the following Python code snippet to generate and publish fictional telemetry data in batches to our just created Azure Event Hub. It just requires the module <a href="https://pypi.org/project/azure-eventhub/">azure-eventhub</a> to be installed as well as the adjustment of the variables <em>connection_str</em> and <em>eventhub_name </em>before starting it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FbIEmiLtSOBUUQeiN0HtI%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FbIEmiLtSOBUUQeiN0HtI&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b411e53b23d25ebe67cb869967a45fee/href">https://medium.com/media/b411e53b23d25ebe67cb869967a45fee/href</a></iframe><h3>6. Querying and analyzing data</h3><p>If everything is set up correctly and data is available in the Azure Event Hub, we should finally be able to receive the data in the correct format by triggering the query again via the CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_j9yehaCKb2nG5mOySdtZg.png" /><figcaption>Example SQL Query Azure Event Hub Trino (by Author)</figcaption></figure><p>Since the Azure Event Hub is now available in Trino like any other table, we could also load data further into Power BI. For this example, I have used my self-developed and open-sourced custom connector for Trino available <a href="https://github.com/pichlerpa/PowerBITrinoConnector">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*c8QJfN-RSTpcKZS58795pA.png" /></figure><h3><strong>Conclusion</strong></h3><p>We have gone through a little working example proofing how Trino could be leveraged to easily join multiple streaming data sources with static data coming from somewhere else in a single SQL statement. This can open up lots of new opportunities besides giving you an insight about offsets and, in general, what’s currently going on in your Azure Event Hub. This pattern should also work for any other messaging platform providing an endpoint compatible with the Apache Kafka APIs.</p><h3><strong>Resources</strong></h3><ul><li><a href="https://github.com/bitsondatadev/trino-getting-started/tree/main/kafka/trino-kafka">trino-getting-started/kafka/trino-kafka at main · bitsondatadev/trino-getting-started</a></li><li><a href="https://trino.io/docs/current/connector/kafka-tutorial.html#step-5-add-a-topic-description-file">Kafka connector tutorial - Trino 377 Documentation</a></li><li><a href="https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/kafka.rst">trino/kafka.rst at master · trinodb/trino</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b64cfda3f63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creative-data/interactive-analytics-on-azure-event-hub-with-trino-1b64cfda3f63">Interactive Analytics on Azure Event Hub with Trino</a> was originally published in <a href="https://medium.com/creative-data">Creative Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>