<?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 Amar Singhal on Medium]]></title>
        <description><![CDATA[Stories by Amar Singhal on Medium]]></description>
        <link>https://medium.com/@amar.singhal?source=rss-44b079b1067------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bIGdVXPtD4R7v_6kvgDqqw.jpeg</url>
            <title>Stories by Amar Singhal on Medium</title>
            <link>https://medium.com/@amar.singhal?source=rss-44b079b1067------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 15:47:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amar.singhal/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[Automated ETL migration from Pentaho to Airflow]]></title>
            <link>https://medium.com/@amar.singhal/automated-etl-migration-from-pentaho-to-airflow-e5a2e81479d6?source=rss-44b079b1067------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5a2e81479d6</guid>
            <category><![CDATA[automatic-code-generation]]></category>
            <category><![CDATA[airflow-installation]]></category>
            <category><![CDATA[etl-migration]]></category>
            <category><![CDATA[pentaho]]></category>
            <dc:creator><![CDATA[Amar Singhal]]></dc:creator>
            <pubDate>Thu, 23 Nov 2023 17:22:51 GMT</pubDate>
            <atom:updated>2024-02-22T18:17:34.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zxd-WWsIveZF1y3_6GhpxQ.png" /></figure><p>In the ever-evolving landscape of data management and ETL (Extract, Transform, Load) processes, businesses demand greater flexibility and adaptability to meet their evolving needs. Pentaho Data Integration (PDI) has been a trusted tool for capturing, cleansing, and storing data, but the demands for more agile solutions have never been higher. This is where Apache Airflow steps in as a game-changer, offering the flexibility and adaptability required for modern data workflows.</p><h3><strong>The Power of Apache Airflow</strong></h3><p>Apache Airflow is an open-source platform designed for developing, scheduling, and monitoring batch-oriented workflows. What sets Airflow apart is its extensible Python framework, allowing you to build workflows that connect with virtually any technology. Its web interface makes workflow management a breeze, and it can be deployed in various ways, from a single process on your laptop to a distributed setup capable of supporting the most extensive workflows.</p><p>At the heart of Airflow’s workflow management are Directed Acyclic Graphs (DAGs), which are collections of tasks organized to reflect their relationships and dependencies. Migrating your existing ETL workflows to Airflow takes your data management to the next level. You can leverage Airflow’s scheduling and monitoring capabilities to automate business processes on any scale, whether it’s on-premises or in the cloud, often with minimal additional cost.</p><h3>Introducing Our Migration Tool — Autoflow</h3><p>To assist with this transition, we have developed a migration tool that can accelerate the migration of your existing Pentaho pipelines to Airflow and save migration efforts by 40–70%.</p><p>Autoflow reads your Pentaho jobs stored locally as XML files and generates Airflow code to replicate your existing ETL workflows into Airflow DAGs and tasks while maintaining existing dependencies and functionalities. The generated code leverages standard Airflow operators wherever possible, and when standard operators are unavailable, it generates custom code and operators to ensure a seamless transition. Following the initial code generation, developers can make necessary modifications to ensure the desired functionality. It allows the developers to reevaluate efficiency improvements and fine-tune them to align the workflows with specific business objectives. The tool provides developers with an Airflow codebase that can be customized to suit their requirements.</p><p>With Autoflow, what could take a team of developers weeks to accomplish can now be done in minutes. It replicates your existing ETL workflows into Airflow programmatically, saving you valuable time and effort. You can redirect this energy towards optimizing your code, increasing the efficiency and impact of your processes. Leveraging Airflow’s scheduling and cloud connectivity capabilities, you can automate your workflows while retaining the flexibility to monitor and adjust processes as desired.</p><p>Make the transition from Pentaho to Airflow and unlock new possibilities for your ETL workflows. Streamline your data integration processes, increase efficiency, and embark on your journey to more dynamic and adaptable data orchestration.</p><h3>Demo</h3><p>Watch the Autoflow in action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKHL1VjzjhdI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKHL1VjzjhdI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKHL1VjzjhdI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d180d1416a75caced8f07b35c4e1572d/href">https://medium.com/media/d180d1416a75caced8f07b35c4e1572d/href</a></iframe><p>If you have any questions or would like to learn more about this tool, please don&#39;t hesitate to contact me at amar.singhal@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5a2e81479d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nutter Framework as a Regression Testing Solution for Data Pipeline]]></title>
            <link>https://medium.com/@amar.singhal/nutter-framework-as-a-regression-testing-solution-for-data-pipeline-b6ff698be517?source=rss-44b079b1067------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6ff698be517</guid>
            <dc:creator><![CDATA[Amar Singhal]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 18:00:30 GMT</pubDate>
            <atom:updated>2023-08-02T18:00:30.842Z</atom:updated>
            <content:encoded><![CDATA[<p>Regression testing is crucial in data engineering to ensure that changes or updates made to data pipelines, data transformations, and data processing workflows do not introduce new errors or issues while maintaining the integrity and quality of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*es4Gxne0AFhSOSc-_iopHQ.png" /></figure><p>To conduct regression testing effectively, the Nutter Framework can be leveraged in conjunction with the lineage information, provided by the Unity Catalog, and DevOps.</p><p>By utilizing the Nutter Framework, the execution of regression test cases can be automated, ensuring efficient and reliable validation of ETL jobs. The extensive lineage information in the Unity Catalog allows us to understand the data flow and dependencies, enabling targeted regression testing based on the changed code.</p><p>Integrating DevOps further enhances the regression testing process. By incorporating continuous integration and continuous delivery (CI/CD) pipelines, test execution can be automated in quickly identifying any regression issues that arise. This enables efficient feedback loops, early bug detection, and faster remediation.</p><p>Overall, by combining the capabilities of the Nutter Framework, the lineage information from the Unity Catalog, and integrating it with DevOps, we can streamline and optimize regression testing, ensuring the robustness and quality of the code.</p><blockquote><strong>What is a Lineage?</strong></blockquote><blockquote>In Unity Catalog, lineage refers to the representation of the data flow and relationships between various data assets within the catalog. It tracks the origin, transformations, and lineage of data assets as they move through different stages and processes.</blockquote><blockquote>Lineage in the Unity Catalog helps users understand how data assets are interconnected and how they have been transformed or derived from other data assets. It provides visibility into the end-to-end data flow, helping users trace data lineage from its source to its destination.</blockquote><h3>How will it work?</h3><p>1. Each ETL job written in Notebook will have associated Nutter test cases.</p><p>2. The Unity catalog-enabled workspace will capture the lineage information automatically, and it will be stored in the tablesystem.access.table_lineage</p><p><em>At the time of writing this article, direct access to the table </em><em>system.access.table_lineage is not available. It’s only available in public preview. For more information on this feature, please refer to this article - </em><a href="https://learn.microsoft.com/en-us/azure/databricks/administration-guide/system-tables/lineage"><em>Analyze the lineage system tables</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*RqrrhCwym3_xEuKHWceIYg.png" /></figure><p>3. A table will be created to capture the information about the ETL jobs and their respective test cases. The table will have the fields as shown in the below figure. The table will have an entity relationship with the system.access.table_lineage table via entity_id and it will have the details of the test cases for the respective ETL job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*zYMX85QSK9x4Ue-W7XqUMA.png" /></figure><p>The sample data for both tables will look like the following:</p><p>system.access.table_lineage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hYGD_GQUyu697r2mVOMQbw.png" /></figure><p>entity_test_cases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGwwZ5H-79TeoiV_dgiC2w.png" /></figure><p>4. As the code is merged from a particular ETL job:<br>(a) DevOps will run the query to get the data from the system.access.table_lineage and entity_test_cases to get the lineage information and the related test case details.<br>(b) DevOps will run the identified test cases and share the results with the development team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*_Nh27IPGIycazoQTLDtSTA.png" /></figure><p>In this article, the concept of regression testing using Nutterframe is discussed, and it is acknowledged that certain adjustments may be necessary during implementation. The article&#39;s primary focus is to share insights into leveraging the Nutter unit testing framework for regression testing in data pipelines. By exploring this approach, the article aims to present an innovative idea for enhancing the quality and reliability of data pipelines through comprehensive testing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6ff698be517" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Quality with Pydeequ]]></title>
            <link>https://medium.com/@amar.singhal/data-quality-with-pydeequ-2719baf6841?source=rss-44b079b1067------2</link>
            <guid isPermaLink="false">https://medium.com/p/2719baf6841</guid>
            <dc:creator><![CDATA[Amar Singhal]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 03:25:47 GMT</pubDate>
            <atom:updated>2023-08-02T03:25:47.490Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EThvU2DUdW4aJi1Rui4BuQ.png" /></figure><p>In today’s rapidly evolving world, data has become the lifeblood of organizations, playing a pivotal role in determining their success. Ensuring the quality of transformed data is of utmost importance, as it directly impacts the effectiveness and reliability of crucial business decisions.</p><p>Data accuracy, completeness, and consistency are critical factors that can make or break the outcomes of strategic initiatives. High-quality data empowers businesses to gain valuable insights, make informed decisions, and seize opportunities in a competitive landscape.</p><p>By prioritizing data quality, organizations can foster trust in their data-driven processes, enhance operational efficiency, and deliver exceptional value to customers. From optimizing internal operations to driving innovation, the importance of dependable and well-validated data cannot be overstated.</p><p>ETL (Extract, Transform, Load) processes play a crucial role in data engineering, facilitating the seamless flow of data from diverse sources, transforming it into a consistent format, and loading it into the target systems. These processes are the backbone of efficient data pipelines, enabling timely and accurate insights.</p><p>Ensuring data quality is an essential aspect of ETL operations. PyDeequ, a powerful data quality library, can thoroughly assess and validate data integrity to ensure high-quality data.</p><h3>What is Pydeequ?</h3><p>PyDeequ is a Python library that provides a high-level API for using Deequ, an open-source library for data quality assessment, constraint verification, and data profiling. Amazon initially developed Deequ and later contributed to the open-source community.</p><p>Deequ allows defining data quality constraints, such as uniqueness, completeness, and other data integrity rules, and then applying these constraints to large datasets for data validation and data profiling purposes. It is beneficial for assessing data quality in big data environments, where ensuring data quality and correctness is essential for reliable analysis and decision-making.</p><p>PyDeequ is a wrapper around the core Deequ library, allowing Python users to leverage Deequ’s capabilities from within their Python-based data processing workflows. With PyDeequ, we can define and run data quality checks, identify data issues, and generate data quality reports directly in Python, making integrating data quality assessment into the existing Python-based data pipelines and analysis processes easier.</p><p>PyDeequ integrates seamlessly with Apache Spark, enabling scalable data quality assessments and profiling on large-scale data in distributed computing environments.</p><h3>Capabilities of PyDeequ</h3><p>The following are the main capabilities of PyDeequ:</p><ol><li><strong>Metrics Computation</strong>: PyDeequ calculates data quality metrics or constraints on a dataset. These metrics provide insights into the data’s quality, completeness, uniqueness, and other characteristics. Those constraints are:<br>a. <strong>Completeness</strong>: Measures the percentage of non-null values for a given column or set of columns.<br>b. <strong>Uniqueness</strong>: Determines the percentage of unique values for a specific column or set of columns, helping to identify potential duplicate entries.<br>c. <strong>Distinctness</strong>: Evaluates the percentage of distinct values among all the rows in a dataset.<br>d. <strong>Approximate Count Distinct</strong>: Calculates an approximate count of distinct values in a column, which is useful for large datasets where an exact count might be computationally expensive.<br>e. <strong>Entropy</strong>: Measures the uncertainty or randomness in a column, indicating how evenly distributed the values are.<br>f. <strong>Mutual Information</strong>: Measures the degree of dependency between two columns, providing insights into the relationship between them.<br>g. <strong>Functional Dependency</strong>: Determining if one column functionally depends on another, indicating potential data quality issues.<br>h. <strong>Compliance</strong>: Checks if the data complies with predefined business rules and constraints.<br>We can better understand the dataset’s health and reliability by computing these data quality metrics.</li><li><strong>Constraint Verification</strong>: Constraint verification is validating data against predefined data quality constraints. Constraints are rules or conditions that specify the expected characteristics of them 2. data in a dataset. These constraints can include requirements on data completeness, uniqueness, range, and other data integrity aspects.</li><li><strong>Constraint suggestion: </strong>refers to the process of automatically generating data quality constraints based on dataset analysis. PyDeequ offers functionality to suggest data quality constraints that capture the characteristics of the data and help ensure data integrity and accuracy.</li></ol><p>When performing constraint suggestions, PyDeequ examines the dataset and uses statistical analysis and data profiling techniques to infer potential constraints that could be relevant and useful for the dataset. These suggested constraints aim to capture various data quality aspects, such as completeness, uniqueness, referential integrity, range, and distribution of values.</p><p>The benefit of constraint suggestion is that it can help data practitioners and engineers quickly identify potential data quality issues or data patterns in the dataset without manual inspection. The suggested constraints serve as a starting point for defining meaningful data quality rules that can be later applied for constraint verification.</p><h3>Implementation</h3><ol><li>Installing pydeequ from Notebook</li></ol><pre>%pip install pydeequ==1.1.0</pre><p>2. Setting Spark version for pydeequ API.</p><pre># Set the SPARK_VERSION environment variable<br>os.environ[&#39;SPARK_VERSION&#39;] = &#39;3.3&#39;</pre><p>3. Reading sample dataset on S3</p><pre>from pyspark.sql import SparkSession, Row<br>import pydeequ<br>from pydeequ.analyzers import *</pre><pre>df = spark.read.parquet(&quot;s3a://amazon-reviews-pds/parquet/product_category=Electronics/&quot;)</pre><p>4. Data analysis</p><p>Analyze the dataset using AnalysisRunner to collect the metrics.</p><pre>analysisResult = AnalysisRunner(spark) \<br>                    .onData(df) \<br>                    .addAnalyzer(Size()) \<br>                    .addAnalyzer(Completeness(&quot;review_id&quot;)) \<br>                    .addAnalyzer(ApproxCountDistinct(&quot;review_id&quot;)) \<br>                    .addAnalyzer(Mean(&quot;star_rating&quot;)) \<br>                    .addAnalyzer(Compliance(&quot;top star_rating&quot;, &quot;star_rating &gt;= 4.0&quot;)) \<br>                    .addAnalyzer(Correlation(&quot;total_votes&quot;, &quot;star_rating&quot;)) \<br>                    .addAnalyzer(Correlation(&quot;total_votes&quot;, &quot;helpful_votes&quot;)) \<br>                    .run()<br>                    <br>analysisResult_df = AnalyzerContext.successMetricsAsDataFrame(spark, analysisResult)<br>analysisResult_df.show()</pre><p>The below output will be shown for the above code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKytQhHVCsmoTOheNr59bA.png" /></figure><p>Let’s understand the meaning of each function used in the code and the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*Av8AejNlIdAG4mqLtKBH5Q.png" /></figure><h3>Data Verification</h3><p>The data can be verified based on the predefined data quality constraints. Constraints are rules or conditions that specify the expected characteristics of the data in a dataset. These constraints can include requirements on data completeness, uniqueness, range, and other data integrity aspects.</p><p>In the below code following constraints will be checked:</p><ol><li>At least 3 million rows in total</li><li>review_id is never NULL</li><li>review_id is unique</li><li>star_rating has a minimum of 1.0 and a maximum of 5.0</li><li>marketplace only contains US, UK, DE, JP, or FR</li><li>year does not contain negative values.</li></ol><p>Pydeequ code:</p><pre>from pydeequ.checks import *<br>from pydeequ.verification import *</pre><pre>check = Check(spark, CheckLevel.Warning, &quot;Amazon Electronics Review Check&quot;)</pre><pre>checkResult = VerificationSuite(spark) \<br>    .onData(df) \<br>    .addCheck(<br>        check.hasSize(lambda x: x &gt;= 3000000) \<br>        .hasMin(&quot;star_rating&quot;, lambda x: x == 1.0) \<br>        .hasMax(&quot;star_rating&quot;, lambda x: x == 5.0)  \<br>        .isComplete(&quot;review_id&quot;)  \<br>        .isUnique(&quot;review_id&quot;)  \<br>        .isComplete(&quot;marketplace&quot;)  \<br>        .isContainedIn(&quot;marketplace&quot;, [&quot;US&quot;, &quot;UK&quot;, &quot;DE&quot;, &quot;JP&quot;, &quot;FR&quot;]) \<br>        .isNonNegative(&quot;year&quot;)) \<br>    .run()<br>    <br>checkResult_df = VerificationResult.checkResultsAsDataFrame(spark, checkResult)<br>checkResult_df.show()</pre><p>Below is the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VX03ROUfuBpt6sGzsYjUyQ.png" /></figure><p>Let’s understand the following columns:</p><p>1. check_level means that the check level is set to warning and allows checks to produce warnings instead of failures when the data quality constraints are not met. This feature enables us to capture potential data quality issues without stopping the execution of the data quality assessment process.</p><p>2. check_status represents the overall status of the data quality check. It can have three possible values:<br>- “Success”: The check was successful, meaning the data quality constraint was satisfied for the specified data.<br>- “Warning”: The check was successful but produced a warning. This means the constraint was not violated, but some issues were identified that might require attention.<br>- “Error”: The check failed, indicating that the data quality constraint was not satisfied.</p><p>3. constraint_status represents the specific status of the constraint being checked. It can have two possible values:<br>- “Success”: The data quality constraint was satisfied, meaning the data met the requirements specified by the constraint.<br>- “Failure”: The data quality constraint was not satisfied, indicating that the data did not meet the requirements specified by the constraint.</p><p>Now, in the above example case where the check_status is &quot;Warning,&quot; it means that the overall check was successful, and the data quality constraint was satisfied. However, some warnings were generated during the verification process. These warnings might indicate potential data quality issues or deviations from expected patterns, but they do not lead to constraint violations.</p><p>It’s interesting to note that the review_id is not unique, and the uniqueness constraint check has failed.</p><h3>Automated Constraints Suggestion</h3><p><strong>Automated Constraint Suggestion</strong> helps in identifying potential data quality problems in the data.</p><p>The automated constraint suggestion feature tracks data and identifies potential problems based on the data distribution. For example, if a column contains only positive values, the suggestion engine might recommend a constraint that ensures that all values in the column are non-negative.</p><p>The automated constraint suggestion feature is a powerful tool that can help improve data quality. However, it is important to remember that the suggestions are not always perfect. One should always review the suggestions carefully and decide whether they are appropriate for their data.</p><p>The following code can be used to generate Automated Constraints Suggestions:</p><pre>from pydeequ.suggestions import *</pre><pre>suggestionResult = ConstraintSuggestionRunner(spark) \<br>             .onData(df) \<br>             .addConstraintRule(DEFAULT()) \<br>             .run()</pre><pre># Constraint Suggestions in JSON format<br>print(json.dumps(suggestionResult, indent=2))</pre><p>The output shows the constraints suggestions:</p><pre>{<br>  &quot;constraint_suggestions&quot;: [<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(review_id,None))&quot;,<br>      &quot;column_name&quot;: &quot;review_id&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;review_id&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;review_id\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;UniquenessConstraint(Uniqueness(List(review_id),None))&quot;,<br>      &quot;column_name&quot;: &quot;review_id&quot;,<br>      &quot;current_value&quot;: &quot;ApproxDistinctness: 0.9647650802419017&quot;,<br>      &quot;description&quot;: &quot;&#39;review_id&#39; is unique&quot;,<br>      &quot;suggesting_rule&quot;: &quot;UniqueIfApproximatelyUniqueRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If the ratio of approximate num distinct values in a column is close to the number of records (within the error of the HLL sketch), we suggest a UNIQUE constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isUnique(\&quot;review_id\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(customer_id,None))&quot;,<br>      &quot;column_name&quot;: &quot;customer_id&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;customer_id&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;customer_id\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;customer_id&#39; has no negative values,customer_id &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;customer_id&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 10005.0&quot;,<br>      &quot;description&quot;: &quot;&#39;customer_id&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;customer_id\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;AnalysisBasedConstraint(DataType(customer_id,None),&lt;function1&gt;,Some(&lt;function1&gt;),None)&quot;,<br>      &quot;column_name&quot;: &quot;customer_id&quot;,<br>      &quot;current_value&quot;: &quot;DataType: Integral&quot;,<br>      &quot;description&quot;: &quot;&#39;customer_id&#39; has type Integral&quot;,<br>      &quot;suggesting_rule&quot;: &quot;RetainTypeRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we detect a non-string type, we suggest a type constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.hasDataType(\&quot;customer_id\&quot;, ConstrainableDataTypes.Integral)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(review_date,None))&quot;,<br>      &quot;column_name&quot;: &quot;review_date&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;review_date&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;review_date\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(helpful_votes,None))&quot;,<br>      &quot;column_name&quot;: &quot;helpful_votes&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;helpful_votes&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;helpful_votes\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;helpful_votes&#39; has no negative values,helpful_votes &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;helpful_votes&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 0.0&quot;,<br>      &quot;description&quot;: &quot;&#39;helpful_votes&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;helpful_votes\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;star_rating&#39; has value range &#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39;, &#39;2&#39;,`star_rating` IN (&#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39;, &#39;2&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;star_rating&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 1&quot;,<br>      &quot;description&quot;: &quot;&#39;star_rating&#39; has value range &#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39;, &#39;2&#39;&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CategoricalRangeRule(com.amazon.deequ.suggestions.rules.CategoricalRangeRule$$$Lambda$7945/101154422@5874afe6)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for a column, we suggest an IS IN (...) constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;star_rating\&quot;, [\&quot;5\&quot;, \&quot;4\&quot;, \&quot;1\&quot;, \&quot;3\&quot;, \&quot;2\&quot;])&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(star_rating,None))&quot;,<br>      &quot;column_name&quot;: &quot;star_rating&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;star_rating&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;star_rating\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;star_rating&#39; has value range &#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39; for at least 94.0% of values,`star_rating` IN (&#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;star_rating&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 0.942110993553861&quot;,<br>      &quot;description&quot;: &quot;&#39;star_rating&#39; has value range &#39;5&#39;, &#39;4&#39;, &#39;1&#39;, &#39;3&#39; for at least 94.0% of values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;FractionalCategoricalRangeRule(0.9,com.amazon.deequ.suggestions.rules.FractionalCategoricalRangeRule$$$Lambda$7946/467315348@630b8b41)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for most values in a column, we suggest an IS IN (...) constraint that should hold for most values&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;star_rating\&quot;, [\&quot;5\&quot;, \&quot;4\&quot;, \&quot;1\&quot;, \&quot;3\&quot;], lambda x: x &gt;= 0.94, \&quot;It should be above 0.94!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;star_rating&#39; has no negative values,star_rating &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;star_rating&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;star_rating&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;star_rating\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;year&#39; has value range &#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39;, &#39;2008&#39;, &#39;2007&#39;, &#39;2006&#39;, &#39;2005&#39;, &#39;2004&#39;, &#39;2003&#39;, &#39;2002&#39;, &#39;2001&#39;, &#39;2000&#39;, &#39;1999&#39;,`year` IN (&#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39;, &#39;2008&#39;, &#39;2007&#39;, &#39;2006&#39;, &#39;2005&#39;, &#39;2004&#39;, &#39;2003&#39;, &#39;2002&#39;, &#39;2001&#39;, &#39;2000&#39;, &#39;1999&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;year&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 1&quot;,<br>      &quot;description&quot;: &quot;&#39;year&#39; has value range &#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39;, &#39;2008&#39;, &#39;2007&#39;, &#39;2006&#39;, &#39;2005&#39;, &#39;2004&#39;, &#39;2003&#39;, &#39;2002&#39;, &#39;2001&#39;, &#39;2000&#39;, &#39;1999&#39;&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CategoricalRangeRule(com.amazon.deequ.suggestions.rules.CategoricalRangeRule$$$Lambda$7945/101154422@5874afe6)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for a column, we suggest an IS IN (...) constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;year\&quot;, [\&quot;2014\&quot;, \&quot;2015\&quot;, \&quot;2013\&quot;, \&quot;2012\&quot;, \&quot;2011\&quot;, \&quot;2010\&quot;, \&quot;2009\&quot;, \&quot;2008\&quot;, \&quot;2007\&quot;, \&quot;2006\&quot;, \&quot;2005\&quot;, \&quot;2004\&quot;, \&quot;2003\&quot;, \&quot;2002\&quot;, \&quot;2001\&quot;, \&quot;2000\&quot;, \&quot;1999\&quot;])&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(year,None))&quot;,<br>      &quot;column_name&quot;: &quot;year&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;year&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;year\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;year&#39; has value range &#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39; for at least 92.0% of values,`year` IN (&#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;year&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 0.9286063997426415&quot;,<br>      &quot;description&quot;: &quot;&#39;year&#39; has value range &#39;2014&#39;, &#39;2015&#39;, &#39;2013&#39;, &#39;2012&#39;, &#39;2011&#39;, &#39;2010&#39;, &#39;2009&#39; for at least 92.0% of values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;FractionalCategoricalRangeRule(0.9,com.amazon.deequ.suggestions.rules.FractionalCategoricalRangeRule$$$Lambda$7946/467315348@630b8b41)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for most values in a column, we suggest an IS IN (...) constraint that should hold for most values&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;year\&quot;, [\&quot;2014\&quot;, \&quot;2015\&quot;, \&quot;2013\&quot;, \&quot;2012\&quot;, \&quot;2011\&quot;, \&quot;2010\&quot;, \&quot;2009\&quot;], lambda x: x &gt;= 0.92, \&quot;It should be above 0.92!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;year&#39; has no negative values,year &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;year&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 1999.0&quot;,<br>      &quot;description&quot;: &quot;&#39;year&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;year\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(product_title,None))&quot;,<br>      &quot;column_name&quot;: &quot;product_title&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;product_title&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;product_title\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(review_headline,None))&quot;,<br>      &quot;column_name&quot;: &quot;review_headline&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 0.9999987183340393&quot;,<br>      &quot;description&quot;: &quot;&#39;review_headline&#39; has less than 1% missing values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;RetainCompletenessRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is incomplete in the sample, we model its completeness as a binomial variable, estimate a confidence interval and use this to define a lower bound for the completeness&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.hasCompleteness(\&quot;review_headline\&quot;, lambda x: x &gt;= 0.99, \&quot;It should be above 0.99!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(product_id,None))&quot;,<br>      &quot;column_name&quot;: &quot;product_id&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;product_id&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;product_id\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(total_votes,None))&quot;,<br>      &quot;column_name&quot;: &quot;total_votes&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;total_votes&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;total_votes\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;total_votes&#39; has no negative values,total_votes &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;total_votes&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 0.0&quot;,<br>      &quot;description&quot;: &quot;&#39;total_votes&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;total_votes\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(product_parent,None))&quot;,<br>      &quot;column_name&quot;: &quot;product_parent&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;product_parent&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;product_parent\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;product_parent&#39; has no negative values,product_parent &gt;= 0,None))&quot;,<br>      &quot;column_name&quot;: &quot;product_parent&quot;,<br>      &quot;current_value&quot;: &quot;Minimum: 6478.0&quot;,<br>      &quot;description&quot;: &quot;&#39;product_parent&#39; has no negative values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;NonNegativeNumbersRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we see only non-negative numbers in a column, we suggest a corresponding constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isNonNegative(\&quot;product_parent\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;AnalysisBasedConstraint(DataType(product_parent,None),&lt;function1&gt;,Some(&lt;function1&gt;),None)&quot;,<br>      &quot;column_name&quot;: &quot;product_parent&quot;,<br>      &quot;current_value&quot;: &quot;DataType: Integral&quot;,<br>      &quot;description&quot;: &quot;&#39;product_parent&#39; has type Integral&quot;,<br>      &quot;suggesting_rule&quot;: &quot;RetainTypeRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If we detect a non-string type, we suggest a type constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.hasDataType(\&quot;product_parent\&quot;, ConstrainableDataTypes.Integral)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(review_body,None))&quot;,<br>      &quot;column_name&quot;: &quot;review_body&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 0.9999724441818453&quot;,<br>      &quot;description&quot;: &quot;&#39;review_body&#39; has less than 1% missing values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;RetainCompletenessRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is incomplete in the sample, we model its completeness as a binomial variable, estimate a confidence interval and use this to define a lower bound for the completeness&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.hasCompleteness(\&quot;review_body\&quot;, lambda x: x &gt;= 0.99, \&quot;It should be above 0.99!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;vine&#39; has value range &#39;N&#39;, &#39;Y&#39;,`vine` IN (&#39;N&#39;, &#39;Y&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;vine&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 1&quot;,<br>      &quot;description&quot;: &quot;&#39;vine&#39; has value range &#39;N&#39;, &#39;Y&#39;&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CategoricalRangeRule(com.amazon.deequ.suggestions.rules.CategoricalRangeRule$$$Lambda$7945/101154422@5874afe6)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for a column, we suggest an IS IN (...) constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;vine\&quot;, [\&quot;N\&quot;, \&quot;Y\&quot;])&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(vine,None))&quot;,<br>      &quot;column_name&quot;: &quot;vine&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;vine&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;vine\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;vine&#39; has value range &#39;N&#39; for at least 99.0% of values,`vine` IN (&#39;N&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;vine&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 0.9939271462617969&quot;,<br>      &quot;description&quot;: &quot;&#39;vine&#39; has value range &#39;N&#39; for at least 99.0% of values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;FractionalCategoricalRangeRule(0.9,com.amazon.deequ.suggestions.rules.FractionalCategoricalRangeRule$$$Lambda$7946/467315348@630b8b41)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for most values in a column, we suggest an IS IN (...) constraint that should hold for most values&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;vine\&quot;, [\&quot;N\&quot;], lambda x: x &gt;= 0.99, \&quot;It should be above 0.99!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;marketplace&#39; has value range &#39;US&#39;, &#39;UK&#39;, &#39;DE&#39;, &#39;JP&#39;, &#39;FR&#39;,`marketplace` IN (&#39;US&#39;, &#39;UK&#39;, &#39;DE&#39;, &#39;JP&#39;, &#39;FR&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;marketplace&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 1&quot;,<br>      &quot;description&quot;: &quot;&#39;marketplace&#39; has value range &#39;US&#39;, &#39;UK&#39;, &#39;DE&#39;, &#39;JP&#39;, &#39;FR&#39;&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CategoricalRangeRule(com.amazon.deequ.suggestions.rules.CategoricalRangeRule$$$Lambda$7945/101154422@5874afe6)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for a column, we suggest an IS IN (...) constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;marketplace\&quot;, [\&quot;US\&quot;, \&quot;UK\&quot;, \&quot;DE\&quot;, \&quot;JP\&quot;, \&quot;FR\&quot;])&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(marketplace,None))&quot;,<br>      &quot;column_name&quot;: &quot;marketplace&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;marketplace&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;marketplace\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;marketplace&#39; has value range &#39;US&#39; for at least 99.0% of values,`marketplace` IN (&#39;US&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;marketplace&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 0.9949982985884372&quot;,<br>      &quot;description&quot;: &quot;&#39;marketplace&#39; has value range &#39;US&#39; for at least 99.0% of values&quot;,<br>      &quot;suggesting_rule&quot;: &quot;FractionalCategoricalRangeRule(0.9,com.amazon.deequ.suggestions.rules.FractionalCategoricalRangeRule$$$Lambda$7946/467315348@630b8b41)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for most values in a column, we suggest an IS IN (...) constraint that should hold for most values&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;marketplace\&quot;, [\&quot;US\&quot;], lambda x: x &gt;= 0.99, \&quot;It should be above 0.99!\&quot;)&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;ComplianceConstraint(Compliance(&#39;verified_purchase&#39; has value range &#39;Y&#39;, &#39;N&#39;,`verified_purchase` IN (&#39;Y&#39;, &#39;N&#39;),None))&quot;,<br>      &quot;column_name&quot;: &quot;verified_purchase&quot;,<br>      &quot;current_value&quot;: &quot;Compliance: 1&quot;,<br>      &quot;description&quot;: &quot;&#39;verified_purchase&#39; has value range &#39;Y&#39;, &#39;N&#39;&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CategoricalRangeRule(com.amazon.deequ.suggestions.rules.CategoricalRangeRule$$$Lambda$7945/101154422@5874afe6)&quot;,<br>      &quot;rule_description&quot;: &quot;If we see a categorical range for a column, we suggest an IS IN (...) constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isContainedIn(\&quot;verified_purchase\&quot;, [\&quot;Y\&quot;, \&quot;N\&quot;])&quot;<br>    },<br>    {<br>      &quot;constraint_name&quot;: &quot;CompletenessConstraint(Completeness(verified_purchase,None))&quot;,<br>      &quot;column_name&quot;: &quot;verified_purchase&quot;,<br>      &quot;current_value&quot;: &quot;Completeness: 1.0&quot;,<br>      &quot;description&quot;: &quot;&#39;verified_purchase&#39; is not null&quot;,<br>      &quot;suggesting_rule&quot;: &quot;CompleteIfCompleteRule()&quot;,<br>      &quot;rule_description&quot;: &quot;If a column is complete in the sample, we suggest a NOT NULL constraint&quot;,<br>      &quot;code_for_constraint&quot;: &quot;.isComplete(\&quot;verified_purchase\&quot;)&quot;<br>    }<br>  ]<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2719baf6841" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing Mainframe files (EBCDIC files)]]></title>
            <link>https://medium.com/@amar.singhal/data-migration-from-mainframes-parsing-ebcdic-files-83d4900eb0ab?source=rss-44b079b1067------2</link>
            <guid isPermaLink="false">https://medium.com/p/83d4900eb0ab</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Amar Singhal]]></dc:creator>
            <pubDate>Mon, 31 Jul 2023 15:36:39 GMT</pubDate>
            <atom:updated>2024-02-21T18:16:07.110Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Mainframes</strong></h3><p>Mainframe systems are known for their high stability, reliability, and robustness. They have a proven track record of handling mission-critical workloads with minimal downtime, which is crucial for industries such as banking, finance, and government, where data integrity and availability are paramount. Mainframe systems are optimized for transaction processing and can efficiently handle large-scale batch-processing tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M84cpt8Wo1jY8l8_FXnkrw.jpeg" /></figure><p>Many companies have built their core business applications and systems on Mainframes over several decades. Replacing or migrating these systems can be a complex and costly process, and it may not always be feasible to transition away from Mainframe completely.</p><h3>What drives the migration of data from Mainframes to modern data engineering platforms?</h3><p>In the era of AI and Analytics, companies are more driven than ever to leverage data to make informed decisions and achieve their business objectives. While the Mainframe holds its own strengths, it may fall short in various aspects where modern data engineering solutions excel. Below are a few of these key areas:</p><ol><li>Cost Optimization: Mainframes often come with high operating and maintenance costs. Modern data engineering platforms offer more cost-effective solutions that can scale efficiently based on actual data processing needs, leading to potential cost savings.</li><li>Scalability and Performance: Mainframes might struggle to handle today&#39;s businesses&#39; ever-increasing data volumes and processing demands. Modern data engineering platforms, with their distributed and parallel processing capabilities, provide the scalability and performance required to process large datasets quickly.</li><li>Integration and Interoperability: Modern data engineering platforms offer seamless integration with various data sources and systems, allowing companies to create a unified data ecosystem. This enables better data sharing, improved data quality, and streamlined processes across the organization.</li><li>Advanced Analytics: Mainframes are not typically equipped with the latest analytics tools and technologies. By moving data to modern platforms, companies gain access to advanced analytics capabilities like machine learning, AI, and real-time analytics, enabling data-driven decision-making and innovative insights.</li><li>Flexibility and Agility: Mainframes are often associated with rigid structures and limited flexibility. Modern data engineering platforms provide more agile and flexible infrastructures, allowing companies to adapt quickly to changing business needs and market demands.</li><li>Cloud Adoption: Many modern data engineering platforms are cloud-based, providing companies with the benefits of cloud computing, such as elasticity, cost-effectiveness, and global accessibility. Moving data to the cloud also enables a more distributed and decentralized approach to data processing.</li><li>Data Governance and Security: Modern data engineering platforms offer robust data governance and security features, ensuring compliance with data regulations and protecting sensitive information. Companies can implement advanced security measures to safeguard their data assets effectively.</li></ol><h3>Data in Mainframe</h3><p>Mainframe data is often stored in fixed-length record format, where each record has a predetermined length, or variable-length record format, where each record’s length may vary. The data is stored in binary format, using EBCDIC encoding, which differs from ASCII encoding.</p><p>The metadata for the EBCDIC file is stored in a copybook file. It defines the structure and layout of data records. It acts as a data schema that specifies the format of data stored in datasets or files. Copybooks are commonly written in COBOL, and they provide a standardized way to represent the structure of data records.</p><p>EBCDIC and copybook files are two crucial files to consider when working with mainframe data conversion. These files play a pivotal role in accurately processing and transforming the data from mainframe systems to modern formats.</p><h3><strong>Parsing EBCDIC files</strong></h3><p>The following are the solutions I explored for parsing EBCDIC files:</p><ol><li>Corbix — Cobrix is a powerful open-source API designed to work with EBCDIC files in the Apache Spark environment. It allows users to process, read, and convert EBCDIC-encoded data to modern formats like JSON, CSV, Parquet, or others compatible with Spark DataFrames.</li><li>Microsoft Host Integration Server (HIS) and Logic APP — Microsoft Host Integration Server (HIS) and Logic App offer powerful capabilities for handling mainframe data conversions. HIS can convert a copybook to a HIDX file and Logic App leverages this HIDX file to parse the EBCDIC file effectively. This integration ensures a seamless and efficient process for transforming mainframe data into a format compatible with modern data engineering platforms. More information about this solution can be found on this <a href="https://techcommunity.microsoft.com/t5/modernization-best-practices-and/mainframe-ebcdic-data-file-to-ascii-conversion-using-azure-logic/ba-p/3763750">page</a>.</li></ol><p>During the evaluation process, certain challenges arose with the HIS and Logic App solution when parsing EBCDIC files containing numeric columns with blank values. While custom C# code could have resolved this issue, I opted for the Cobrix solution as it offered a ready-to-use approach without requiring any additional custom code. Furthermore, considering the data’s ultimate usage in Databricks, Cobrix emerged as the natural choice, aligning seamlessly with our data engineering needs.</p><h3>Cobrix</h3><p>EBCDIC Data Processing: Cobrix enables users to read and process EBCDIC data directly in Spark. It provides utilities to handle EBCDIC-encoded records and fields, making working with Mainframe data in a Spark environment easier.</p><p>Cobrix can effortlessly convert EBCDIC data to modern data formats like JSON or Parquet, which are commonly used in data engineering and analytics tasks.</p><p>Integration with Apache Spark: Cobrix seamlessly integrates with Apache Spark, making it a suitable choice for data processing and transformation tasks in Spark-based data pipelines.</p><p>Cobrix is designed to optimize performance when handling large-scale EBCDIC files, ensuring efficient data processing and minimal resource consumption.</p><h3>Implementation — Cobrix</h3><p>Using Cobix API is pretty to use. Following are the steps I followed for the POC:</p><ol><li>Deploy a Databricks workspace on Azure or AWS. For this project, I opted for Azure as the preferred platform.</li><li>Once the workspace is set up, create a cluster within Databricks to execute data processing tasks.</li><li>To enable EBCDIC file handling, incorporate the Cobrix library into the cluster. I utilized Cobrix version “za.co.absa.cobrix:spark-cobol_2.12:2.6.8” and ensured a cluster restart to apply the changes.</li><li>Develop a Notebook and associate it with the cluster established in the previous step.</li><li>Proceed to upload the EBCDIC file and copybook to the DBFS (Databricks File System) within Databricks. For an optimized approach, consider utilizing a storage account and accessing the files from there. However, for the POC’s simplicity, I chose to upload the files to the DBFS directly.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*_H6Ag3AMdnnTbDoHpdARgA.jpeg" /></figure><ol><li>A few lines of code can parse the EBCDIC file and process the data within the Notebook.</li></ol><pre>spark = SparkSession.builder \<br>    .appName(&quot;COBOL Parser&quot;) \<br>    .config(&quot;spark.jars.packages&quot;, &quot;za.co.absa.cobrix:spark-cobol_2.12:2.6.8&quot;) \<br>    .getOrCreate()<br><br>#Reading EBCDIC file using Cobrix library<br>df = spark.read \<br>    .format(&quot;cobol&quot;) \<br>    .option(&quot;copybook&quot;, &quot;dbfs:/FileStore/cobol_files/copybook.cob&quot; \<br>    .option(&quot;record_format&quot;, &quot;F&quot;) \<br>    .load(&quot;dbfs:/FileStore/Sample_EBCDIC_file&quot;)<br><br>df.show()</pre><p><strong>Below is the output:</strong><br>Each record in the JSON will be printed as JSON</p><pre>{&quot;order_id&quot;:&quot;569856&quot;,&quot;address&quot;:{&quot;number&quot;:&quot;586&quot;,&quot;street&quot;:&quot;Adam St&quot;,&quot;city&quot;:&quot;Chicago&quot;,&quot;country&quot;:&quot;USA&quot;},&quot;date&quot;:&quot;2023/01/23&quot;}<br>{&quot;order_id&quot;:&quot;5896&quot;,&quot;address&quot;:{&quot;number&quot;:&quot;89&quot;,&quot;street&quot;:&quot;Wacker Dr&quot;,&quot;city&quot;:&quot;Chicago&quot;,&quot;country&quot;:&quot;USA&quot;},&quot;date&quot;:&quot;2023/01/25&quot;}<br></pre><p>When processing the EBCDIC file, the resulting output format can be JSON, CSV, or any other supported format. Given the complex nested data structure of the EBCDIC I was parsing, I chose JSON as the output format.</p><h3>Conclusion</h3><p>Mainframe systems have been the backbone of many companies’ core business applications for decades due to their high stability, reliability, and efficiency in handling mission-critical workloads. However, in the era of AI and Analytics, the need to leverage data for informed decision-making has driven companies to explore modern data engineering platforms for their data processing needs.</p><p>Cloud-based solutions have gained popularity, providing companies with the benefits of elasticity, cost-effectiveness, and global accessibility. Additionally, modern data engineering platforms offer robust data governance and security features, ensuring compliance with data regulations and protecting sensitive information.</p><p>When dealing with Mainframe data conversion, EBCDIC and copybook files play a vital role in accurately processing and transforming the data to modern formats. For parsing EBCDIC files, Cobrix emerges as a powerful open-source API designed to work with EBCDIC files in the Apache Spark environment. It offers utilities to handle EBCDIC-encoded records and fields, making working with Mainframe data in a Spark environment easier. Cobrix seamlessly integrates with Apache Spark, optimizing performance when handling large-scale EBCDIC files and ensuring efficient data processing with minimal resource consumption.</p><h3>Reference</h3><ol><li><a href="https://github.com/AbsaOSS/cobrix">Corbix Library</a></li><li><a href="https://techcommunity.microsoft.com/t5/modernization-best-practices-and/mainframe-ebcdic-data-file-to-ascii-conversion-using-azure-logic/ba-p/3763750">HIS and Logic App</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83d4900eb0ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>