<?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 Rajas Walavalkar on Medium]]></title>
        <description><![CDATA[Stories by Rajas Walavalkar on Medium]]></description>
        <link>https://medium.com/@rajaswalavalkar?source=rss-9d6533586028------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*KwiUDuD2PgqNVkSkNNQUNg.jpeg</url>
            <title>Stories by Rajas Walavalkar on Medium</title>
            <link>https://medium.com/@rajaswalavalkar?source=rss-9d6533586028------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 13:07:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajaswalavalkar/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[Navigating the AI Landscape: Understanding Generative AI, AI Agents, and Agentic AI]]></title>
            <link>https://rajaswalavalkar.medium.com/navigating-the-ai-landscape-understanding-generative-ai-ai-agents-and-agentic-ai-97dbf4940815?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/97dbf4940815</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[llm-agent]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Mon, 13 Oct 2025 14:23:45 GMT</pubDate>
            <atom:updated>2025-10-13T14:24:57.310Z</atom:updated>
            <content:encoded><![CDATA[<h4>INTRODUCTION</h4><p>Artificial Intelligence is a rapidly evolving field, with new terms and concepts emerging all the time. Three terms that are often used, but have distinct meanings, are Generative AI, AI Agents, and Agentic AI. This blog post will break down these concepts in simple terms, while also acknowledging that the distinctions are not always rigid.</p><h4>What is Generative AI?</h4><p>At its core, Generative AI is a type of artificial intelligence model that can create new and original content, such as text, images, or videos. This is done by learning patterns from vast amounts of existing historical data. The heart of many Generative AI systems is a Large Language Model (LLM), which is trained on a massive dataset from the internet, including diverse sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Vp-yKHluLWuiDllr8E8oEA.png" /><figcaption>Generic Gen AI LLM Model</figcaption></figure><p>However, a simple LLM-based Generative AI has a significant limitation which is a knowledge cutoff date, which is nothing but the date until which the data is used train the model. This means it might not be able to provide information about very recent events or real-time data. For example,</p><ul><li>It wouldn’t be able to tell you the precise, current price of a flight ticket for tomorrow.</li><li>It wouldn’t be able to tell you the details of any world wide event which took place just yesterday.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*V2u6zXzxkB7jXaNDXjYwjA.png" /><figcaption>Generic Gen AI LLM Model</figcaption></figure><p>This is where we have more advanced feature of Generative AI which is able to solve the above mentioned limitations by going a step further i.e. <strong>AI Agents</strong></p><h4>AI Agents</h4><p>An AI Agent is a more advanced system that can not only generate content but also take actions to complete tasks. Think of an AI Agent as a program that can perceive its environment, think, and act to achieve a specific goal.</p><p>You can also compare an AI Agent with a real world agent, which we contact for any kind of assistance related to booking of flight tickets, train tickets or assistance in finding a house in a locality and so on</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*39h01x_BjuUoi7bTXWrGug.png" /><figcaption>AI Agent</figcaption></figure><p>To overcome the limitations of a simple LLM, an AI Agent is typically given access to tools, such as APIs for travel websites or weather services. This allows the agent to fetch real-time information and perform actions like identifying and suggesting the cheapest flight for you. The key here is that the agent has a degree of autonomy and can make independent decisions to complete a task.</p><p>Now what if we need to plan an entire trip to a specific destination, which not only includes booking of flights, hotels, but also getting details on sightseeing and their timings, travel cab agency, best local food recommendations and restaurants to try out. This is where a single AI Agent won’t be able handle multiple of these tasks, as it would be trained for a specific task — which will be booking Flight tickets.</p><p>This issue can be further solved using an <strong>Agentic AI Workflows</strong></p><h4>The Power of Agentic AI / Agentic AI Workflows</h4><p>Agentic AI takes a step further in which it refers to a system where one or more AI agents work together autonomously to accomplish complex, multi-step goals. These systems can handle long-running tasks and make decisions using a variety of tools and even other AI agents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4HNy4kcn8j_7UL40Lz3LQ.png" /><figcaption>Agentic AI Workflow</figcaption></figure><p>Consider the sophisticated travel planning scenario which we discussed above. An Agentic AI system could not only book a flight within a specific budget but also check the weather for your destination to ensure it’s sunny during your trip. It could even go a step further and collaborate with an “Immigration AI Agent” to verify your visa status before finalizing the flight booking. This demonstrates the multi-step reasoning, planning, and collaborative capabilities of Agentic AI.</p><h4>Understanding the Overlap</h4><p>It’s important to understand that these differences are not always a hard and fast distinction. There is always going to be an overlap of concepts across them. For instance, an AI Agent will often utilize Generative AI capabilities to understand prompts or formulate responses. Similarly, an Agentic AI system is, by definition, composed of multiple AI Agents.</p><p>Think of it as a spectrum rather than rigid boxes. As AI technology advances, the lines between these categories may continue to blur, with systems incorporating elements from each to achieve increasingly complex objectives.</p><h4>The Bottom Line</h4><p>The progression from Generative AI to AI Agents and then to Agentic AI represents an increase in the complexity, autonomy, and sophistication of the tasks that AI can perform.</p><ul><li><strong>Generative AI:</strong> Focuses on creating new content with the help of the past historic data on which it is trained on</li><li><strong>AI Agents:</strong> Perform autonomous actions to achieve specific tasks, often leveraging external tools or APIs.</li><li><strong>Agentic AI:</strong> Involves multiple agents collaborating to achieve complex, long-term, multi-step goals.</li></ul><p>As this technology continues to develop, we can expect to see even more powerful and capable AI systems that can assist us in all aspects of our lives.</p><p>—<em> Rajas Walavalkar</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97dbf4940815" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master tips for Amazon QuickSight: SPICE dataset & Direct Query Mode to boost your analytics game!]]></title>
            <link>https://rajaswalavalkar.medium.com/master-tips-for-amazon-quicksight-spice-dataset-direct-query-mode-to-boost-your-analytics-game-d7dea5ba51de?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7dea5ba51de</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[real-time-analytics]]></category>
            <category><![CDATA[aws-quicksight]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 14:55:29 GMT</pubDate>
            <atom:updated>2024-07-22T15:15:39.356Z</atom:updated>
            <content:encoded><![CDATA[<h3>Best Practices with Amazon QuickSight SPICE Dataset and Direct Query Mode</h3><h3><strong>Introductions</strong></h3><p>Amazon QuickSight is a scalable, serverless business intelligence (BI) service powered by machine learning (ML). It seamlessly integrates data sources from Amazon Web Services (AWS), other cloud providers, and on-premises environments. Commonly utilized data sources within QuickSight include Amazon Simple Storage Service (Amazon S3), Amazon Athena, Amazon Relational Database Service (Amazon RDS), and Amazon Redshift.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*12q7t44dF-cKVWMv.png" /></figure><p>Once connected to a data source, QuickSight allows users to create datasets that can operate in either <strong>SPICE </strong>(Super-fast, Parallel, In-memory Calculation Engine) or <strong>direct query mode</strong>. These datasets serve as the foundation for building interactive dashboards, paginated reports, and Q topics, enabling intuitive natural language querying capabilities over the underlying data.</p><h3>Benefits of SPICE Memory</h3><ul><li><strong>SPICE</strong>, Amazon QuickSight’s in-memory calculation engine, accelerates dashboard performance by ingesting data from sources based on scheduled, on-demand, or API-driven refreshes.</li><li>It utilizes columnar storage, in-memory technologies, and machine code generation for rapid interactive query responses on large datasets. During dataset refreshes, dashboards display the previous snapshot to ensure uninterrupted user interaction.</li><li>SPICE reduces data source workload by querying it only when necessary for data ingestion. Charges for SPICE usage are based solely on purchased storage capacity in gigabytes (GB), allowing data consumption across multiple dashboards and users without additional costs.</li><li>For security, data stored in SPICE is encrypted at rest, with AWS managing the encryption key by default or allowing customer-managed keys through AWS Key Management Service (AWS KMS). This setup supports auditing access and compliance with regulatory requirements, with immediate access lockdown by revoking AWS KMS key access.</li><li>Data transfers between SPICE and users are encrypted in transit using Transport Layer Security (TLS), ensuring secure data transmission throughout.</li></ul><h3>When to use SPICE Dataset Memory?</h3><p>A common use case is to use the APIs to invoke a SPICE data refresh once extract, transform, and load (ETL) processes have been completed and data is stored in the data lake or data warehouse. This on-demand refresh process involves initiating a data ingestion either through the QuickSight UI or using the QuickSight API call <a href="https://docs.aws.amazon.com/quicksight/latest/APIReference/API_CreateIngestion.html"><strong><em>CreateIngestion</em></strong></a>. A point to note here is that you cannot initiate an on-demand full refresh or incremental refresh after the limit has been reached. However, this doesn’t impact schedules that are configured; they will continue to run as planned.</p><p>Another important consideration is the total SPICE capacity, which is allocated at an account level. If this available capacity is consumed by either a single dataset or multiple datasets, this will lead to data ingestion failures. To prevent such failures, you can manually purchase additional SPICE capacity from the QuickSight UI as needed. Alternatively, you can enable the <em>Auto-purchase capacity</em> option, which allows SPICE to automatically acquire the necessary capacity and so avoid data ingestion failures.</p><h3>Benefits of using Direct Query Mode</h3><p>Direct query mode enables near real-time querying directly from the data source. When a user opens or refreshes a dashboard in QuickSight, queries are sent directly to the data source. The data source processes these queries and returns results that are immediately visualized in the dashboard. Utilizing direct query mode can provide the benefits of accessing the freshest data from regularly updated sources and maintaining high-performance dashboards, especially when the data source responds quickly.</p><p>Unlike SPICE, direct query mode does not impose limits on the number of rows or dataset size, making it suitable for scenarios where data exceeds SPICE’s capacity constraints. To optimize query performance for slower queries, dataset parameters can be used to filter data and reduce the volume queried. User interactions within the dashboard, such as selections in controls, filters, and visuals, can propagate to the data source through live, customized, and parameterized SQL queries.</p><h3>When to use Direct Query Mode?</h3><ul><li>Performance in direct query mode depends on the runtime performance of the data source. Longer query execution times can lead to longer wait times for dashboard visuals compared to SPICE datasets. For a good user experience, it’s recommended to use a data source with fast response times when using direct query mode.</li><li>QuickSight imposes a 2-minute timeout for generating dashboard visuals, applicable to both direct query mode and SPICE. Not all database drivers may respond to this timeout by cancelling queries; manual or programmatic cancellation may be required.</li><li>Direct query mode supports up to 2,000 columns per dataset. Data source-specific timeouts also apply and vary for each type of data source.</li><li>Scaling up the capacity of the data source may be necessary as data volume grows, which can incur additional costs. High concurrency in direct query mode, especially with frequent dashboard users, can overwhelm the data source’s ability to handle the query load effectively.</li></ul><h3>Different Scenarios with their Outcomes</h3><h4>Dashboard Data Updates Daily</h4><p>Dashboard data often requires daily updates to reflect the previous day’s information. Typically, this involves extracting data from source systems, transforming it, and loading it into a data lake or data warehouse through batch ETL processes, usually scheduled outside of regular business hours. The recommended approach for using SPICE depends on how data updates occur in the source system.</p><ul><li>If individual records are updated in the source system, SPICE with a daily full refresh is suitable.</li><li>For scenarios where data is primarily appended, SPICE with a daily incremental refresh is preferable to manage new additions.</li><li>Align SPICE data refresh with the completion of ETL processes by scheduling it at a fixed time each day.</li><li>If ETL processing times vary, invoke SPICE refresh programmatically using the QuickSight API after ETL completion.</li></ul><h4>Dashboard Data Updates every 20 minutes</h4><p>If you require more real-time dashboard data updates, especially when new data is appended with a creation timestamp, consider scheduling a SPICE incremental refresh instead of a full refresh. This refresh can occur as frequently as every 20 minutes.</p><p>To achieve even more frequent updates, such as every 10 minutes, while leveraging SPICE for enhanced dashboard performance, you can combine different data refresh methods — full refresh, incremental refresh, and API refresh — on the same dataset.</p><p>This strategy optimizes data freshness and performance, adapting to both real-time data needs and operational efficiency throughout the day.</p><h4>Dashboard Data has Batch Data Updates and Near Real-Time Data Updates</h4><p>Dashboards often display diverse data types with varying dimensions and temporal granularity. For instance, a dashboard’s landing page typically showcases high-level key performance indicators (KPIs), monthly trends, and aggregated data across different dimensions. A secondary sheet within the dashboard delves deeper, offering near real-time insights at a transactional level.</p><p>Amazon QuickSight supports the integration of multiple datasets within a single dashboard. In this setup, the landing page utilizes a SPICE dataset scheduled for daily updates, ensuring fast performance with aggregated data. Meanwhile, the secondary sheet requires continuously fresh data directly from the source, utilizing direct query mode for this dataset.</p><h4>Dashboard Data refreshes in Real-Time</h4><p>When dashboards require immediate access to business-critical operational data, retrieving information in near real-time directly from the data source is crucial. Direct query mode stands out as the optimal solution for displaying data promptly on visuals.</p><p>In this mode, QuickSight queries data directly from the source for each visual upon dashboard loading, ensuring users always have access to the latest data available. This approach minimizes delays and supports timely decision-making and actions based on current information.</p><h3>Conclusion</h3><p>Thus mastering the best practices of Amazon QuickSight, particularly with SPICE datasets and Direct Query mode, is pivotal for optimizing data visualization and analysis workflows. SPICE’s in-memory calculation engine empowers users with faster query responses and offline access capabilities, making it ideal for interactive dashboards and reports. On the other hand, Direct Query mode ensures real-time data freshness directly from the source, essential for scenarios requiring up-to-the-minute insights.</p><p>By strategically choosing between SPICE and Direct Query based on data requirements and usage patterns, organizations can enhance dashboard performance, manage costs efficiently, and empower decision-makers with timely, accurate information. Implementing these best practices not only improves operational efficiency but also maximizes the value derived from Amazon QuickSight, driving continuous improvement in business intelligence strategies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7dea5ba51de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging Amazon Athena with Apache Spark Engine to Analyze Data and deriving Insights]]></title>
            <link>https://rajaswalavalkar.medium.com/leveraging-amazon-athena-with-apache-spark-engine-to-analyze-data-and-deriving-insights-95660552818d?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/95660552818d</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[aws-athena]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[pyspark]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 18:08:06 GMT</pubDate>
            <atom:updated>2024-04-15T18:08:06.236Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nh5oLKGai4jE76me.jpg" /></figure><h3>INTRODUCTION</h3><p>The dynamic duo of data processing Amazon Athena and Apache Spark Engine. In the realm of big data analytics, efficiency and flexibility are paramount, and this powerful combination delivers just that. Amazon Athena, a serverless interactive query service, enables users to analyze vast datasets stored in Amazon S3 with standard SQL queries, without the need for complex infrastructure management.</p><p>Now, with the integration of the Apache Spark Engine, Athena elevates its capabilities to new heights. Apache Spark, renowned for its lightning-fast processing speeds and versatile data processing capabilities, enhances Athena’s querying power, enabling users to tackle even the most demanding analytics tasks with ease. Amazon Athena With Apache Spark Engine will offer a seamless and scalable solution for organizations seeking to unlock insights from their data quickly and efficiently, ushering in a new era of data-driven innovation.</p><h4>Benefits Of Spark Engine for Athena</h4><p><strong>1. Accelerate time to insights — </strong>You can spend more time on insights, not on waiting for results. Interactive Spark applications start in under a second and run faster with our optimized Spark runtime.</p><p><strong>2. Leverage Spark for complex, powerful analytics — </strong>Use the expressiveness of Python with the popular open-source Spark framework to seek more complex insights from your data. Use notebooks to query data, chain calculations, and visualize results.</p><p><strong>3. Build applications without managing resources — </strong>Run Spark applications cost-effectively, without provisioning and managing resources. Build Spark applications without worrying about Spark configurations or version upgrades.</p><p><strong>4. Work with your data where it lives — </strong>Work with data in various data lakes, in open-data formats, and with your business applications without moving the data. Use data discovered and categorized by AWS Glue to build your Spark insights.</p><p>So let’s now see how we can spin up the entire tech stack which can power Spark Engine with Athena and give us the desired results</p><h4>Pre-requisites</h4><ol><li>Full Access of Athena and its features</li><li>Access to create and Modify IAM roles</li><li>Access to S3 buckets and to upload files and to edit bucket policies</li></ol><h4>STEP 1: Create a new Athena Workgroup</h4><p>Open the Amazon Athena Console which will redirect you to the Athena Query Editor console, over there you can open up the left side panel and then click on <strong><em>Workgoups</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCf34jclcK6XvMvZwDtUwg.png" /></figure><p>Over here you will have an already existing workgroup <strong><em>default </em></strong>which is a default workgroup for any AWS account. So let now click on <strong><em>Create Workgroup </em></strong>button to create a new Workgroup. Over fill in the details as follows</p><ul><li>Workgroup name: <strong>demo-spark-workgroup</strong></li><li>Analytics Engine Type : Select the analytics engine as <strong>Spark</strong></li><li>Analytics Engine Version : Select the option <strong>PySpark Engine Version 3</strong></li></ul><p>Keep the remaining parameters same and then you can click on Create Workspace.</p><p><strong><em>Note: Once the workgroup is created, we need to update the IAM role which is attached to this workgroup. In this IAM role add access the permissions to read the data from the S3 bucket where you have the data stored</em></strong></p><p>Once we have created the Spark Workspace, we can move with the next step</p><h4>STEP 2: Create a Spark Notebook within the Workspace</h4><p>After the creation of Workspace, there you will get an option to create a notebook, then click on <strong><em>Create Notebook</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w5oKENuPVGD0HkIGHi_Rjw.png" /></figure><p>You can enter a name for your notebook, in our example we are going to use <strong><em>spark-notebook. </em></strong>In the Apache Spark properties, you can define the table format of the source tables. Currently Athena Spark Engine supports 4 types of table formats</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*X4s1zO8TsVTH-p3ky1HhkA.png" /></figure><p>As per your table requirement, you can select the table format as per the requirements. For our demo purpose, we are not going to select any specific table format and going to keep it open. Going ahead you can see the session parameters that you can define as per the processing power required in your Spark notebook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*TRX4IoPG7U6udfkL3mQYNQ.png" /></figure><p>Now click on Create, which will create our Spark Notebook. Once the spark notebook is created you can actually see the Python IDE interface of a python notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iua6dLwyRHl5PKjQIorkRQ.png" /></figure><h4>STEP 3: Try out some code in Spark Notebook</h4><p>Lets import some of the Python and Spark libraries into the code and then run the cell</p><pre>from pyspark.sql.functions import max<br>import calendar<br>import seaborn as sns<br>import matplotlib.pyplot as plt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnD_yCgLa1rbsv_AyJqTYg.png" /></figure><pre>noa_22_csv = spark.read.option(&quot;header&quot;,&quot;true&quot;).csv(f&quot;s3://&lt;S3-bucket-name-path&gt;/2022/&quot;)<br>noa_22_csv.printSchema()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rCOxJAbyl8dLI5GABhdog.png" /></figure><pre>noa_22_csv.createOrReplaceTempView(&quot;noa_22view&quot;)<br># UDF to convert month number to month name<br>spark.udf.register(&quot;month_name_udf&quot;,lambda x: calendar.month_name[int(x)])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YREu7_J9bd5LFYUXd8u62g.png" /></figure><pre>min_temp_df=spark.sql(&quot;select month_name_udf(month(to_date(date,&#39;yyyy-MM-dd&#39;))) as month_yr_22,\<br>min(min) as min_temp \<br>from noa_22view \<br>group by 1 order by 2 desc&quot;)<br><br>min_temp_df.createOrReplaceTempView(&quot;min_temp_view&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_UZCfCb1dSjq5EBE_geBw.png" /></figure><pre>min_temp_df.show(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hV8n9wFIzeCnx0LTxt33kw.png" /></figure><p>The example shows how, we can leverage the Athena Spark engine to run our spark based codes on Athena and perform analytics on the same</p><h3>CONCLUSION</h3><p>Thus the integration of Amazon Athena with the Apache Spark Engine represents a significant advancement in the field of data analytics. By combining the ease of use and scalability of Amazon Athena with the powerful processing capabilities of Apache Spark, organizations gain access to a comprehensive solution for analyzing large datasets with unprecedented speed and efficiency.</p><p>This synergy not only simplifies the process of querying and analyzing data but also opens up new possibilities for extracting valuable insights and driving informed decision-making. As businesses continue to grapple with the complexities of big data, the collaboration between Amazon Athena and Apache Spark Engine emerges as a transformative force, empowering organizations to stay ahead in today’s data-driven world.</p><h3>REFERENCES</h3><ol><li>Apache Spark on Amazon Athena — <a href="https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark.html">https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark.html</a></li><li>Setting up Spark on Athena — <a href="https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-getting-started.html">https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-getting-started.html</a></li><li>Troubleshooting Notebooks — <a href="https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-troubleshooting-workgroups.html">https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-troubleshooting-workgroups.html</a></li><li>Python Libraries Sypported — <a href="https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-preinstalled-python-libraries.html">https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-preinstalled-python-libraries.html</a></li><li>JARs and Custom configuration — <a href="https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-custom-jar-cfg.html">https://docs.aws.amazon.com/athena/latest/ug/notebooks-spark-custom-jar-cfg.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95660552818d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cognito user authorization using IAM roles and accessing AWS services using temporary…]]></title>
            <link>https://rajaswalavalkar.medium.com/aws-cognito-user-authorization-using-iam-roles-and-accessing-aws-services-using-temporary-bb7035854c74?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb7035854c74</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[temporary-credentials]]></category>
            <category><![CDATA[cognito-identity-pool]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cognito]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 17:44:16 GMT</pubDate>
            <atom:updated>2024-04-24T17:12:57.802Z</atom:updated>
            <content:encoded><![CDATA[<h3>Amazon Cognito user authorization using IAM roles and accessing AWS services using temporary credentials</h3><h3>INTRODUCTION</h3><p>In most of the scenarios where we have applications and Amazon Cognito being used as an User Authentication and Authorization, there are requirements of accessing AWS services depending on the user roles. Access to application users depends on the user groups or roles which are tied to the Business application of the web application. Thus it becomes necessary to tie back the application users to the AWS service access depending on the authorization levels defined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*zdzl3p9shC3q8o43PkBurw.png" /></figure><p>Today, we are going to see how to achieve this functionality in any kind of web application. For this we are going to implement the above access methodology defined in the architecture image shown. So let’s get started with the implementation</p><h4>Step 1: Generate the ID Tokens using User Credentials</h4><p>At this step, we need to understand that, the user is already registered in the Amazon Cognito User pool and there are Cognito groups defined, where the user is part of the group.</p><p>Every Cognito group have been assigned an IAM role which defines AWS service level access for the users. These IAM roles are also defined in the AWS Lake formation principals which defined the AWS Database and tables access in Glue Data Catalog</p><pre><br>import boto3<br><br>client=boto3.client(&quot;cognito-idp&quot;)<br><br>#Add your Cognito Identity Pool ID in this variable<br>identityPoolId=&#39;&lt;Cognito-Identity-PoolID&gt;&#39;<br><br>#Define the User Credentials for the user for which Token&#39;s needs to be generated<br>user_name=&#39;&lt;UserName&gt;&#39;<br>user_password=&#39;&lt;User-Passowrd&gt;&#39;<br><br>#Define the Client ID for the application defined in the Cognito User Pool<br>client_id=&#39;&lt;Cognito-application-client-id&gt;&#39;<br><br>response = client.initiate_auth(<br>    AuthFlow=&#39;USER_PASSWORD_AUTH&#39;,<br>    AuthParameters={<br>        &#39;USERNAME&#39;: user_name,<br>        &#39;PASSWORD&#39;: user_password<br>    },<br>    ClientId=client_id<br>)</pre><p>In the above code, we are defining the User credentials and then the Cognito application client id which is registered with the Cognito user pool. The response that we will get will be the tokens of the users</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*lR-vOC6fKc9YLyA7OjW63w.png" /></figure><p>If the user’s credentials are correct then you will get response of the above boto3 API and then you can check the response variable which will be the Cognito token id</p><h4>STEP 2: Pass the Cognito ID Token and then generate the Identity id</h4><p>At this step we will be passing the previously obtained Cognito ID token and then will be getting the Identity ID for the user. For this we need to define the Identity Pool ID (identityPoolId) which we have already defined in the previous step.</p><pre><br>cognito_IdToken=response[&#39;AuthenticationResult&#39;][&#39;IdToken&#39;]<br><br>print(cognito_IdToken)<br><br>cog_client=boto3.client(&quot;cognito-identity&quot;)<br><br>#Need to define the Cognito IDPusing the URL as cognito-idp.&lt;region&gt;.amazonaws.com/&lt;user-pool-id&gt;<br>response = cog_client.get_id(IdentityPoolId=identityPoolId, Logins={&#39;cognito-idp.&lt;region&gt;.amazonaws.com/&lt;user-pool-id&gt;&#39;: cognito_IdToken})</pre><p>Then we create cognito-identity client using boto3 and then use the <strong>get_id </strong>API. Once we hit this API we will get the identity id for the user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UxCNjLyXo1mVN5LhfEmzyQ.png" /></figure><p>Once we get the identity id, we need to generate the temporary user credentials using the API</p><h4>STEP 3: Pass the Identity ID and then generate the temporary user credentials</h4><p>At this stage the Identity ID which we received from the previous API call will be leveraged to call the <strong>get_credentials_for_identity </strong>API and generate the temporary credentials of the user</p><pre><br>IdentityId=response[&#39;IdentityId&#39;]<br><br>#Need to define the Cognito IDPusing the URL as cognito-idp.&lt;region&gt;.amazonaws.com/&lt;user-pool-id&gt;<br>response = cog_client.get_credentials_for_identity(IdentityId=IdentityId, Logins={&#39;cognito-idp.&lt;region&gt;.amazonaws.com/&lt;user-pool-id&gt;&#39;: cognito_IdToken})<br><br>access_key_id=response[&#39;Credentials&#39;][&#39;AccessKeyId&#39;]<br>secret_key=response[&#39;Credentials&#39;][&#39;SecretKey&#39;]<br>session_token=response[&#39;Credentials&#39;][&#39;SessionToken&#39;]<br><br>print(&quot;Access Key ID : &quot;+str(access_key_id))<br>print(&quot;Access Scret Key : &quot;+str(secret_key))<br>print(&quot;Session Key : &quot;+str(session_token))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZdnPaXpKG4LO1cDXqYvsEw.png" /></figure><h4>STEP 4: Leverage the temporary credentials to access the AWS services</h4><p>Now, after we got the AWS Secret keys of the users, then we can access the AWS services using boto3 APIs. For that we need to define the temporary credentials while creating the client of the server. Just follow the following code for the same</p><pre><br>s3_client = boto3.client(<br>    &#39;s3&#39;,<br>    aws_access_key_id=access_key_id,<br>    aws_secret_access_key=secret_key,<br>    aws_session_token=session_token<br>)<br><br>response = s3_client.list_objects_v2(<br>    Bucket=&#39;&lt;S3-bucket-name&gt;&#39;<br>)<br><br><br>athena_client = boto3.client(&#39;athena&#39;,<br>    aws_access_key_id=access_key_id,<br>    aws_secret_access_key=secret_key,<br>    aws_session_token=session_token<br>)<br><br>response = athena_client.start_query_execution(<br>    QueryString=&#39;SELECT * FROM &quot;&lt;database-name&gt;&quot;.&quot;&lt;table-name&gt;&quot; limit 100;&#39;,<br>    WorkGroup=&#39;primary&#39;<br>)</pre><p>This is the way in which you can access the various AWS services depending on the user who is logged in to the application by generating the user specific temporary credentials. Thus all the APIs in which we will be using these credentials will only be getting the access defined for the user which has been defined in the cognito</p><p>In case if the user does not have access to a specific S3 bucket or a specific Database and table in the Glue data Catalog, the APIs will give an error as <strong>Access Denied, </strong>as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*DBn9nv2ZfPHmnwTftVpoQw.png" /></figure><h3><strong>CONCLUSION:</strong></h3><p>Amazon Cognito User Pools serves as a robust and scalable solution for managing user authentication and authorization in web and mobile applications. With its seamless integration with other AWS services, extensive support for various authentication methods, and built-in security features, Cognito User Pools empowers developers to rapidly build and deploy secure applications without the complexities of managing user identities.</p><p>By offering features such as multi-factor authentication, user profile management, and fine-grained access control, Cognito User Pools enables organizations to deliver a seamless and secure user experience while maintaining compliance with industry standards and regulations. As a foundational component of the AWS ecosystem, Cognito User Pools plays a pivotal role in enabling organizations to innovate and deliver value to their users in today’s digital landscape.</p><h3>REFERENCES:</h3><ol><li>Amazon Cognito Overview — <a href="https://aws.amazon.com/cognito/">https://aws.amazon.com/cognito/</a></li><li>Amazon Cognito User Pools — <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html">https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html</a></li><li>Amazon Cognito Identity Pools — <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html">https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html</a></li><li>Get Credentials -<a href="https://docs.aws.amazon.com/cognito/latest/developerguide/getting-credentials.html">https://docs.aws.amazon.com/cognito/latest/developerguide/getting-credentials.html</a></li><li>Amazon Cognito with token generation — <a href="https://aws.amazon.com/blogs/publicsector/getting-started-healthcare-data-lakes-deeper-dive-amazon-cognito/">https://aws.amazon.com/blogs/publicsector/getting-started-healthcare-data-lakes-deeper-dive-amazon-cognito/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb7035854c74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring AWS Data Exchange for sharing datasets across AWS accounts]]></title>
            <link>https://rajaswalavalkar.medium.com/exploring-aws-data-exchange-for-sharing-datasets-across-aws-accounts-dc810d3256b0?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc810d3256b0</guid>
            <category><![CDATA[multi-account]]></category>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-share]]></category>
            <category><![CDATA[aws-data-exchange]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Sat, 13 Apr 2024 16:19:56 GMT</pubDate>
            <atom:updated>2024-04-13T16:19:56.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/677/0*QpMEBn8JW3ahtV7q" /></figure><h3>INTRODUCTION</h3><p>Welcome to the gateway of boundless data possibilities — AWS Data Exchange. In the era of information abundance, AWS Data Exchange emerges as a pivotal platform, seamlessly connecting data providers with consumers, facilitating the exchange of high-quality, curated data sets. Whether you’re a data scientist seeking to enrich your analytics, a business leader aiming to fuel strategic decisions, or a developer looking to enhance your applications, AWS Data Exchange offers a diverse array of data products, coupled with the reliability, scalability, and security synonymous with Amazon Web Services.</p><p>AWS Data Exchange offers a plethora of advantages for both data providers and consumers, making it a premier platform for data exchange:</p><ol><li><strong>Diverse Data Selection: </strong>Access a wide range of high-quality, third-party data sets from various industries, including financial services, healthcare, retail, and more. This breadth of data options allows consumers to find precisely the data they need to drive insights and innovation.</li><li><strong>Data Curation and Quality Assurance: </strong>Data listed on AWS Data Exchange undergoes rigorous curation and quality assurance processes, ensuring accuracy, reliability, and compliance with industry standards. This assurance mitigates risks associated with using unreliable or unverified data sources.</li><li><strong>Streamlined Data Acquisition: </strong>Simplify the process of acquiring external data by leveraging AWS Data Exchange’s intuitive platform. With standardized data delivery mechanisms and easy integration with AWS services, consumers can quickly access and ingest data into their analytics pipelines or applications.</li><li><strong>Flexible Subscription Models: </strong>Choose from various subscription models, including free, one-time purchase, or subscription-based pricing, depending on individual data consumption needs and budget constraints. This flexibility enables consumers to align their data access costs with their usage patterns effectively.</li><li><strong>Secure Data Exchange: </strong>Benefit from the robust security measures inherent in the AWS ecosystem, including encryption, access controls, and compliance certifications. AWS Data Exchange prioritizes data privacy and security, ensuring that sensitive information remains protected throughout the exchange process.</li><li><strong>Scalability and Performance:</strong> Leverage the scalability and performance capabilities of AWS infrastructure to handle large volumes of data efficiently. Whether processing real-time streaming data or performing complex analytics on massive datasets, AWS Data Exchange delivers the performance needed to meet evolving business requirements.</li><li><strong>Integration with AWS Services:</strong> Seamlessly integrate AWS Data Exchange with other AWS services, such as Amazon S3, Amazon Redshift, and AWS Lambda, to leverage additional capabilities for data processing, storage, and analysis. This integration simplifies workflows and enables consumers to derive maximum value from their data assets.</li></ol><p>Let’s get our hand’s dirty on the AWS console itself by creating a Data Exchange to share data across datasets</p><h4>Step 1: Create a Data Exchange Dataset</h4><p>Go to the AWS Data Exchange home page and navigate to the Owned datasets and then click on the <strong><em>Create data set, </em></strong>to create a new Dataset for the data exchange</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXKAjAC_t8WPsmcvxP1JEQ.png" /></figure><p>Here you will get multiple options to select data set type, for our demo purpose lets stick to Amazon S3 data access and provide a name to the dataset <strong><em>s3-covid-</em></strong>data and then click on<strong><em> Next</em></strong></p><p>Next, we need to configure the S3 data access, for that lets click on <strong><em>Choose Amazon S3 Location </em></strong>where you can browse to the s3 location and select a particular location which will be used by the dataset. When you scroll down you see a bucket policy — which you need to copy and add it to the specific S3 bucket as a bucket policy. This policy will ensure that the S3 access is allowed to the Data Exchange jobs. Keep the remaining configurations default and then click on Next</p><p>At this stage it will create a backend job to import the data into the dataset. once your job is completed, the click on create data set and this will complete the process of creating a dataset</p><h4>Step 2: Create a Data Grant for the Dataset</h4><p>Data Grant is where we can grant access to our previously created dataset to different AWS accounts. For this lest navigate to the <strong><em>Sent Data Grants </em></strong>subsection and then lets create a data grant</p><p>On the first section, we need to select the dataset which we own and have create din the previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MYPK3s7_bfbvdwyD7PF2eQ.png" /></figure><p>In the next step add a Grant name and some description to the grant and then click on next button. In the next page we need to define the time period for which the grant will be valid by the receiver account. You need add the receiver AWS accounts <strong>Account ID </strong>information first</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDx7HjP6wkn-aDeSWUUd-A.png" /></figure><p>Once you add the receiver’s AWS account ID, then we need to define the Access end date for our data grant. In this there are two options to select.</p><ul><li>No End Date — Here there wont be any specific end date for the data grant to be expired automatically and the receiver account will be able to access the dataset which is shared without any time period boundaries</li><li>Specific End Date — Here you can define a specific end date for the Data grant till the point it will be accessible by the receiver’s AWS account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRU24idQIEyqp0DujlMuoA.png" /></figure><p>On the last page, you can review the entire grant and option and then click on <strong><em>Create and Sent data grant</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KJPdk5QPF68OCiP8H1Xzg.png" /></figure><p>Once you click on Create Data Grant — it will execute a process in the backend , which you can see the status of it. Once the data grant status is <strong><em>Completed </em></strong>then you can proceed with the next step</p><h4>Step 3: Accept the Data Grant for the Receiver’s AWS Account</h4><p>Up to this step — the sender AWS account has already done its work of creating a Dataset and sending a Data grant to the receiver’s account. Now, the receiver’s AWS account need to accept the Grant which has been received. For our demo, purpose, let’s now login and to the receiver’s AWS account and check the Data grant</p><p>For this, you need to open the AWS Data Exchange service console and then navigate to the <strong><em>Received data grants </em></strong>section. On this screen — you will see the <strong><em>Pending data grants </em></strong>which you need to accept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihN1wxbxcEurxHj4cAd9QA.png" /></figure><p>Let’s now click on the data grant request that is received and then proceed with the acceptance. Once you click — you will be able to see all the details of the data grant received. Once you have reviewed all the details then you can click on <strong><em>Accept data grant </em></strong>button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwiwDo7Cv1WVa8bUKUEVSw.png" /></figure><p>Once you can click — on Accept, it will take some time of 5 minutes to complete the granting process. Once the process is completed, then you can click on it and browse the S3 location by clicking on the <strong><em>Browse shared s3 location</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tMhxg_yWyvXLgjNQiKpQQ.png" /></figure><p>Once you can click on the browse S3 location, you will be able to see the s3 paths and files which can be browsed from the console itself and download as well the files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*9GQq-RkQ3xKDqaE_bS0VOw.png" /></figure><h3>CONCLUSION</h3><p>AWS Data Exchange stands as a cornerstone of modern data ecosystems, offering unparalleled advantages for both data providers and consumers alike. By providing access to a diverse array of high-quality, curated data sets from various industries, AWS Data Exchange empowers organizations to unlock insights, drive innovation, and make informed decisions with confidence. Through streamlined data acquisition processes, flexible subscription models, and robust security measures, AWS Data Exchange ensures that data exchange is efficient, cost-effective, and secure.</p><p>With seamless integration with AWS services, scalability, and global accessibility, AWS Data Exchange is poised to revolutionize the way organizations leverage external data assets, fostering collaboration, and driving transformative outcomes across industries. As the data landscape continues to evolve, AWS Data Exchange remains at the forefront, facilitating the exchange of data-driven insights that fuel success in the digital age.</p><h3>REFERENCES</h3><ol><li>AWS Data Exchange Overview — <a href="https://docs.aws.amazon.com/data-exchange/latest/userguide/what-is.html">https://docs.aws.amazon.com/data-exchange/latest/userguide/what-is.html</a></li><li>Data in AWS Exchnage — <a href="https://docs.aws.amazon.com/data-exchange/latest/userguide/data-sets.html">https://docs.aws.amazon.com/data-exchange/latest/userguide/data-sets.html</a></li><li>Create Data grant —<a href="https://docs.aws.amazon.com/data-exchange/latest/userguide/creating-a-new-data-grant.html"> https://docs.aws.amazon.com/data-exchange/latest/userguide/creating-data-grants.html</a></li><li>Accept Data Grant — <a href="https://docs.aws.amazon.com/data-exchange/latest/userguide/data-grant-access-data-set.html">https://docs.aws.amazon.com/data-exchange/latest/userguide/data-grant-access-data-set.html</a></li><li>Subscribing Data Marketplace — <a href="https://docs.aws.amazon.com/data-exchange/latest/userguide/subscribe-to-data-sets.html">https://docs.aws.amazon.com/data-exchange/latest/userguide/subscribe-to-data-sets.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc810d3256b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real-time pipeline with Zero-ETL integration from Aurora MySQL to Amazon Redshift]]></title>
            <link>https://rajaswalavalkar.medium.com/real-time-pipeline-with-zero-etl-integration-from-aurora-mysql-to-amazon-redshift-5a9f14f07abd?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a9f14f07abd</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[aurora-mysql]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[zero-etl]]></category>
            <category><![CDATA[redshift]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 17:02:31 GMT</pubDate>
            <atom:updated>2024-04-09T17:02:31.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Real-time pipeline with ZERO-ETL from Aurora MySQL to Amazon Redshift</h3><h3>INTRODUCTION</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*XPBINJXOU1J_KOy9a0mkpQ.png" /></figure><p>In the dynamic landscape of data management, efficiency is paramount. Enterprises today grapple with the challenge of seamlessly transferring data between various databases and warehouses while maintaining integrity, security, and speed. Amazon Web Services (AWS) offers a robust solution to this conundrum with Amazon Aurora MySQL and Redshift, two powerful services tailored to handle heavy workloads and vast datasets.</p><p>The advent of “zero ETL” strategies has further revolutionized data processing, allowing organizations to bypass traditional Extract, Transform, Load (ETL) processes and directly ingest data into Redshift from Aurora MySQL in near real-time. This blog delves into the intricacies of this cutting-edge approach, exploring the benefits, implementation strategies, and best practices for achieving seamless data integration between Aurora MySQL and Redshift, thus optimizing data pipelines for enhanced performance and agility.</p><h4>Why do we require Zero ETL Data pipelines?</h4><ol><li><strong>Real-Time Analytics:</strong> Businesses increasingly rely on real-time insights to make timely decisions. Traditional ETL processes introduce latency, delaying the availability of data for analysis. By bypassing ETL and directly transferring data from Aurora MySQL to Redshift, organizations can achieve near real-time analytics, gaining a competitive edge in today’s fast-paced markets.</li><li><strong>Data Freshness: </strong>With the exponential growth of data, maintaining data freshness is crucial for accurate insights. Zero ETL enables organizations to ingest data into Redshift without delay, ensuring that analytics are based on the most up-to-date information available in Aurora MySQL.</li><li><strong>Capturing Data History : </strong>Operational database has a lot of CRUD operations which constantly keeps on updating the data as per the business need. Thus for analyzing trends we need to maintain history of the data.</li><li><strong>Scalability and Flexibility: </strong>As data volumes and processing requirements scale, flexibility becomes paramount. Zero ETL architectures facilitate seamless scalability, allowing organizations to adapt to changing business needs without the constraints imposed by traditional ETL processes.</li></ol><p>Lets quickly get our hands dirty by implementing this zero ETL feature by considering source Aurora MySQL and Amazon Redshift as a destination.</p><h4>Pre-requisite required for Demo</h4><ol><li>Aurora MySQL database — required as a source. You need to choose MySQL DB engine</li><li>Amazon Redshift — required as a target. (in this example I am using a serverless instance)</li></ol><h4><strong>Step 1: Create a Cluster Parameter Group</strong></h4><p>Create a new Cluster Parameter Group with name as <strong><em>zero-etl-custom-pg-mysql </em></strong>and with the following configurations</p><ul><li>binlog_backup=0</li><li>binlog_replication_globaldb=0</li><li>binlog_format=ROW</li><li>aurora_enhanced_binlog=1</li><li>binlog_row_metadata=FULL</li><li>binlog_row_image=FULL</li></ul><h4>STEP 2: Attach the Cluster Parameter Group to Aurora MySQL Cluster</h4><p>Cick on the cluster node and then click on Modify to update the configuration of the Aurora instance and then in the Addtional Configuration section, you can select the Cluster Parameter grop which created in the previous step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*98pLgxx7hSgwugUWOMgMpw.png" /></figure><p>Once you click on Continue button, it will ask you if you want to apply the effect immediately, then for development purpose — you can chose apply immediately, but if it was Production Database cluster then you can apply it on the next maintenance window. As it is a development environment so I am going select <strong><em>Apply Immediately </em></strong>and then click on <strong><em>Modify cluster</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*SGme6csF_2yt7ummfjAWxg.png" /></figure><p>Once, this is done, you can check the configuration and see the cluster parameter group for the clsuter which will be the one which had attached just now</p><h4><strong>STEP 3</strong>: Creation of Zero-EL integration</h4><ol><li>In the Amazon RDS console and navigate to the cluster DB and then go to the <strong><em>Zero-ETL Integration </em></strong>section and then click on <strong><em>Create Zero-ETL Integration</em></strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdxjBnEbCnH6HVJvWP7Rvg.png" /></figure><p>2. provide a name — first-zero-etl-integration</p><p>3. Source will be automatically selected with the current Database cluster</p><p>4. Target — Select the current AWS account option and then browse the target Redshift cluster which you want to leverage as a target for the integration. Once you select the target redshift, you will see an error message as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*Y_eWFUQjFgUPTd66C1oh5A.png" /></figure><p>5. Here you need to click on <strong><em>Fix it for me </em></strong>option which will take care of the configuration required for case sensitivity parameter from the Redshift side and then click on <strong><em>Next </em></strong>and then you will get a Pop-up message box, click on C<strong><em>ontinue</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*H-vN7-TU6tbXP7atQRl4Qg.png" /></figure><p>6. On the Review page, just review all the configuration and the click on <strong><em>Create zero-etl integration</em></strong>, then you get an error shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*jGf8eSCHfVI7HRY6O6Ljmg.png" /></figure><p>7. At this stage wait for sometime, as its making change to the Redshift configuration which will take sometime and once you get the following message, then you can click on <strong><em>Create zero-etl integration</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PI9YZzpGlLK_GwLQnjWcTQ.png" /></figure><p><strong><em>NOTE: At this stage if you are getting any error then check the AWS documentation (</em></strong><a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html"><strong><em>Link</em></strong></a><strong><em>) for any sort of limitation in the source database engine versions supported for zero-etl integration</em></strong></p><p>8. The integration would take sometime to complete and you can check the status from the console itself. It can take up to 15–20 mins for the integration to complete, so just be Patient! :)</p><h4>STEP 4: Configure target Redshift to accept the Integration</h4><p>Go to the Redshift console, you can check Redshift serverless namespace, that you had selected in the target while creating the integration. There you will see the integration in the <strong><em>Zero-ETL Integration</em></strong> tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t19QSOCCiI76GRNm3-AmnQ.png" /></figure><p>For that page, you can note down the <strong><em>Integration ID </em></strong>and then we will use it in the next step while creating connection to Aurora MySQL source</p><p>Next Open the Query-Editor V2 for Redshift namespace and then lets create a database for the Aurora MySQL source using a Create Database query</p><pre>CREATE DATABASE aurora_mysql_zeroetl_db FROM INTEGRATION ‘&lt;add-your-integration-id&gt;’;</pre><p>Once you run the above query by replacing the Integration ID with yours Id then it will create a database in Redshift which will be pointing to the Aurora MySQL DB as shown below in the diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWX1sEYuO6URq2Zcq7vBAA.png" /></figure><p>Currently, you wont see any tables or schemas, as the source MySQL DB is currently empty and there are no DB objects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*3YVfk9RIbEAWlkfA0CE8-Q.png" /></figure><h4>STEP 4: Add Databases and Tables to Aurora MySQL DB and check whether we can access it from Redshift namespace</h4><p>Lets, first connect to the Aurora MySQL DB using any IDE that you are comfortable with. I am using MySQL Workbench for the same. Lets run the below SQL script which will create two Tables and will insert some dummy records into it</p><pre>Create Database aurora_source_mysql; <br><br>Create table aurora_source_mysql.student (id int(10) PRIMARY KEY, name varchar(50), location varchar(50), department varchar(100));<br><br>Insert into aurora_source_mysql.student(id,name,location,department)<br>Values (1,&#39;Suresh Kumar&#39;, &#39;Mumbai&#39;, &#39;Computer Science&#39;),<br>(2,&#39;Siddhesh Mehta&#39;, &#39;Delhi&#39;, &#39;Computer Science&#39;),<br>(3,&#39;Anant Shah&#39;, &#39;Mumbai&#39;, &#39;Electronics&#39;),<br>(4,&#39;Chirag Patil&#39;, &#39;Mumbai&#39;, &#39;Computer Science&#39;),<br>(5,&#39;Jayesh Choubey&#39;, &#39;Delhi&#39;, &#39;Electronics&#39;);<br><br>Select * from aurora_source_mysql.student;<br><br>Create table aurora_source_mysql.grades (grade_id int(10) Primary Key,student_id int(10), subject varchar(50), grade varchar(50), result varchar(100),<br>FOREIGN KEY (student_id) REFERENCES student(id));<br><br>Insert into aurora_source_mysql.grades(grade_id,student_id,subject,grade,result)<br>Values (101,1,&#39;JAVA&#39;, &#39;A+&#39;, &#39;PASS&#39;),<br>(102,2,&#39;Networking&#39;, &#39;A&#39;, &#39;PASS&#39;),<br>(103,3,&#39;Micro Controllers&#39;, &#39;C&#39;, &#39;PASS&#39;),<br>(104,4,&#39;Python Programming&#39;, &#39;F&#39;, &#39;FAIL&#39;),<br>(105,5,&#39;Digital Analog&#39;, &#39;B&#39;, &#39;PASS&#39;);<br><br>Select * from aurora_source_mysql.grades;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*QsY-0ZBtbwYzMU0hDvcv3Q.png" /></figure><p>Now lets see the <strong><em>MAGIC!</em></strong></p><p>Lets navigate to the Redshift Visual Editor V2 console and just refresh the Database and tables panel which is there on the left side to see whether the changes are reflected here in the redshift as well.</p><p>Now, you might not see the Magic instantaneously, as its running the integration process in the backend and it might take some 5– 10 seconds to see both the tables here in the Redshift</p><p>To check the Integrations which are running in the backend, you can run the folowing query and see outputs</p><pre>SELECT * FROM SYS_INTEGRATION_ACTIVITY; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjK9CW3vYZRLG5yabwSAHg.png" /></figure><p>Once you open up the Databases and Schema on Redshift you should be able to see all the tables and databases defined in the Aurora MySQL DB source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*OfKBuB_snjsf2WOjs3jP0g.png" /></figure><p>Lets now, run a query and see if we are able to access the data from both the tables on redshift, for that just run the below query and see the <strong>Magic!</strong></p><pre>Select * FROM aurora_source_mysql.student s inner join  aurora_source_mysql.grades g on s.id = g. student_id; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8agxW2gk84Gj4y9H9rC8A.png" /></figure><p><strong>Awesome! We are successfully created a ZERO-ETL Integration between Source Aurora MYSQL DB serverless and Amazon Redshift Serverless</strong></p><p>But, now lets make it more practical and real-life usecase by allowing only certain tables to be pushed down to the target rather than integrating all the tables from the source. In a real-life scenario, you will only be integrating the required tables and not all the tables to the Redshift Warehouse Layer.</p><h4>STEP 5: (OPTIONAL) Filtering only required tables from the source to be integrated with the target Redshift cluster</h4><p>Let’s again navigate back to the Zero-ETL integration screen on the RDS console and lets modify the current integration which is created. When you click on modify button, then you can see the filter option, where you can see two options possible</p><ul><li>Include — Where only certain DB objects are included in the integration to be pushed down to the target</li><li>Exclude — Where you define specific DB objects which are skipped or excluded from being pushed to the target</li></ul><p>For our example I am going to use Include option, in which I am going to include the <strong><em>student </em></strong>table in the integration so that only <strong><em>student </em></strong>table will be pushed to the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*VcGxqOKOY-lQqh7lIDZtmw.png" /></figure><p>Now modifying the Integrations can take good amount of time like somewhat 20–45 minutes as its going to update the backend logic to filter the DB objects from the integration, so be Patient with it. Also the best option would be to add the filter conditions while you are creating the integration so that you avoid modifying it later.</p><p>Once the modification is completed successfully, then lets navigate to the Redshift Query Editor V2, to see what effect it has on the target database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3i3Rm0_-R5imcxoI9zd-IQ.png" /></figure><p>Form the above image, you can see that we are only able to see the student table and no other table apart from that. Lets now try running the previous JOIN query between student and grade table and then see the what output we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*mWMsyg4ly_0RbUstgz-E0Q.png" /></figure><p>From the above image, we can see that <strong><em>grades </em></strong>table does not exist. So from here we can conclude that the when you remove a data filter from an integration, Aurora reevaluates the remaining filters as if the removed filter never existed. Aurora then replicates the data that previously didn’t match the filtering criteria (but now does) into the target Amazon Redshift data warehouse. Removing one or more data filters causes all affected tables to resynchronize.</p><h3>CONCLUSION:</h3><p>So the journey towards a streamlined data pipeline through Amazon Aurora MySQL zero ETL to Redshift represents a pivotal shift in modern data management practices. By embracing this innovative approach, organizations can unlock new levels of agility, efficiency, and real-time insights. The elimination of traditional ETL bottlenecks not only accelerates data processing but also reduces costs and complexity, empowering businesses to stay competitive in today’s data-driven landscape.</p><p>As organizations continue to evolve and scale, the integration of Amazon Aurora MySQL and Redshift offers a scalable and flexible solution that aligns seamlessly with their growing data needs. Through strategic implementation and adherence to best practices, businesses can leverage this powerful combination to drive actionable intelligence, foster innovation, and ultimately achieve their goals in an increasingly data-centric world.</p><h3><strong>REFERENCE:</strong></h3><ol><li>Zero-ETL Integration Overview and Benefits — <a href="https://aws.amazon.com/rds/aurora/zero-etl/">https://aws.amazon.com/rds/aurora/zero-etl/</a></li><li>Aurora Zero-ETL integration with Redshift AWS documentation— <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html">https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html</a></li><li>Setting up Zero-ETL integration for Redshift — <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/zero-etl-using.setting-up.html">https://docs.aws.amazon.com/redshift/latest/mgmt/zero-etl-using.setting-up.html</a></li><li>Zero-ETL integrations LIMITATIONS — <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html#zero-etl.reqs-lims">https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html#zero-etl.reqs-lims</a></li><li>Zero-ETL Quota Limits — <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html#zero-etl.quotas">https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/zero-etl.html#zero-etl.quotas</a></li><li>Amazon RDS Zero-ETL parameters configurations — <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/zero-etl.setting-up.html#zero-etl.parameters">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/zero-etl.setting-up.html#zero-etl.parameters</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a9f14f07abd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Apache Iceberg Data Lake on Amazon S3 using AWS Glue Spark job]]></title>
            <link>https://rajaswalavalkar.medium.com/deploy-apache-iceberg-data-lake-on-amazon-s3-using-aws-glue-spark-job-e14feb38e048?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/e14feb38e048</guid>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[aws-athena]]></category>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 18:51:08 GMT</pubDate>
            <atom:updated>2024-03-19T18:51:08.392Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*T8OBLrnBigJq7eiT.png" /></figure><h3>INTRODUCTION</h3><p>A data lake is a centralized repository that you can use to store all your structured and unstructured data at any scale. You can store your data as-is, without having to first structure the data and then run different types of analytics for better business insights. On AWS cloud the go-to service for creating a Data Lake is to use <a href="https://aws.amazon.com/s3/">Amazon S3</a> service and then we leverage other services to perform analytics on the data lake</p><p>Currently there has been spike in a new type of usage pattern for data lake which is more like a transactional system rather then historic analytics. In transactional system the most important types of operations are Updates, Inserts &amp; Deletes which was difficult and not so feasible in traditional S3 data lake structure. Thus there has been rise of a new concept of Open Table Formats — which actually help in performing CRUD operation on a data lake. One of the open table format is Apache Iceberg format.</p><h4>What is Apache Iceberg Format?</h4><p>Apache Iceberg is an open <strong>table format</strong> designed for huge, petabyte-scale tables. The function of a table format is to determine how you manage, organize and track all of the files that make up a table. You can think of it as an abstraction layer between your physical data files (written in Parquet or ORC etc.) and how they are structured to form a table.</p><p>Iceberg brings the reliability and simplicity of SQL tables to big data, while making it possible for engines like Spark, Trino, Flink, Presto, Hive and Impala to safely work with the same tables, at the same time.</p><p>Some of the important features of Apache Iceberg are as follows</p><ul><li>Transactional consistency between multiple applications where files can be added, removed or modified atomically, with full read isolation and multiple concurrent writes</li><li>Full schema evolution to track changes to a table over time</li><li><a href="https://www.dremio.com/wiki/time-travel/">Time travel</a> to query historical data and verify changes between updates</li><li>Partition layout and evolution enabling updates to partition schemes as queries and data volumes change without relying on hidden partitions or physical directories</li><li>Rollback to prior versions to quickly correct issues and return tables to a known good state</li><li>Advanced planning and filtering capabilities for high performance on large data volumes</li></ul><p>Seems INTERESTING ! Right? So lets see how can leverage Apache Iceberg format in AWS Glue Jobs</p><h3>Create Apache Iceberg Data Lake using AWS Glue</h3><p>To get started with this, there some pre-requisite activities that are needed here.</p><ul><li>Access to AWS services — AWS Glue, S3 &amp; Athena</li><li>Glue IAM service role which has access to Amazon S3</li><li>An existing Glue Table which you can create by running just a simple crawler which will be used as a source for the Glue Job. In our example we will be using Covid table data</li><li>An existing Glue database which we will be leveraging as a destination database to create a Iceberg table</li></ul><p>Once you have the above pre-requisites completed, then we can start to write the Glue Spark job</p><h4>1. Define some of the important spark and python libraries which are required in the job</h4><pre>import sys<br>from awsglue.transforms import *<br>from awsglue.utils import getResolvedOptions<br>from pyspark.context import SparkContext<br>from pyspark.sql import SparkSession<br>from pyspark.sql.functions import *<br>from awsglue.context import GlueContext<br>from awsglue.job import Job<br><br>args = getResolvedOptions(sys.argv, [&quot;JOB_NAME&quot;])<br>catalog_nm = &quot;glue_catalog&quot;<br><br>#The Glue Database Name which has the source table<br>in_database=&quot;&lt;glue-database-input&gt;&quot; <br><br>#The input Glue Table which we will be using as a source for the Iceberg data<br>in_table_name=&quot;covid_19_data&quot;<br><br>#The Glue Database Name which will be used to create an output Icerberg table<br>database_op=&#39;database_ib&#39;<br><br>#The Glue Table Name which will be used as a destination for Icerberg table<br>table_op=&#39;covid_dataset_iceberg&#39;<br><br>#The S3 path which will be use to store the Iceberg files as output<br>s3_output_path=&#39;s3://&lt;your-destination-bucket-name&gt;/iceberg-output/&#39;<br><br>table = str(catalog_nm)+&#39;.`&#39;+str(database_op)+&#39;`.&#39;+str(table_op)<br><br>print(&quot;\nINPUT Database : &quot; + str(in_database))<br>print(&quot;\nINPUT Table : &quot; + str(in_table_name))<br>print(&quot;\nOUPUT IcerBerg Database : &quot; + str(database_op))<br>print(&quot;\nOUPUT IcerBerg Table : &quot; + str(table))<br>print(&quot;\nOUPUT IcerBerg S3 Path : &quot; + str(s3_output_path))</pre><p>The above code snippet, will import all the required python and spark packages for our Glue script. Along with that we also need to define some important parameters and variables which will be used through out the script</p><p>In line with the script we need to define a important job parameter in the glue which will indicate the Glue job executer to leverage the Iceberg table format as output for the data. For this you need to define a parameter named as</p><pre>--datalake-formats : iceberg</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*ItO2yIvJFqaUnR6tdHFTcw.png" /></figure><h4>2. Define Spark and Glue context for the Iceberg Table format</h4><p>In this step, we will be defining the spark iceberg object which will defined with the with Glue Catalog as a spark Catalog, S3 path as a Spark Data warehouse.</p><pre><br>def create_spark_iceberg(catalog_nm:str = &quot;glue_catalog&quot;):<br>    &quot;&quot;&quot;<br>    Function to initialize a session with iceberg by default<br>    :param catalog_nm:<br>    :return spark:<br>    &quot;&quot;&quot;<br>    from pyspark.sql import SparkSession<br>    # You can set this as a variable if required<br>    warehouse_path = s3_output_path<br><br>    spark = SparkSession.builder \<br>    .config(f&quot;spark.sql.catalog.{catalog_nm}&quot;,<br>        &quot;org.apache.iceberg.spark.SparkCatalog&quot;) \<br>    .config(f&quot;spark.sql.catalog.{catalog_nm}.warehouse&quot;, <br>        warehouse_path) \<br>    .config(f&quot;spark.sql.catalog.{catalog_nm}.catalog-impl&quot;,<br>        &quot;org.apache.iceberg.aws.glue.GlueCatalog&quot;) \<br>    .config(f&quot;spark.sql.catalog.{catalog_nm}.io-impl&quot;,<br>        &quot;org.apache.iceberg.aws.s3.S3FileIO&quot;) \<br>    .config(f&quot;spark.sql.extensions&quot;,<br>        &quot;org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions&quot;) \<br>    .getOrCreate()<br>    return spark<br><br>ibspark = create_spark_iceberg(catalog_nm)<br>ibsc = ibspark.sparkContext<br>ibglueContext = GlueContext(ibsc)<br>ibjob = Job(ibglueContext)<br>ibjob.init(args[&quot;JOB_NAME&quot;], args)</pre><p>Once you define the Spark object, then we need to set the Spark Context and set the Glue Context. Once you have all the context set, then we can start to play with the source data and Iceberg table</p><h4>3. Read the source Glue table and write into a destination Glue Table in Iceberg format</h4><p>In this step, we will read the data from the existing source Glue Table which we have defined in our previous steps. Then we convert the glue dynamic frame into a spark DataFrame. The Spark DataFrame is then registered as a temp table/view so that we can leverage Spark SQL on it</p><pre><br>#Read the Glue inout table from thr Catalog using a Glue DynamicFrame<br>InputDynamicFrameTable = ibglueContext.create_dynamic_frame.from_catalog(database=in_database, table_name=in_table_name)<br><br>#Convert the Glue DynamicFrame into a Spark DataFrame<br>InputDynamicFrameTable_DF = InputDynamicFrameTable.toDF()<br><br>#Register the Spark DataFrame as TempView<br>InputDynamicFrameTable_DF.createOrReplaceTempView(&quot;InputDataFrameTable&quot;)<br>ibspark.sql(&quot;select * from InputDataFrameTable LIMIT 10&quot;).show()<br><br>#Filter the source table with country as &#39;Australia&#39;<br>colname_df = ibspark.sql(&quot;SELECT * FROM InputDataFrameTable WHERE country=&#39;Australia&#39;&quot;)<br>colname_df.createOrReplaceTempView(&quot;OutputDataFrameTable&quot;)<br><br>#Write the filtered Data into an ICEBERG table format in Glue destination table<br>ib_Write_SQL = f&quot;&quot;&quot;<br>    CREATE OR REPLACE TABLE {catalog_nm}.{database_op}.{table_op}<br>    USING iceberg<br>    TBLPROPERTIES (&quot;format-version&quot;=&quot;2&quot;, &quot;write_compression&quot;=&quot;gzip&quot;)<br>    AS SELECT * FROM OutputDataFrameTable;<br>    &quot;&quot;&quot;<br><br>#Run the Spark SQL query<br>ibspark.sql(ib_Write_SQL)</pre><p>In our example, we will be filtering the table on a certain column and then write the data into a specific Glue database and table which we had defined earlier.</p><h4>4. Let’s now Run the Glue Job and see the output in S3 and Query it through Athena</h4><p>At this stage, you can save the Glue and then run the Glue job. Once the Glue job completes the execution then we can go ahead and check the Glue Database and Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bU15sJCu209lA_1v3c3xag.png" /></figure><p>The screenshot above provides detail on the table which we created though the Glue job. The Table format defined is Iceberg format and also has a defined S3 path where the output table files are stored in the Data Lake</p><p>Let’s take a look at the S3 destination and how the folder structure looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GPt156wedZ3Cbcd2qxVAA.png" /></figure><p>There are by default <strong><em>data</em></strong> and <strong><em>metadata </em></strong>folders created and which stores important data for the table. The <strong><em>data </em></strong>folder, as name suggests it stored the data files in the Iceberg format and the <strong><em>metadata </em></strong>folder only stores the metadata information about the table</p><p>Now lets start querying the Iceberg table using Athena. Once you query the table you can actually see the table has only filtered data for Australia which we had added in the Glue script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLukdPLEV3H5z3swjlyANg.png" /></figure><p>Lets run a Update query on the table and see whether we are able to update the actual records in the Iceberg table. For that lets update <strong><em>Australia </em></strong>value in the <strong><em>country </em></strong>column to <strong><em>AUS.</em></strong></p><pre>UPDATE &quot;database_ib&quot;.&quot;covid_dataset_iceberg&quot; SET country = &#39;AUS&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELMJ4HfsociOuzhS9hXeNw.png" /></figure><p>You can see that the query ran successfully and without any errors. Lets now actually see whether we can see the country column updated by again firing SELECT query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQ_DlhfIwbWZx8RE8NI3oQ.png" /></figure><p>In the above screenshot, you can actually see that all the records are updated with the new value of country which is <strong><em>AUS</em></strong></p><h3>CONCLUSION</h3><p>Thus through this blog we can actually see how we can use Apache Iceberg table format through AWS Glue and then leverage other AWS services for manipulating the data. Iceberg format comes with a number of advantages from transactional query standpoint as well.</p><p>In this post, we introduced the Apache Iceberg framework and how it helps resolve some of the challenges we have in a modern data lake. I hope this post provides some useful information for you to get started with Apache Iceberg in your data lake solution.</p><h3>REFERENCE:</h3><ol><li>Iceberg Format and Versions — <a href="https://iceberg.apache.org/spec/#format-versioning">https://iceberg.apache.org/spec/#format-versioning</a></li><li>Iceberg and AWS — <a href="https://aws.amazon.com/what-is/apache-iceberg/">https://aws.amazon.com/what-is/apache-iceberg/</a></li><li>Apache Iceberg with Athena — <a href="https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg.html">https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg.html</a></li><li>AWS Glue with Iceberg — <a href="https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format-iceberg.html">https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format-iceberg.html</a></li><li>Creating Iceberg using Athena — <a href="https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg-creating-tables.html">https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg-creating-tables.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e14feb38e048" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate Glue Data Quality rules within AWS Glue Visual Studio ETL jobs]]></title>
            <link>https://rajaswalavalkar.medium.com/integrate-glue-data-quality-rules-within-aws-glue-visual-studio-etl-jobs-892abaa5b860?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/892abaa5b860</guid>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[aws-glue-studio]]></category>
            <category><![CDATA[data-quality-management]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 17:10:37 GMT</pubDate>
            <atom:updated>2024-03-11T17:10:37.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create an ETL pipeline using AWS Glue Studio with Glue Data Quality Ruleset</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*hsMEpLT_YjZ4UQuuiS-YZw.png" /></figure><h3>INTRODUCTION</h3><p>AWS Glue Data Quality is a feature using which you can create a Data Quality rulesets across datasets, this is something that we have already discussed in our previous blog which you can read <a href="https://medium.com/@rajaswalavalkar/create-aws-glue-data-quality-ruleset-with-recommendations-and-dqdl-rules-4899bcf71536">here</a> (if you haven’t read it, I would urge you to go through it)</p><p>AWS Glue Studio is a graphical interface that makes it easy to create, run, and monitor data integration jobs in AWS Glue. You can visually compose data transformation workflows and seamlessly run them on the Apache Spark–based serverless ETL engine in AWS Glue.</p><p>What if, we could merge the power of both the above features in glue and use a Visual interface to create a Glue Job which will use the Glue Data Quality ruleset to evaluate the Quality of the dataset within a Glue ETL Job. Doesn’t it sounds INTERESTING! :)</p><p>So lets do a quick hands-on on the same</p><h3>Let’s Create a Visual ETL Flow</h3><p>We need to navigate to the AWS Glue Console and then select <strong><em>ETL jobs</em></strong> from the left hand side panel. It will open up all the existing ETL jobs in the account and there you will see the option to create a <strong><em>Visual ETL</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nM0pqtTLxE-CeJm9JSNmPg.png" /></figure><p>Once you click on the <strong><em>Visual ETL </em></strong>it will open a Glue Visual Studio Canvas, which is were we will be creating our Glue Job, but before that lets add some <strong><em>Job details </em></strong>by clicking on the tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hqThp3J_SLk8j4xQ-IoMgA.png" /></figure><p>Name — Data-Quality-Visual-ETL-Job</p><p>IAM Role — Select an existing IAM role which will have access to AWS S3 and AWS Glue</p><p>Keep the remaining configurations default and lets just click on <strong><em>Save </em></strong>button at top right corner</p><p>And lets start to create a Visual ETL flow by again going back to the <strong><em>Visual </em></strong>tab on the top</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sp8axN_JtDsjVkTwrYsixA.png" /></figure><h3>Let’s Design the ETL Flow with Data Quality Rules</h3><p>Firstly, lets configure the source for the data, for that click on the AWS Glue Data Catalog option, which will automatically add a node on the canvas. If you click on the node which got added it will ask you to configure the node, so lets do that.</p><p>Name — Source: Glue Movie Table</p><p>Database — Select the database of the source table</p><p>Table — Select the table from the above database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydeCBuPqlfUqX4GNRl1CVg.png" /></figure><p>Now, as we have source configured properly, lets add the <strong>Data Quality Ruleset </strong>as an intermediate processing node to the flow. For that, you need to again click on the<strong><em> + (plus)</em></strong> icon at the top left corner in the canvas and open the <strong><em>add node </em></strong>panel.</p><p>Once you get Add Node panel, then you need select the transform tab. In the transform tab — you can add any type of transformations that is required for you ETL job, for our case we are going to select the <strong><em>Evaluate Data Quality </em></strong>transform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1h2S4LRenOGVhoO2flYaQ.png" /></figure><p>Again we need to configure the new node that we added to the canvas, so for that we need to add the following details</p><p>Name — Data Quality Ruleset</p><p>In Ruleset Editor, we need to add Data Quality rules that we want to evaluate for the source table. For that you can add the rules from the Helper module and then change it as per your need. For our example, I am going to add the DQDL statement which is shown below</p><pre>Rules = [<br>    ColumnDataType &quot;imdb_id&quot; = &quot;String&quot;,<br>    ColumnExists &quot;homepage&quot;,<br>    IsComplete &quot;imdb_id&quot;,<br>    ColumnValues &quot;source_id&quot; matches &quot;[1-9]*&quot; with threshold &gt; 0.1,<br>    ColumnValues &quot;vote_count&quot; &gt;= 50<br>]</pre><p>If, you want to get more understanding about the DQDL language, then do refer the previous blog where I have explained the entire AWS Glue Data Quality feature in detail (<a href="https://medium.com/@rajaswalavalkar/create-aws-glue-data-quality-ruleset-with-recommendations-and-dqdl-rules-4899bcf71536">link</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uRqUVft27EYONXqga2T_qA.png" /></figure><p><strong><em>Note: This is the place where we need to save our progress, otherwise we may loose all the configurations which we have set, if we do not do that. For saving, just click on Save button on the top right corner.</em></strong></p><h3>Identify the Records which have Passed and Failed the rules defined</h3><p>Now to identify and flag the records which do not satisfy our rules and also identify overall status of each Data Quality rules and percentages, we will have to add two more nodes to our workflow.</p><p>So for that, we need to just click on the existing <strong><em>Data Quality Ruleset </em></strong>node and then in the configuration panel, scroll down to the bottom, where you see some more options</p><p>From multiple options, you need to select the following option under <strong><em>Data quality transform output </em></strong>—</p><ul><li>Enable <strong><em>Original data </em></strong>and then also enable the option of <strong><em>Add new columns to indicate data quality errors</em></strong></li><li>Enable <strong><em>data quality result </em></strong>option as well</li></ul><p>Please refer to the following image, and you workflow should like the one shown in the following image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-QNvvebX4VVGaq2lpHebw.png" /></figure><p>Now, lets save both the result outputs to a S3 location by adding two more nodes to the workflow which will be our target locations. For that you need to again open the <strong><em>Add Node Panel </em></strong>and then select the <strong><em>Targets</em></strong> tab.</p><p>In the Targets tab, we need to select <strong>Amazon S3 </strong>as a node. You need to click on the S3 node twice to add two nodes each for the outputs.</p><p>Once you get the S3 nodes, just click on those nodes and then configure the 1st S3 node as follows</p><p><strong><em>Node Parents —Select the ruleOutcomes as Node Parents</em></strong></p><p><strong><em>S3 target location — Browse the S3 bucket location, where you would want to store the Data Quality Rule Outcome outputs</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U742-or5_tCaPYw6tW0Eg.png" /></figure><p>For the second S3 node, just click on the other S3 node and then configure it as follows</p><p><strong><em>Node Parents — Select the rowLevelOutcomes as Node Parents</em></strong></p><p><strong><em>S3 target location — Browse the S3 bucket location, where you would want to store the Row Level DQ Rule Outcome outputs</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJUeJzS_T5baT01RS9qZQg.png" /></figure><p><strong><em>Note: This is the place where we need to save our progress, otherwise we may loose all the configurations which we have set, if we do not do that. For saving, just click on Save button on the top right corner.</em></strong></p><p>Finally, you Visual ETL workflow should look like the one shown the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*PK-W_Y_Gof2xCrwj0YFEsg.png" /></figure><p>Now Lets run the Job by clicking on the <strong><em>Run </em></strong>button on the top right corner. Once you run the job, you can see all the history of the previous runs in the Runs tab on the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ow4Y3JT8Fhuf5gJRAJRmKw.png" /></figure><h3>Lets query the output files and have a look at the difference in the outputs that we have received</h3><p>Once the Job is successfully executed, then you need to just navigate to the specific S3 locations and see the output files. Once you can see the parquet files in both the S3 locations, then we just need to query the data from these two locations</p><p>For that you can create a AWS Glue Crawler and then run the Crawlers on these two locations to create Tables in Amazon Athena</p><p>I have already created a crawler and ran it over both the s3 locations and created Athena tables. Lets go to the Athena console and see both the tables which are created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7eravAbB99U9We8YhTmTg.png" /></figure><p><strong>For the RuleOutcomes data </strong>— You can see all the rules that we have defined in our DQDL rulesets within Glue job and it provides which rules <strong>Passed </strong>and which one <strong>Failed. </strong>For the Failed rules, it also provide details on why the rules failed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bAo4bsPBVFwIrLdfA8y69g.png" /></figure><p><strong>For the RowLevelOutputs data — </strong>You will see all the records from the original dataset, along with some additional columns which are added by glue to identify the which rules got failed for which reason.</p><h3>CONCLUSION</h3><p>AWS Glue Studio with the Visual Studio has provided and interesting to create ETL and Spark Jobs. Glue studio helps the data analysts and business users to create their own basic level of data aggregation and data preparation. Combining AWS Glue studio with the AWS Glue Data Quality rulesets to create a pipeline that will evaluate the Data Quality of the data and can flag those records which failed the data quality rules.</p><p>This blog just gives you starter and introduces you to this interesting feature so that you can use your imaginations and create complex pipelines and integrate it within your ETL workflows</p><h3>REFERENCES</h3><ol><li>AWS Glue Visual Studio — <a href="https://docs.aws.amazon.com/glue/latest/dg/edit-nodes-chapter.html">https://docs.aws.amazon.com/glue/latest/dg/edit-nodes-chapter.html</a></li><li>Visual ETL Transformations lists — <a href="https://docs.aws.amazon.com/glue/latest/dg/edit-jobs-transforms.html">https://docs.aws.amazon.com/glue/latest/dg/edit-jobs-transforms.html</a></li><li>Source and Target for ETL Visual Studio — <a href="https://docs.aws.amazon.com/glue/latest/dg/edit-job-add-job-parameters.html">https://docs.aws.amazon.com/glue/latest/dg/edit-job-add-job-parameters.html</a></li><li>Data Quality with Glue Studio — <a href="https://docs.aws.amazon.com/glue/latest/dg/tutorial-data-quality.html">https://docs.aws.amazon.com/glue/latest/dg/tutorial-data-quality.html</a></li><li>Data Quality Rule Builder (Glue Studio) — <a href="https://docs.aws.amazon.com/glue/latest/dg/data-quality-rule-builder.html">https://docs.aws.amazon.com/glue/latest/dg/data-quality-rule-builder.html</a></li><li>Data Quality DQDL Format — <a href="https://docs.aws.amazon.com/glue/latest/dg/dqdl.html">https://docs.aws.amazon.com/glue/latest/dg/dqdl.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892abaa5b860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create AWS Glue Data Quality Ruleset with Recommendations and DQDL Rules]]></title>
            <link>https://rajaswalavalkar.medium.com/create-aws-glue-data-quality-ruleset-with-recommendations-and-dqdl-rules-4899bcf71536?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/4899bcf71536</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[data-governance]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <category><![CDATA[data-quality]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 13:00:03 GMT</pubDate>
            <atom:updated>2024-03-10T17:22:13.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create AWS Glue Data Quality with Recommendations and DQDL Rules</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ti45ScxlKWyk4Yiu.jpg" /></figure><h3>INTRODUCTION</h3><p>AWS Glue Data Quality is a feature of the AWS Glue service which allows you to measure and monitor the quality of your data so that you can make good business decisions. AWS Glue Data Quality is a complete serverless service and does not require provisioning of any server or compute.</p><p>The AWS Glue Data Quality evaluates objects that are stored in the AWS Glue Data Catalog. It offers non-coders an easy way to set up data quality rules.</p><h3><strong>When to use AWS Glue Data Quality?</strong></h3><ul><li>If you want to perform data quality tasks on data sets that you’ve already cataloged in the AWS Glue Data Catalog.</li><li>When you are not sure that the quality and correctness of the raw data that you want to ingest</li><li>You work on data governance and need to identify or evaluate data quality issues in your data lake on an ongoing basis.</li><li>When you have specific business rules which you want to evaluate against your dataset</li></ul><h4>Some important features of AWS Glue Data Quality</h4><ul><li><strong>Serverless</strong> — Complete serverless and does not require installation, patching or maintenance.</li><li><strong>ML Detection of data quality issues</strong> — Use machine learning (ML) to detect anomalies and hard-to-detect data quality issues.</li><li><strong>Get Data Quality Score and to business decisions</strong> — Once you evaluate the rules, you get a Data Quality score that provides an overview of the health of your data. Use Data Quality score to make confident business decisions.</li><li><strong>Pay as you go</strong> — There are no annual licenses you need to use AWS Glue Data Quality.</li><li><strong>Data quality checks</strong> — AWS Glue Data Quality You can enforce data quality checks on Data Catalog and AWS Glue ETL pipelines allowing you to manage data quality at rest and in transit.</li><li><strong>ML-based data quality detection</strong> — Use machine learning (ML) to detect anomalies and hard-to-detect data quality issues.</li><li><strong>ML based Recommendations</strong> — Get automatic data quality recommendations considering dataset schemas and data types</li></ul><p>To get started with defining the Data Quality rulesets, its important to understand the DQDL language which is used to write the rules. Lets get basic understanding the DQDL (Data Quality Definition Language)</p><h4>What is DQDL in AWS Glue Data Quality?</h4><p>Data Quality Definition Language (DQDL) is a domain specific language that you use to define rules for AWS Glue Data Quality.</p><p>A DQDL document is case sensitive and contains a <em>ruleset</em>, which groups individual data quality rules together. To construct a ruleset, you must create a list named Rules (capitalized), delimited by a pair of square brackets. The list should contain one or more comma-separated DQDL rules like the following example.</p><pre>Rules = [<br>   IsComplete &quot;order-id&quot;,<br>   IsUnique &quot;order-id&quot;<br>]</pre><h3>The above example defined a Data Quality ruleset which has two rules which checks the Completeness and Uniqueness of the order-id column in the dataset.</h3><p>To get more in depth understanding of the entire DQDL, please refer to the AWS documentation page <a href="https://docs.aws.amazon.com/glue/latest/dg/dqdl.html">here</a></p><h3>Let’s get our hand’s dirty with the AWS Glue Data Quality console</h3><p>To get started with the Data Quality rulesets, it is necessary to have a table defined in the AWS Glue Data Catalog. For our example, I already have a table in Glue Data Catalog which has the movie dataset data file on S3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcDeBbrhwrSblnY36ZGm1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZnYoWqaKlFE1Q2KcitJEA.png" /></figure><h4><strong>1. Create a Data Quality Ruleset:</strong></h4><p>To create the Data Quality Ruleset, lets navigate to the Glue Data Catalog Console and select the table on which we want to define the Data Ruleset. When you select the table, then you can see the option of Data Quality at the top as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ex0zW8wg7lq1n9_rYJ2ELQ.png" /></figure><p>At the bottom, of the page, you can see the <strong>Create data quality rules </strong>button, using which we need to create the data quality rules.</p><p>It will redirect you to the Data Quality Ruleset Canvas, where you can create your own rulesets as shown in the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YC6rzslRwVsoYF8hbSmwig.png" /></figure><p>Now, rather than creating the Data Quality ruleset on your own, lets try to see the Recommend Data Quality ruleset feature of Glue</p><h4><strong>2. Get Recommendations of the DQ Ruleset:</strong></h4><p>Once you click on the <strong>recommend rules </strong>at the top right corner, then you need to select the IAM role which you need to associate the DQ ruleset with. Other options, you can keep default for now and the click on <strong>Recommend rules</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*Qp85-0__e_SAc4BOG0zXIw.png" /></figure><p>Once you click on Recommend rules, you can see the recommendation process running in the backend as shown in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSXqLlsw1R1PECkSlZTQGA.png" /></figure><p>After, the recommend rules process is completed, you see an option to <strong>insert rule recommendations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cxFzy_Zf5AR0oUJ-HqJsFQ.png" /></figure><p>Once you click the <strong>insert rule recommendations </strong>button, you can see the list of all the records and then you can select the rules which you want to include and then it will automatically populate the rules in the canvas as shown bellow in the diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZZlSUWv8PiJ08kYLtfnaw.png" /></figure><p>Once you are done with selecting the rules, you can add the rules to the Data Quality ruleset and then click on the <strong>Save Ruleset </strong>button to save the rules. You need to provide the Ruleset Names — <strong>DQ-ruleset-demo </strong>while saving ruleset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7q0rLbx75BPVDGbRTQgmVA.png" /></figure><p>You can even go-ahead and update and edit the ruleset obtained as per your requirements and business rules. Further ahead, you can add even more customized rules from the left side panel. To get details on pre-defined rulesets of Glue, you can refer the AWS documentations <a href="https://docs.aws.amazon.com/glue/latest/dg/dqdl.html">here</a></p><h4><strong>3. Run DQ Ruleset</strong></h4><p>Let’s now Run the Data Quality ruleset by clicking on <strong>Run </strong>button and select the IAM role and click on <strong>Run. </strong>It will take some time depending on the volume of the dataset to complete the Data Quality ruleset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x50Ce-6hOO54pUCRI9xzNw.png" /></figure><p>Once the DQ ruleset is executed successfully, you can click on the DQ ruleset execution run to get the outputs and details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mDqk27XNmPPkYxHH9_1hMg.png" /></figure><p>If the see the output results, it shows following things about the quality of the data</p><ul><li><strong>Data Quality Score — </strong>Its the number of rules that got passed after evaluating them across the dataset. In our example it shows 8/8 (which means 8 DQ rules got passed out of 8 rules i.e. <strong>100% </strong>is the DQ Score)</li><li><strong>Data Quality Status —</strong> It shows the overall Status of the Data Quality. If anyone of the rule gets failed status after evaluating it across the dataset then the overall Status is shown as Failed. In our example as all the rules are passed thus it shows <strong>DQ Passed</strong></li><li><strong>Data Quality Results —</strong> It describes which of the rule is actually passed and which one got failed. For the Failed rules it also provides the information — like because of which value in the dataset the rule Failed</li></ul><p>Also have a look at the below screenshot, which provides an example where some of the Data Quality rules are not passed as per the datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ItF7D3DH3pLbphHjZMPzyw.png" /></figure><h3><strong>CONCLUSION</strong></h3><p>AWS Glue Data Quality provides you with an easier option to define business rules and data quality standards which are required for the incoming datasets and accordingly also provides a way to evaluate those rules across the dataset. The interesting part of the AWS Glue Data Quality module is that the defining of the DQ rulesets, does not require any Data Engineering technical knowledge and can be easily done by personas like Data Analysts and Business Analysts using the DQDL language.</p><h3>REFERENCE</h3><ol><li>Introduction to AWS Glue Data Quality — <a href="https://aws.amazon.com/glue/features/data-quality/">https://aws.amazon.com/glue/features/data-quality/</a></li><li>AWS Glue Data Quality Feature — <a href="https://docs.aws.amazon.com/glue/latest/dg/glue-data-quality.html">https://docs.aws.amazon.com/glue/latest/dg/glue-data-quality.html</a></li><li>Data Quality Definition Language — <a href="https://docs.aws.amazon.com/glue/latest/dg/dqdl.html">https://docs.aws.amazon.com/glue/latest/dg/dqdl.html</a></li><li>Anomaly detection in AWS Glue Data Quality — <a href="https://docs.aws.amazon.com/glue/latest/dg/data-quality-anomaly-detection.html">https://docs.aws.amazon.com/glue/latest/dg/data-quality-anomaly-detection.html</a></li><li>IAM Permissions for AWS Glue Data Quality — <a href="https://docs.aws.amazon.com/glue/latest/dg/data-quality-authorization.html">https://docs.aws.amazon.com/glue/latest/dg/data-quality-authorization.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4899bcf71536" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gen AI powered by Amazon Code Whisperer within AWS Glue Studio Notebooks]]></title>
            <link>https://awstip.com/gen-ai-powered-by-amazon-code-whisperer-within-aws-glue-studio-notebooks-c741fa0611e?source=rss-9d6533586028------2</link>
            <guid isPermaLink="false">https://medium.com/p/c741fa0611e</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[codewhisperer]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rajas Walavalkar]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 15:54:28 GMT</pubDate>
            <atom:updated>2023-08-21T18:34:50.558Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>INTRODUCTION</strong></h3><p>Gen AI, short for “general artificial intelligence,” is one of the most groundbreaking advancements in the field of technology. Unlike narrow AI systems that are designed for specific tasks, Gen AI possesses the ability to understand and perform a wide range of intellectual tasks that previously were exclusive to human intelligence.</p><p>Can we think, how this advancement can actually help developers from performing mundane tasks regularly which can be easily automated. Lets take a scenario, where a ETL developer who is working on developing Spark code has write similar piece of code to read data from a source, perform joins and write the output to a target database or destination.</p><p>This is where Amazon has enabled a feature within AWS Glue which can assist the developers to improve the speed of writing spark scripts, or generic functions by integrating the power of <a href="https://aws.amazon.com/codewhisperer/?trk=1eeef2da-27cf-45cf-9b05-e6814dbe6387&amp;sc_channel=ps&amp;ef_id=Cj0KCQjwrfymBhCTARIsADXTabkCv1o79rfqZqXXDPAv_JdqKJXwPTl3s60G0HSVfpaKwsvuYJaMJc4aAnZMEALw_wcB:G:s&amp;s_kwcid=AL!4422!3!654933461192!e!!g!!amazon%20codewhisperer!19966636791!151629956041"><strong>Amazon CodeWhisperer</strong></a> with <a href="https://docs.aws.amazon.com/glue/latest/ug/what-is-glue-studio.html"><strong>AWS Glue Studio</strong></a><strong>. </strong>Lets try out this feature with a help of an example.</p><h4>STEP 1: Create an IAM role for the Glue Spark Notebook</h4><p>To create an IAM role, open up the IAM console and provide the following details to create a new role</p><ul><li>Select Trusted Entity page— Select Glue service from the drop down provided</li><li>Add Permission page — Create a new IAM policy and copy paste the following JSON document in the IAM policy</li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor0&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ec2:DeleteTags&quot;,<br>                &quot;ec2:CreateTags&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:ec2:*:*:instance/*&quot;,<br>                &quot;arn:aws:ec2:*:*:security-group/*&quot;,<br>                &quot;arn:aws:ec2:*:*:network-interface/*&quot;<br>            ],<br>            &quot;Condition&quot;: {<br>                &quot;ForAllValues:StringEquals&quot;: {<br>                    &quot;aws:TagKeys&quot;: &quot;aws-glue-service-resource&quot;<br>                }<br>            }<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor1&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;glue:BatchCreatePartition&quot;,<br>                &quot;glue:GetConnections&quot;,<br>                &quot;glue:DeleteDatabase&quot;,<br>                &quot;glue:GetTableVersions&quot;,<br>                &quot;glue:GetPartitions&quot;,<br>                &quot;glue:BatchDeletePartition&quot;,<br>                &quot;glue:UpdateTable&quot;,<br>                &quot;glue:DeleteTable&quot;,<br>                &quot;glue:CreateUserDefinedFunction&quot;,<br>                &quot;s3:ListBucket&quot;,<br>                &quot;glue:DeleteJob&quot;,<br>                &quot;glue:*&quot;,<br>                &quot;glue:GetDevEndpoint&quot;,<br>                &quot;codewhisperer:GenerateRecommendations&quot;,<br>                &quot;glue:CreateJob&quot;,<br>                &quot;iam:PassRole&quot;,<br>                &quot;glue:GetConnection&quot;,<br>                &quot;glue:GetUserDefinedFunction&quot;,<br>                &quot;glue:ResetJobBookmark&quot;,<br>                &quot;glue:UpdateJob&quot;,<br>                &quot;glue:CreatePartition&quot;,<br>                &quot;glue:GetJobBookmark&quot;,<br>                &quot;glue:GetUserDefinedFunctions&quot;,<br>                &quot;glue:UpdatePartition&quot;,<br>                &quot;glue:UpdateDatabase&quot;,<br>                &quot;glue:CreateTable&quot;,<br>                &quot;glue:GetJobs&quot;,<br>                &quot;glue:UpdateUserDefinedFunction&quot;,<br>                &quot;glue:GetTables&quot;,<br>                &quot;glue:BatchGetPartition&quot;,<br>                &quot;s3:GetBucketAcl&quot;,<br>                &quot;glue:GetDatabases&quot;,<br>                &quot;glue:DeleteUserDefinedFunction&quot;,<br>                &quot;glue:CreateConnection&quot;,<br>                &quot;glue:GetTable&quot;,<br>                &quot;glue:GetDatabase&quot;,<br>                &quot;glue:GetPartition&quot;,<br>                &quot;glue:DeleteConnection&quot;,<br>                &quot;glue:GetDevEndpoints&quot;,<br>                &quot;glue:UpdateConnection&quot;,<br>                &quot;s3:ListAllMyBuckets&quot;,<br>                &quot;glue:CreateDatabase&quot;,<br>                &quot;glue:BatchDeleteConnection&quot;,<br>                &quot;glue:UpdateDevEndpoint&quot;,<br>                &quot;glue:BatchDeleteTable&quot;,<br>                &quot;s3:GetBucketLocation&quot;,<br>                &quot;glue:DeletePartition&quot;,<br>                &quot;glue:GetJob&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor2&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::crawler-public*&quot;,<br>                &quot;arn:aws:s3:::aws-glue*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor3&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::aws-glue*&quot;<br>        }<br>    ]<br>}</pre><ul><li>Name, Review &amp; Create page — Provide a name to the IAM role <a href="https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/Glue-CodeWhisperer-GenerateRecommendations-Role"><strong><em>Glue-CodeWhisperer-GenerateRecommendations-Role</em></strong></a><strong><em>. </em></strong>Then click on create role</li></ul><p>This will set you up with the IAM permissions that are needed by the Glue Spark notebook to pull in recommendations from the Code Whisperer</p><h4>STEP 2: Create a Glue Spark Notebook in the Glue Studio</h4><p>For this, you need to open up the Glue Studio console and then click on the ETL jobs and then select the Jupyter Notebook and then click on Create. This will open up a form and you will have to fill in the following details</p><ul><li>Job Name — Enter the name of the job as <strong><em>SparkCodeWhispererJob</em></strong></li><li>IAM Role — From the dropdown select the option <a href="https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/Glue-CodeWhisperer-GenerateRecommendations-Role"><strong><em>Glue-CodeWhisperer-GenerateRecommendations-Role</em></strong></a><strong><em> </em></strong>(The IAM role which we created in the previous step)</li><li>Kernel — From the dropdown select the Spark option</li></ul><p>Once all the inputs are given then click on the <strong><em>Start Notebook </em></strong>button in the bottom right corner. This will start you Jupyter Spark Notebook on Glue Studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27ZYLIJWesCR-Bn2wBAqhw.png" /><figcaption>Aamzon Glue Studio Spark Notebook</figcaption></figure><p>To check if the IAM roles are properly setup — you can check that in the notebook bottom section you can actually see the CodeWhisperer option which is highlighted in Yellow in the above image as well.</p><h4>STEP 3: Let’s try out the Magic of Code Whisperer Recommendations while writing the Spark code</h4><ol><li><strong>Lets try and read a CSV file kept in a S3 location into a Spark dataframe using the CodeWhisperer recommendations</strong></li></ol><p>For that you need to use # (hash) before any statement, so that you can get the recommendation from the CodeWhisperer. For example,</p><pre>#Read CSV file data from S3 path in a Spark dataframe with header and inferschema</pre><p>Once you write the above statement into the Jupyter notebook cell and press ENTER, then it will respond back with the piece of code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*rUqyrQSGHRBAtb_N55WSXA.png" /><figcaption>Read CSV Code Recommendation</figcaption></figure><p>If you check the above screenshot — the line below the<strong> hash (#</strong>) is automatically flashed on the screen by the CodeWhisperer and to accept it you need press <strong>TAB </strong>button.</p><p>Do not believe it! I would suggest you to try it out by yourself :)</p><p><strong>2. Now lets try out something COMPLEX</strong></p><p>For this, I am going to write down multiple statements to get a piece of code</p><pre>#register the above spark dataframe into a table<br><br>#write a spark sql query to get sum of total_mks column from the students table into a sum_df dataframe<br><br>#print the sum_df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*kx53xVAs2qgmkEDzKxy3uA.png" /><figcaption>Spark Transformations using Recommendations</figcaption></figure><p>If you check the above screenshot, you can see how easy it is to get the code written if you know what actions and transformations needs to be performed</p><p><strong>3. Let’s try out recommendation with some Spark specific functions</strong></p><p>For this, I am going to write down multiple statements to get a piece of code</p><pre>#repartion the sum_df dataframe with 5 partitions<br><br>#combine the data in sum_df within 1 partition<br><br>#write output back the data into S3 location</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*kzZ6D4oZTBwYjcy6V78mvg.png" /><figcaption>Spark Functions Recommendations</figcaption></figure><p>The above screenshot shows that CodeWhisperer can understand the Spark functions and provides a syntactical code as a response back</p><p><strong>4. We can check if its able to create functions and pass arguments with parameters</strong></p><p>For this, I am going to write down following statements to get a piece of code</p><pre>#show the top 5 students having highest total_mks from the df dataframe by defining a function<br><br>#pass the df to the above function</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKUzp6icopMm2ix2AcKD5w.png" /><figcaption>User-Defined Functions Recommendation</figcaption></figure><p>If you check the above screenshots, it remembers the previous dataframes and what arguments are to be passed to the function and accordingly it prompts the code</p><h3>CONCLUSION</h3><p>The integration of Amazon CodeWhisperer with Amazon Glue Studio provides an efficient way to write a code and accordingly can be a great tool to structure the code. It is able to provide the Spark based function recommendations along with their appropriate syntax as well. Although its just a start and further it can help the developers across programming languages.</p><p>This blog, majorly focusses on PySpark based code and its recommendations, but this is just for experiment purpose. I hope that this would give you a good understanding on how to configure this and start using it</p><h3>REFERENCES</h3><ol><li>AWS CodeWhisperer — <a href="https://docs.aws.amazon.com/codewhisperer/latest/userguide/what-is-cwspr.html">https://docs.aws.amazon.com/codewhisperer/latest/userguide/what-is-cwspr.html</a></li><li>AWS Glue studio — <a href="https://docs.aws.amazon.com/glue/latest/ug/what-is-glue-studio.html">https://docs.aws.amazon.com/glue/latest/ug/what-is-glue-studio.html</a></li><li>Glue Studio with CodeWhisperer integration — <a href="https://aws.amazon.com/about-aws/whats-new/2023/07/aws-glue-studio-amazon-codewhisperer/">https://aws.amazon.com/about-aws/whats-new/2023/07/aws-glue-studio-amazon-codewhisperer/</a></li><li>AWS Glue studio Jupyter Notebook — <a href="https://docs.aws.amazon.com/glue/latest/ug/notebook-getting-started.html">https://docs.aws.amazon.com/glue/latest/ug/notebook-getting-started.htm</a></li><li>PySpark Code Examples — <a href="https://sparkbyexamples.com/pyspark-tutorial/">https://sparkbyexamples.com/pyspark-tutorial/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c741fa0611e" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/gen-ai-powered-by-amazon-code-whisperer-within-aws-glue-studio-notebooks-c741fa0611e">Gen AI powered by Amazon Code Whisperer within AWS Glue Studio Notebooks</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>