<?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 Community Post on Medium]]></title>
        <description><![CDATA[Stories by Community Post on Medium]]></description>
        <link>https://medium.com/@mage_community?source=rss-78f1259c8acd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9sq9hySnfwYGas8ZMH_Wqg.png</url>
            <title>Stories by Community Post on Medium</title>
            <link>https://medium.com/@mage_community?source=rss-78f1259c8acd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 04:19:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mage_community/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[DBT Meets Mage: Powering Advanced Data Transformations]]></title>
            <link>https://m.mage.ai/dbt-meets-mage-powering-advanced-data-transformations-86cadd27e92f?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/86cadd27e92f</guid>
            <category><![CDATA[data-orchestration]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 00:24:16 GMT</pubDate>
            <atom:updated>2023-10-17T00:24:16.093Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L5MyQ0TyaeWiR0vx" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p>When <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> , a renowned data transformation framework, converges with <a href="https://www.mage.ai/">Mage</a>, it amplifies ETL processes to new heights. This article explores this powerful synergy which facilitates enhanced data modeling, giving businesses a competitive edge. By tapping into this combo, data professionals can supercharge their operations and drive data precision to the forefront.</p><h3>Outline</h3><ul><li>Introduction to Mage</li><li>Transform DBT with Mage</li><li>Set up DBT models &amp; orchestrate DBT runs</li><li>Conclusion</li></ul><h3>Introduction to Mage</h3><p>In an age where data is the new oil, efficient and reliable data management tools are essential. <a href="https://www.mage.ai/">Mage</a> is a platform committed to simplifying data integration and analytics. Designed for seamless data transformation and loading, Mage is transforming how businesses approach data management. Here are its key features:</p><p><em>Automated Data Pipeline: </em>Mage automates data extraction, transformation, and loading (ETL) processes. It can extract data from multiple sources, transform it to a desirable format, and load it into a data warehouse.</p><p><em>Data Connectors:</em> Mage offers various data connectors to widely-used data sources like Shopify, Facebook Ads, Google Ads, Google Analytics, etc. This makes it easier to import data from these platforms.</p><p><em>Easy Integration: </em>Mage provides easy integration with popular data warehouses including Google BigQuery, Amazon Redshift, and Snowflake.</p><p><em>Pre-built SQL Models:</em> Mage comes with pre-built SQL models for popular e-commerce platforms like Shopify and WooCommerce. These models simplify the process of data analysis.</p><p><em>Incremental Loading:</em> Mage supports incremental loading, which means only new or updated data is loaded into the data warehouse. This saves storage space and improves efficiency.</p><p><em>Data Transformations:</em> Mage performs automatic data transformations, converting raw data into a more usable format. This process makes the data ready for analysis and reporting.</p><p><em>Scheduled Refresh:</em> Data refreshes can be scheduled in Mage, ensuring that the data in the warehouse is always up-to-date.</p><p><em>Data Security: </em>Mage places a high emphasis on data security, ensuring data privacy and compliance with GDPR and other data protection regulations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*-HJezEmqwJwVpVjH.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/bbmas-bbmas-2016-xT4uQaQ2ZhlZybPiFO">Giphy</a>)</figcaption></figure><h3>Transform DBT with Mage</h3><p>By integrating <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> with <a href="https://www.mage.ai/">Mage</a>, data transformation reaches new heights of efficiency and precision. This synergy unlocks unparalleled ETL capabilities, setting a new standard in data processing.</p><p><strong>Overview</strong> - Build, run, and manage your dbt models with Mage.</p><p><strong>Analytics engineers </strong>- With Mage and dbt combined, you can expand, build and run complex data pipelines.</p><p><strong>Data engineers</strong> - Simplify your data infrastructure and reduce the amount of redundant tools in your “modern” data stack. Replace dbt cloud and Airflow with Mage’s native integration with dbt.</p><p><strong>Features</strong></p><ul><li><em>Schedule dbt model runs </em>— Trigger your dbt model runs on a regular schedule, from an event, or via API request.</li><li>Run specific dbt models and their dependencies</li><li>Run all models and optionally exclude others</li><li>DBT models can depend on non-dbt related tasks, Examples:<br>- Build model after data ingestion from API<br>- Build model after another pipeline completes</li><li>Preview dbt model results as you write SQL</li><li>Build dynamic dbt pipelines using flexible variable interpolation, Examples:<br>- {{ env_var(‘…’) }}<br>- {{ variables(‘…’) }}<br>- {{ mage_secret_var(‘…’) }}</li><li><em>Automatically run dbt tests every time a pipeline runs</em> - Write checks using dbt tests, then Mage will run them and fail the pipeline if the test results produce any failures.</li><li><em>Observability built-in</em> - Monitor your dbt pipelines and get alerted when things break.</li></ul><p><strong>Supported connectors</strong></p><ul><li>dbt-bigquery</li><li>dbt-core</li><li>dbt-postgres</li><li>dbt-redshift</li><li>dbt-snowflake</li><li>dbt-sqlserver</li><li>dbt-trino</li><li>dbt-spark</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*hDkzPmONasulngUN.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/bumblebeemovie-transformers-bumblebee-movie-BLEQ47IrPlXn5LhGuY">Giphy</a>)</figcaption></figure><h3>Set up DBT models &amp; orchestrate DBT runs</h3><p>Configuring <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> models paves the way for robust data structures, while orchestrating DBT runs ensures seamless, automated workflows in data transformation.</p><p>1. Set up new Mage project</p><ul><li>Read the <a href="https://docs.mage.ai/getting-started/setup">setup guide</a> to initialize a new project and start the Mage tool locally.</li><li>For the rest of this tutorial, we’ll use the project name demo_project.</li></ul><p>2. Set up dbt project</p><ul><li>Create dbt project<br>- Open Mage and go to the terminal page: <a href="http://localhost:6789/terminal">http://localhost:6789/terminal</a><br>- Initiate your dbt project using the init command (for this tutorial, we’ll use the dbt project name demo):</li></ul><pre>cd demo_project/dbt<br>dbt init demo -s<br>touch demo/profiles.yml</pre><p>For more information on creating a dbt project, read their <a href="https://docs.getdbt.com/quickstarts/manual-install?step=1">documentation</a></p><p>3. C<strong>reate standard pipeline</strong></p><ul><li>Go to the Mage dashboard and click the button <strong>+ New pipeline</strong> and select the option labeled <strong>Standard (batch)</strong>.</li><li>Click the <strong>Pipeline settings</strong> icon in the left pane, and change its name to <strong>dbt demo pipeline</strong>, then click the <strong>Save pipeline settings</strong> button.</li></ul><p>4. <strong>Create dbt profile for database connections</strong></p><ul><li>On the left side of the page in the file browser, expand the folder <strong>demo_project/dbt/demo/</strong></li><li>Click the file named <strong>profiles.yml</strong></li><li>Paste the following credentials in that file:</li></ul><pre>demo:<br>  target: dev<br>  outputs:<br>    dev:<br>      dbname: xyleviup<br>      host: queenie.db.elephantsql.com<br>      password: edSrMWH7Mww-lTKpp-jPHX9sYSNLy7LG<br>      port: 5432<br>      schema: dbt_demo<br>      type: postgres<br>      user: xyleviup</pre><ul><li>Save the <strong>profiles.yml</strong> file by pressing <strong>Command (⌘) + S</strong>.</li><li>Close the file by pressing the <strong>X</strong> button on the right side of the file name <strong>dbt/demo/profiles.yml</strong></li></ul><p>5. A<strong>dd data loader block to pipeline</strong></p><ul><li>Click the <strong>+ Data loader button</strong>, select <strong>Python</strong>, then click <strong>API</strong>.</li><li>In the popup dialog <strong>Data loader block name</strong>, change its name to <strong>load data</strong>, then click the <strong>Save and add block</strong> button.</li><li>Paste the following code in that block:</li></ul><pre>import io<br>import pandas as pd<br>import requests<br>from pandas import DataFrame<br>@data_loader<br>def load_data_from_api(**kwargs) -&gt; DataFrame:<br>    url = &#39;https://raw.githubusercontent.com/mage-ai/datasets/master/restaurant_user_transactions.csv&#39;<br>    response = requests.get(url)<br>    df = pd.read_csv(io.StringIO(response.text), sep=&#39;,&#39;)<br>    df.columns = [&#39;_&#39;.join(col.split(&#39; &#39;)) for col in df.columns]<br>   			    return df</pre><p>6. <strong>Add dbt model block to pipeline</strong></p><ul><li>Under the data loader block you just added, click the button <strong>dbt model</strong>, then click the option <strong>Single model</strong>.</li><li>In the file browser that pops up, click the file named <strong>my_second_dbt_model.sql</strong> under the folders <strong>demo/models/example/</strong><br>- This will add 2 dbt blocks to your pipeline: 1 for the dbt model named <strong>my_first_dbt_model</strong> and the 2nd for the dbt model named <strong>my_second_dbt_model</strong>.<br>- The model named <strong>my_first_dbt_model</strong> was added to the pipeline because <strong>my_second_dbt_model</strong> references it.</li></ul><p>7. <strong>Edit dbt model my_first_dbt_model</strong></p><ul><li>In the dbt block named <strong>my_first_dbt_model</strong>, next to the label Target at the top, choose <strong>dev</strong> in the dropdown list. You can also check <strong>Manually enter target</strong>, and enter <strong>dev</strong> in the input field.</li><li>Paste the following SQL into the dbt model named <strong>my_first_dbt_model</strong>:</li></ul><pre>WITH source_data AS (<br>    SELECT 1 AS id<br>    UNION ALL<br>    SELECT 2 AS id<br>)<br>SELECT *<br>FROM source_data</pre><ul><li>Run the dbt model block by pressing the play button on the top right of the block or by pressing <strong>Command + Enter</strong>.</li><li>You should see a preview of the query execution logs. To see the query results, click the <strong>Expand table</strong> link at the bottom right corner.</li><li>After previewing the results, in the top right corner of the block, click on the triple dots to reveal a dropdown menu.</li><li>Under the dropdown menu, click the option Run model. This command will execute the <strong>dbt run</strong> command and create the table in your data source.</li></ul><p>8. <strong>Edit dbt model my_second_dbt_model</strong></p><ul><li>In the dbt block named my_second_dbt_model, next to the label Target at the top, choose dev in the dropdown list. You can also check <strong>Manually enter target</strong>, and enter <strong>dev</strong> in the input field.</li><li>Paste the following SQL into the dbt model named <strong>my_second_dbt_model</strong>:</li></ul><pre>SELECT<br>    a.*<br>    , b.*<br>FROM {{ ref(&#39;my_first_dbt_model&#39;) }} AS a<br>LEFT JOIN {{ source(&#39;mage_demo&#39;, &#39;dbt_demo_pipeline_load_data&#39;) }} AS b<br>ON 1 = 1<br>WHERE a.id = 1</pre><p><a href="https://docs.getdbt.com/docs/build/sources">dbt sources</a></p><p>When a dbt model depends on an upstream block that isn’t a dbt model, a source for that block is automatically added to the <strong>demo_project/dbt/demo/models/example/mage_sources.yml</strong> file.</p><p>Read more about dbt sources in their <a href="https://docs.getdbt.com/docs/build/sources">documentation</a>.</p><ul><li>Run the dbt model block by pressing the play button on the top right of the block or by pressing <strong>Command + Enter</strong>.</li><li>You should see a preview of the query execution logs. To see the query results, click the <strong>Expand table</strong> link at the bottom right corner.</li></ul><p>9. <strong>Add test for dbt model</strong></p><ul><li>On the right side of the screen, click the tab labeled <strong>Terminal</strong>.</li><li>Create a new dbt test file by running the following command:</li></ul><pre>touch demo_project/dbt/demo/tests/test_my_second_dbt_model.sql</pre><ul><li>On the left side of the page in the file browser, expand the folder <strong>demo_project/dbt/demo/tests/ </strong>and click the file named <strong>test_my_second_dbt_model.sql</strong>. If you don’t see it, refresh the page.</li><li>Paste the following SQL in the file:</li></ul><pre>SELECT id<br>FROM {{ ref(&#39;my_second_dbt_model&#39;) }}<br>GROUP BY id<br>HAVING (id = 0)</pre><ul><li>Read more about dbt tests in their <a href="https://docs.getdbt.com/docs/build/tests"><strong>documentation</strong></a>.</li></ul><p>10. <strong>Execute pipeline end-to-end</strong></p><ul><li>Click the name of the pipeline in the header breadcrumbs to go back to the detail page.</li><li>Create a new trigger with a type <strong>Schedule</strong> and a Frequency <strong>once</strong>. For more details, follow these <a href="https://docs.mage.ai/design/data-pipeline-management#create-trigger">steps</a>.</li><li>After your trigger is created, click the <strong>Start trigger</strong> button at the top of the page.</li><li>The pipeline will eventually fail because a dbt test failed. This means everything is working as expected.</li><li>Open the file <strong>demo_project/dbt/demo/models/example/schema.yml</strong> and remove the tests named unique under both models. Your file should look like this:</li></ul><pre>version: 2<br>models:<br>  - name: my_first_dbt_model<br>    description: &quot;A starter dbt model&quot;<br>    columns:<br>      - name: id<br>        description: &quot;The primary key for this table&quot;<br>        tests:<br>          - not_null<br>  - name: my_second_dbt_model<br>    description: &quot;A starter dbt model&quot;<br>    columns:<br>      - name: id<br>        description: &quot;The primary key for this table&quot;<br>        tests:<br>          - not_null</pre><ul><li>Click on the <strong>Failed</strong> button next to the pipeline run and click <strong>Retry run</strong>. It should complete running successfully after a few minutes.</li></ul><p><strong>Congratulations!</strong> You’ve created a data pipeline that orchestrates your dbt models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*UVSeHKnU0o4grFMm.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/quixyofficial-happy-nocode-no-code-XsMwhdxF8uxMd9doiS">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In the evolving landscape of data processing, the fusion of <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> and <a href="https://www.mage.ai/">Mage</a> signifies a transformative leap. By integrating DBT’s modeling prowess with Mage’s advanced ETL capabilities, businesses are now better equipped to harness the full potential of their data. As we’ve explored, from setup to orchestration, this synergy not only streamlines operations but also enhances the precision of data outcomes. As data continues to be an invaluable asset, leveraging such powerful tools becomes imperative for any data-driven enterprise.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/dbt-meets-mage-powering-advanced-data-transformations"><em>https://www.mage.ai/blog/dbt-meets-mage-powering-advanced-data-transformations</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86cadd27e92f" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/dbt-meets-mage-powering-advanced-data-transformations-86cadd27e92f">DBT Meets Mage: Powering Advanced Data Transformations</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing and Documentation in DBT: Ensuring Data Quality and Accessibility]]></title>
            <link>https://m.mage.ai/testing-and-documentation-in-dbt-ensuring-data-quality-and-accessibility-d1dd738678cf?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1dd738678cf</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Tue, 12 Sep 2023 22:27:49 GMT</pubDate>
            <atom:updated>2023-09-12T22:33:51.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Vwr3Os6olyW24C-" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p>Testing and documentation in <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> are crucial pillars for maintaining data integrity and understanding. They work hand-in-hand to ensure data transformations are accurate and comprehensible for teams, promoting both data quality and easy accessibility.</p><h3>Outline</h3><ul><li>The importance of testing in DBT</li><li>Writing tests in DBT</li><li>Using DBT to generate documentation</li><li>Maintaining and updating DBT documentation</li><li>A practical example of testing and documenting a DBT model</li><li>Conclusion</li></ul><h3>The importance of testing in DBT</h3><p>In the world of data transformation and analytics, <a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> has emerged as a key player. A crucial aspect of DBT, which sets it apart from many traditional ETL tools, is its robust testing capabilities. Here’s a deep dive into the importance of testing in DBT:</p><p><strong>Catching Data Anomalies Early:</strong></p><ul><li>With DBT’s testing capabilities, data anomalies or issues can be identified and rectified early in the data transformation process.</li><li>This early detection can prevent costly mistakes downstream, such as presenting misleading insights to stakeholders.</li></ul><p><strong>Built-in Test Functions:</strong></p><ul><li>DBT comes with a set of predefined tests like unique, not_null, and accepted_values.</li><li>These built-in tests are tailored for common data integrity checks, making it easy to validate data without writing extensive custom logic.</li></ul><p><strong>Custom Test Creation:</strong></p><ul><li>While built-in tests cover many scenarios, DBT’s flexibility in allowing users to define custom tests ensures that specific business logic and edge cases can also be validated.</li><li>This ensures that data models are not just technically sound but also business-relevant.</li></ul><p><strong>Ensuring Consistency:</strong></p><ul><li>Regular testing in DBT ensures data consistency across models, especially important when multiple analysts or data engineers are involved.</li><li>This reduces the chance of conflicting transformations or duplicate work.</li></ul><p><strong>Source Data Validation:</strong></p><ul><li>Before diving deep into transformations, DBT tests can validate source data, ensuring that any external data ingested into the system meets the required standards.</li><li>This is particularly useful when integrating with third-party systems or external data providers where data quality might vary.</li></ul><p>In essence, testing in DBT isn’t just a feature — it’s a fundamental part of the data transformation philosophy. It emphasizes the principle that data quality is paramount, and regular, rigorous testing is the key to achieving and maintaining that quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ZsV95AQWny3Xj3Pz.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/cbc-schitts-creek-jRpkPKdCEnFG1L1r27">Giphy</a>)</figcaption></figure><h3>Writing tests in DBT</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> incorporates a foundational principle: “Test your data, not your code.” This shifts the focus from merely coding transformations to ensuring the outcomes of these transformations are accurate and trustworthy. Here’s how you can leverage DBT to write tests:</p><p><strong>Utilizing Built-in Tests:</strong></p><ul><li><em>unique:</em> Validates that a column has no duplicate values.</li><li><em>not_null:</em> Checks that a column contains no null values.</li><li><em>accepted_values:</em> Ensures a column’s values fall within a specific set of acceptable values.</li></ul><p><strong>Writing Custom Tests:</strong></p><ul><li>While the built-in tests cater to common scenarios, DBT’s Jinja context allows for crafting custom SQL-based tests for specific use-cases.</li><li>A custom test is typically a SQL query that should return no rows if the test passes.</li></ul><p><em>— Example: Ensure the ‘revenue’ column is always positive</em></p><pre>select *<br>from {{ ref(&#39;your_model&#39;) }}<br>where revenue &lt; 0</pre><p><strong>Test Configurations:</strong> Tests in DBT can be configured using the <strong>dbt_project.yml</strong> file or directly within the model’s SQL file.</p><ul><li><em>warn_if:</em> Set a threshold for failure warning without failing the run.</li><li><em>error_if:</em> Define a threshold that will fail the run if exceeded.</li><li><em>severity:</em> Determine the severity (e.g., warn or error) of a test failure.</li></ul><p><strong>Source Tests:</strong></p><ul><li>DBT also allows testing directly on source data with source configurations.</li><li>This ensures that the raw data ingested into the transformation pipeline adheres to expected standards from the outset.</li></ul><pre>sources:<br>  - name: my_source<br>    tables:<br>      - name: my_table<br>        tests:<br>          - unique:<br>              column_name: id</pre><p><strong>Running and Reporting:</strong></p><ul><li>Use the <strong>dbt test </strong>command to execute tests.</li><li>DBT’s CLI provides comprehensive feedback, listing which tests passed and which failed. This transparency aids in proactive error rectification.</li></ul><p>In summary, DBT’s testing capabilities, both built-in and customizable, provide an extensive toolkit for data engineers and analysts to assert the quality and consistency of their data models. Proper testing in DBT ensures that analytics and insights derived are both accurate and reliable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*PwJdli50wX3jBOVV.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/muppets-LmBsnpDCuturMhtLfw">Giphy</a>)</figcaption></figure><h3>Using DBT to generate documentation</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> isn’t just about transforming data. One of its standout features is its ability to auto-generate comprehensive documentation for your data models. This ensures that stakeholders, data engineers, and analysts have a clear understanding of the data’s structure, lineage, and transformation logic. Here’s how DBT achieves this:</p><p><strong>Self-Documenting Code:</strong></p><ul><li>DBT uses the principle of “self-documenting” code. This means that the code you write for your models, tests, and other configurations inherently serves as its own documentation.</li><li>It reduces the gap between code creation and documentation, ensuring they evolve together.</li></ul><p><strong>description Field:</strong></p><ul><li>Within your DBT models and configurations, there’s an option to use the <strong>description </strong>field.</li><li>This field allows you to provide detailed explanations for your models, columns, or tests, enhancing the auto-generated documentation.</li></ul><pre>models:<br>  - name: my_model<br>    description: &quot;This model joins user data with transaction data to calculate LTV.&quot;</pre><p><strong>Visualization of Data Lineage:</strong></p><ul><li>One of DBT’s powerful features is its ability to visually depict data lineage. This showcases the flow of data from source to transformation.</li><li>Stakeholders can easily trace back through a model’s lineage, understanding its dependencies and sources.</li></ul><p><strong>Web-based Interface:</strong></p><ul><li>Running<em> </em><strong><em>dbt docs serve</em> </strong>will launch a local web server, presenting an interactive, web-based version of your project’s documentation.</li><li>This interface is user-friendly, searchable, and provides a clear overview of models, tests, and sources.</li></ul><p><strong>Integration with dbt_artifacts:</strong></p><ul><li>DBT generates JSON artifacts post-run, which contain rich metadata about the run.</li><li>These artifacts can be utilized to enhance documentation with run statistics, test results, and more.</li></ul><p><strong>Keeping Documentation Fresh:</strong></p><ul><li>As you evolve your DBT models and logic, the documentation can be regenerated with the <strong><em>dbt docs generate </em></strong>command.</li><li>This ensures that your documentation remains updated with the most recent changes and provides an accurate representation of your data landscape.</li></ul><p><strong>Sharing and Collaboration:</strong></p><ul><li>The web-based documentation can be easily shared among teams. This promotes collaboration and ensures that everyone is on the same page regarding data definitions and structures.</li></ul><p>In conclusion, DBT’s documentation capabilities ensure that your data transformations aren’t just accurate and efficient, but also transparent and understandable. By bridging the gap between data engineering and analytics, DBT promotes a culture where data’s story is as important as the insights derived from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*2AD9MNDcCrT_hHTp.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/xT4uQwLt2AyurOGWFW">Giphy</a>)</figcaption></figure><h3>Maintaining and updating DBT documentation</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> revolutionizes the way data teams think about transformations by offering a “source of truth” through its auto-generated documentation. Maintaining and updating this documentation is critical for ensuring a seamless workflow and fostering trust with stakeholders. Here’s a guide on how to do this efficiently:</p><p><strong>Auto-generation is Key:</strong></p><ul><li>At the heart of DBT’s approach is the auto-generation of documentation. Running <strong>dbt docs generate </strong>automatically captures changes in your models, tests, and other configurations.</li><li>This ensures that as you evolve your models, the documentation is always kept in sync with minimal manual intervention.</li></ul><p><strong>Leverage the description Field:</strong></p><ul><li>Always update the description field when making changes to your models, columns, or tests.</li><li>This not only provides context about the data transformations but also informs users about recent updates or changes.</li></ul><p><strong>Use Version Control:</strong></p><ul><li>Incorporating DBT within a version control system (like Git) offers a historical view of changes.</li><li>This facilitates tracking alterations in both the transformation logic and the accompanying documentation.</li></ul><p><strong>Schedule Regular Reviews:</strong></p><ul><li>Designate times (e.g., end of sprint, monthly) to review documentation for completeness and accuracy.</li><li>This is particularly crucial if multiple team members are contributing to the DBT project.</li></ul><p><strong>Highlight Deprecations:</strong></p><ul><li>If certain models or transformations are deprecated, ensure they’re clearly marked in the documentation.</li><li>This provides clarity and prevents reliance on outdated data processes.</li></ul><p><strong>Integrate with CI/CD:</strong></p><ul><li>Use Continuous Integration and Continuous Deployment (CI/CD) pipelines to automate the generation and deployment of documentation updates.</li><li>Tools like Jenkins or GitHub Actions can automatically run dbt docs generate and dbt docs serve whenever changes are pushed.</li></ul><p>While DBT greatly simplifies the documentation process with its auto-generation feature, maintaining its freshness and relevance requires a systematic approach. By integrating best practices and leveraging automation, teams can ensure that their DBT documentation remains a reliable and up-to-date resource for all stakeholders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*TWhSoePwBgFpXZpI.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/TheDemocrats-democrats-dnc-dncgif-tltOxW1fPVE1xxEX3j">Giphy</a>)</figcaption></figure><h3>A Practical Example of Testing and Documenting a DBT Model</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> offers powerful capabilities not just for transforming data but also for testing and documenting it. Let’s walk through a practical example of both testing and documenting a DBT model.</p><p><strong>Scenario:</strong></p><p>Imagine we have a DBT model that aggregates user data, generating a table of daily active users (DAU) from raw event logs.</p><p><strong>Model Creation:</strong></p><ul><li>First, we create our DBT model, <strong>dau.sql:</strong></li></ul><pre>SELECT<br>    DATE(event_timestamp) as date,<br>    COUNT(DISTINCT user_id) as daily_active_users<br>FROM<br>    raw_event_logs<br>GROUP BY<br>    1</pre><p><strong>Testing the Model</strong></p><ul><li>Before deploying our model to production, we want to ensure its accuracy. DBT offers built-in tests, and we can also define custom tests.</li><li><strong><em>Unique Test:</em></strong> Ensure that each date has a single entry.</li></ul><pre>version: 2<br><br><br>models:<br>  - name: dau<br>    tests:<br>      - unique:<br>          column_name: date</pre><p><strong>Not Null Test:</strong> Ensure that there are no NULL values in the date column.</p><pre>     - not_null:<br>          column_name: date</pre><p><strong>Documenting the Model:</strong></p><ul><li>DBT’s description field provides a seamless way to add documentation directly in the code.</li><li><strong>Model Description:</strong> At the top of <strong>dau.sql</strong>, add a comment to describe the model’s purpose.</li></ul><p>— This model aggregates raw event logs to compute daily active users.</p><p><strong>Column Descriptions:</strong> In the schema.yml file associated with the model, provide descriptions for each column.</p><pre>version: 2<br><br><br>models:<br>  - name: dau<br>    description: &quot;This model aggregates raw event logs to compute daily active users.&quot;<br>    columns:<br>      - name: date<br>        description: &quot;The specific day for the DAU count.&quot;<br>      - name: daily_active_users<br>        description: &quot;The count of unique active users for that day.&quot;</pre><p><strong>Generating and Viewing Documentation:</strong></p><ul><li>After adding the necessary tests and documentation:<br>- Run <strong>dbt docs generate </strong>to update the project’s documentation.<br>- Use <strong>dbt docs serve </strong>to start a local server and view the interactive documentation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ht6JeQ4ayOvItszr.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/quentin-tarantino-pulp-fiction-samuel-l-jackson-xT9KVqOt8xuRYhNpq8">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>DBT’s integrated testing and documentation underscore a new era of data reliability and transparency. By intertwining rigorous quality checks with clear, accessible documentation, DBT empowers teams to foster trust, drive understanding, and elevate the overall standard of data practices in today’s digital landscape. In the next article of this series, we’ll see how we can integrate DBT with Mage.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/testing-and-documentation-in-dbt-ensuring-data-quality-and-accessibility"><em>https://www.mage.ai/blog/testing-and-documentation-in-dbt-ensuring-data-quality-and-accessibility</em></a></p><p><a href="https://medium.com/tag/dbt?source=post_page-----d6a5a7b20137---------------dbt-----------------">Dbt</a></p><p><a href="https://medium.com/tag/data-modeling?source=post_page-----d6a5a7b20137---------------data_modeling-----------------">Data Modeling</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1dd738678cf" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/testing-and-documentation-in-dbt-ensuring-data-quality-and-accessibility-d1dd738678cf">Testing and Documentation in DBT: Ensuring Data Quality and Accessibility</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging DBT for Data Modeling and Transformation]]></title>
            <link>https://m.mage.ai/leveraging-dbt-for-data-modeling-and-transformation-d6a5a7b20137?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6a5a7b20137</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-transformation]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Tue, 29 Aug 2023 03:42:55 GMT</pubDate>
            <atom:updated>2023-08-29T03:42:55.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*75xlu70JeWEi-Hj3" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> streamlines data modeling and transformations in modern data platforms. This tech blog dives into the essentials of setting up DBT projects, executing transformations, and offers an illustrative project example, capped off with best practices for creating robust DBT models.</p><h3>Outline</h3><ul><li>Introduction to data modeling with DBT</li><li>Understanding DBT projects and packages</li><li>Writing and running DBT transformations</li><li>Best practices for writing DBT models</li><li>Conclusion</li></ul><h3>Introduction to data modeling with DBT</h3><p>Data modeling is about creating a structured representation of data to ensure it is useful and meaningful. With DBT, this means defining the structure, relations, and integrity of data tables and views within your warehouse.</p><p><strong>DBT Models:</strong></p><ul><li><em>Definition:</em> At its core, a DBT model is a SQL select statement. When DBT runs a model, it translates this SQL into a table or view in the data warehouse.</li><li><em>File-based:</em> Each model lives in its file and is written in SQL. This ensures clarity and separation of different data entities.</li></ul><p><strong>Materializations:</strong></p><ul><li>One of the core concepts in DBT. It dictates how the SQL code in a model is executed in the warehouse.</li><li>Common types include:<br>- <em>table:</em> creates a table and rebuilds it on every DBT run.<br>-<em> view:</em> creates a SQL view.<br><em>- incremental:</em> only adds new records since the last DBT run.</li></ul><p><strong>DBT’s Approach to Data Modeling:</strong></p><ul><li><em>Source Tables: </em>Start with raw data, often termed ‘source tables’ in DBT. This raw data is then refined into more structured and useful entities.</li><li><em>Building Layers: </em>DBT promotes creating multiple layers of transformation, often starting with a base layer (raw data with minimal changes), followed by intermediate layers, and ending with a final business-logic layer. Each layer is a refined version of the previous one.</li></ul><p><strong>Relations and Joins:</strong></p><ul><li>Like any data modeling tool, DBT models can define relations between different data entities using SQL joins. This allows for the creation of comprehensive datasets from disparate sources.</li></ul><p><strong>Testing Data Models:</strong></p><ul><li>DBT allows you to write tests against your models, ensuring data integrity and consistency. For instance, you can check if a column has unique values or if there are null values where they shouldn’t be.</li></ul><p><strong>Documentation:</strong></p><ul><li>One of DBT’s strengths in the realm of data modeling is its ability to auto-generate documentation based on the models and their descriptions. This ensures stakeholders have clarity on data structures and transformations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*l3wvClUSl9fKabC1.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/betplus-bet-real-husbands-of-hollywood-vate-private-mass-tagsbet-plus-OxJ87QBlFbEaAzopcJ">Giphy</a>)</figcaption></figure><h3>Understanding DBT projects and packages</h3><p>DBT projects and packages are core components of the DBT framework that allow data teams to organize, reuse, and share their transformation logic. This organization and modularity play a crucial role in scaling and maintaining a clean data transformation workflow.</p><p><strong>DBT Projects:</strong></p><ul><li><strong>Definition: </strong><br>- A DBT project is a directory of configuration files, models, tests, and other assets that define how DBT should transform your data.</li><li><strong>Initialization: </strong><br>- Projects are initiated with the <strong>dbt init &lt;project-name&gt; </strong>command. This creates a standard directory structure to begin your work.</li><li><strong>Key Components:</strong><br><em>- Models:</em> Core SQL transformations that you’ll run.<br>- <em>Tests: </em>Assertions and checks on your data models.<br>- <em>Macros:</em> Reusable SQL snippets or logic.<br>- <em>Snapshots: </em>Track changes in data over time.<br>- <em>Analysis:</em> One-off analyses that don’t result in persistent models.<br>- <em>Documentation:</em> Auto-generated and custom documentation for your data transformations.</li><li><strong>dbt_project.yml Configuration:</strong><br>- The heart of a DBT project, it includes settings such as project name, configuration versions, source data configurations, and default materializations.</li></ul><p><strong>DBT Packages:</strong></p><ul><li><strong>Definition: </strong><br>- Packages are bundles of DBT models, macros, and other assets that can be reused across multiple DBT projects.</li><li><strong>Why Use Packages?</strong><br>- <em>Reusability:</em> Avoid rewriting common transformations or macros.<br>- <em>Community Contributions: </em>The DBT community has developed numerous packages for common tasks or specific platforms (e.g., Google Analytics, HubSpot).<br>-<em> Consistency:</em> Standardize certain transformations across different projects or teams.</li><li><strong>Using Packages:</strong><br>- You can incorporate a package into your DBT project by adding it to your <strong>packages.yml </strong>file and then running <strong>dbt deps </strong>to download the specified packages.<br>- Example <strong>packages.yml </strong>entry:</li></ul><pre>packages:<br>  - package: fishtown-analytics/dbt_utils<br>    version: 0.6.4</pre><p><strong>Building Your Own Package:</strong></p><ul><li>If you have a set of models or macros reused across projects, consider turning them into a package.</li><li>Organize the reusable assets in a directory, ensure it has a valid <strong>dbt_project.yml</strong>, and then reference this directory in the <strong>packages.yml </strong>of other projects.</li></ul><p><strong>Updating and Versioning:</strong></p><ul><li>DBT’s package manager supports versioning. This means you can specify which version of a package to use, ensuring stability and compatibility.</li><li>Regularly running <strong>dbt deps </strong>ensures you have the latest compatible versions of all packages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*8oIL555ktW8Lol43.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/TheDemocrats-dnc-democrats-dncgif-wjSgGiHkXnzuPYqJh8">Giphy</a>)</figcaption></figure><h3>Writing and running DBT transformations</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> is revolutionizing the way data engineers and analysts work with data transformations, specifically in the ‘T’ of the ELT (Extract, Load, Transform) paradigm. Writing and executing transformations in DBT requires a blend of SQL skills, understanding of DBT’s command-line interface, and familiarity with its core principles. Let’s walk through the process:</p><p><strong>Setting Up Your DBT Project:</strong></p><ul><li>Before you write transformations, ensure you’ve set up a DBT project using <strong>dbt init &lt;project-name&gt;</strong></li><li>This will create a directory structure with folders such as <strong>models</strong>, <strong>tests</strong>, and <strong>macros</strong>.</li></ul><p><strong>Writing Transformations:</strong></p><ul><li>Transformations are written as <strong>SQL SELECT</strong> statements in DBT models.</li><li>Each model corresponds to a single file in the <strong>models </strong>directory.</li><li>Example:</li></ul><pre>SELECT<br>    order_id,<br>    SUM(order_amount) as total_amount<br>FROM source_data.orders<br>GROUP BY order_id;</pre><p><strong>Materializations:</strong></p><ul><li>Determine how the transformation will be executed in the database.</li><li>Types include:<br>-<em> table: </em>Creates or replaces a table.<br>- <em>incremental:</em> Adds new records.<br>- <em>view:</em> Creates a database view.</li><li>Specify the materialization type in the model’s configuration using:</li></ul><pre>{{<br>    config(materialized=&#39;table&#39;)<br>}}</pre><p><strong>Using Macros for Reusability:</strong></p><ul><li>Macros allow you to write reusable SQL snippets.</li><li>Defined in the <strong>macros </strong>directory.</li><li>Called using the <strong>{{ }} </strong>Jinja syntax.</li><li>Useful for repetitive logic, like date transformations.</li></ul><p><strong>Running the Transformation:</strong></p><ul><li>Use the command line to navigate to your DBT project directory.</li><li>Use the <strong>dbt run </strong>command. This will execute all models in your project.</li><li>For a specific model: <strong>dbt run — models &lt;model_name&gt;</strong></li></ul><p><strong>Incremental Builds:</strong></p><ul><li>To save time and resources, DBT supports incremental runs.</li><li>Models with <strong>incremental </strong>materialization will only process new data.</li><li>Define logic using the <strong>is_incremental() </strong>function in your SQL.</li></ul><p><strong>Testing Your Transformations:</strong></p><ul><li>Ensure data consistency by writing tests.</li><li>Use <strong>dbt test </strong>to run tests defined in the <strong>tests </strong>directory.</li><li>Common tests include checking for null values or verifying unique keys.</li></ul><p><strong>Viewing Execution Results:</strong></p><ul><li>After running transformations, DBT provides a log in the console.</li><li>Details like execution time, data scanned, and any errors are visible.</li></ul><p><strong>Compiling SQL for Debugging:</strong></p><ul><li>Before running, you can compile the SQL to see the generated SQL statement.</li><li>Use <strong>dbt compile </strong>to achieve this. Useful for debugging and understanding macros.</li></ul><p><strong>Documentation and Lineage:</strong></p><ul><li>Once transformations are written and executed, generate documentation using <strong>dbt docs generate</strong></li><li>View it using <strong>dbt docs serve</strong>, offering insights into model lineage and dependencies.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*zsqB4n6aCPvNk1k9.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/fallontonight-jimmy-fallon-butter-the-tonight-show-Axj4KMCPkGBsLQHcRH">Giphy</a>)</figcaption></figure><h3>Best practices for writing DBT models</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> brings a software engineering approach to the realm of data transformations. Writing maintainable, efficient, and clear models is essential for the long-term success of your data operations. Here are some best practices to consider:</p><p><strong>Modularize Your Models:</strong></p><ul><li><em>Why? </em>Modular models are easier to understand, test, and maintain.</li><li><em>How?</em> Break down transformations into logical components. If a transformation step becomes too complex, consider splitting it into multiple models.</li></ul><p><strong>Leverage Naming Conventions:</strong></p><ul><li><em>Why? </em>Consistency aids clarity.</li><li><em>How? </em>Adopt a consistent naming scheme (e.g., prefixes like stg_ for staging models, dim_ for dimensions, fct_ for facts).</li></ul><p><strong>Use Descriptive Model Names</strong>:</p><ul><li><em>Why?</em> Understand the purpose of a model at a glance.</li><li><em>How?</em> Choose names that capture the essence of the data or transformation (e.g., orders_summary).</li></ul><p><strong>Document as You Go:</strong></p><ul><li><em>Why?</em> Future you, and other team members, will appreciate it.</li><li><em>How?</em> Use the description field in models. DBT will use this when auto-generating documentation.</li></ul><p><strong>Test Your Models:</strong></p><ul><li><em>Why?</em> Ensure data quality and catch issues early.</li><li><em>How?</em> Regularly use DBT’s built-in testing framework to validate things like uniqueness, non-null constraints, or relationships.</li></ul><p><strong>Optimize for Incremental Builds:</strong></p><ul><li><em>Why? </em>Faster build times and reduced data processing costs.</li><li><em>How?</em> Use the incremental materialization and leverage the is_incremental() function in your SQL logic.</li></ul><p><strong>Abstract Reusable Logic with Macros:</strong></p><ul><li><em>Why?</em> DRY (Don’t Repeat Yourself) principle.</li><li><em>How?</em> For frequently used SQL snippets or logic, turn them into macros. This also aids in code consistency across models.</li></ul><p><strong>Ensure Readability:</strong></p><ul><li><em>Why? </em>Code is read more often than it’s written.</li><li><em>How?</em> Format SQL consistently, use comments generously, and keep lines of code to a reasonable length.</li></ul><p><strong>Organize with Folders:</strong></p><ul><li><em>Why?</em> Easier navigation and model management.</li><li><em>How?</em> Group related models in subdirectories, like orders or inventory.</li></ul><p><strong>Manage Dependencies Explicitly:</strong></p><ul><li><em>Why? </em>Ensure models run in the correct order.</li><li><em>How?</em> Use ref() function to reference other models. DBT will then build a dependency graph and execute models in the correct sequence.</li></ul><p><strong>Be Cognizant of Warehouse Costs:</strong></p><ul><li><em>Why?</em> Optimize for cost and performance.</li><li><em>How?</em> Use the table materialization judiciously, especially on large datasets, to avoid excessive compute costs. Lean towards views where suitable.</li></ul><p><strong>Regularly Review and Refactor:</strong></p><ul><li><em>Why?</em> Needs change, and so does data.</li><li><em>How? </em>Periodically reassess your models in light of new business requirements or data changes. Refactoring can improve efficiency, clarity, and relevance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*W7OySp-HsZZcVruW.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/betplus-bet-plus-all-the-queens-mean-VDHCbkTQEe4S1wCS2T">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In the evolving landscape of data engineering, DBT emerges as a powerful tool to streamline and optimize the transformation process. By adopting best practices in modeling, understanding the intricacies of projects and packages, and leveraging its robust framework, teams can revolutionize their ELT workflows. Embracing DBT today paves the way for a more agile, transparent, and efficient data-driven future.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/leveraging-dbt-for-data-modeling-and-transformation"><em>https://www.mage.ai/blog/leveraging-dbt-for-data-modeling-and-transformation</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6a5a7b20137" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/leveraging-dbt-for-data-modeling-and-transformation-d6a5a7b20137">Leveraging DBT for Data Modeling and Transformation</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding DBT (Data Build Tool): An Introduction]]></title>
            <link>https://m.mage.ai/understanding-dbt-data-build-tool-an-introduction-751112595dc7?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/751112595dc7</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[real-time-analytics]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 23:54:21 GMT</pubDate>
            <atom:updated>2023-08-16T23:54:21.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*oQ-pxbLsyEMmvZuJ" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p><a href="https://www.getdbt.com/product/what-is-dbt/">DBT (Data Build Tool)</a> is an open-source software tool that enables data analysts and engineers to transform and model data in the data warehouse. It simplifies the ETL process by focusing on the ‘T’ — transformation — and integrates seamlessly with modern cloud-based data platforms.</p><h3>Outline</h3><ul><li>Overview of DBT</li><li>Core principles of DBT</li><li>DBT architecture</li><li>Challenges with DBT</li><li>Conclusion</li></ul><h3>Overview of DBT</h3><p>DBT (Data Build Tool) is an open-source tool that has revolutionized the way data analysts and engineers view and handle data transformation and modeling in the modern data stack. Here’s an overview of DBT:</p><p><strong>Philosophy:</strong></p><ul><li>Focuses on the ELT (Extract, Load, Transform) approach, leveraging modern cloud data warehouses.</li></ul><p><strong>Core Components:</strong></p><ul><li><em>Models:</em> SQL queries that define data transformations.</li><li><em>Tests:</em> Ensure data quality by validating models.</li><li><em>Snapshots:</em> Track historical changes in data.</li><li><em>Documentation:</em> Auto-generates documentation for clarity on data processes.</li></ul><p><strong>Development Workflow:</strong></p><ul><li>Developer-centric with version control (typically Git), branching, and pull requests.</li></ul><p><strong>Execution:</strong></p><ul><li>Compiles models into SQL and runs them directly on data warehouses like Snowflake, BigQuery, and Redshift.</li></ul><p><strong>Adapters:</strong></p><ul><li>Makes DBT versatile by connecting to various databases and data platforms.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*_9a-P1lcVodeDEWX.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/GlobalEsports-start-lets-let-the-games-begin-nxC1YCvGlsLDVGZ2Vt">Giphy</a>)</figcaption></figure><h3>Core principles of DBT</h3><p>DBT (Data Build Tool) operates on a set of core principles that guide its philosophy and approach to data transformation and modeling:</p><p><strong>Data Warehouse-Centric:</strong></p><ul><li>Raw data is ingested into the data warehouse, using its computational capabilities for in-database transformations. This principle capitalizes on modern warehouses like Snowflake, BigQuery, or Redshift for heavy computations.</li></ul><p><strong>ELT Workflow:</strong></p><ul><li>Instead of pre-transforming data (ETL), DBT supports ELT, where raw data is loaded into the data warehouse (Extract, Load) and then transformed using SQL-based models (Transform).</li></ul><p><strong>SQL as the DSL:</strong></p><ul><li>DBT uses SQL as its domain-specific language. This eliminates the need for proprietary transformation languages or GUI-based ETL tools, providing direct and transparent transformation logic.</li></ul><p><strong>Git-based Version Control:</strong></p><ul><li>DBT projects are typically version-controlled using Git, allowing for branch-based development, commit histories, and collaboration through pull requests.</li></ul><p><strong>Model Dependencies:</strong></p><ul><li>Models, written in SQL, can reference other models (ref() function). This creates a DAG (Directed Acyclic Graph) of dependencies, which DBT uses to run models in the correct order.</li></ul><p><strong>Data Testing:</strong></p><ul><li>DBT’s schema tests (e.g., unique, not_null, accepted_values) validate the integrity of the transformed data. Custom data tests can also be written in SQL to enforce specific business rules or constraints.</li></ul><p><strong>Jinja Templating:</strong></p><ul><li>DBT uses the Jinja2 templating engine. This allows for dynamic SQL code generation, loops, conditional logic, and macro creation for reusable SQL snippets.</li></ul><p><strong>CLI and API Integration:</strong></p><ul><li>DBT’s command-line interface (CLI) supports operations like run, test, and docs generate. It can also be integrated with CI/CD tools and other platforms through APIs.</li></ul><p><strong>Configurations &amp; Hooks:</strong></p><ul><li>Technical configurations can be set at the project, model, or global level (dbt_project.yml). Pre- and post-hooks allow for operations (like data quality checks or audit trails) to be executed before or after a model runs.</li></ul><p><strong>Extensibility with Adapters:</strong></p><ul><li>DBT’s architecture allows for custom adapters. While it comes with adapters for popular data platforms, the community or organizations can develop adapters for other platforms, ensuring wide compatibility.</li></ul><p>By emphasizing these technical principles and functionalities, DBT provides a powerful and flexible framework for data engineers and analysts to manage data transformations with precision and efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*5P3XMVBu1FqolBCl.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/thedailyshow-funny-reaction-5z0cCCGooBQUtejM4v">Giphy</a>)</figcaption></figure><h3>DBT architecture</h3><p>DBT (Data Build Tool) employs a unique architecture that sets it apart from traditional ETL tools and frameworks. At its core, DBT is a command-line tool that uses SQL and Jinja2 templating to transform and model data. Let’s break down its architecture:</p><p><strong>Command-Line Interface (CLI):</strong></p><ul><li><em>Central Control:</em> DBT is primarily operated through its command-line interface, allowing users to run commands for transformations (dbt run), testing (dbt test), and documentation generation (dbt docs generate).</li></ul><p><strong>SQL + Jinja2 Templating:</strong></p><ul><li><em>Dynamic SQL Generation:</em> By combining SQL with the Jinja2 templating engine, DBT allows for dynamic SQL code generation. This lets users incorporate loops, conditional logic, and macros into their transformation logic.</li></ul><p><strong>Projects and Configuration:</strong></p><ul><li><em>DBT Project:</em> The foundational unit in DBT. It contains models, tests, snapshots, macros, and the essential dbt_project.yml configuration file.</li><li><em>Configuration Files:</em> These YAML files (dbt_project.yml, profiles.yml, etc.) define project details, model configurations, and database connections.</li></ul><p><strong>Models &amp; Directed Acyclic Graph (DAG):</strong></p><ul><li><em>Models</em>: SQL files that represent the transformation logic.</li><li><em>DAG:</em> DBT builds a DAG of model dependencies using the ref() function in models. The DAG determines the execution order when running transformations.</li></ul><p><strong>Adapters:</strong></p><ul><li><em>Database Compatibility:</em> DBT uses adapters to connect and interface with different data platforms, like Snowflake, BigQuery, and Redshift. Adapters translate DBT’s generic SQL into database-specific SQL.</li></ul><p><strong>Testing Framework:</strong></p><ul><li><em>Built-in &amp; Custom Tests:</em> DBT supports both built-in tests (like unique or not_null) and custom tests defined in SQL, ensuring data quality and conformity to business rules.</li></ul><p><strong>Version Control Integration:</strong></p><ul><li><em>Git Integration:</em> DBT projects are typically stored in Git repositories, enabling collaboration, versioning, and branching.</li></ul><p><strong>Documentation:</strong></p><ul><li><em>Auto-generation:</em> DBT automatically generates a web-based documentation portal that visualizes model metadata, lineage, and descriptions.</li></ul><p><strong>Plugins and Extensibility:</strong></p><ul><li><em>Community Plugins:</em> DBT’s architecture allows for extensions, and the community has contributed various plugins, adding functionality and compatibility with other tools.</li></ul><p><strong>Runtime Environment:</strong></p><ul><li><em>In-database Computation: </em>Unlike ETL tools that may have their own computation engines, DBT compiles and runs SQL directly in the target data warehouse, leveraging its computational power for transformations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*pXNdxCBWJS-I06q4.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/em4i0bDs9Hm2Q">Giphy</a>)</figcaption></figure><h3>Challenges with DBT</h3><p>While DBT (Data Build Tool) has gained substantial popularity due to its approach to data transformation, it is not without its technical challenges, especially when viewed in the context of the broader data pipeline design:</p><p><strong>Initial Data Ingestion:</strong></p><ul><li>DBT focuses mainly on the transformation (T) part of the ELT process. The extraction (E) and load (L) phases are out of its scope, requiring other tools or manual setups to ingest data into the data warehouse.</li></ul><p><strong>Complex Dependency Management:</strong></p><ul><li>As DBT projects grow, managing model dependencies (DAG) can become complex. Ensuring models run in the right order without causing circular dependencies is crucial and can be challenging in large projects.</li></ul><p><strong>Performance Considerations:</strong></p><ul><li>Relying on the computational power of the data warehouse for transformations can lead to increased costs, especially if not optimized.</li><li>Some transformations might be less efficient in SQL compared to other data processing languages or tools.</li></ul><p><strong>Concurrency and Parallelism:</strong></p><ul><li>Handling concurrent DBT runs or ensuring that parallel transformations don’t interfere with each other can be challenging. There’s a need to fine-tune data warehouse configurations and manage resource contention.</li></ul><p><strong>Incremental Processing:</strong></p><ul><li>While DBT supports incremental models, designing them effectively requires careful consideration to ensure data integrity and avoid data duplication.</li></ul><p><strong>Real-time Data Processing:</strong></p><ul><li>DBT is batch-oriented by design. Real-time or near-real-time data processing pipelines might need additional tools or configurations outside of DBT’s standard capabilities.</li></ul><p><strong>Integration with External Tools:</strong></p><ul><li>DBT’s ecosystem is primarily SQL-focused. Integrating with non-SQL tools or platforms might require additional effort or custom plugins.</li></ul><p><strong>Operational Monitoring and Alerting:</strong></p><ul><li>Out-of-the-box, DBT does not provide comprehensive monitoring or alerting mechanisms for transformations. Integration with monitoring tools or building custom alert systems might be necessary.</li></ul><p><strong>Error Handling:</strong></p><ul><li>Granular error handling, especially for non-fatal issues, can be complex. DBT will fail a run if a model encounters an error, requiring manual intervention or a robust orchestration tool to manage failures.</li></ul><p><strong>Security and Compliance:</strong></p><ul><li>Ensuring that DBT processes adhere to data governance, security, and compliance requirements might necessitate additional configurations, especially when working with sensitive data.</li></ul><p><strong>Scalability:</strong></p><ul><li>As data volume grows, some DBT models might need refactoring or optimization to maintain performance. This requires ongoing maintenance and tuning.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*-e2TD0SuS-PE7RUc.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/DefyTVNetwork-come-on-man-counting-cars-thats-a-challenge-pqcWLv9btMBin5T92o">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In the ever-evolving landscape of data processing and analytics, DBT emerges as a powerful tool that merges software engineering best practices with data operations. Its ELT-centric approach, modular design, and emphasis on code and collaboration make it an attractive solution for modern data teams.</p><p>Yet, like any tool, it is not without its challenges. Factors like dependency management, real-time processing, and scalability require thoughtful consideration in the broader context of data pipeline design.</p><p>With proper planning and awareness of its intricacies, DBT can be a pivotal element in a data team’s toolkit, driving efficiency, transparency, and reliability in data transformations. As with all tools, a balance of its strengths against its challenges is essential in leveraging its full potential effectively.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/understanding-dbt-data-build-tool-an-introduction"><em>https://www.mage.ai/blog/understanding-dbt-data-build-tool-an-introduction</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=751112595dc7" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/understanding-dbt-data-build-tool-an-introduction-751112595dc7">Understanding DBT (Data Build Tool): An Introduction</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Integration: Google BigQuery with Mage]]></title>
            <link>https://m.mage.ai/data-integration-google-bigquery-with-mage-437838aff8b4?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/437838aff8b4</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[data-integration]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[low-code]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 17:50:05 GMT</pubDate>
            <atom:updated>2023-07-21T18:57:33.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*AZoiTuIkU_NJgdgQ" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p>This article outlines the integration between <a href="https://www.mage.ai/">Mage</a> and <a href="https://cloud.google.com/bigquery">Google BigQuery</a>, a serverless data warehousing service. We’ll discuss the integration process, its benefits, and how it aids businesses in making data-driven decisions.</p><h3>Outline</h3><ul><li>Introduction to Mage</li><li>Overview of Google BigQuery</li><li>Step by step process to integrate Google BigQuery with Mage</li><li>Conclusion</li></ul><h3>Introduction to Mage</h3><p>In an age where data is the new oil, efficient and reliable data management tools are essential. <a href="https://www.mage.ai/github">Mage</a> is a platform committed to simplifying data integration and analytics. Designed for seamless data transformation and loading, Mage is transforming how businesses approach data management. Here are its key features:</p><ul><li><em>Automated Data Pipeline: </em>Mage automates data extraction, transformation, and loading (ETL) processes. It can extract data from multiple sources, transform it to a desirable format, and load it into a data warehouse.</li><li><em>Data Connectors:</em> Mage offers various data connectors to widely-used data sources like Shopify, Facebook Ads, Google Ads, Google Analytics, etc. This makes it easier to import data from these platforms.</li><li><em>Easy Integration:</em> Mage provides easy integration with popular data warehouses including Google BigQuery, Amazon Redshift, and Snowflake.</li><li><em>Pre-built SQL Models:</em> Mage comes with pre-built SQL models for popular e-commerce platforms like Shopify and WooCommerce. These models simplify the process of data analysis.</li><li><em>Incremental Loading:</em> Mage supports incremental loading, which means only new or updated data is loaded into the data warehouse. This saves storage space and improves efficiency.</li><li><em>Data Transformations: </em>Mage performs automatic data transformations, converting raw data into a more usable format. This process makes the data ready for analysis and reporting.</li><li><em>Scheduled Refresh: </em>Data refreshes can be scheduled in Mage, ensuring that the data in the warehouse is always up-to-date.</li><li><em>Data Security:</em> Mage places a high emphasis on data security, ensuring data privacy and compliance with GDPR and other data protection regulations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*95p91uIO4M9HqIxL.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/bbmas-bbmas-2016-xT4uQaQ2ZhlZybPiFO">Giphy</a>)</figcaption></figure><h3>Overview of Google BigQuery</h3><p><a href="https://cloud.google.com/bigquery">Google BigQuery</a> is a highly scalable, serverless data warehouse offered by Google as part of its Google Cloud Platform (GCP). It is designed to streamline and simplify the processing of big data.</p><ul><li><em>Serverless Architecture:</em> BigQuery operates on a serverless model, which means users don’t need to manage any servers or infrastructure. This means you can focus more on analysis and less on maintenance. It allows you to query massive datasets in seconds and get insights in real-time, without needing to worry about resource provision.</li><li><em>Real-Time Analytics:</em> BigQuery is engineered for real-time analytics. It allows users to analyze real-time data streams instantly. With its ability to run SQL queries on petabytes of data, it delivers speedy results on real-time data analytics, enabling businesses to make timely decisions.</li></ul><p>Google BigQuery, with its serverless architecture and real-time analytics, serves as a robust platform to handle, analyze, and draw insights from massive datasets with ease.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*DMVvOFKd0P3gRC8Q.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/abcnetwork-yes-great-thats-UVTGqXQDtSgiMuKi2K">Giphy</a>)</figcaption></figure><h3>Step by step process to migrate Google BigQuery with Mage</h3><p>Before we begin, we’ll need to create a service account key. Please read <a href="https://cloud.google.com/iam/docs/keys-create-delete">Google Cloud’s documentation</a> on how to create that.</p><p>Once we are finished, following these steps:</p><ol><li>Create a new pipeline or open an existing pipeline.</li><li>Expand the left side of the screen to view the file browser.</li><li>Scroll down and click on a file named <strong>io_config.yaml</strong></li><li>Enter the following keys and values under the key named default (we can have multiple profiles, add it under whichever is relevant for us)</li><li>Note: we only need to add the keys under <strong>GOOGLE_SERVICE_ACC_KEY </strong>or the value for key<strong> GOOGLE_SERVICE_ACC_KEY_FILEPATH </strong>(both are not simultaneously required).</li></ol><pre>version: 0.1.1<br>default:<br>  GOOGLE_SERVICE_ACC_KEY:<br>    type: service_account<br>    project_id: project-id<br>    private_key_id: key-id<br>    private_key:<br>      &quot;-----BEGIN PRIVATE KEY-----\nyour_private_key\n-----END_PRIVATE_KEY&quot;<br>    client_email: your_service_account_email<br>    auth_uri: &quot;https://accounts.google.com/o/oauth2/auth&quot;<br>    token_uri: &quot;https://accounts.google.com/o/oauth2/token&quot;<br>    auth_provider_x509_cert_url: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;<br>    client_x509_cert_url: <br>&quot;https://www.googleapis.com/robot/v1/metadata/x509/your_service_account_email&quot;<br>  GOOGLE_SERVICE_ACC_KEY_FILEPATH: &quot;/path/to/your/service/account/key.json&quot;</pre><p><strong>Using SQL block</strong></p><ol><li>Create a new pipeline or open an existing pipeline.</li><li>Add a data loader, transformer, or data exporter block.</li><li>Select <strong>SQL</strong>.</li><li>Under the <strong>Data provider </strong>dropdown, select <strong>BigQuery</strong></li><li>Under the <strong>Profile </strong>dropdown, select <strong>default </strong>(or the profile we added credentials underneath).</li><li>Next to the <strong>Database </strong>label, enter the database name we want this block to save data to.</li><li>Next to the <strong>Save to schema </strong>label, enter the schema name we want this block to save data to.</li><li>Under the <strong>Write policy </strong>dropdown, select <strong>Replace </strong>or <strong>Append </strong>(please see <a href="https://docs.mage.ai/guides/sql-blocks">SQL blocks guide</a> for more information on write policies).</li><li>Enter in this test query: <strong>SELECT 1</strong></li><li>Run the block.</li></ol><p><strong>Using Python block</strong></p><ol><li>Create a new pipeline or open an existing pipeline.</li><li>Add a data loader, transformer, or data exporter block (the code snippet below is for a data loader).</li><li>Select <strong>Generic </strong>(no template).</li><li>Enter this code snippet (note: change the <strong>config_profile </strong>from default if we have a different profile):</li></ol><pre>from mage_ai.data_preparation.repo_manager import get_repo_path<br>from mage_ai.io.bigquery import BigQuery<br>from mage_ai.io.config import ConfigFileLoader<br>from os import path<br>from pandas import DataFrame</pre><pre>if &#39;data_loader&#39; not in globals():<br>    from mage_ai.data_preparation.decorators import data_loader</pre><pre>@data_loader<br>def load_data_from_big_query(**kwargs) -&gt; DataFrame:<br>    query = &#39;SELECT 1&#39;<br>    config_path = path.join(get_repo_path(), &#39;io_config.yaml&#39;)<br>    config_profile = &#39;default&#39;</pre><pre>    return BigQuery.with_config(ConfigFileLoader(config_path, config_profile)).load(query)</pre><p>5. Run the block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*j-ErIDx43sZdUfXo.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/cbc-schitts-creek-moira-1wpt0Aef5EdGyczbLk">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>Integrating Mage with Google BigQuery provides your team with a potent combination of automated data pipeline management and robust data warehousing. This partnership not only simplifies data extraction, transformation, and loading but also provides a seamless pathway for data analysis and insight generation. As we’ve demonstrated in this step-by-step guide, the integration process is straightforward, making it an accessible option for businesses of all sizes. By leveraging this integration, you can unlock the full potential of your data, streamline operations, and drive data-informed decisions.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/data-integration-google-bigquery-with-mage"><em>https://www.mage.ai/blog/data-integration-google-bigquery-with-mage</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=437838aff8b4" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/data-integration-google-bigquery-with-mage-437838aff8b4">Data Integration: Google BigQuery with Mage</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google BigQuery: Serverless data warehousing made simple]]></title>
            <link>https://m.mage.ai/google-bigquery-serverless-data-warehousing-made-simple-9a42c80327a9?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a42c80327a9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[google-big-query]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 18:21:04 GMT</pubDate>
            <atom:updated>2023-07-07T18:30:07.621Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*oVoM5W50Cgv_osdG_aj4IA.png" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p><a href="https://cloud.google.com/bigquery">Google BigQuery</a> is a serverless, scalable data warehouse on Google Cloud. It supports real-time analytics, machine learning, and GIS capabilities. With its unique architecture separating storage and computing, it offers automatic scalability and strong security, ideal for data-driven businesses.</p><h3>Outline</h3><ul><li>Introduction to Google BigQuery</li><li>Key features of Google BigQuery</li><li>BigQuery’s Unique Architecture</li><li>Benefits of Using BigQuery</li><li>Conclusion</li></ul><h3>Introduction to Google BigQuery</h3><p><a href="https://cloud.google.com/bigquery">Google BigQuery</a> is a highly scalable, serverless data warehouse offered by Google as part of its Google Cloud Platform (GCP). It is designed to streamline and simplify the processing of big data.</p><ul><li><em>Serverless Architecture:</em> BigQuery operates on a serverless model, which means users don’t need to manage any infrastructure or do any server management. This helps in focusing more on data analysis rather than worrying about capacity planning or server management. It allows you to query massive datasets in seconds and get insights in real-time, without needing to worry about resource provision.</li><li><em>Real-Time Analytics:</em> BigQuery is engineered for real-time analytics. It allows users to analyze real-time data streams instantly. With its ability to run SQL queries on gigabytes to petabytes of data, it delivers speedy results on real-time data analytics, enabling businesses to make timely decisions.</li></ul><p>In summary, Google BigQuery, with its serverless architecture and real-time analytics, serves as a robust platform to handle, analyze, and draw insights from massive datasets with ease.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*aBxHLSP7TeOrAQ2Z.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/Filmeditor--halloween-ashley-olsen-3otPoHMzdMgfZznjpe">Giphy</a>)</figcaption></figure><h3>Key features of Google BigQuery</h3><p><a href="https://cloud.google.com/bigquery">Google BigQuery</a> offers a robust set of features that make it an ideal choice for businesses looking to leverage data for actionable insights. These features extend from machine learning capabilities and geospatial analytics to multi-cloud data analysis and automated data transfer services. These cutting-edge functionalities position BigQuery as a powerful tool in the data analytics landscape. Let’s dive into some of these key features:</p><ul><li><em>Machine Learning Integration: </em>Google BigQuery provides built-in machine learning capabilities, enabling data scientists to create and execute machine learning models on structured and semi-structured data directly inside BigQuery using SQL. This ML integration allows users to build models with the ease of SQL commands, eliminating the need to move data across different environments or learn a new language.</li><li><em>GIS Capabilities: </em>BigQuery GIS, or Geo Viz, allows analysts to manage and analyze geospatial data in BigQuery by providing SQL geographic functions. These functions make it easier to understand spatial relationships and provide insights about geographic-based data that are critical for businesses, like determining delivery routes, analyzing service coverage areas, and much more.</li><li><em>BI Engine:</em> BigQuery BI Engine is a fast, in-memory analysis service that allows users to analyze data stored in BigQuery with sub-second query response time and high concurrency. Integrated with popular tools like Google Data Studio, it enables analysts and data scientists to create interactive dashboards and reports without any performance latency.</li><li><em>BigQuery Omni:</em> BigQuery Omni is a multi-cloud data analytics solution that allows users to execute BigQuery’s powerful analytics capabilities on data stored not just in Google Cloud, but also AWS and Azure. This means you can break down data silos and gain insights across different cloud platforms without having to move or copy data, enabling a truly multi-cloud data analytics approach.</li><li><em>BigQuery Data Transfer Service: </em>The BigQuery Data Transfer Service automates data movement from SaaS applications to Google BigQuery on a scheduled, managed basis. This allows businesses to maintain an updated data warehouse without the hassle of writing custom scripts or manually importing data, simplifying data ingestion and ensuring that data is readily available for analysis.</li></ul><p>In essence, Google BigQuery provides a comprehensive suite of tools and capabilities that not only simplify data warehousing tasks but also empower businesses to draw actionable insights from their data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ehDLZNWsq4SVt9Zp.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/abcnetwork-yes-great-thats-UVTGqXQDtSgiMuKi2K">Giphy</a>)</figcaption></figure><h3>Google BigQuery’s unique architecture</h3><p>At its core, Google BigQuery’s architecture is a manifestation of Google’s Dremel technology. Dremel is a highly scalable, interactive ad-hoc query system for the analysis of read-only nested data, and BigQuery utilizes this technology to execute SQL-like queries over multi-terabyte datasets in seconds.</p><ul><li><em>Dremel-Inspired Architecture:</em> BigQuery’s Dremel-inspired architecture allows it to deliver incredibly fast analytics on a petabyte scale. By creating a tree architecture for dispatching queries and aggregating results, Dremel enables BigQuery to scan trillions of rows in seconds and return results in a blink. This architecture uses a combination of columnar storage for data organization and tree architecture for query execution, allowing BigQuery to run SQL queries on large datasets swiftly.</li><li><em>Separation of Compute and Storage:</em> A fundamental design principle of BigQuery is the decoupling of compute and storage. The data you store in BigQuery is kept in a multi-tenant distributed architecture, separated from the computational resources. This separation allows for nearly infinite scalability: as your data grows, BigQuery scales to meet your storage needs without any intervention, and you can ramp up query computing power as needed without being limited by your data size.</li><li><em>Compute Resources:</em> When you run a query, BigQuery dynamically allocates computing resources as needed. This serverless model means that you don’t have to worry about pre-provisioning compute capacity, and you only pay for the queries you run.</li><li><em>Storage Layer: </em>On the storage side, BigQuery automatically replicates data for durability and high availability. It also handles all ongoing maintenance, including patches and upgrades. Data in BigQuery is stored in Capacitor, Google’s next-generation columnar storage format, which is highly compressed and optimized for reading large amounts of structured data.</li></ul><p>Google BigQuery’s unique architecture, inspired by Dremel, and its separation of compute and storage lead to high-speed query performance, automatic scalability, and strong data security, thereby making it an efficient data warehouse solution for businesses of all sizes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*jWQKjbSxUiMB16T4.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/paramountnetwork-paramount-network-juan-pablo-di-pace-M9QXzEx8dLmMapqufW">Giphy</a>)</figcaption></figure><h3>Benefits of using Google BigQuery</h3><p><a href="https://cloud.google.com/bigquery">Google BigQuery</a> provides a number of benefits that make it a compelling choice for businesses of all sizes, from startups to large enterprises, who are looking to derive insights from their data. These benefits stem from BigQuery’s serverless architecture, automatic scalability, strong security features, and other business benefits:</p><ul><li><em>Serverless Data Warehousing:</em> As a serverless solution, BigQuery eliminates the need for businesses to manage, administer, or tune any infrastructure, saving them time and resources. This allows businesses to focus on what truly matters — deriving insights from their data and using them to make informed business decisions.</li><li><em>Automatic Scalability:</em> BigQuery scales automatically to accommodate your data and workloads. Its architecture separates storage and computation, enabling each to scale independently. This ensures that the system can handle any volume of data and any number of queries while maintaining high performance.</li><li><em>Strong Security Features:</em> BigQuery is designed with a robust security model that integrates with other Google Cloud security tools. It offers data encryption at rest and in transit, identity and access management, and a host of other security features that help businesses protect their sensitive data.</li><li><em>Business Benefits: </em>Beyond the technical features, BigQuery offers tangible business benefits. It provides real-time insights that enable businesses to make timely decisions, improving operational efficiency and enabling new opportunities. It also reduces costs, as businesses only pay for the storage they use and the queries they run, making BigQuery a cost-effective solution for data warehousing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Tu-BIaXnUizxAtNv.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/BritanniaOnEpix-britannia-britanniaonepix-britanniaepix-f9jwBVzohvX7LSRqWU">Giphy</a>)</figcaption></figure><p>In conclusion, Google BigQuery stands out as a robust, serverless data warehouse in the Google Cloud Platform. Its unique Dremel-inspired architecture supports immense scalability and swift, real-time analytics. With features like machine learning integration, GIS capabilities, and multi-cloud data analytics, it equips businesses to derive critical insights from massive datasets efficiently and securely. BigQuery simplifies data management, providing a potent solution for data-driven decision-making in the ever-evolving digital landscape.</p><p>In episode 4 of Datawarehouse series, we’ll explore how we can integrate Data Warehousing services like Snowflake/Redshift/Google BigQuery with Mage.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/google-bigquery-serverless-data-warehousing-made-simple"><em>https://www.mage.ai/blog/google-bigquery-serverless-data-warehousing-made-simple</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a42c80327a9" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/google-bigquery-serverless-data-warehousing-made-simple-9a42c80327a9">Google BigQuery: Serverless data warehousing made simple</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake: Revolutionizing data warehousing]]></title>
            <link>https://m.mage.ai/snowflake-revolutionizing-data-warehousing-b2a7fd387253?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2a7fd387253</guid>
            <category><![CDATA[redshift]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 01:04:10 GMT</pubDate>
            <atom:updated>2023-07-07T01:04:10.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*q_n82FbzVmBfFuS4" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p><a href="https://www.snowflake.com/en/">Snowflake</a> is a cloud-based data warehousing platform that brings a new level of performance, simplicity, and affordability to businesses that require big data processing and analytics.</p><h3>Outline</h3><ul><li>Introduction to snowflake</li><li>Key features of snowflake</li><li>Snowflake’s unique architecture</li><li>Benefits of using snowflake</li><li>Conclusion</li></ul><h3>Introduction to snowflake</h3><p><a href="https://www.snowflake.com/en/">Snowflake</a> is a powerful, cloud-based data warehousing platform known for its unique, flexible architecture. By separating compute and storage resources, it offers scalable, efficient, and cost-effective data management. Snowflake eliminates the complexity of traditional data warehouses, offering a user-friendly, fully-managed solution. It supports various data formats and integrates well with diverse data processing tools and BI software. With robust security measures including encryption and role-based access control, Snowflake ensures data safety. Essentially, it empowers organizations to be data-driven, delivering a powerful and simple-to-use data warehouse solution in the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*MyUzuLfyh6Lyk07t.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/hrvy-kiss-snow-blow-fGX6wuxK5cOdwn3T5J">Giphy</a>)</figcaption></figure><h3>Key features of snowflake</h3><p><a href="https://www.snowflake.com/en/">Snowflake</a> is a powerful data warehousing platform that incorporates a broad set of capabilities designed to make data storage, retrieval, and analysis more efficient, flexible, and scalable. Let’s dive into some of the prime features that make Snowflake a standout choice in the realm of cloud data platforms:</p><ul><li><em>Elastic Scalability:</em> Snowflake enables you to scale up or down instantaneously. It can handle any volume of data, the number of users, or the complexity of queries without compromising performance.</li><li><em>Zero Management:</em> Snowflake is a fully-managed service that requires no management from your end, such as indexing or tuning, and it handles all infrastructure, optimization, availability, data protection, and more.</li><li><em>Multi-Cloud Platform:</em> Snowflake can run on multiple clouds, including AWS, Google Cloud, and Azure. This cross-cloud capability allows businesses to leverage the advantages of different cloud providers.</li><li><em>Data Sharing:</em> Snowflake allows you to share live, ready-to-query data across your organization, with partners, or even with your customers, securely and in real time.</li><li><em>Performance and Speed:</em> Snowflake’s unique architecture offers excellent query performance and allows for quick data retrieval, empowering businesses with real-time insights.</li><li><em>Data Security:</em> Snowflake offers robust security features, including automatic data encryption, network policies, and role-based access control to protect your data.</li><li><em>Support for Structured and Semi-Structured Data:</em> Snowflake natively supports JSON, Avro, XML, ORC, and Parquet, allowing you to work with various data formats in a flexible and straightforward manner.</li><li><em>Time Travel:</em> Snowflake’s Time Travel feature enables access to historical data at any point in the past, providing easy data recovery and audit capabilities.</li><li><em>Automatic Concurrency Scaling:</em> During high demand, Snowflake automatically spins up additional computing resources to ensure consistent, high-speed performance for all users and queries.</li><li><em>In-Database Machine Learning:</em> Snowflake supports in-database machine learning, allowing you to train models directly where your data resides, reducing data movement and improving security and efficiency.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*0U-wldme60SL2HBx.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/mtv-katy-perry-golden-globes-gif-fmT4vJRi9q2A0">Giphy</a>)</figcaption></figure><h3>Snowflake’s unique architecture</h3><p>Snowflake’s architecture is a hybrid of traditional shared-disk and shared-nothing architectures with an additional layer of cloud services. This three-tier architecture consists of:</p><p>1. <strong><em>Storage Layer:</em></strong> The base layer of Snowflake’s architecture is the database storage layer. It manages all aspects of data storage in Snowflake.</p><ul><li><em>Cloud Agnostic Storage:</em> Snowflake can store an unlimited amount of structured and semi-structured data across multiple cloud platforms. It can run on AWS, Google Cloud, or Azure.</li><li><em>Automatic Organization:</em> Data is automatically divided into micro-partitions when loaded into Snowflake. These micro-partitions are columnar and compressed for optimal storage and query performance.</li><li><em>Immutable Data:</em> Once written, data in Snowflake is immutable, which provides the ability to access data at any point in time, a feature known as ‘Time Travel’.</li></ul><p>2. <strong><em>Compute Layer:</em></strong> The second layer is the compute layer, known as virtual warehouses. This layer is responsible for executing queries on the data.</p><ul><li><em>Elasticity and Separation of Compute and Storage:</em> Virtual warehouses are independent compute resources that do not share CPU, memory, or storage, enabling them to scale up or down instantaneously based on workload, ensuring optimal performance without any contention.</li><li><em>Multi-cluster Warehouses:</em> For large concurrent workloads, Snowflake can automatically scale out queries across multiple compute clusters to maintain performance.</li></ul><p>3. <strong><em>Cloud Services Layer:</em></strong> The top layer is the cloud services layer. It coordinates and manages all aspects of Snowflake’s functionality.</p><ul><li><em>Security and Access Control</em>: This layer handles tasks such as user authentication, session management, access control, and encryption.</li><li><em>Metadata Management:</em> Snowflake automatically maintains detailed metadata about all objects in the system, including data files, table structures, and data statistics.</li><li><em>Query Optimization and Execution:</em> The cloud services layer optimizes and executes all SQL queries. It compiles SQL statements into low-level code that’s executed on virtual warehouses.</li><li><em>Transactions and ACID Compliance:</em> Snowflake supports fully ACID-compliant transactions, ensuring data consistency and reliability.</li></ul><p>In essence, Snowflake’s unique architecture enables a highly efficient, flexible, and scalable data processing environment, making it a powerful choice for organizations seeking to leverage data for business insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*DRASBz42Mw5dysAy.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/oscars-academy-awards-oscars-2020-QWX4CSDyx1VELvO5lm">Giphy</a>)</figcaption></figure><h3>Benefits of using snowflake</h3><p>Snowflake offers numerous advantages that make it a highly effective solution for data warehousing. These benefits, spanning from operational efficiency to strategic decision-making, are designed to cater to both technical needs and business objectives, providing an edge in today’s data-driven landscape.</p><ul><li><em>Seamless Data Integration:</em> Snowflake integrates effortlessly with existing data management tools, ETL/ELT solutions, and business intelligence platforms. This allows organizations to continue using their preferred tools while leveraging Snowflake’s powerful data warehousing capabilities.</li><li><em>Multi-Cloud and Cross-Cloud Capabilities:</em> Snowflake isn’t tied to a single cloud provider. You can use it on AWS, Google Cloud, or Azure, giving you the flexibility to choose your preferred cloud vendor, leverage multi-cloud strategies, or even migrate between them.</li><li><em>Disaster Recovery:</em> The platform’s ability to replicate data across cloud regions helps in achieving a robust disaster recovery strategy, mitigating the risk of data loss and ensuring business continuity.</li><li><em>Democratizing Data:</em> Snowflake empowers organizations to democratize their data by making it accessible for stakeholders across the organization. The increased availability of data for business users can drive data-driven decisions at all levels of the organization.</li><li><em>Collaboration and Data Exchanges:</em> Snowflake data exchange allows organizations to share live data with their business partners, creating collaborative opportunities and enabling more informed decision-making across the business ecosystem.</li><li><em>Reduced Total Cost of Ownership (TCO):</em> With its fully managed services, Snowflake reduces the need for extensive in-house data management and infrastructure, bringing down the total cost of ownership. The resources saved can be utilized for business-critical operations and innovation.</li><li><em>Resource Optimization:</em> Snowflake’s separate compute and storage resources allow organizations to optimize resource usage based on their specific needs. This not only enhances performance but also results in cost savings by ensuring resources are not wasted.</li><li><em>Business Agility:</em> With its robust features, scalability, and ease of use, Snowflake empowers businesses to be more agile. Organizations can rapidly adapt to changes, whether it’s increased demand, new data sources, or evolving business needs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*nTIxN6aZwrH_Nfu1.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/johnbcrist-comedy-john-crist-johncrist-wRgtUUCRA8uQ42TnxS">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>Snowflake is a comprehensive data warehousing solution designed for the cloud era. Its unique architecture and suite of features empower organizations to handle vast amounts of data with ease, speed, and flexibility. From effortless integration with existing tools to unparalleled scalability, and from secure real-time data sharing to cost-effective operations, Snowflake offers a transformative approach to data management. It ensures that businesses of all sizes and industries can leverage data effectively to derive valuable insights, make informed decisions, and ultimately, drive growth and innovation in an increasingly data-centric world. Whether you’re a small business looking to harness the power of data or a large enterprise aiming to optimize your data operations, Snowflake stands as a compelling choice in the realm of cloud data warehousing.</p><p>In episode 3 of data warehouse series, we’ll explore Google BigQuery.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/snowflake-revolutionizing-data-warehousing"><em>https://www.mage.ai/blog/snowflake-revolutionizing-data-warehousing</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a7fd387253" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/snowflake-revolutionizing-data-warehousing-b2a7fd387253">Snowflake: Revolutionizing data warehousing</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Redshift: Robust and Scalable Data Warehousing]]></title>
            <link>https://m.mage.ai/aws-redshift-robust-and-scalable-data-warehousing-4d0083904ca7?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d0083904ca7</guid>
            <category><![CDATA[redshift]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-warehousing]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 21:37:45 GMT</pubDate>
            <atom:updated>2023-06-14T21:38:30.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*L5YDdAc8ikLa24DN" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p><a href="https://aws.amazon.com/redshift/">Amazon Redshift</a> is a powerful, scalable data warehousing service within the AWS ecosystem. It excels in handling large datasets with its columnar storage, parallel query execution, and features like Redshift Spectrum and RA3 instances. Redshift’s clustered architecture, robust security, and integration with AWS services make it a go-to choice for businesses needing efficient and secure data management solutions.</p><h3>Outline</h3><ul><li>Introduction to AWS Redshift</li><li>Key Features of AWS Redshift</li><li>Redshift Architecture</li><li>Benefits and Use Cases</li><li>Conclusion</li></ul><h3>Introduction to AWS Redshift</h3><p><a href="https://aws.amazon.com/redshift/">Amazon Redshift</a> is a fully managed, petabyte-scale data warehousing service in the cloud, part of the expansive Amazon Web Services (AWS) ecosystem. As organizations today deal with astronomical amounts of data, they require efficient tools to store, retrieve, and analyze this data. Redshift is AWS’s answer to this growing need.</p><p>Designed for high-performance analysis of large datasets, Redshift allows businesses to run complex, data-heavy queries against big data sets, with results returned in seconds. It leverages columnar storage technology and parallel queries to quickly process data across multiple nodes.</p><p>The service is integrated with other AWS services, making it a natural choice for organizations already invested in the AWS infrastructure. With its scalability, speed, and integration capabilities, AWS Redshift opens the door to cost-effective big data analytics, helping businesses leverage their data for actionable insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*08HxYdvXpPgBIUDG.gif" /><figcaption>(Source: <a href="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZjc1MGRjMzU4YjA5NTAzZTJkMzE0ZGI3NGM2OGJkMjIxYjVkYmM0NCZlcD12MV9pbnRlcm5hbF9naWZzX2dpZklkJmN0PWc/65wfzcLCmxtSQAZORw/giphy.gif">Giphy</a>)</figcaption></figure><h3>Key features of AWS Redshift</h3><p>Amazon Redshift packs a number of unique features designed to provide reliable, scalable, and fast data warehousing:</p><ul><li><em>Redshift Spectrum:</em> This feature allows users to run queries directly against vast amounts of data stored in Amazon S3. You don’t need to import or load the data, and you can use the same SQL-based interface you use for your regular Redshift queries.</li><li><em>Data Lake Integration:</em> AWS Redshift can directly query and analyze data across your operational databases, data warehouse, and data lake. This gives you the ability to understand the complete picture using all your data without moving it around.</li><li><em>Concurrency Scaling:</em> This feature enhances performance by adding more query processing power when you need it. As demand for data processing increases, Redshift automatically adds additional capacity to handle that demand, allowing multiple queries to run concurrently without any decrease in performance.</li><li><em>RA3 instances:</em> RA3 instances let you size your cluster based primarily on your compute needs. They feature managed storage, meaning Redshift will automatically manage your data from high-performance SSDs to S3 as per the workload demand.</li><li><em>Advanced Data Compression:</em> AWS Redshift employs columnar storage technology, which minimizes the amount of data read from the disk, and advanced compression techniques that require less space compared to traditional relational databases.</li><li><em>Data Encryption:</em> Redshift provides robust security through automatic encryption for data at rest and in transit.</li></ul><p>By offering these key features, AWS Redshift delivers a flexible, powerful, and efficient solution for data warehousing and analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*jAbttcAoOIh8qO9n.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/amazed-rVVFWyTINqG7C">Giphy</a>)</figcaption></figure><h3>Redshift Architecture</h3><p>Amazon Redshift’s architecture is the cornerstone of its efficiency and high-speed performance when dealing with vast data volumes. Redshift utilizes a Massively Parallel Processing (MPP) data warehouse architecture, which partitions data across multiple nodes and executes queries in parallel, dramatically enhancing query performance. Here’s a deeper look at its design:</p><ul><li><em>Cluster: </em>The fundamental building block of Amazon Redshift data warehouse is a cluster. A cluster is a set of nodes, which consists of a leader node and one or more compute nodes. The number of compute nodes can be scaled up or down depending upon the processing power needed, and each node has its own CPU, storage, and RAM.</li><li><em>Leader Node:</em> The leader node is the orchestrator of the Redshift environment. It manages communication between client applications and the compute nodes. Client applications send SQL requests to the leader node, which parses and creates optimized query execution plans. The leader node then coordinates query execution with the compute nodes and compiles the final results to send back to the client applications. This node is also responsible for managing the distribution of data to the compute nodes.</li><li><em>Compute Nodes:</em> Compute nodes are responsible for executing the query plans received from the leader node. Each compute node scans its local data blocks and performs the operations needed by the query. Intermediate results are then sent back to the leader node for aggregation before the results are returned to the client. The compute nodes ensure the MPP (Massively Parallel Processing) architecture of Amazon Redshift.</li><li><em>Node Slices:</em> Each compute node is divided into slices. The number of slices per node depends on the node size of the cluster. Each slice is allocated a portion of the node’s memory and disk space, and it operates independently of other slices. When a query is run, each slice can work on its portion of the data concurrently, which contributes to Redshift’s high query performance.</li><li><em>Columnar Storage:</em> Redshift uses columnar storage, which means data is stored by column rather than by row. This can dramatically improve query speed, as it means that only the columns needed for a query are read from the disk, reducing the amount of I/O and boosting query performance.</li><li><em>Data Distribution:</em> Redshift distributes the rows of a table to the compute nodes according to a key chosen when the table is created. Proper choice of this key can significantly speed up query performance by minimizing the amount of data that needs to be transferred between nodes during query execution.</li><li><em>Data Compression:</em> Redshift uses various encoding techniques to compress columns of data, which can result in less disk I/O and faster query performance.</li></ul><p>This robust and thoughtfully designed architecture allows Amazon Redshift to efficiently manage and process huge volumes of data, making it a go-to solution for organizations dealing with big data analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*JCTSJIq6nG8ESvpo.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/masterpiecepbs-poldark-youre-crazy-insane-W0K7upPWCDIu3ryFmk">Giphy</a>)</figcaption></figure><h3>Benefits and Use Cases of AWS Redshift</h3><p><strong>Benefits</strong></p><p>Amazon Redshift provides several benefits that make it a potent choice for businesses looking to leverage their data effectively:</p><ul><li><em>AWS Integration: </em>As part of the AWS ecosystem, Redshift integrates seamlessly with other AWS services such as S3, Kinesis, and DynamoDB, which facilitates diverse data workflows.</li><li><em>Robust Security: </em>Redshift provides robust security features like automatic encryption, network isolation using Amazon VPC, and robust access control policies, ensuring your sensitive data is protected.</li><li><em>Cost-Effectiveness:</em> With Redshift’s ability to automatically scale resources, businesses only pay for what they need, making it a cost-effective solution. Also, Redshift’s columnar storage and data compression reduce the amount of storage needed, leading to additional cost savings.</li><li><em>Performance:</em> Redshift’s columnar storage, parallel query execution, and data compression lead to high-performance data processing, allowing businesses to gain insights from their data quickly.</li><li><em>Scalability:</em> Redshift allows you to start with a few hundred gigabytes of data and scale up to a petabyte or more, making it an excellent choice for businesses of all sizes.</li></ul><p><strong>Use Cases</strong></p><p>Redshift is ideal for various scenarios, but it truly shines in the following:</p><ul><li><em>Business Intelligence (BI) Tools:</em> Redshift integrates well with various BI tools like Tableau, Looker, and QuickSight, enabling organizations to create visualizations and perform detailed data analysis.</li><li><em>Data Lake Analytics:</em> With Redshift Spectrum, users can directly query data in an Amazon S3 data lake without having to move or transform it.</li><li><em>Log Analysis:</em> Businesses can use Redshift to analyze log data and understand website user behavior, application performance, and security patterns.</li><li><em>Real-Time Analytics:</em> Combined with other AWS services like Kinesis, Redshift can power real-time analytics applications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*WwJBqAHqaiWvz3uF.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/BritanniaOnEpix-britannia-britanniaonepix-britanniaepix-f9jwBVzohvX7LSRqWU">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In conclusion, AWS Redshift offers a powerful, scalable, and secure data warehousing solution. Its robust features and benefits, combined with seamless integration within the AWS ecosystem, make it a formidable tool for businesses looking to glean valuable insights from their data. Whether it’s powering real-time analytics, driving business intelligence tools, or analyzing vast data lakes, Redshift’s potential to unlock the power of big data is immense.</p><p>In episode 2 of the Datawarehouse series, we’ll explore <a href="https://www.snowflake.com/">Snowflake</a>.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/aws-redshift-robust-and-scalable-data-warehousing"><em>https://www.mage.ai/blog/aws-redshift-robust-and-scalable-data-warehousing</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d0083904ca7" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/aws-redshift-robust-and-scalable-data-warehousing-4d0083904ca7">AWS Redshift: Robust and Scalable Data Warehousing</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stream data processing with Mage]]></title>
            <link>https://m.mage.ai/stream-data-processing-with-mage-35c721796ea1?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/35c721796ea1</guid>
            <category><![CDATA[data-processing]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[real-time-streaming-data]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Tue, 06 Jun 2023 23:15:51 GMT</pubDate>
            <atom:updated>2023-06-06T23:15:51.758Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a1XAT3Ebf4jh3ZHh" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p>Dive into the implementation of stream data processing with <a href="https://www.mage.ai/">Mage</a>, using <a href="https://kafka.apache.org/">Kafka</a> as source.</p><h3>Outline</h3><ul><li>Introduction to Mage</li><li>Why is kafka a popular component of streaming applications?</li><li>Step by step guide to create streaming pipeline on Mage</li><li>Conclusion</li></ul><h3>Introduction to Mage</h3><p><a href="https://www.mage.ai/">Mage</a> is a powerful data processing tool allowing integration and synchronization of data from third-party sources. It supports building real-time and batch pipelines using Python, SQL, and R, making data transformation simple and efficient. Moreover, it enables running, monitoring, and orchestrating thousands of pipelines, ensuring a smooth data operation without the risk of data loss or interruption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*9moakih9oR7xjGzf" /><figcaption>(Source: <a href="https://giphy.com/gifs/theoffice-the-office-tv-episode-818-vKHKDIdvxvN7vTAEOM">Giphy</a>)</figcaption></figure><h3>Why is kafka a popular component of streaming applications?</h3><p><a href="https://kafka.apache.org/">Apache Kafka</a> is an open-source stream-processing software platform developed by LinkedIn and later donated to the Apache Software Foundation. It’s built on the publish-subscribe messaging system and designed to handle real-time data feeds. Kafka is essentially a distributed event log service that is fault-tolerant, highly scalable, and provides high throughput for publishing and subscribing records.</p><p>Given its robust features, Kafka is a popular component of streaming applications due to the following reasons:</p><ul><li><em>Performance and Scalability:</em> Kafka can handle real-time data feeds on a large scale, processing millions of messages per second. Its distributed architecture allows for effortless scalability.</li><li><em>Durability and Reliability: </em>Kafka’s distributed commit log ensures robust data persistence, safeguarding against data loss. If a node fails, the data can still be retrieved from other nodes, hence ensuring reliability.</li><li><em>Fault Tolerance:</em> Kafka can handle system failures without impacting the availability of data streams, which is crucial for applications that require constant, uninterrupted access to data.</li><li><em>Real-time Processing:</em> Kafka supports both batch and real-time use cases, providing developers with flexibility when creating various applications.</li><li><em>Integration Capabilities:</em> Kafka can integrate with a wide range of programming languages and data systems, making it versatile for differing application needs.</li></ul><p>Kafka’s popularity stems from its high performance, reliability, fault tolerance, real-time processing, and comprehensive integration capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/0*dTwgjPShJRlU6BUu.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/shy-shahrukh-khan-oh-stop-it-you-IHuF78peMmj3G">Giphy</a>)</figcaption></figure><h3>Step by step guide to create streaming pipeline on Mage</h3><p>Dive into a comparison of Flink and Spark based on their performance benchmarks and scalability. Discover how they handle processing speed, in-memory computing, resource management, and more.</p><ul><li><em>Processing Speed:</em> Flink excels in <strong>low-latency</strong>, high-throughput stream processing, while Spark is known for its fast batch processing capabilities. Both frameworks can process large volumes of data quickly, with Flink focusing on real-time analytics and Spark catering to <strong>batch </strong>data processing tasks.</li><li><em>In-Memory Computing:</em> Both Flink and Spark leverage in-memory computing, which allows them to cache intermediate results during data processing tasks. This approach significantly reduces the time spent on <strong>disk I/O </strong>operations and improves overall performance.</li><li><em>Resource Management:</em> Flink and Spark can efficiently manage resources by <strong>dynamically </strong>allocating and deallocating them according to workload requirements. This enables both frameworks to scale horizontally, handling large-scale data processing tasks across multiple nodes in a distributed environment.</li><li><em>Adaptive Query Execution:</em> Spark’s Adaptive Query Execution (AQE) feature optimizes query execution plans at runtime, allowing it to adapt to changing data and workload characteristics. This results in improved performance and resource utilization. Flink, on the other hand, does not currently have an equivalent feature.</li><li><em>Backpressure Handling:</em> Flink is designed to handle backpressure, ensuring that the system remains stable even under high loads. This is achieved through its built-in flow control mechanisms, which prevent data processing bottlenecks. Spark Streaming, in contrast, may <strong>struggle </strong>to handle <strong>backpressure</strong>, leading to potential performance degradation.</li><li><em>Data Partitioning:</em> Both Flink and Spark utilize data partitioning techniques to improve parallelism and optimize resource utilization during data processing tasks. While Spark employs RDDs and data partitioning strategies like Hash and Range partitioning, Flink uses <strong>operator chaining</strong> and pipelined execution to optimize data processing performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/0*4VkzC7O9gZVX0t46.gif" /><figcaption>(Source: <a href="https://media.giphy.com/media/5GoVLqeAOo6PK/giphy.gif">Giphy</a>)</figcaption></figure><h3>Recommendations for choosing the right tool for specific use cases</h3><p><strong>Set up Kafka</strong></p><p>Here is a quick guide on how to run and use Kafka locally.</p><p>Clone repository: <em>git clone https://github.com/wurstmeister/kafka-docker.git</em></p><ul><li>Change directory into that repository: <em>cd kafka-docker</em></li><li>Edit the <em>docker-compose.yml</em> file to match this:</li></ul><pre>version: &quot;2&quot;<br>services:<br>  zookeeper:<br>    image: wurstmeister/zookeeper:3.4.6<br>    ports:<br>      - &quot;2181:2181&quot;<br>  kafka:<br>    build: .<br>    container_name: docker_kafka<br>    ports:<br>      - &quot;9092:9092&quot;<br>    expose:<br>      - &quot;9093&quot;<br>    environment:<br>      KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9093,OUTSIDE://localhost:9092<br>      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT<br>      KAFKA_LISTENERS: INSIDE://0.0.0.0:9093,OUTSIDE://0.0.0.0:9092<br>      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE<br>      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock</pre><ul><li>Start Docker: <em>docker-compose up</em></li><li>Start a terminal session in the running container:</li></ul><pre>docker exec -i -t -u root $(docker ps | grep docker_kafka | cut -d&#39; &#39; -f1) /bin/bash</pre><ul><li>Create a topic:</li></ul><pre>$KAFKA_HOME/bin/kafka-topics.sh --create --partitions 4 --bootstrap-server kafka:9092 -<br>topic test</pre><ul><li>List all available topics in Kafka instance:</li></ul><pre>$KAFKA_HOME/bin/kafka-topics.sh --bootstrap-server kafka:9092 --list</pre><ul><li>Start a producer on topic named <em>test</em>:</li></ul><pre>$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic=test</pre><ul><li>Send messages to the topic named <em>test</em> by typing the following in the terminal:</li></ul><pre>&gt;hello<br>&gt;this is a test<br>&gt;test 1<br>&gt;test 2<br>&gt;test 3</pre><ul><li>Open another terminal and start a consumer on the topic named <em>test</em>:</li></ul><pre>$KAFKA_HOME/bin/kafka-console-consumer.sh --from-beginning --bootstrap-server kafka:9092<br>--topic=test</pre><ul><li>The output should look something like this:</li></ul><pre>hello<br>test 1<br>test 3<br>this is a test<br>test 2</pre><p>Setup stream data ingestion in Mage</p><ul><li>Run the following command to run Docker in network mode:</li></ul><pre>docker run -it -p 6789:6789 -v $(pwd):/home/src \<br>  --env AWS_ACCESS_KEY_ID=your_access_key_id \<br>  --env AWS_SECRET_ACCESS_KEY=your_secret_access_key \<br>  --env AWS_REGION=your_region \<br>  --network kafka-docker_default \<br>  mageai/mageai /app/run_app.sh  mage start default_repo</pre><ul><li>If the network named <em>kafka-docker_default</em> doesn’t exist, create a new network:</li></ul><pre>docker network create -d bridge kafka-docker_default</pre><ul><li>Check that it exists:</li></ul><pre>docker network ls</pre><p>If not able to connect with Kafka locally in a Docker container using Mage, in a Docker container the follow these steps:</p><ul><li>Clone Mage: <em>git clone </em><a href="https://github.com/mage-ai/mage-ai.git"><em>https://github.com/mage-ai/mage-ai.git</em></a></li><li>Change directory into Mage: <em>cd mage-ai</em></li><li>Edit the <em>docker-compose.yml</em> file to match this:</li></ul><pre>version: &#39;3&#39;<br>services:<br>  server:<br>    ... (original config)<br>    networks:<br>      - kafka<br>  app:<br>    ... (original config)<br>networks:<br>  kafka:<br>    name: kafka-docker_default<br>    	external: true</pre><ul><li>Run the following script in terminal:<em> ./scripts/dev.sh</em></li></ul><p>This will run Mage in development mode, which runs it in a Docker container using docker compose instead of docker run.</p><p>Create streaming data pipeline</p><ul><li>Open Mage in your browser.</li><li>Click +<em>New pipeline</em>, then select<em> Streaming</em>.</li><li>Add a data loader block, select <em>Kafka</em>, and paste the following:</li></ul><pre>connector_type: kafka<br>bootstrap_server: &quot;localhost:9092&quot;<br>topic: test<br>consumer_group: unique_consumer_group<br>batch_size: 100</pre><ul><li>By default, the <em>bootstrap_server</em> is set to <em>localhost:9092</em>, If you’re running Mage in a container, the <em>bootstrap_server</em> should be<em> kafka:9093</em></li><li>Messages are consumed from source in micro batch mode for better efficiency. The default batch size is 100. You can adjust the batch size in the source config.</li><li>Add a transformer block and paste the following:</li></ul><pre>from typing import Dict, List<br><br>if &#39;transformer&#39; not in globals():<br>    from mage_ai.data_preparation.decorators import transformer<br>@transformer<br>def transform(messages: List[Dict], *args, **kwargs):<br>    for msg in messages:<br>        print(msg)<br>    return messages</pre><ul><li>Add a data exporter block, select <em>OpenSearch</em> and paste the following:</li></ul><pre>connector_type: opensearch<br>host: https://search-something-abcdefg123456.us-west-1.es.amazonaws.com/<br>index_name: python-test-index</pre><ul><li>Change the host to match your OpenSearch domain’s endpoint.</li><li>Change the <em>index_name</em> to match the index you want to export data into.</li></ul><p>Test pipeline</p><ul><li>Open the streaming pipeline you just created, and in the right side panel near the bottom, click the button Execute pipeline to test the pipeline.</li><li>You should see an output like this:</li></ul><pre>[streaming_pipeline_test] Start initializing kafka consumer.<br>[streaming_pipeline_test] Finish initializing kafka consumer.<br>[streaming_pipeline_test] Start consuming messages from kafka.</pre><p>Publish messages using Python</p><ul><li>Open a terminal on your local workstation.</li><li>Install <em>kafka-python</em>:</li></ul><pre>pip install kafka-python</pre><ul><li>Open a Python shell and write the following code to publish messages:</li></ul><pre>from kafka import KafkaProducer<br>from random import random<br>import json<br><br>topic = &#39;test&#39;<br>producer = KafkaProducer(<br>    bootstrap_servers=&#39;kafka:9093&#39;,<br>)<br>def publish_messages(limit):<br>    for i in range(limit):<br>        data = {<br>            &#39;title&#39;: &#39;test_title&#39;,<br>            &#39;director&#39;: &#39;Bennett Miller&#39;,<br>            &#39;year&#39;: &#39;2011&#39;,<br>            &#39;rating&#39;: random(),<br>        }<br>        producer.send(topic, json.dumps(data).encode(&#39;utf-8&#39;))<br>publish_messages(5)</pre><ul><li>Once you run the code snippet above, go back to your streaming pipeline in Mage and the output should look like this:</li></ul><pre>[streaming_pipeline_test] Start initializing kafka consumer.<br>[streaming_pipeline_test] Finish initializing kafka consumer.<br>[streaming_pipeline_test] Start consuming messages from kafka.<br>[streaming_pipeline_test] [Kafka] Receive message 2:16: v=b&#39;{&quot;title&quot;: &quot;test_title&quot;,<br>&quot;director&quot;: &quot;Bennett Miller&quot;, &quot;year&quot;: &quot;2011&quot;, &quot;rating&quot;: 0.7010424523477785}&#39;,<br>time=1665618592.226788<br>[streaming_pipeline_test] [Kafka] Receive message 0:16: v=b&#39;{&quot;title&quot;: &quot;test_title&quot;,<br>&quot;director&quot;: &quot;Bennett Miller&quot;, &quot;year&quot;: &quot;2011&quot;, &quot;rating&quot;: 0.7886308380991354}&#39;,<br>time=1665618592.2268753<br>[streaming_pipeline_test] [Kafka] Receive message 0:17: v=b&#39;{&quot;title&quot;: &quot;test_title&quot;,<br>&quot;director&quot;: &quot;Bennett Miller&quot;, &quot;year&quot;: &quot;2011&quot;, &quot;rating&quot;: 0.0673276352704153}&#39;,<br>time=1665618592.2268832<br>[streaming_pipeline_test] [Kafka] Receive message 3:10: v=b&#39;{&quot;title&quot;: &quot;test_title&quot;,<br>&quot;director&quot;: &quot;Bennett Miller&quot;, &quot;year&quot;: &quot;2011&quot;, &quot;rating&quot;: 0.37935417366095525}&#39;,<br>time=1665618592.2268872<br>[streaming_pipeline_test] [Kafka] Receive message 3:11: v=b&#39;{&quot;title&quot;: &quot;test_title&quot;,<br>&quot;director&quot;: &quot;Bennett Miller&quot;, &quot;year&quot;: &quot;2011&quot;, &quot;rating&quot;: 0.21110511524126563}&#39;,<br>time=1665618592.2268918<br>[streaming_pipeline_test] {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;:<br>&#39;2011&#39;, &#39;rating&#39;: 0.7010424523477785}<br>[streaming_pipeline_test] {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;:<br>&#39;2011&#39;, &#39;rating&#39;: 0.7886308380991354}<br>[streaming_pipeline_test] {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;:<br>&#39;2011&#39;, &#39;rating&#39;: 0.0673276352704153}<br>[streaming_pipeline_test] {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;:<br>&#39;2011&#39;, &#39;rating&#39;: 0.37935417366095525}<br>[streaming_pipeline_test] {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;:<br>&#39;2011&#39;, &#39;rating&#39;: 0.21110511524126563}<br>[streaming_pipeline_test] [Opensearch] Batch ingest data [{&#39;title&#39;: &#39;test_title&#39;,<br>&#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;: &#39;2011&#39;, &#39;rating&#39;: 0.7010424523477785}, {&#39;title&#39;:<br>&#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;: &#39;2011&#39;, &#39;rating&#39;: 0.7886308380991354},<br>{&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;: &#39;2011&#39;, &#39;rating&#39;:<br>0.0673276352704153}, {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;, &#39;year&#39;: &#39;2011&#39;,<br>&#39;rating&#39;: 0.37935417366095525}, {&#39;title&#39;: &#39;test_title&#39;, &#39;director&#39;: &#39;Bennett Miller&#39;,<br>&#39;year&#39;: &#39;2011&#39;, &#39;rating&#39;: 0.21110511524126563}], time=1665618592.2294626</pre><p>Consume messages using Python</p><ul><li>If you want to programmatically consume messages from a Kafka topic, here is a code snippet:</li></ul><pre>from kafka import KafkaConsumer<br>import time<br><br>topic = &#39;test&#39;<br>consumer = KafkaConsumer(<br>    topic,<br>    group_id=&#39;test&#39;,<br>    bootstrap_servers=&#39;kafka:9093&#39;,<br>)<br>for message in consumer:<br>    print(f&quot;{message.partition}:{message.offset}: v={message.value}, time={time.time()}&quot;)</pre><p>Run in production</p><p>If you want to programmatically consume messages from a Kafka topic, here is a code snippet:</p><ul><li><a href="https://docs.mage.ai/design/data-pipeline-management#create-trigger">Create a trigger</a>.</li><li>Once the trigger is created, click the <em>Start trigger</em> button at the top of the page to make the streaming pipeline active.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*Q9bkAnCMG8m8Lsxt.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/reaction-tkYaChn7aZClW">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In conclusion, <a href="https://www.mage.ai/">Mage</a> is an exceptional tool for stream data processing, adept at managing data from various sources and transforming it through real-time and batch pipelines using Python, SQL, and R. It stands out in its capacity to efficiently handle thousands of pipelines simultaneously, ensuring smooth operations and data integrity. Given the increasing need for real-time data processing in today’s data-driven world, Mage is positioned as a vital tool in the arsenal of data professionals. Its versatility and robust capabilities make it a reliable choice for handling complex and voluminous streaming data.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/stream-data-processing-with-Mage"><em>https://www.mage.ai/blog/stream-data-processing-with-Mage</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35c721796ea1" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/stream-data-processing-with-mage-35c721796ea1">Stream data processing with Mage</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Apache Flink: A guide to stream processing]]></title>
            <link>https://m.mage.ai/getting-started-with-apache-flink-a-guide-to-stream-processing-70a785e4bcea?source=rss-78f1259c8acd------2</link>
            <guid isPermaLink="false">https://medium.com/p/70a785e4bcea</guid>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[flink]]></category>
            <category><![CDATA[apache-flink]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[stream-processing]]></category>
            <dc:creator><![CDATA[Community Post]]></dc:creator>
            <pubDate>Mon, 05 Jun 2023 23:20:37 GMT</pubDate>
            <atom:updated>2023-06-06T23:16:14.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*mutP94MAbuN1SySt" /></figure><p><em>Guest blog by </em><a href="https://www.linkedin.com/in/shashank219/"><em>Shashank Mishra</em></a><em>, Data Engineer @ Expedia</em></p><h3>TLDR</h3><p>This guide introduces <a href="https://flink.apache.org/">Apache Flink</a> and stream processing, explaining how to set up a Flink environment and create simple applications. Key Flink concepts are covered along with basic troubleshooting and monitoring techniques. It ends with resources for further learning and community support.</p><h3>Outline</h3><ul><li>Introduction to Apache Flink and stream processing</li><li>Setting up a Flink development environment</li><li>A simple Flink application walkthrough: data ingestion, processing, and output</li><li>Understanding Flink’s key concepts (DataStream API, windows, transformations, sinks, sources)</li><li>Basic troubleshooting and monitoring for Flink applications</li><li>Conclusion</li></ul><h3>Introduction to Apache Flink and Stream Processing</h3><p><a href="https://flink.apache.org/">Apache Flink</a> is an open-source, high-performance framework designed for large-scale data processing, excelling at real-time stream processing. It features low-latency and stateful computations, enabling users to process live data and generate insights on-the-fly. Flink is fault-tolerant, scalable, and provides powerful data processing capabilities that cater to various use cases.</p><p>Stream processing, on the other hand, is a computing paradigm that allows <strong>real-time data processing </strong>as soon as it arrives or is produced. Unlike traditional batch processing systems that deal with data at rest, stream processing handles data in motion. This paradigm is especially useful in scenarios where insights need to be derived immediately, such as real-time analytics, fraud detection, and event-driven systems. Flink’s powerful stream-processing capabilities and its high-throughput, low-latency, and exactly-once processing semantics make it an excellent choice for such applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yu1khxRXm_thFhyG" /><figcaption>(Source: <a href="https://flink.apache.org/use-cases/">Flink</a>)</figcaption></figure><h3>Setting up a Flink development environment</h3><p>Setting up a development environment for Apache Flink is a straightforward process. Here’s a brief step-by-step guide:</p><ul><li><em>Install Java:</em> Flink requires Java 8 or 11, so you need to have one of these versions installed on your machine. You can download Java from the <a href="https://www.oracle.com/in/java/technologies/downloads/">Oracle</a> website or use OpenJDK.</li><li><em>Download and Install Apache Flink:</em> You can download the latest <a href="https://flink.apache.org/downloads/">binary of Apache Flink</a> from the official Flink website. Once downloaded, extract the files to a location of your choice.</li><li><em>Start a Local Flink Cluster:</em> Navigate to the Flink directory in a terminal, then go to the <strong>‘bin’ </strong>folder. Start a local Flink cluster using the command. <strong>/start-cluster.sh </strong>(for Unix/Linux/macOS) or <strong>start-cluster.bat</strong>(for Windows).</li><li><em>Check Flink Dashboard: </em>Open a web browser and visit <a href="http://localhost:8081/">http://localhost:8081</a>, you should see the Flink Dashboard, indicating that your local Flink cluster is running successfully.</li><li><em>Set up an Integrated Development Environment (IDE):</em> For writing and testing your Flink programs, you can use an IDE such as <strong>IntelliJ IDEA </strong>or Eclipse. Make sure to also install the Flink plugin if your IDE has one.</li><li><em>Create a Flink Project:</em> You can create a new Flink project (Refer — <a href="https://github.com/apache/flink-playgrounds">Apache Flink Playground</a>) using a build tool like Maven or Gradle. Flink provides quickstart Maven archetypes to set up a new project easily.</li></ul><p>Once you’ve set up your Flink development environment, you’re ready to start developing Flink applications. Remember that while this guide describes a basic local setup, a production Flink setup would involve a distributed cluster and possibly integration with other big data tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*QaOYqqKGITHF83NE.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/TheDemocrats-dnc-democrats-dncgif-NR3ZKwpdNoSgAMeas0">Giphy</a>)</figcaption></figure><h3>A simple Flink application walkthrough: Data ingestion, Processing and Output</h3><p>A simple Apache Flink application can be designed to consume a data stream, process it, and then output the results. Let’s walk through a basic example:</p><ul><li><em>Data Ingestion (Sources):</em> Flink applications begin with one or more data sources. A source could be a file on a filesystem, a Kafka topic, or any other data stream.</li><li><em>Data Processing (Transformations): </em>Once the data is ingested, the next step is to process or transform it. This could involve filtering data, aggregating it, or applying any computation.</li><li><em>Data Output (Sinks):</em> The final step in a Flink application is to output the processed data, also known as a sink. This could be a file, a database, or a Kafka topic.</li><li><em>Job Execution:</em> After defining the sources, transformations, and sinks, the Flink job needs to be executed.</li></ul><p>Here’s a complete example that reads data from a Kafka topic, performs some basic word count processing on the stream, and then writes the results into a Cassandra table. This example uses Java and Flink’s DataStream API.</p><pre>import org.apache.flink.api.common.functions.FlatMapFunction;<br>import org.apache.flink.api.java.tuple.Tuple2;<br>import org.apache.flink.streaming.api.datastream.DataStream;<br>import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;<br>import org.apache.flink.streaming.connectors.cassandra.CassandraSink;<br>import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;<br>import org.apache.flink.util.Collector;<br>import org.apache.kafka.common.serialization.SimpleStringSchema;<br> <br>import java.util.Properties;<br> <br>public class KafkaToCassandraExample {<br> <br>    public static void main(String[] args) throws Exception {<br> <br>        final StreamExecutionEnvironment env =<br>StreamExecutionEnvironment.getExecutionEnvironment();<br> <br>        Properties properties = new Properties();<br>        properties.setProperty(&quot;bootstrap.servers&quot;, &quot;localhost:9092&quot;); // address of your<br>Kafka server<br>        properties.setProperty(&quot;group.id&quot;, &quot;test&quot;); // specify your Kafka consumer group<br> <br>        DataStream&lt;String&gt; stream = env.addSource(new FlinkKafkaConsumer&lt;&gt;(&quot;topic&quot;, new<br>SimpleStringSchema(), properties));<br> <br>        DataStream&lt;Tuple2&lt;String, Integer&gt;&gt; processedStream = stream<br>                .flatMap(new Tokenizer())<br>                .keyBy(0)<br>                .sum(1);<br> <br>        CassandraSink.addSink(processedStream)<br>                .setQuery(&quot;INSERT INTO wordcount.word_count (word, count) values (?, ?);&quot;)<br>                .setHost(&quot;127.0.0.1&quot;) // address of your Cassandra server<br>                .build();<br> <br>        env.execute(&quot;Kafka to Cassandra Word Count Example&quot;);<br>    }<br> <br>    public static final class Tokenizer implements FlatMapFunction&lt;String, Tuple2&lt;String,<br>Integer&gt;&gt; {<br>        @Override<br>        public void flatMap(String value, Collector&lt;Tuple2&lt;String, Integer&gt;&gt; out) {<br>            // normalize and split the line into words<br>            String[] words = value.toLowerCase().split(&quot;\\W+&quot;);<br> <br>            // emit the words<br>            for (String word : words) {<br>                if (word.length() &gt; 0) {<br>                    out.collect(new Tuple2&lt;&gt;(word, 1));<br>                }<br>            }<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/0*zDgsZkSNbl9PAYAH" /><figcaption>(Source: <a href="https://giphy.com/gifs/rock-coding-programming-MdA16VIoXKKxNE8Stk">Giphy</a>)</figcaption></figure><h3>Understanding Flink’s key concepts</h3><ul><li><a href="https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/datastream/overview/">DataStream API</a>: Flink’s main tool for creating stream processing applications, providing operations to transform data streams.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/datastream/operators/windows/">Windows</a>: Defines a finite set of stream events for computations, based on count, time, or sessions.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/dataset/transformations/">Transformations</a>: Operations applied to data streams to produce new streams, including map, filter, flatMap, keyBy, reduce, aggregate, and window.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/connectors/datastream/overview/">Sinks</a>: The endpoints of Flink applications where processed data ends up, such as a file, database, or message queue.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/connectors/datastream/overview/">Sources</a>: The starting points of Flink applications that ingest data from external systems or generate data internally, such as a file or Kafka topic.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/concepts/time/">Event Time vs. Processing Time</a>: Flink supports different notions of time in stream processing. Event time is the time when an event occurred, while processing time is the time when the event is processed by the system. Flink excels at event time processing, which is crucial for correct results in many scenarios.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/libs/cep/#:~:text=FlinkCEP%20is%20the%20Complex%20Event,what&#39;s%20important%20in%20your%20data.">CEP (Complex Event Processing)</a>: Flink supports CEP, which is the ability to detect patterns and complex conditions across multiple streams of events.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/overview/">Table API &amp; SQL</a>: Flink offers a Table API and SQL interface for batch and stream processing. This allows users to write complex data processing applications using a SQL-like expression language.</li><li><a href="https://nightlies.apache.org/flink/flink-statefun-docs-master/">Stateful Functions (StateFun)</a>: StateFun is a framework by Apache Flink designed to build distributed, stateful applications. It provides a way to define, manage, and interact with a dynamically evolving distributed state of functions.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/concepts/flink-architecture/">Operator Chain and Task</a>: Flink operators (transformations) can be chained together into a task for efficient execution. This reduces the overhead of thread-to-thread handover and buffering.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/ops/state/savepoints/">Savepoints</a>: Savepoints are similar to checkpoints, but they are triggered manually and provide a way to version and manage the state of Flink applications. They are used for planned maintenance and application upgrades.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/datastream/fault-tolerance/state/">State Management</a>: Flink provides fault-tolerant state management, meaning it can keep track of the state of an application (e.g., the last processed event) and recover it if a failure occurs.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/datastream/event-time/generating_watermarks/">Watermarks</a>: These are a mechanism to denote progress in event time. Flink uses watermarks to handle late events in stream processing, ensuring the system can handle out-of-order events and provide accurate results.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/ops/state/checkpoints/">Checkpoints</a>: Checkpoints are a snapshot of the state of a Flink application at a particular point in time. They provide fault tolerance by allowing an application to revert to a previous state in case of failures.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*BpxGHbb9kvfm2i51.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/poptv-pop-tv-poptv-now-amBn6ssHs8ql3RCGSd">Giphy</a>)</figcaption></figure><h3>Basic troubleshooting and monitoring in Flink</h3><p>Troubleshooting and monitoring are essential aspects of running Apache Flink applications. Here are some key concepts and tools:</p><ul><li><a href="https://docs.cloudera.com/csa/1.2.0/monitoring/topics/csa-hs-webui.html">Flink Dashboard</a>: This web-based user interface provides an overview of your running applications, including statistics on throughput, latency, and CPU/memory usage. It also allows you to drill down into individual tasks to identify bottlenecks or issues.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/deployment/advanced/logging/">Logging</a>: Flink uses SLF4J for logging. Logs can be crucial for diagnosing problems or understanding the behavior of your applications. Log files can be found in the log directory in your Flink installation.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/">Metrics</a>: Flink exposes a wide array of system and job-specific metrics, such as the number of elements processed, bytes read/written, task/operator/JobManager/TaskManager statistics, and more. These metrics can be integrated with external systems like Prometheus or Grafana.</li><li><a href="https://catalog.us-east-1.prod.workshops.aws/workshops/429cec9e-3222-4943-82f7-1f45c45ed99a/en-US/2-flinkdashboard/job-level-insights">Exceptions</a>: If your application fails to run, Flink will throw an exception with a stack trace, which can provide valuable information about the cause of the error. Reviewing these exceptions can be a key part of troubleshooting.</li><li><a href="https://catalog.us-east-1.prod.workshops.aws/workshops/429cec9e-3222-4943-82f7-1f45c45ed99a/en-US/2-flinkdashboard/job-level-insights">Savepoints/Checkpoints</a>: These provide a mechanism to recover your application from failures. If your application isn’t recovering correctly, it’s worth investigating whether savepoints/checkpoints are being made correctly and can be successfully restored.</li><li><a href="https://nightlies.apache.org/flink/flink-docs-master/docs/ops/monitoring/back_pressure/">Backpressure</a>: If a part of your data flow cannot process events as fast as they arrive, it can cause backpressure, which can slow down the entire application. The Flink dashboard provides a way to monitor this.</li><li><em>Network Metrics:</em> Flink provides metrics on network usage, including buffer usage and backpressure indicators. These can be useful for diagnosing network-related issues.</li></ul><p>SRemember, monitoring and troubleshooting are iterative processes. If you notice performance degradation or failures, use these tools and techniques to investigate, identify the root cause, and apply a fix. Then monitor the system again to ensure that the problem has been resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*0jhLS4nAn2q3du1G.gif" /><figcaption>(Source: <a href="https://giphy.com/gifs/coding-engineering-anand-TilmLMmWrRYYHjLfub">Giphy</a>)</figcaption></figure><h3>Conclusion</h3><p>In conclusion, Apache Flink is a robust and versatile open-source stream processing framework that enables fast, reliable, and sophisticated processing of large-scale data streams. Starting with a simple environment setup, we’ve walked through creating a basic Flink application that ingests, processes, and outputs data. We’ve also touched on the foundational concepts of Flink, such as the DataStream API, windows, transformations, sinks, and sources, all of which serve as building blocks for more complex applications.</p><p>In episode 4 of Apache Flink series, we’ll see how to consume data from kafka in real time and process it with Mage.</p><p><em>Link to the original blog: </em><a href="https://www.mage.ai/blog/getting-started-with-apache-flink-a-guide-to-stream-processing"><em>https://www.mage.ai/blog/getting-started-with-apache-flink-a-guide-to-stream-processing</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70a785e4bcea" width="1" height="1" alt=""><hr><p><a href="https://m.mage.ai/getting-started-with-apache-flink-a-guide-to-stream-processing-70a785e4bcea">Getting started with Apache Flink: A guide to stream processing</a> was originally published in <a href="https://m.mage.ai/">Mage AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>