<?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 Jason Li on Medium]]></title>
        <description><![CDATA[Stories by Jason Li on Medium]]></description>
        <link>https://medium.com/@jasonli.lijie?source=rss-fa612fc951a0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Jz05VdHcuX6V82K1.jpg</url>
            <title>Stories by Jason Li on Medium</title>
            <link>https://medium.com/@jasonli.lijie?source=rss-fa612fc951a0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:20:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasonli.lijie/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[A High-Level Analysis of a Global Consulting Leader Using Public Data]]></title>
            <link>https://medium.com/@jasonli.lijie/a-high-level-analysis-of-a-global-consulting-leader-using-public-data-9a2e5725435c?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a2e5725435c</guid>
            <category><![CDATA[random-thoughts]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Tue, 25 Aug 2026 11:20:26 GMT</pubDate>
            <atom:updated>2026-08-26T09:48:25.009Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Full disclosure</strong> — and apparently this needs to be said louder for the people in the back — I wrote this as a <strong>data professional</strong>, not as some ex‑employee still clutching old grievances. Thanks to the helpful chorus advising me to “move on”. The only reason this particular company ended up as my case study is painfully simple: the company is publicly listed and the data actually exists. My current employer isn’t listed, so unless you want a post built on vibes and imagination, this is the dataset we’ve got.</p><p>I recently came across several online articles discussing the uncertain outlook for the consulting industry, along with some negative sentiment reflected in the stock market. This prompted me to conduct a basic analysis of my former employer, Accenture, using publicly available information from <a href="https://en.wikipedia.org/wiki/Accenture">Wikipedia</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*uLybJEInBsOyI44NcCf3UA.png" /><figcaption>source data from wikipedia</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*k0ZZ837ba73oo__pjlSNHA.png" /><figcaption>Headcount over time</figcaption></figure><p>Headcount nearly tripled over the period — 275,000 (2013) to 779,000 (2025), a 9.1% CAGR. Growth was fairly steady through 2020, but 2021 and 2022 stand out sharply (+23% and +16% respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*QmFvAsZ78I2MYdBA4M53FQ.png" /><figcaption>Revenue and Net income over time</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*gZJOPLAg0p3b032hLLOTKA.png" /><figcaption>Net income margin over time</figcaption></figure><h3>What the numbers say</h3><p><strong>Growth has been strong but decelerating in quality.</strong> Revenue grew from $30.4B to $69.7B (7.2% CAGR), but headcount grew faster (9.1% CAGR, 275k → 779k). Revenue per employee fell from ~$110k (2013) to ~$89k (2025) — the firm is scaling by adding people faster than it’s adding revenue per person, consistent with a shift toward more labor-intensive delivery (managed services, large-scale implementation) rather than premium advisory work.</p><p><strong>Margins are stable, not expanding.</strong> Net margin has bounced in a tight 9–12% band for 13 straight years (9.2% in 2014, peaking at 11.8% in 2016, sitting at 11.2% in 2025) with no structural improvement despite more than doubling in size. Scale hasn’t bought margin leverage here — a classic signature of a people-intensive services business rather than a software/product business.</p><p><strong>Assets are growing much faster than revenue.</strong> Total assets rose 3.9x (16.9B → 65.4B) against 2.3x revenue growth, so asset turnover fell from 1.80x to 1.07x and ROA dropped from ~19.5% to ~12%. This pattern — assets ballooning faster than revenue — usually signals heavy M&amp;A activity (goodwill/intangibles from acquisitions) rather than organic capacity building.</p><p><strong>Three distinct eras stand out:</strong></p><ul><li><strong>2013–2019</strong>: steady, unspectacular growth (~4–8%/year), margin volatility but no clear trend.</li><li><strong>2020–2022</strong>: acceleration despite (then following) the pandemic — 2021 and 2022 posted revenue growth of ~14% and ~22%, with headcount up 15% in 2022 alone. This looks like an aggressive post-pandemic hiring and acquisition wave.</li><li><strong>2023–2024</strong>: sharp slowdown — revenue growth collapsed to ~4% then ~1.2%, even as headcount kept climbing (733k → 774k), which is why 2024 margin dipped slightly. This tracks the broader 2023–24 consulting/tech-services demand slump. <strong>2025 reaccelerated</strong> to +7.4% revenue growth with margin recovering to 11.2%, suggesting the correction was cyclical rather than structural.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*E1YocqctLJnv-HzIfT8n5Q.png" /><figcaption>revenue and net income per employee over time</figcaption></figure><p>Both metrics tell the same story: <strong>per-employee productivity has been declining structurally, even as the headline numbers grow.</strong></p><ul><li><strong>Revenue per employee</strong> fell from $110.5k (2013) to a low of $81.0k in 2021, before recovering to $89.4k by 2025 — still ~19% below the 2013 level.</li><li><strong>Net income per employee</strong> shows the same shape: $11.9k in 2013 down to $8.1k in 2017, recovering to $10.1k by 2025 — still ~16% below 2013.</li></ul><p>Two things worth noting:</p><ol><li><strong>The dips don’t line up perfectly</strong> — revenue/employee bottoms in 2021 (the aggressive hiring wave), while net income/employee bottoms earlier, in 2017. That earlier dip in profitability-per-head, with revenue/employee also falling through the same years, suggests margin pressure independent of the later hiring surge — possibly pricing/mix effects from acquisitions made throughout the decade.</li><li><strong>Both metrics are recovering, not just growing with revenue.</strong> From 2021–2025, headcount growth (624k → 779k, +25%) has been much slower than revenue growth (50.5B → 69.7B, +38%), so the firm appears to be digesting its post-2020 hiring wave and extracting more value per person again — a sign the recent slowdown (2023–24) may have forced better capacity utilization rather than just hurting the business.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*o0QYwO1O_SC8c-hr-F6HUQ.png" /><figcaption>Share price history</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*INa_YspiLoK2dyow5TwnYw.png" /><figcaption><strong>Correlation with year-end share price (Pearson r, 2013–2025)</strong></figcaption></figure><p><em>Credit: Wikipedia &amp; Claude &amp; Copilot</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a2e5725435c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Experience to Imagination: a Data Analytics Platform in Azure]]></title>
            <link>https://medium.com/@jasonli.lijie/from-experience-to-imagination-a-data-analytics-platform-in-azure-996967d095c0?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/996967d095c0</guid>
            <category><![CDATA[azure-synapse-analytics]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sap-data-integration]]></category>
            <category><![CDATA[data-platforms]]></category>
            <category><![CDATA[data-ingestion]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Sun, 21 Sep 2025 12:31:46 GMT</pubDate>
            <atom:updated>2025-09-21T23:00:48.173Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is a continuation of my 2025 roadmap, first outlined in <a href="https://medium.com/@jasonli.lijie/from-experience-to-imagination-a-data-analytics-platform-in-aws-a87d4a309231">From Experience to Imagination: a Data Analytics Platform in AWS | by Jason Li | Medium</a>. There, I committed to distilling real-world architectural lessons into a reusable framework — one that transcends specific tools, industries, or implementations, in Microsoft Azure.<br>What follows is an imagined project in Microsoft Azure, shaped by patterns observed across multiple engagements. It’s not a blueprint for any one specific solution, but a conceptual scaffold designed to help readers think more clearly about their own data platforms. By abstracting away the particulars, I aim to surface the enduring principles that make analytics platforms resilient, scalable, and adaptable.</p><h3>Business Challenges to Address</h3><h4>Data Integration</h4><p>Organizations often manage data from diverse sources, including structured and unstructured formats such as flat files, REST APIs, various database systems (such as Microsoft SQL Server and Oracle), and SAP system. The inconsistency in data structure and access pattern poses challenges for analytics and reporting.</p><h4>Multi-Destination Data Management</h4><p>Business operations frequently require data to be delivered to multiple destinations, including data warehouses, visualization tools, and third-party applications. Without a well-structured distribution mechanism, ensuring consistency, security, and accuracy becomes increasingly complex.</p><h4>Manual Processes and Data Quality Issues</h4><p>Many organizations rely on manual data entry and transformation methods, increasing the risk of human errors. The absence of automated quality checks leads to inconsistencies, redundancies, and inaccuracies, impacting decision-making and operational efficiency.</p><h3>Choice of Solutions</h3><p>The solution is based on <a href="https://learn.microsoft.com/en-us/azure/architecture/example-scenario/dataplate2e/data-platform-end-to-end">https://learn.microsoft.com/en-us/azure/architecture/example-scenario/dataplate2e/data-platform-end-to-end</a>, but with customizations on additional use cases to support in various projects.</p><p>This reference architecture leverages Azure services to ingest, store, process, enrich, and serve both structured and unstructured data in various formats from on-premises sources into a unified data lake-house and data warehouse environment. It follows a layered data lake approach (Raw → Enriched → Curated) and implements both cold (batch) and hot (streaming) paths of the Lambda architecture.</p><h3>Why Use a Self-Hosted Integration Runtime(SHIR)</h3><p>Self-hosted integration runtime (SHIR) is introduced to let Synapse pipelines reach into your <strong>private</strong> networks and <strong>on-premises</strong> systems securely and reliably.</p><h4>Secure Connectivity to Private and On-Premises Networks</h4><ul><li>Enables outbound-only communication from your network to Azure over HTTPS</li><li>Works seamlessly behind firewalls, proxies, and NAT(network address translation)</li><li>Avoids exposing data sources directly to the public internet</li></ul><h4>Support for Legacy and Proprietary Data Sources</h4><ul><li>Hosts custom ODBC/OLE DB drivers for Oracle, DB2, Teradata, <strong>SAP</strong>, mainframes, etc.</li><li>Can mount Windows file shares (SMB) or Linux NFS volumes for batch file ingest</li><li>Lets you keep using existing on-premises tooling without rearchitecting sources</li></ul><h4>Data Sovereignty and Compliance</h4><ul><li>Ensures data never leaves your controlled environment unencrypted</li><li>Meets regulatory requirements by keeping data movement within approved network zones</li><li>Integrates with corporate identity and key-management systems for credential security</li></ul><h4>High Throughput and Scale-Out Capability</h4><ul><li>Deploy multiple SHIR nodes on separate VMs or servers for parallel data transfers</li><li>Distribute copy, lookup, and data flow workloads across nodes to avoid bottlenecks</li><li>Scale horizontally with auto-upgrade and load-balancing built in</li></ul><h4>Execution of SSIS Packages and Custom Activities</h4><ul><li>Hosts the SSIS integration runtime so you can lift and shift existing SSIS packages</li><li>Runs custom .NET, Python, or Spark activities close to your data for optimized performance</li><li>Provides the compute environment for mapping data flows when data must stay on-prem</li></ul><h4>Network Performance and Latency Control</h4><ul><li>Places the SHIR within your LAN or data center for minimal hop counts</li><li>Reduces data egress costs by staging data in perimeter networks before pushing to Azure</li><li>Allows tuning of node resources (CPU, memory, disk) to meet throughput SLAs</li></ul><h3>Design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFl_QfSLDffRk79zb-AYKg.png" /><figcaption>High Level Architecture</figcaption></figure><h4>Data Lake Storage Layers</h4><p>Within Azure Data Lake Storage Gen2, organize containers by lifecycle zones:<br>- <em>Raw</em>: Landing area for unmodified data from all sources.<br>- <em>Enriched</em>: Cleansed, filtered, and semi-transformed data.<br>- <em>Curated</em>: Consumer-ready, business-trusted datasets.<br>Refer to the Data Lake zones and containers guidance for best practices on folder structures and file formats.</p><h4>Data Ingestion Strategies</h4><p><strong>Relational Data</strong><br>- Use Azure Synapse pipelines with self-hosted Integration Runtime to connect to on-premises SQL Server, Oracle, or cloud databases.<br>- Copy data into the Raw layer as delimited text or Parquet files via the Copy Data activity.<br>- Trigger pipelines on schedule, events, or REST API calls.<br><strong>Semi-Structured Data</strong><br>- Ingest CSV/JSON/COBOL files from file shares or object stores using Synapse pipelines.<br>- Call REST APIs to capture application events.<br>- Preserve original format in the Raw layer for schema-on-read flexibility, and transform into standard format ( CSV or Parquet) in Currated layer. There are multiple real world scenarios on source files, such as delimited files without header row, or with custom header row and/or footer row, or with delimiters other than comma ( such as pipe or dollar sign), or COBOL files with custom copybook syntax. Multiple patterns are developed to support the variouty of the source files and the transformation logic is controlled by configuration file in JSON format.</p><p><strong>Unstructured Data</strong><br>- Use Synapse pipelines to ingest multimedia (images, video, audio) and free-form text documents.<br>- Store files in the Raw layer, maintaining original binary formats for downstream AI and knowledge mining processes.<br><strong>Streaming Data</strong><br>- Route event streams from applications or IoT devices into Event Hubs or IoT Hub.<br>- Enable Event Hubs Capture (or IoT Hub storage endpoints) to dump raw event batches into the Raw layer (cold path).<br>- Connect consumers directly for hot-path processing (see next section).</p><p><strong>SAP Data</strong></p><p><em>Prerequisites</em></p><p>Ensure your SAP landscape and Azure subscription meet the following prerequisites:</p><ul><li>A running SAP system with RFC-enabled application server or OData services exposed.</li><li>SAP .NET Connector 3.0 installed on the SHIR host for RFC-based extraction.</li></ul><p><em>Network and Infrastructure Setup</em></p><p>Architect secure connectivity between your SAP servers and SHIR host:</p><ul><li>Place the SHIR VM in the same subnet or network segment as the SAP application servers.</li><li>Open outbound HTTPS ports (443) from SHIR to Azure Data Factory/Synapse endpoints.</li><li>If using SAP RFC, allow TCP 33xx (application server) inbound on SHIR.</li><li>For OData ingestion, ensure SHIR can reach SAP Gateway URLs over HTTPS.</li><li>Establish VPN or ExpressRoute with private peering to minimize latency and data egress costs.</li></ul><p><em>Self-Hosted Integration Runtime Configuration</em></p><p>Install and configure SHIR to run copy activities close to SAP:</p><ul><li>Download the SHIR installation executable from <a href="https://www.microsoft.com/en-us/download/details.aspx?id=39717">Microsoft </a>.</li><li>During setup, register the node with your Synapse service using the generated key.</li><li>Enable auto-update and configure multiple SHIR nodes for high availability and scale-out.</li><li>Verify connectivity by running the “Test connection” wizard against Azure endpoints.</li><li>Use Azure Key Vault to store SHIR credentials and rotate them periodically.</li></ul><p><em>SAP Connector Configuration</em></p><p>Set up the SAP-specific connector in your pipelines:</p><ul><li>For RFC-based loads, use the “SAP Table” or “SAP BW” connector in Synapse.</li><li>Install SAP .NET Connector libraries on the SHIR machine and add environment variables pointing to the SAP client installation path.</li><li>Configure SAP connection details: Application server host, System number, Client, User, Password (stored in Key Vault).</li><li>For OData services, use the “HTTP” or “OData” connector and supply the service endpoint and OAuth credentials.</li><li>Test connector connectivity and retrieve sample metadata before building pipelines.</li></ul><p><em>Synapse Pipeline Design</em></p><p>Design modular pipelines for SAP data extraction:</p><p><strong>Master Pipeline</strong></p><ul><li>Orchestrates child pipelines for each SAP module.</li><li>Passes parameters such as table name, extraction date field, and pagination settings.</li></ul><p><strong>Child Pipelines</strong></p><ul><li>Use Copy Activity with the SAP connector as source, ADLS Gen2 as sink (Raw container).</li><li>Map source columns to parquet or CSV schema; enable column projection for performance.</li><li>Implement pagination using the SAP “Rows per page” setting or OData $skip/$top query options.</li><li>Write to a dated folder path (e.g., /raw/sap/FI/2025–09–20/).</li></ul><p><strong>Control Flow</strong></p><ul><li>Use If Condition activities to branch full vs. incremental loads.</li><li>Invoke stored procedures in SAP to mark extraction points or delta flags.</li></ul><p><strong>Incremental Load Strategy</strong></p><p>Minimize data volume and improve performance by capturing only changes:</p><ul><li>Identify a suitable watermark column (e.g., LAST_CHANGED_DATE) in each SAP table.</li><li>Store the last extraction watermark in a metadata table in Azure SQL or Key Vault.</li><li>In your Copy Activity source query, filter records where LAST_CHANGED_DATE &gt; @watermark.</li><li>After a successful run, update the watermark store with the pipeline’s max date.</li><li>For SAP CDC scenarios, consider using SAP’s Change Data Capture APIs or SAP Landscape Transformation (SLT) replication into SQL Server on-prem as a staging source.</li></ul><p><strong>Monitoring, Error Handling, and Logging</strong></p><p>Build observability into your SAP ingestion workflows:</p><ul><li>Enable detailed logging on Copy Activities and Data Flows; capture row counts, throughput, and error rows.</li><li>Use Azure Monitor alerts on pipeline run failures or activity throttling.</li><li>Send failure notifications to Microsoft Teams or email via Logic Apps.</li><li>Implement retry policies with exponential backoff on transient errors (network or SAP side).</li><li>Archive pipeline logs in a separate ADLS Gen2 container for auditing and troubleshooting.</li></ul><p><strong>Security and Compliance Considerations</strong></p><p>Ensure data protection and regulatory compliance throughout ingestion:</p><ul><li>Encrypt data in transit (HTTPS/TCP TLS) and at rest (ADLS Gen2 encryption with customer-managed keys).</li><li>Use Entra ID–based managed identities for ADF/Synapse to access Key Vault secrets — avoid embedding credentials.</li><li>Apply role-based access control (RBAC) on ADLS containers so only authorized pipelines and users can read/write.</li><li>Scan SAP data extracts with Microsoft Purview for sensitive data classification.</li><li>Implement network security groups (NSGs) to restrict inbound and outbound traffic on the SHIR VM.</li></ul><p><strong>Serving and Consumption</strong></p><ul><li>Data Warehouse: Load curated datasets into Azure Synapse SQL dedicated pools for high-performance SQL analytics and reporting.</li><li>Data Lake Queries: Expose curated files via SQL Serverless external tables for ad hoc analytics.</li><li>Power BI: Build semantic models and dashboards against SQL pools, Data Explorer pools, or Serverless queries.</li><li>Azure Data Share: Securely distribute curated datasets across business units and trusted external partners.</li><li>Knowledge Mining: Apply Azure Cognitive Search and AI over unstructured assets (PDFs, Office docs, images, audio) stored in Synapse workspaces to extract entity, sentiment, and key-phrase insights.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=996967d095c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Experience to Imagination: a Data Analytics Platform in AWS]]></title>
            <link>https://medium.com/@jasonli.lijie/from-experience-to-imagination-a-data-analytics-platform-in-aws-a87d4a309231?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a87d4a309231</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics-platforms]]></category>
            <category><![CDATA[data-platforms]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 12:02:35 GMT</pubDate>
            <atom:updated>2025-06-13T01:00:18.407Z</atom:updated>
            <content:encoded><![CDATA[<p>This post introduces an imagined project, shaped by insights gained across multiple real-world experiences. It distills lessons learned into a broad, adaptable framework, free from any project-specific details. The goal is to create a concept that remains universally relevant, allowing readers to connect the ideas to their own contexts.</p><h3><strong>Business Challenges to Address:</strong></h3><p>1. <strong>Data Integration and Normalization:</strong> Organizations often manage data from diverse sources, including structured and unstructured formats such as flat files, REST APIs, and various database systems. There are different mechanisms(push v.s. pull) to integrate with source systems. The inconsistency in data structure poses challenges for analytics and reporting. Establishing a standardized data model is crucial to ensure seamless integration and facilitate accurate business intelligence.</p><p>2. <strong>Multi-Destination Data Management:</strong> Business operations frequently require data to be delivered to multiple destinations, including data warehouses, visualization tools, and third-party applications. Without a well-structured distribution mechanism, ensuring consistency, security, and accuracy becomes increasingly complex.</p><p>3. <strong>Manual Processes and Data Quality Issues:</strong> Many organizations rely on manual data entry and transformation methods, increasing the risk of human errors. The absence of automated quality checks leads to inconsistencies, redundancies, and inaccuracies, impacting decision-making and operational efficiency.</p><p>4. <strong>Extended Turnaround Time for Data Insights:</strong> The process of collecting, cleaning, and analyzing data is often time-consuming, delaying the ability to extract actionable insights. Streamlining data workflows and implementing efficient automation can significantly reduce processing time, enabling businesses to make timely, informed decisions.</p><h3><strong>Choice of Solutions — Why Athena:</strong></h3><p>There are multiple options in AWS for an underline data platform, namely <strong>Athena</strong>, <strong>Redshift</strong> and <strong>RDS</strong>. In this particular project, choosing <strong>Athena</strong> over <strong>Redshift</strong> and <strong>RDS</strong> comes down to flexibility, cost efficiency, and the nature of the data workloads.</p><p>Here’s a detailed breakdown of why Athena is the better choice:</p><h4>1. Serverless &amp; Cost Efficiency</h4><ul><li><strong>Athena</strong> is a <strong>serverless</strong> query service, meaning we don’t need to provision or manage any infrastructure. We only pay for the queries we run, and the data storage.</li><li><strong>Redshift</strong> requires upfront provisioning, meaning we have to allocate storage and compute resources ahead of time. Costs are based on <strong><em>reserved</em></strong> capacity rather than usage.</li><li><strong>RDS</strong> is a managed relational database service that requires us to provision instance sizes, storage, and compute power, leading to fixed costs.</li></ul><h4>2. Ease of Use for Ad-Hoc Analysis</h4><ul><li><strong>Athena</strong> is ideal for querying data stored in <strong>Amazon S3</strong> using SQL, without needing to load data into a separate database system. Great for ad-hoc queries on raw files like logs, JSON, Parquet, or CSV.</li><li><strong>Redshift</strong> is better suited for structured data warehousing, where performance optimization through indexing and schema design is needed.</li><li><strong>RDS</strong> works well for transactional databases but isn’t optimized for large-scale analytical queries.</li></ul><h4>3. Big Data &amp; Scalability</h4><ul><li><strong>Athena</strong> works well with <strong>data lakes</strong> in Amazon S3, handling petabytes of data seamlessly without requiring manual scaling.</li><li><strong>Redshift</strong> is a highly optimized data warehouse designed for complex analytics but requires maintenance (like vacuuming, distribution keys, and optimizing queries).</li><li><strong>RDS</strong> is a relational database suited for OLTP workloads but lacks built-in analytical capabilities for big data.</li></ul><h4>4. Schema-On-Read vs. Schema-On-Write</h4><ul><li><strong>Athena</strong> uses a <strong>schema-on-read</strong> approach, meaning we can query data without needing to structure it upfront.</li><li><strong>Redshift</strong> and <strong>RDS</strong> follow <strong>schema-on-write</strong>, meaning data needs to be structured before it can be effectively queried.</li></ul><h4>5. Integration &amp; Data Lake Compatibility</h4><ul><li><strong>Athena</strong> is deeply integrated with Amazon S3, AWS Glue, and various AWS services, making it perfect for querying data lakes.</li><li><strong>Redshift</strong> can integrate with S3 using Redshift Spectrum, but it requires additional configuration and costs.</li><li><strong>RDS</strong> is not optimized for data lake queries and is more suited for traditional transactional applications.</li></ul><h4>When Athena is the Best Choice for our case case</h4><ul><li>We need <strong>flexibility</strong>, and don’t want to manage infrastructure.</li><li>we’re working with <strong>semi-structured or raw data</strong> in Amazon S3.</li><li>Our queries are <strong>ad-hoc</strong>, rather than frequent and optimized for a specific workload.</li><li>We prefer <strong>pay-as-you-go</strong> pricing instead of reserved instance costs.</li></ul><p>Athena shines when dealing with exploratory, sporadic queries over large datasets, whereas Redshift is better for structured, high-performance analytics, and RDS is best for transactional databases.</p><h3>Design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzYBgQR6MDezHsdXE8a5zA.png" /><figcaption>End-to-End Solution</figcaption></figure><p>1) <strong>Secure Data Ingestion via AWS Transfer Family with S3:</strong> Implement AWS Transfer Family to enable <strong>secure</strong> file transfers using SFTP (Secure File Transfer Protocol). This solution supports fully managed SFTP servers for handling user authentication (via either ssh keys or password) and file transmission. Data providers will regularly <strong>push </strong>compressed CSV files (.csv.gz) to the SFTP server, which are then stored in an Amazon S3 bucket. The CSV files contain specific columns with complex JSON payloads, which will require further processing for analytic workload.</p><p>2) <strong>Automated Event Notifications with S3 and Amazon SQS:</strong> Configure <strong>Amazon S3 Event Notifications</strong> to trigger actions when new objects matching specified prefixes and suffixes are created within the designated S3 bucket. These event notifications are designed to be <strong>eventually consistent</strong>, ensuring delivery at least once. Notifications will be forwarded to <strong>Amazon Simple Queue Service (SQS)</strong>, allowing downstream processes to reliably consume and act upon the file events.</p><p>3) <strong>Event Processing via Python script and SQS Queue Retrieval:</strong> Develop a <strong>Python-based solution</strong> to periodically retrieve event messages from the SQS queue. Since real-time processing is not required, this retrieval mechanism will operate on a scheduled basis, optimizing performance and resource utilization &amp; cost.</p><p>4) <strong>Data Normalization and Schema Standardization:</strong> Based on the event payload details ( incoming file path in S3 bucket), the Python script will process incoming files by <strong>flattening nested JSON structures</strong> within the CSV files. This transformation will convert complex hierarchical data into a <strong>consistent two-dimensional (2D) schema</strong>, improving accessibility and usability for analytics. The processed data will be stored in <strong>Parquet format</strong>, partitioned by date, and saved in a designated <strong>landing S3 bucket</strong> for efficient querying.</p><blockquote>Choosing <strong>Parquet</strong> over <strong>CSV</strong> comes down to efficiency, performance, and cost considerations when handling large datasets. Here’s why <strong>Parquet</strong> is our preferred choice:</blockquote><blockquote>1. Columnar Storage vs. Row-Based Storage</blockquote><blockquote><strong>Parquet</strong> is a <strong>columnar</strong> format, meaning it stores data <strong>by column</strong> rather than by row. This is ideal for analytical queries where only specific columns need to be read.</blockquote><blockquote><strong>CSV</strong> is <strong>row-based</strong>, meaning every query scans the entire dataset, making it much slower for analytical workloads.</blockquote><blockquote>2. Compression &amp; Storage Efficiency</blockquote><blockquote><strong>Parquet</strong> uses <strong>efficient compression</strong> techniques tailored for columnar data, significantly reducing storage space and improving query speeds.</blockquote><blockquote><strong>CSV</strong> does not support efficient compression or encoding, leading to larger file sizes and higher storage costs.</blockquote><blockquote>3. Faster Query Performance</blockquote><blockquote><strong>Parquet</strong> allows <strong>predicate pushdown</strong>, meaning queries can skip unnecessary rows based on filters, reducing scan time.</blockquote><blockquote><strong>CSV</strong> requires scanning the entire dataset to find relevant rows, which is much slower.</blockquote><blockquote>4. Schema Enforcement &amp; Data Types</blockquote><blockquote><strong>Parquet</strong> enforces <strong>strong data types</strong> and schemas, reducing errors during processing.</blockquote><blockquote><strong>CSV</strong> stores everything as text, which can lead to data inconsistencies, requiring extra processing to convert data types.</blockquote><blockquote>5. Compatibility with Big Data &amp; Analytics</blockquote><blockquote><strong>Parquet</strong> is optimized for <strong>big data processing</strong>, working seamlessly with tools like Apache Spark, Presto, Hive, and Amazon Athena.</blockquote><blockquote><strong>CSV</strong> is simple but lacks optimizations for large-scale analytical workloads.</blockquote><p>5) <strong>Schema Definition and External Table Creation in Athena:</strong> Create an <strong>external table</strong> in <strong>Amazon Athena</strong>, referencing the structured Parquet files in the landing S3 bucket. This setup ensures efficient querying without modifying the underlying data. This table creation is a <strong>one-time process</strong>, defining a standardized schema for structured query execution. It is recommended to <a href="https://docs.aws.amazon.com/athena/latest/ug/partition-projection-setting-up.html#partition-projection-setting-up-procedure">configure and enable partition projection using the AWS Glue console</a> to avoid manual load partition every time.</p><p>6) <strong>Database and Querying Framework in Athena:</strong> Amazon Athena utilizes <strong>Apache Hive</strong> for schema definition and database creation, providing a logical namespace for structured data. Various <strong>SerDe (Serializer-Deserializer) libraries</strong>will be leveraged to interpret Parquet-formatted files. Athena employs the <strong>AWS Glue Data Catalog</strong> to store schema metadata, enabling SQL-based queries against the S3-resident data without requiring a dedicated database storage layer.</p><p>7) <strong>Automated Query Execution and Results Storage:</strong> Business-specific SQL queries will be designed and embedded within <strong>Python automation scripts</strong> to streamline analytics processing. Query results, formatted as <strong>CSV files</strong>, will be systematically stored in Amazon S3 for further consumption.</p><p>8) <strong>Data Extraction from REST APIs and Conversion to CSV:</strong> A separate Python module will be developed to <strong>scrape(pull) data from REST APIs</strong>, transforming JSON responses into CSV format before storing them in S3. This ensures uniformity in data structure across ingestion methods. To support currency exchange requirements, dedicated Python scripts have been built to pull currency exchange rate from APIs so that data can be enriched with local currency.</p><p>9) <strong>Data Transformation, Aggregation, and Relational Storage:</strong> To support advanced analytics, a <strong>Python-based ETL (Extract, Transform, Load) process</strong> will be used to aggregate, enrich, and structure the data before loading it into a <strong>PostgreSQL relational database</strong>. This approach facilitates efficient relational querying and reporting.</p><p>10) <strong>Integration with AWS Visualization Tools:</strong> PostgreSQL database tables will be exposed to <strong>AWS-native visualization tools</strong>, enabling <strong>interactive data exploration and reporting</strong> for business users.</p><p>11) <strong>Data Distribution to Google Cloud-Based Solutions:</strong> Processed CSV results can be <strong>pushed to Google platforms</strong>, such as <strong>Google Sheets or Google Cloud Storage</strong>, making them accessible for analytics and visualization in <strong>Google Looker Studio</strong> or other BI solutions.</p><p>12) <strong>Custom Data Enrichment and External System Integration:</strong> To accommodate extended business requirements, enriched datasets can be forwarded to <strong>custom SFTP servers</strong>, allowing integration with third-party <strong>BI tools</strong> and visualization solutions. Different BI solutions require different data formats or even additional meta data file. The diagram includes an implementation of both .tsv.gz data file and .json metadata file for the target BI solution.</p><p>13) <strong>Monitoring and Reporting:</strong> To enhance operational efficiency, a <strong>comprehensive data quality validation process</strong> is integrated within the data pipelines, enabling early detection of inconsistencies and anomalies. Additionally, <strong>job execution status — whether successful or failed — is systematically recorded and reported</strong> to ensure visibility into pipeline performance. The generated report, including detailed job logs, is automatically dispatched to the operations team via <strong>Amazon Simple Email Service (SES)</strong> and <strong>Slack</strong> for timely review and intervention.</p><h3>Summary</h3><p>Ironically the end to end solution is inspired by <a href="https://learn.microsoft.com/en-us/azure/architecture/example-scenario/dataplate2e/data-platform-end-to-end">https://learn.microsoft.com/en-us/azure/architecture/example-scenario/dataplate2e/data-platform-end-to-end</a>. The Azure architecture provides better integration with capabilities anticipated by enterprise, such as data governance (Purview) and IAM service (Entra ID, aka Azure Active Directory).</p><p><em>So another todo for 2025 : From Experience to Imagination: a Data Analytics Platform in Azure.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a87d4a309231" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Technical Solution to Addressing CBA’s Non-Compliance with Australia’s Spam Regulations, from an…]]></title>
            <link>https://medium.com/@jasonli.lijie/a-technical-solution-to-addressing-cbas-non-compliance-with-australia-s-spam-regulations-from-an-2f2f3c5d13b2?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f2f3c5d13b2</guid>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 06:41:02 GMT</pubDate>
            <atom:updated>2025-12-26T02:38:28.867Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Technical Solution to Addressing CBA’s Non-Compliance with Australia’s Spam Regulations, from an AI Engineer’s Perspective</h3><p>I recently read an article on the Australian Communications and Media Authority (ACMA) website (<a href="https://www.acma.gov.au/articles/2024-10/commonwealth-bank-pays-75m-more-spam-breaches">https://www.acma.gov.au/articles/2024-10/commonwealth-bank-pays-75m-more-spam-breaches</a>), reporting that the Commonwealth Bank of Australia (CBA) has incurred a $7.5 million penalty for non-compliance with Australia’s spam regulations. Between November 2022 and April 2024, CBA sent over 170 million marketing emails without a proper unsubscribe option, violating Australian spam laws. Of these, 34.8 million messages were sent to individuals who had either not given consent or had withdrawn their consent to receive such communications.</p><p>This incident marks CBA’s second significant infringement of spam regulations, following a $3.55 million penalty in May 2023 for distributing 65 million emails lacking functional unsubscribe mechanisms.</p><p>Although I am not privy to the specific process CBA employs for its marketing email communications, I can propose a draft process based on general industry practices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*2grGElrJoFnAiW8OEfhGng.png" /><figcaption>general industry practices</figcaption></figure><p>Initially, a communication template and its styling are prepared based on business requirements. This template, which includes placeholders for customer details, is then reviewed by marketing experts to ensure the content’s accuracy and that it adheres to branding guidelines.</p><p>Next, a strategy to identify the target audience is developed. This strategy is typically based on identifying customers who own the specific product and who have opted in to receive communications related to that product. The strategy undergoes scrutiny and approval by marketing specialists to confirm the accuracy of the target audience, and by technical specialists to ensure that the Customer Relationship Management (CRM) system holds accurate information.</p><p>Once both the template and selection criteria receive approval, the Database Administrator (DBA) extracts the recipient list. This list, along with the template, is provided to the email sending service, which generates the actual email messages based on the template and customer details and sends them to the target recipients.</p><p>According to the article from the Australian Communications and Media Authority (ACMA) (<a href="https://www.acma.gov.au/articles/2024-10/commonwealth-bank-pays-75m-more-spam-breaches">https://www.acma.gov.au/articles/2024-10/commonwealth-bank-pays-75m-more-spam-breaches</a>), the Commonwealth Bank of Australia (CBA) may have encountered issues in the following areas:</p><ol><li>The content review process may not adequately verify that templates include an option to unsubscribe (opt-out) from the communication.</li><li>The methodology for identifying recipients may be flawed, or the flags in the CRM database may be incorrect. For instance, changes may not be reflected in the CRM database when a customer opts out.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*8USfM56uDujCJ3UqJ951-g.png" /><figcaption>What went wrong?</figcaption></figure><p>To address the <strong>second</strong> issue, it is essential to review the Customer Relationship Management (CRM) data to ensure it accurately captures customer information, including product ownership and communication preferences. This initiative will be undertaken as a data quality project.</p><p>To address the <strong>first</strong> issue, we can leverage artificial intelligence (AI) to evaluate the email templates by answering the following questions:</p><ol><li>What is the email about?</li><li>Does the email include the sender’s details?</li><li>Does the email include a method to unsubscribe?</li><li>Are the hyperlinks in the email valid?</li></ol><p>The benefits of AI-based solutions include:</p><p>. The capability to scale and manage increased workloads efficiently.</p><p>. The potential for full automation, streamlining processes and reducing manual intervention.</p><p>. The design to minimize human bias, ensuring fair and objective outcomes.</p><p>The first step involves creating test data. I used the following prompt to generate test data with Copilot:</p><blockquote>You are a marketing specialist in Australia and you are tasked to create marketing emails for the new financial products to be launched by your company next month. Please create 10 email templates. they should follow the marketing guidelines from regulators and include method to opt out the marketing communication. Please provide the result in tabular format.</blockquote><p>The prompt gives the following response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*k4lq2z009ioHU186f6sybw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*s1wrxUi_XVKmEY5Mm-zR6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*qZAn9XgXcwW_sygOnGPamA.png" /></figure><p>The content has been copied and pasted into .txt files, with customizations made for various scenarios.</p><p>For the proof of concept (POC), I created an OpenAI service in Azure, named jason-openai-service, and deployed the GPT-4o-mini model (for cost reason). I can also use a private VNET for Azure OpenAI to ensure that all LLM traffic stays inside a secure, isolated, enterprise‑controlled network. This reduces risk, supports regulatory compliance, strengthens data governance, and aligns the AI solution with zero‑trust security principles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*YXlV8KiyfY5bd-W-IPXr7A.png" /></figure><p>The following function is built to interact with the LLM to get the information we need:</p><pre>def analysis_with_llm(email_content):<br>    response = client.chat.completions.create(<br>                model=deployment_name,<br>                messages=[<br>                        {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are an email marketing specialist in Australia.&quot;},<br>                        {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;&quot;&quot;Please analysis the following marketing email content to see 1)if the email is related to a product or a service 2) if it violates Australia Spam Act 2003 or Spam Regulations 3) if the email includes the sender&#39;s identity. 4) if the email includes the link to unsubscribe or manage preference. Please make the response in a table and each response for the first question should be either product or service, and the response for last 3 questions should be either yes or no.<br>                        ------------------------<br>                        &quot;&quot;&quot; + email_content}<br>                    ]<br>                )<br>    resp1,resp2,resp3,resp4 = process_llm_response(response.choices[0].message.content)</pre><p>The following function processes the llm response and creates a structured dictionary which can be feed into the result CSV:</p><pre>def process_llm_response(llm_response):<br>    resp1,resp2,resp3,resp4 = &#39;&#39;,False,False,False<br>    lines = llm_response.split(&#39;\n&#39;)<br>    start_line_index = -1<br>    for index, line in enumerate(lines):<br>        if (&#39;|---&#39; in line) and (&#39;---|&#39; in line) and (&#39;----|---&#39; in line):<br>            start_line_index = index<br>            break<br>    if start_line_index != -1:<br>        resp1 = lines[start_line_index+1].split(&#39;|&#39;)[-2].strip()<br>        resp3 = lines[start_line_index+3].split(&#39;|&#39;)[-2].strip()<br>        resp4 = lines[start_line_index+4].split(&#39;|&#39;)[-2].strip()<br>        if (&#39;yes&#39; in resp3.lower()) and (&#39;yes&#39; in resp4.lower()):<br>            resp2 = &#39;NO&#39;<br>        else:<br>            resp2 = &#39;YES&#39;<br> <br>    return resp1,resp2,resp3.upper(),resp4.upper()</pre><p>To address the fourth question (Are the hyperlinks in the email valid?), we do not require the use of AI. The following function can extract all URLs from the email text:</p><pre>def find_urls(string):<br>    # findall() has been used<br>    # with valid conditions for urls in string<br>    regex = r&quot;(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:&#39;\&quot;.,&lt;&gt;?&lt;&lt;&gt;&gt;]))&quot;<br> <br>    url = re.findall(regex, string)<br>    return [x[0] for x in url]</pre><p>The following function not only validates the URL but also retrieves the page title:</p><pre>def process_https://medium.com/url(url):<br>    url_is_valid = False<br>    url_is_reachable = False<br>    page_title = &#39;N/A&#39;<br>    if not (url.startswith(&#39;https://&#39;) or url.startswith(&#39;http://&#39;)):<br>        new_url = &#39;https://&#39; + url<br>    else:<br>        new_url = url<br>    validation = validators.url(https://medium.com/new_url)<br>    if validation:<br>        print(f&#39;[URL Validation Result] URL {new_url} is valid&#39;)<br>        logger.info(f&#39;[URL Validation Result] URL {new_url} is valid&#39;)<br>        if True:<br>        # try:<br>            response = requests.request(&quot;GET&quot;, new_url, headers={}, data={})<br>            print(f&#39;checking if {new_url} is reacheable response {response}&#39;)<br>            if response.status_code &gt;= 200 and response.status_code &lt; 400:<br>                print(f&#39;To parse response from {url} with beautifulsoap!!!&#39;)<br>                soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<br>                if soup.title is None:<br>                        page_title = &#39;&#39;<br>                else:<br>                        page_title = soup.title.string<br>                # title = soup.title.string<br>                print(f&#39;[URL Validation Result] {url} is reacheable. Page title: {page_title}&#39;)<br>                logger.info(f&#39;[URL Validation Result] {url} is reacheable. Page title: {page_title}&#39;)<br>                url_is_valid = True<br>                url_is_reachable = True<br>                # detail_report_all.append({&#39;filename&#39;: email, &#39;url&#39;: url, &#39;valid&#39;: True, &#39;reachable&#39;: True, &#39;page_title&#39;: title})<br>            else:<br>                print(f&#39;[URL Validation Result] URL {url} is not reacheable. Response: {response.text}&#39;)<br>                logger.info(f&#39;[URL Validation Result] URL {url} is not reacheable. Response: {response.text}&#39;)<br>                url_is_valid = True<br>                url_is_reachable = False<br>                # detail_report_all.append({&#39;filename&#39;: email, &#39;url&#39;: url, &#39;valid&#39;: True, &#39;reachable&#39;: False, &#39;page_title&#39;: &#39;N/A&#39;})<br>        # except:<br>        else:<br>            print(f&#39;An exception has occured for url {url}&#39;)<br>            detail_report_all.append({&#39;filename&#39;: email, &#39;url&#39;: url, &#39;valid&#39;: True, &#39;reachable&#39;: False, &#39;page_title&#39;:&#39;N/A&#39;})<br> <br>    else:<br>        print(f&#39;[URL Validation Result] !!! URL {url} is invalid&#39;)<br>        logger.info(f&#39;[URL Validation Result] !!! URL {url} is invalid&#39;)<br>        url_is_valid = False<br>        url_is_reachable = False<br> <br>        # detail_report_all.append({&#39;filename&#39;: email, &#39;url&#39;: url, &#39;valid&#39;: False, &#39;reachable&#39;: False, &#39;page_title&#39;: &#39;N/A&#39;})<br>    return url_is_valid, url_is_reachable, page_title</pre><p>The complete code can be found at <a href="https://github.com/jasonli-lijie/marketing-email-compliance-poc-pub">here</a></p><p>The following environment config file has cloud OpenAI service environment specific values:</p><pre>openai_apikey=**********<br>openai_endpoint=https://jason-openai-service.openai.azure.com/<br>openai_apiversion=2024-08-01-preview<br>deployment_name=gpt-4o-mini</pre><p>Below are the sample output CSV files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XWyvaQYUYcKpp8Nuf_Sc-Q.png" /><figcaption>file-level summary report</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*wYFzm_EjQpPGYnKsHtsNDg.png" /><figcaption>detail report on individual url</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f2f3c5d13b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An issue When Upgrading to Apache Spark 3.4 in Azure Synapse (pycobol2csv)]]></title>
            <link>https://medium.com/@jasonli.lijie/an-issue-caused-by-azure-synapse-runtime-for-apache-spark-3-4-upgrade-30c684379817?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/30c684379817</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cobol]]></category>
            <category><![CDATA[csv]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Fri, 28 Jun 2024 12:40:26 GMT</pubDate>
            <atom:updated>2024-10-09T06:33:43.700Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The Background</strong></p><p>We built a data platform based on Synapse pipelines for a client, based on Azure Synapse Runtime for Apache Spark 3.2, with custom Python code running in Synapse notebooks. One notebook is responsible for converting Cobol files into CSV format with <a href="https://pypi.org/project/pycobol2csv/">pycobol2csv · PyPI</a>. The functionality has been working well for more than 1 years.</p><p><strong>The Issue</strong></p><p>Microsoft announced End of Support for Azure Apache Spark 3.2 in July 2023 and users are urged to upgrade to Apache Spark 3.3 or Apache Spark 3.4 (<a href="https://azure.microsoft.com/en-au/updates/azure-synapse-runtime-for-apache-spark-32-end-of-support/">https://azure.microsoft.com/en-au/updates/azure-synapse-runtime-for-apache-spark-32-end-of-support/</a>). One key lesson leart here is that the upgrade should have been planned and executed earlier but we started the upgrade only one month prior to the deadline.</p><p>After upgrading to Apache Spark 3.4, we started getting a new error exceptions for certain Cobol file conversion, and the error message is:</p><blockquote>_csv.Error: need to escape, but no escapechar set</blockquote><p><strong>The Troubleshooting Process &amp; Solution</strong></p><p>The same library worked well with the same files prior to Apache Spark 3.4 upgrade. And it has been working well on my laptop in the standalone test script. So library implementation issue can be ruled out and it might be an environment issue.</p><p>When looking into the component versions of each Apache Spark runtime, Python versions look suspicious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ue6C9E-8bEohYb9ZmX7XWA.png" /><figcaption>Component Version</figcaption></figure><p>Then I realized the Python on my laptop is <strong>Python 3.11</strong>. To verify my hypothesis I created a virtual environment with Python 3.10 and reproduced the issue on my laptop eventually:</p><blockquote>_csv.Error: need to escape, but no escapechar set</blockquote><p>I searched for the error message with “Python 3.10” keyword and found out lots of users in Python community have encountered the issue:</p><p><a href="https://github.com/python/cpython/issues/97503">CSV Writer can not write strings with nulls when no escapechar is specified · Issue #97503 · python/cpython</a></p><p>The following comment tells the full story:</p><blockquote>3.6.15<br>‘“\x00”,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><blockquote>3.7.0<br>‘“\x00”,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><blockquote>3.7.12<br>‘“\x00”,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><blockquote>3.8.12<br>‘“\x00”,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><blockquote>3.9.9<br>‘“\x00”,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><blockquote>3.10.1<br>Traceback (most recent call last):<br> File “/home/widders/csvtest.py”, line 7, in &lt;module&gt;<br> csv.writer(b).writerow([“\0”, “\”\0&quot;, “\n\0”, “\0\r\n”])<br>_csv.Error: need to escape, but no escapechar set</blockquote><blockquote>3.11.0<br>‘\x00,”””\x00&quot;,”\n\x00&quot;,”\x00\r\n”\r\n’</blockquote><p>So the csv module in Python has different behavior in <strong>Python 3.10</strong>!</p><p>As Apache Spark runtime is managed by Microsoft and we cannot change the Python version ourselves, I had to add the workaround from the library side, by specifying the escape character explicitly, instead of rely on the default value (which seems missing in Python 3.10) . The workaround is released in pycobol2csv version 1.0.6 (<a href="https://pypi.org/project/pycobol2csv/1.0.6/">pycobol2csv · PyPI</a>) and <strong>pycobol2csv library users are suggested to upgrade to the latest version if they have CSV workload in Synapse</strong>.</p><p>But WHY did Microsoft make such a decision to choose Python 3.10 for an important release and force all users to go with Python 3.10 where CSV processing is a significant part of Synapse pipelines?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30c684379817" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Process large Cobol files efficiently with pycobol2csv / pycobol2parquet]]></title>
            <link>https://medium.com/@jasonli.lijie/process-large-cobol-files-efficiently-with-pycobol2csv-pycobol2parquet-f023533607e4?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f023533607e4</guid>
            <category><![CDATA[multiprocessing]]></category>
            <category><![CDATA[cobol]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[parquet]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 07:01:31 GMT</pubDate>
            <atom:updated>2024-02-28T11:35:36.723Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Background</strong></h3><p>To this day, COBOL is widely used in applications deployed on mainframe computers, such as large-scale batch and transaction processing jobs. Many large financial institutions and government agencies were developing new systems in the language as late as 2006, but most programming in COBOL today is purely to maintain existing applications. There are also use cases to process data from mainframe computers with modern data engineering frameworks and tools.</p><p>In 2021, I released <a href="https://pypi.org/project/pycobol2csv/">pycobol2csv</a> to enable the conversion from Cobol to CSV format with my favourite programming language — Python. CSV is the plain text row-based storage format widely used in data engineering domain and has much better support in the ecosystem. The library has been deployed to multiple production systems for various clients, and I have received very positive feedback from the community as well.</p><p>In 2024, I released a new package <a href="https://pypi.org/project/pycobol2parquet/">pycobol2parquet</a> based on the feature request I received. As a data engineer I under stand the the importance of supporting Parquet format directly as it is a highly optimized columnar storge for analytical workload. Even though it is possible ( and relatively easy) to convert from CSV to Parquet but <a href="https://pypi.org/project/pycobol2parquet/">pycobol2parquet</a> can bring value to data engineers who want to have less steps in their data pipelines.</p><blockquote>Note: if you are from the Scala world there is an easier solution (<a href="https://github.com/AbsaOSS/cobrix">https://github.com/AbsaOSS/cobrix</a>)</blockquote><h3><strong>Problem statement</strong></h3><p>When I built the Python packages, I had the principle in mind to request minimal resources so that the solution can be used in any runtime, either physical infrastructure with massive RAM or lightweight Lambda functions. Records in the Cobol file are processed sequentially. Horizontal scaling is possible with multiple instances if there are <strong>large amount of smaller Cobol files</strong> to process. Furthermore the libraries are built for traditional file systems but not for distributed file system like HDFS.</p><p>However there is also a scenario of large Cobol files to process, and the processing time is increased (almost) linearly. Here are some statistics I recieved in my test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSTHgMhFS8WXOCEz5oubFg.png" /></figure><p>It is not sustainable when large Cobol files are expected.</p><h3><strong>Solution</strong></h3><p>There is a map-reduce concept from Hadoop framework (<a href="https://www.talend.com/resources/what-is-mapreduce/">credit</a>) which is a good fit for the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*8cUlTD8SXQP7sMfLa-kkBA.png" /></figure><p>Based on the concept above I designed the flow like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*G9oAIwHQ5x3PIYaD1FC07A.png" /></figure><p><strong>Step 1:</strong> split one large cobol file to smaller cobol files</p><p><strong>Step 2:</strong> fork multiple processes to convert the smaller cobol files in parallel to smaller csv files</p><p><strong>Step 3: </strong>combine smaller csv files into one large csv</p><p>In step 1 there can be various criteria of splitting, it can be</p><p>· the number of records in one file, for example, 1 million records per file, or</p><p>· the file size, for example, 600MB per file</p><p>Based on the variarity of record length, the second option ( file size) is a better choice, althogh some additional calculation is required. Refer to the psudo code below for more details.</p><p><strong>Psudo code for step 1 (Azure Synapse Notebook):</strong></p><blockquote>Note: both <a href="https://pypi.org/project/pycobol2csv/">pycobol2csv</a> and <a href="https://pypi.org/project/pycobol2parquet/">pycobol2parquet</a> support traditional file system only, we will have to copy the files to local file system (/mnt/) if the files are in Azure ADLS Gen2.</blockquote><pre>MAX_CHUNK_SIZE_ROUGH = 600*1024*1024 # 600MB size limit<br>## parse copybook to get record row length<br>row_length, cobol_struc = decode_copybook_file(processed_copbybook_filename)<br>rec_number = os.path.getsize(data_filename) / row_length<br>if os.path.getsize(data_filename) &gt; MAX_CHUNK_SIZE_ROUGH:<br>    max_num_of_record_in_one_chunk = int(MAX_CHUNK_SIZE_ROUGH/row_length)<br>    file_part_list = []<br>    with open(data_filename, &#39;rb&#39;) as in_file:<br>        index = 0<br>        while True:<br>            block = in_file.read(max_num_of_record_in_one_chunk*row_length)<br>            if not block:<br>                break<br>            index = index + 1<br>            output_file = data_filename + &#39;_part&#39; + str(index).zfill(3)<br>            file_part_list.append(output_file)<br>            with open(output_file, &#39;wb&#39;) as out_file:<br>                out_file.write(block)<br>    logger.info(f&quot;Large Cobol file: # of records: {rec_number}. Splitted to {index} chunks.&quot;)</pre><p><strong>Psudo code for step 2(Azure Synapse Notebook):</strong></p><pre>process_array = []<br>for cobol_part_file in file_part_list:<br>    p = Process(target=convert_file, args=(cobol_part_file,processed_copbybook_filename, format_file_path, dp_param_cobol_encoding, ))<br>    p.start()<br>    process_array.append(p)<br>for p in process_array:<br>    p.join()</pre><p><strong>Psudo code for step 3(Azure Synapse Notebook):</strong></p><pre>## combine all CSV files together<br>target_filename = &#39;combined.csv&#39;<br>file_part_list = [data_file + &#39;_output.csv&#39; for data_file in file_part_list]<br>mssparkutils.fs.cp(&#39;file:&#39;+file_part_list[0], &#39;file:&#39;+target_filename)<br>for csv_file in file_part_list[1:]:<br>    !tail -n +2 {csv_file} &gt;&gt; {target_filename}<br>## Clean up the temporary files - TODO</pre><h3>Result</h3><p>The above solution delivers a much better performance for Cobol to CSV conversion, especially for larger Cobol files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsWJYauDCv0Qr7qsj_sBRg.png" /></figure><h3>Next step</h3><p>Step 1 needs to be refined further when the amount of chunks is much larger than the available CPU cores. Further batching is required so that the operating system will not be overwhelmed by large amounts of processes.</p><p>credit: Sophia Li for spelling / grammar check</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f023533607e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Thoughts on Cloud Providers]]></title>
            <link>https://medium.com/@jasonli.lijie/my-thoughts-on-cloud-providers-57a6edc56022?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/57a6edc56022</guid>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 11:34:55 GMT</pubDate>
            <atom:updated>2023-03-16T11:34:55.965Z</atom:updated>
            <content:encoded><![CDATA[<p>Cloud computing has become an essential part of modern businesses, providing flexibility, scalability, and cost-effectiveness. As a professional in this field, I have had the opportunity to work with the three major cloud providers — Azure, AWS, and GCP — and have been asked many times about my favorite. In this blog post, I will share my preferences for each of these providers in this post.</p><p>As an enterprise worker, I prefer Azure due to its compatibility with Windows and Office, which are the standard operating environment (SOE) for most organizations. This makes it relatively easy to build and develop on Azure, as it seamlessly integrates with existing technology infrastructure. This is an important consideration for enterprise workers who need to maintain compatibility with their existing systems.</p><p>As an architect, I prefer AWS due to its clear and consistent architecture definition. AWS has the largest market share among cloud providers and provides reference blueprints for almost all use cases, making it easier for architects to design and implement cloud solutions that are efficient and effective.</p><p>As a developer, I might prefer GCP due to its innovation. Google has always been at the forefront of technological innovation, and this has translated into their cloud offering ( I might have change my calendar to 2020 before saying that) . GCP provides developers with a range of innovative tools and services, making it easier to develop and deploy applications in the cloud.</p><p>In conclusion, each of the major cloud providers has its own strengths and weaknesses, and the choice of provider depends on the specific needs of the user. Whether it is compatibility with existing infrastructure, clear and consistent architecture definition, or innovation in tools and services, professionals in the technology industry need to stay informed and adapt to the changing landscape.</p><p><strong>However, as an employee, I would not choose any of these cloud providers for now, due to the recent job cuts that have affected all of them</strong>.</p><p>Credit: ChatGPT</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57a6edc56022" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating Synthetic Data for Data Engineering & Machine Learning Pipelines]]></title>
            <link>https://medium.com/@jasonli.lijie/generate-sample-csv-files-for-data-pipelines-testing-30b5824da70a?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/30b5824da70a</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[csv]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Wed, 17 Aug 2022 10:15:05 GMT</pubDate>
            <atom:updated>2025-11-25T03:07:25.006Z</atom:updated>
            <content:encoded><![CDATA[<h3>Executive Summary ( Generated by AI )</h3><p>This post explores practical strategies for creating robust CSV test files to simulate real-world data scenarios in data engineering and machine learning pipelines. It begins by demystifying the structure and quirks of CSV files — highlighting encoding issues, delimiter variations, and Excel-induced formatting surprises that often complicate production workflows.<br>To address these challenges, the author introduces a Python-based CSV generator that uses a seed file and a JSON config to produce large-scale, customizable CSV files. The tool supports various encodings, quoting levels, and delimiter options, and can generate files hundreds of gigabytes in size with unique UUIDs per row — ideal for stress-testing data pipelines.<br>The post then transitions to AI-ready synthetic data generation using the SDV (Synthetic Data Vault) library. Synthetic data mimics the statistical properties of real datasets and is especially valuable for training ML models when real data is scarce or privacy-restricted. A sample SDV workflow is provided to help readers generate realistic tabular data from seed files.<br>Whether you’re testing ETL pipelines or training AI models, this guide equips you with scalable tools to simulate diverse data conditions — bridging the gap between idealized test cases and messy production realities.</p><p>A Comma Separated Values (CSV) file is a plain text file that contains a list of data. These files are often used for exchanging data between different applications and systems. These files may sometimes be called Character Separated Values or Comma Delimited files. They mostly use the comma character(“,”) to separate (or delimit) data, but sometimes use other characters, like semicolons(“;”) and pipes(“|”). They mostly use UTF-8 encoding but the system generates them have the freedom to choose a different encoding.</p><p>The idea is that you can export complex data from one application to a CSV file, and then import the data in that CSV file into another application, without worrying about the smart being played by Microsoft Excel, such as formatting and type casting.</p><h3>The (ideal) Structure of a CSV file</h3><p>A CSV file has a fairly simple structure. It’s a list of data separated by commas. For example, let’s say you have a few contacts in a contact manager, and you export them as a CSV file. You’d get a file containing text like this:</p><pre>First Name,Last Name,Gender,Age,Email,Phone,Education,Occupation,Experience (Years),Salary,Marital Status<br>Fenton,Alexander,Male,27,f.alexander@randatmail.com,329-3799-40,Bachelor,Scientist,7,166896,Married<br>Tiana,Payne,Female,25,t.payne@randatmail.com,580-6209-94,Primary,Carpenter,9,77377,Married<br>Cadie,Lloyd,Female,19,c.lloyd@randatmail.com,788-9355-32,Upper secondary,Physicist,2,108877,Married<br>Edwin,Rogers,Male,22,e.rogers@randatmail.com,097-7380-76,Master,Social Worker,6,134694,Single<br>Elise,Davis,Female,24,e.davis@randatmail.com,987-3297-01,Bachelor,Salesman,10,87347,Single</pre><h3>The (real) CSV files you can get in Production</h3><p>In an idea world, the CSV files to be processed by my pipelines are UTF-8 encoded, proper quoted, delimited by comma, and in reasonable size can be loaded with Pandas data frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*tBPsZu8cwBUuil0XURshdQ.png" /><figcaption>Expectation v.s. Reality — source <a href="https://cheezburger.com/5360645/23-expectation-vs-reality-photos-that-will-have-you-shouting-so-true">https://cheezburger.com/5360645/23-expectation-vs-reality-photos-that-will-have-you-shouting-so-true</a></figcaption></figure><p>CSV can be more complicated than we have expected, it may not have the headers at the top, and some may use quotation marks to surround each bit of data, some may have a different encoding other than UTF-8. When the CSV file is opened and saved by Microsoft Excel it is converted to UFT-8 encoding which changes the test scenario in an unexpected way.</p><p>Some CSV might contain millions of lines, more entries on each line, or long strings of text. You may have seen this dialog when trying to open a large CSV file with Microsoft Excel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*gLRis1DLEc8SJeCRUlt7gQ.png" /><figcaption>When opening a large CSV beyond Microsoft Excel’s capability</figcaption></figure><h3>Generate CSV test files in Various Format</h3><p>As the first step to prepare CSV test files representing all possible scenarios in Production, especially for large CSV file beyond Microsoft Excel’s capability, I have built a Python script to generate CSV file based on a seed file (small CSV file encoded in UTF-8) and a config file ( in JSON).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*jwXC9sujaFB-dubWWwKDCw.png" /><figcaption>Components for CSV generator</figcaption></figure><p>The config file (csv_config.json) specify the format of the CSV file:</p><pre>{<br>  &quot;delimiter&quot;:&quot;,&quot;,    <br>  &quot;quotechar&quot;:&quot;\&quot;&quot;,    <br>  &quot;quoting_level&quot;:1,    <br>  &quot;encoding&quot;:&quot;utf_8&quot;,    <br>  &quot;extra_large&quot;:false,    <br>  &quot;repeat_times&quot;:500000<br>}</pre><p>For <strong>quoting_level</strong> I use the numeric values defined in Python csv module:</p><p>0. csv.QUOTE_MINIMAL</p><p>1. csv.QUOTE_ALL</p><p>2. csv.QUOTE_NONNUMERIC</p><p>3. csv.QUOTE_NONE</p><p>For <strong>encoding</strong>, the following values are supported ( as inherited from Python):</p><p>ascii,big5,big5hkscs,cp037,cp273,cp424,cp437,cp500,cp720,cp737,cp775,cp850,cp852,cp855,cp856,cp857,cp858,cp860,cp861,cp862,cp863,cp864,cp865,cp866,cp869,cp874,cp875,cp932,cp949,cp950,cp1006,cp1026,cp1125,cp1140,cp1250,cp1251,cp1252,cp1253,cp1254,cp1255,cp1256,cp1257,cp1258,cp65001,euc_jp,euc_jis_2004,euc_jisx0213,euc_kr,gb2312,gbk,gb18030,hz,iso2022_jp,iso2022_jp_1,iso2022_jp_2,iso2022_jp_2004,iso2022_jp_3,iso2022_jp_ext,iso2022_kr,latin_1,iso8859_2,iso8859_3,iso8859_4,iso8859_5,iso8859_6,iso8859_7,iso8859_8,iso8859_9,iso8859_10,iso8859_11,iso8859_13,iso8859_14,iso8859_15,iso8859_16,johab,koi8_r,koi8_t,koi8_u,kz1048,mac_cyrillic,mac_greek,mac_iceland,mac_latin2,mac_roman,mac_turkish,ptcp154,shift_jis,shift_jis_2004,shift_jisx0213,utf_32,utf_32_be,utf_32_le,utf_16,utf_16_be,utf_16_le,utf_7,utf_8,utf_8_sig</p><p>When <strong>extra_large</strong> is set to “True”, CSV data rows are to be repeated for <strong>repeat_times</strong> times. While <strong>repeat_times </strong>is set to a large number, it is possible to generate a CSV file at hundreds of GBs in minutes, which might be a real challenge for any text editor.</p><p>When generating the target CSV file, one extra column named “ID” is added with a UUID value so that each row is unique, regardless of how many times it is repeated.</p><p>The script has been used in multiple data engineering projects and highly appreciated by the test teams.</p><p>Both source code and configuration file are available from: <a href="https://github.com/jasonli-lijie/diverse_csv">https://github.com/jasonli-lijie/diverse_csv</a></p><h3>Enhancing CSV Test Files with Synthetic Data</h3><p>While the data generated in previous step may satisfy volume requirements, its repetitive nature often falls short in terms of quality and variability, especially for Machine Learning training data requirements. To address this, we turn to a more sophisticated approach: synthetic data generation.<br>Synthetic data refers to artificially created datasets that replicate the statistical characteristics of real-world data. These datasets are typically produced using statistical modeling techniques or AI-driven generative methods. Despite being synthetic, they preserve the essential patterns and distributions of the original data, making them suitable for a wide range of applications.<br>One of the primary use cases for synthetic data is in training machine learning models, especially when access to high-quality, real-world data is limited, costly, or constrained by privacy regulations. Beyond AI development, synthetic data is increasingly being adopted in industries like finance and healthcare, where data scarcity and compliance requirements pose significant challenges. According to Gartner, by January 2026, 75% of enterprises are expected to use generative AI to produce synthetic customer data.<br>To streamline the creation of synthetic tabular data, the <a href="https://pypi.org/project/sdv/">Synthetic Data Vault</a> (SDV) Python library offers a comprehensive toolkit. It’s a powerful resource for generating realistic datasets from seed data. Before integrating SDV into any enterprise workflow, be sure to review its licensing terms carefully.<br>Here’s a simple example to get started with SDV for generating synthetic data from a seed CSV file:</p><pre>import pandas as pd<br>from sdv.single_table import GaussianCopulaSynthesizer<br>from sdv.metadata import Metadata<br><br>data = pd.read_csv(&#39;seed.csv&#39;)<br>metadata = Metadata.detect_from_dataframe(data)<br><br>synthesizer = GaussianCopulaSynthesizer(metadata)<br>synthesizer.fit(data)<br>synthetic_data = synthesizer.sample(num_rows=1000)<br><br>#### manipulate output data format based on configuration - same as step 1<br></pre><h3>Next Step</h3><p>The current output format is CSV, which provides a simple, widely compatible structure for tabular data. However, depending on downstream requirements, this format can be optimized further: CSV files can be converted into Parquet format, offering efficient columnar storage that is well-suited for modern analytics platforms and big data processing frameworks. Alternatively, the data can be imported directly into a SQL database, enabling relational queries, indexing, and integration with business intelligence tools. This flexibility ensures that the same dataset can be adapted for lightweight portability, high-performance analytics, or structured query operations, depending on the needs of the application.</p><p><em>Credit: Sophia for spelling &amp; grammar check</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30b5824da70a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architecting a Scalable Data Ingestion Solution with AWS Glue and Snowflake]]></title>
            <link>https://medium.com/@jasonli.lijie/data-pipeline-project-recap-fd92390e5450?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd92390e5450</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[aws-glue]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 23:23:38 GMT</pubDate>
            <atom:updated>2025-05-27T00:19:26.886Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2021, I took on a personal challenge — revamping my architecting skills while balancing a full-time job. I joined a project that aimed to build a robust data ingestion solution, transforming disparate data sources into a seamless pipeline feeding an enterprise data warehouse in the cloud.</p><p><strong>The challenge</strong></p><p>The client required an ingestion framework capable of handling multiple data sources:</p><ul><li><strong>On-Prem Oracle database</strong></li><li><strong>Flat delimited files</strong></li><li><strong>Excel spreadsheets</strong></li><li><strong>Mainframe files</strong> (from both on-premises and cloud-based SFTP servers)</li></ul><p>Beyond the complexity of data sources, we faced additional hurdles:</p><ol><li><strong>Infrastructure Complexity</strong> — Integrating both on-premises and cloud-based infrastructure.</li><li><strong>Security Constraints</strong> — The solution had to run in an isolated VPC with no internet connectivity.</li><li><strong>Integration Challenges</strong> — Custom integrations were needed for Oracle, Snowflake, SFTP servers, and mainframe files with diverse copybooks and intricate syntax unsupported by open-source libraries.</li></ol><p>An existing accelerator framework based on <strong>Apache Airflow</strong> provided a cloud-agnostic foundation but lacked AWS-specific implementations. My role was to refine the architecture and enable <strong>AWS Glue</strong> as the backbone of the pipeline, ensuring best practices and efficiency.</p><p><strong>Solution Overview</strong></p><p>Here’s how we structured the data pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRaamDxwWD7hu6pbpGI1zQ.png" /><figcaption>Data Pipeline Flow</figcaption></figure><ol><li>DB Connector</li></ol><p>A custom-built utility for connecting to <strong>On-Prem Oracle databases</strong> using an AWS-recommended approach within Glue. Since traditional Oracle clients couldn’t be used within AWS Glue, we stored credentials in <strong>AWS Secrets Manager</strong> and leveraged VPC connectivity techniques documented in <a href="https://aws.amazon.com/blogs/big-data/how-to-access-and-analyze-on-premises-data-stores-using-aws-glue/">this AWS blog</a>.</p><p>2. SFTP Connector</p><p>Built using <strong>Python’s pysftp library</strong>, this utility facilitated secure data transfer from <strong>on-premises SFTP servers</strong> while enforcing policies on file retention and folder selection. Connection details were managed via <strong>AWS Secrets Manager</strong>.</p><p>3. Data Quality Check</p><p>Data integrity was critical, so we developed a validation utility that assessed source file integrity against configurable rules. Once validated, data was transferred to the <strong>landing zone</strong>.</p><p>4. Data Extraction</p><p>Transforming complex files into a Snowflake-ready format was no small feat. Our custom Glue job extracted data from:</p><ul><li><strong>Mainframe COBOL files</strong> (parsed using a custom-built Python library: <a href="https://pypi.org/project/pycobol2csv/">pycobol2csv</a>)</li><li><strong>Excel spreadsheets</strong></li><li><strong>Other complex formats</strong></li></ul><p>The mapping between raw and processed files was maintained in a metadata database for traceability.</p><p>5. Data Loading</p><p>A Glue job ingested <strong>delimited files</strong> into Snowflake, handling detailed communication via the <strong>snowflake.connector</strong> library.</p><p>6. Data Warehouse Connector</p><p>Integration with Snowflake was challenging due to VPC isolation across AWS accounts. We modified the <strong>snowflake.connector</strong> open-source library to support AWS Glue runtime, allowing seamless interaction with Snowflake. Credentials were stored securely in <strong>AWS Secrets Manager</strong>.</p><p>7. Orchestrator</p><p>Apache Airflow orchestrated all pipeline jobs via DAGs (Directed Acyclic Graphs), ensuring automated, dependable execution.</p><p><strong>Final Thoughts</strong></p><p>This project was a deep dive into architecting a scalable, secure, and efficient data pipeline. It sharpened my technical skills and reinforced the importance of well-structured design principles in cloud-based data ingestion.</p><p>For anyone venturing into data pipeline architecture, I highly recommend checking out <strong>Semantix’s data pipeline visualization</strong> — it’s one of the best representations I’ve seen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*qFKGq7wxnZCkDTzFpsB2cw.gif" /><figcaption>from: <a href="https://en.semantix.ai/produtos/sdp-data-platform">https://en.semantix.ai/produtos/sdp-data-platform</a></figcaption></figure><p><em>Updated on 01/01/2023: repeated the same pattern for another client in Microsoft Azure, and another successful production deployment of </em><a href="https://pypi.org/project/pycobol2csv/">pycobol2csv</a></p><p><em>Updated on 01/12/2024: repeated the same pattern for another client in AWS， with more integration patterns. To create a new medium post.</em></p><p><em>Updated on 27/05/2025: AI rewrite :-)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd92390e5450" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recap of My First AWS Project]]></title>
            <link>https://medium.com/@jasonli.lijie/recap-of-my-first-aws-project-808b48cae9e?source=rss-fa612fc951a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/808b48cae9e</guid>
            <category><![CDATA[newbie]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <dc:creator><![CDATA[Jason Li]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 08:54:29 GMT</pubDate>
            <atom:updated>2022-02-25T00:23:56.398Z</atom:updated>
            <content:encoded><![CDATA[<p>Serverless , AWS Newbie</p><p><em>Declaration: This post does not include any information about my client or my organisation, and the technologies being used in the solution might be outdated.</em></p><p>In 2018 my organisation was approached by a clinical trial company who wanted to digitise its pathology collection process, which was paper-based and any error could introduce penalty, based on the clinical trial contract.</p><p>The paper based process is a flow like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2vcX-hCbDxfymt_hqP7qfw.png" /><figcaption>original paper based process</figcaption></figure><ol><li>Protocol Manager maintains test protocols which defines what’s included in the protocols, such as test cohorts, test periods, test kits required, test parcipants, etc</li><li>Nurses receive instructions in paper from protocol manager and work with test participants to record the sample information</li><li>The data is entered into Excel manually by data entry, as well as HL7 repository system via web interface</li></ol><p>The client observed lots of human errors caused by handwritten text, manual information exchange between the parties, inaccurate timestamp and data entry issues. All errors were ended with additional communication between parties, and even financial penalty.</p><p>I was studying the serverless architecture at that time and realized this is a perfect use case for AWS serverless solution. Luckily the client was using AWS to host its web site so it took no time to convince them to adopt cloud.</p><p>What’s needed in the solution:</p><ol><li>A web portal for protocol managers to create, update test protocols -&gt; Website hosted in S3, then distributed via CloudFront</li><li>A system to manage users, such as account creation, password reset and user decommission, etc -&gt; AWS Cogonito</li><li>Database to persist test protocols, test cohorts and collections -&gt; RDS database</li><li>An integration with SharePoint because client still wants the test cohort to be managed by SharePoint -&gt; Lambda function or Cron job</li><li>An integration with HL7 document repository, which has a REST API interface-&gt; Lambda function or Cron job</li><li>Operational functionalities, such as reporting, notification -&gt; SNS</li><li>An iPad app for nurses in clinical test centres to collect and label samples</li></ol><p>Based on the requirements I designed an architecture very close to the AWS reference architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KF0zgyS0zQPOKU_aT3E9Q.png" /><figcaption>Architecture</figcaption></figure><p>Besides the common components from AWS, I added the following custom component specifically to address the project requirements:</p><ol><li>ETL job to handle the changes from web portal and iPad app — those changes are time consuming so the API will create a job in DB and return immediately, the job is picked up by a cron job afterwards, and the changes are cascaded to all other parties and systems in their own pace without being impacted by external systems’ SLA which is out of our control</li><li>ETL job to calculate metrics data from multiple sources and take action upon the calculated value — Again this is a time consuming process involving lots of database and file access, so it makes more sense to decouple it from the main logic</li><li>ETL job to synchronize patient demographics data with SharePoint — business wants SharePoint to be the single source of truth even it might be changed from time to time on SharePoint. The main reason to use an ETL job is, the response time from SharePoint server is unpredictable.</li><li>Both iPad app and web portal are integrated with Google Analytics</li></ol><p>The end-to-end solution went live in Aug 2018 and is still being used today :-)</p><p>Client was impressed by the fact that there is no application server / web server to maintain, and the speed of delivery (thanks for the comprehensive documentation from AWS).</p><p>Lesson learnt: actually the ETL jobs can be implemented in Step Functions (triggered by CloudWatch timer events), which eliminates the dependency on the EC2 instance hosting the jobs. But AWS Step Function was released after the project started so I could not achieve a pure serverless architecture :-(</p><p>It has been a great learning experience for me, and the experience helped me pass the AWS Solutions Architect Associate exam and the AWS Developer Associate exam in a relatively short time, and I even realised some design mistakes I made during the exam preparation.</p><p><em>Credit: Sophia for spelling &amp; grammar check</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=808b48cae9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>