<?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 Kamal Maiti on Medium]]></title>
        <description><![CDATA[Stories by Kamal Maiti on Medium]]></description>
        <link>https://medium.com/@kamal.maiti?source=rss-2f5ffcb6b46e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hylJ1hGCcixiY4ubbhpkGA.jpeg</url>
            <title>Stories by Kamal Maiti on Medium</title>
            <link>https://medium.com/@kamal.maiti?source=rss-2f5ffcb6b46e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:08:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kamal.maiti/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[How we optimized Pyspark Setting for better performance in AWS EMR]]></title>
            <link>https://medium.com/@kamal.maiti/how-we-optimized-pyspark-setting-for-better-performance-in-aws-emr-5f4ffdf14f2d?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f4ffdf14f2d</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 08:52:46 GMT</pubDate>
            <atom:updated>2026-03-07T08:52:46.388Z</atom:updated>
            <content:encoded><![CDATA[<p>Are your PySpark jobs taking hours to run while consuming massive cluster resources? It could be due to misconfigured parameters. Let’s explore the essential tuning options that can dramatically reduce execution time and cut cloud costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eB-a8BVu1TFCbEpu" /><figcaption>Photo by <a href="https://unsplash.com/@henry_be?utm_source=medium&amp;utm_medium=referral">enrico bet</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s deep dive those parameters that required to be tuned.</p><h3>Explanation of Spark Optimization Configurations</h3><p>Following configurations optimize <strong>Apache Spark’s performance</strong> by tuning partitioning, shuffle operations, and adaptive execution. Let’s break down each setting:</p><pre>spark.conf.set(&quot;spark.sql.files.maxPartitionBytes&quot;, 256 * 1024 * 1024)  # 256MB<br>spark.conf.set(&quot;spark.sql.shuffle.partitions&quot;, 200)  # Adjust based on data size<br>spark.conf.set(&quot;spark.sql.adaptive.enabled&quot;, &quot;true&quot;)<br>spark.conf.set(&quot;spark.sql.adaptive.coalescePartitions.enabled&quot;, &quot;true&quot;)<br>spark.conf.set(&quot;spark.sql.adaptive.skewJoin.enabled&quot;, &quot;true&quot;)<br>spark.conf.set(&quot;spark.default.parallelism&quot;, 200)<br>spark.conf.set(&quot;spark.sql.broadcastTimeout&quot;, 300)</pre><h4>1. File Partitioning: Control the Size of Each Partition</h4><pre>spark.conf.set(&quot;spark.sql.files.maxPartitionBytes&quot;, 256 * 1024 * 1024)  # 256MB</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It limits the maximum <strong>size per partition</strong> when reading files.</li><li><strong>256 MB per partition</strong> ensures that partitions are neither too small (overhead) nor too large (memory pressure).</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li><strong>Too small partitions:</strong> More overhead (task scheduling takes longer).</li><li><strong>Too large partitions:</strong> Higher memory usage &amp; potential OutOfMemory (OOM) errors.</li></ul><p><strong>Best Practice:</strong> Adjust based on file size (default is 128MB, but increasing to 256MB is better for large datasets).</p><h4>2. Shuffle Optimization: Reduce Expensive Shuffling</h4><pre>spark.conf.set(&quot;spark.sql.shuffle.partitions&quot;, 200)  # Adjust based on data size</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It sets the <strong>number of partitions for shuffle operations</strong> (e.g., groupBy, join, repartition).</li><li>Default is <strong>200</strong> in Spark, but increasing or decreasing this value based on data size improves performance.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li><strong>Too few partitions:</strong> Large tasks → OOM errors.</li><li><strong>Too many partitions:</strong> Small tasks → Scheduling overhead increases.</li></ul><p><strong><em>Best Practice:</em></strong></p><ul><li>For <strong>small datasets</strong>, decrease (e.g., spark.sql.shuffle.partitions = 50).</li><li>For <strong>large datasets</strong>, increase (e.g., spark.sql.shuffle.partitions = 400+).</li></ul><h4>3. Enable Adaptive Query Execution (AQE): Dynamic Optimization</h4><pre>spark.conf.set(&quot;spark.sql.adaptive.enabled&quot;, &quot;true&quot;)</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It enables <strong>Adaptive Query Execution (AQE)</strong>, which dynamically optimizes query plans at runtime.</li><li>It helps with <strong>partition coalescing</strong>, <strong>skew handling</strong>, and <strong>broadcast joins</strong>.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li>It automatically <strong>adjusts partition sizes</strong> to reduce shuffle overhead.</li><li>It optimizes execution <strong>based on runtime statistics</strong> instead of static plans.</li></ul><p><strong><em>Best Practice:</em></strong> Always enable AQE in Spark 3+ for dynamic optimization.</p><h4>4. Coalesce Partitions: Reduce Small Partitions</h4><pre>spark.conf.set(&quot;spark.sql.adaptive.coalescePartitions.enabled&quot;, &quot;true&quot;)</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It merges <strong>small shuffle partitions</strong> to create <strong>optimal partition sizes</strong>.</li><li>It also helps avoid too many small files in <strong>S3/HDFS storage</strong>.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li>It reduces <strong>task scheduling overhead</strong> caused by too many small partitions.</li><li>It improves <strong>performance on S3/HDFS writes</strong> by <strong>reducing small file issues</strong>.</li></ul><p><strong><em>Best Practice</em>:</strong> Always enable this for <strong>efficient partition merging</strong> in AQE.</p><h4>5. Skew Join Optimization: Handle Skewed Data</h4><pre>spark.conf.set(&quot;spark.sql.adaptive.skewJoin.enabled&quot;, &quot;true&quot;)</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It detects and <strong>handles skewed joins</strong> (when one key has significantly more data than others).</li><li>It splits skewed partitions into <strong>smaller chunks</strong> to <strong>prevent bottlenecks</strong>.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li>If <strong>one partition has 90% of the data</strong>, it causes slow joins &amp; resource imbalance.</li><li>AQE <strong>dynamically adjusts join execution plans</strong> to balance partitions.</li></ul><p><strong><em>Best Practice</em>:</strong> Enable this <strong>when working with joins on large datasets</strong> to avoid skew-related slowdowns.</p><h4>6. Parallelism: Control Number of Tasks</h4><pre>spark.conf.set(&quot;spark.default.parallelism&quot;, 200)</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It sets <strong>default number of parallel tasks</strong> in <strong>RDD operations</strong> (like reduceByKey, repartition).</li><li>Default is usually <strong># of CPU cores</strong>, but increasing this <strong>improves parallelism</strong> in large clusters.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li>It helps balance <strong>task distribution</strong> across cluster nodes.</li><li>Too <strong>low parallelism = Under-utilized CPU resources</strong>.</li><li>Too <strong>high parallelism = Excessive task overhead</strong>.</li></ul><p><strong><em>Best Practice</em>:</strong> Set based on <strong>cluster size &amp; data volume</strong> (e.g., 2x to 4x <strong>number of cores</strong>).</p><h4>7. Broadcast Join Timeout: Avoid Timeout Errors</h4><pre>spark.conf.set(&quot;spark.sql.broadcastTimeout&quot;, 300)</pre><p><strong><em>What It Does?</em></strong></p><ul><li>It increases <strong>broadcast timeout</strong> (default is 300s = 5 min).</li><li>It helps when <strong>broadcast joins</strong> take longer due to large datasets.</li></ul><p><strong><em>Why Optimize It?</em></strong></p><ul><li>If org.apache.spark.sql.execution.adaptive.BroadcastTimeoutException happens, increase timeout.</li><li>It ensures <strong>small tables get broadcasted efficiently</strong>, improving join performance.</li></ul><p><strong><em>Best Practice:</em></strong></p><ul><li>If experiencing <strong>broadcast join failures</strong>, increase timeout to <strong>600 seconds or more</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f4ffdf14f2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What should be the environment strategy for AWS SageMaker Unified Studio (SMUS)?]]></title>
            <link>https://medium.com/@kamal.maiti/what-should-be-the-environment-strategy-for-aws-sagemaker-unified-studio-smus-6a98b37f815e?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a98b37f815e</guid>
            <category><![CDATA[studio]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[aws-sagemaker]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 07:23:11 GMT</pubDate>
            <atom:updated>2026-02-04T07:23:11.285Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>AWS SageMaker Unified Studio</strong> integrates Analytics, BI, AI/ML, Amazon Bedrock, Agentic AI, build tools, discovery tools, the marketplace, governance, and more. Because of this broad capability set, it makes sense to use Studio as a development IDE.</p><p>However, when we also consider using these capabilities in production, it introduces a dilemma: <strong>how should SageMaker Unified Studio be used in a production environment?</strong></p><p>Do we need to enable end users directly in the SageMaker Unified Studio production environment?</p><p>More broadly, when promoting SageMaker Unified Studio workloads from <strong>development to production</strong>, what should be the overall <strong>strategy</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oku7UD6cH7yLeZFU" /><figcaption>Photo by <a href="https://unsplash.com/@v2osk?utm_source=medium&amp;utm_medium=referral">v2osk</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Solution</h3><p>It depends on <strong>what role SageMaker Studio plays in the workflow. </strong>Let’s explain them environment wise.</p><h4>1. Development Environment (Dev)</h4><ul><li><strong>SageMaker Studio is needed here.</strong></li><li>Data scientists/Developer / Analysts / engineers use it for <strong>interactive development</strong>, <strong>Visual ETL experiments</strong>, <strong>model prototyping</strong>, and <strong>debugging</strong>.</li><li>Studio is tied to a VPC, IAM execution role, and S3 buckets for notebooks and artifacts.</li></ul><h4>2. QA and Production</h4><p>We have two options here:</p><p><strong>Option A</strong>: <strong>Minimal Studio (Best Practice for Enterprise)</strong></p><ul><li><strong>Provision SageMaker Studio in QA and Prod</strong>, but as It’s usually <strong>restricted</strong> (only a few users, or none).</li><li>This is mainly used for <strong>troubleshooting pipelines</strong> or validating deployments. Should not be used development purpose.</li><li>Actual pipelines (ETL, training, batch transform) are generally promoted via <strong>Terraform + CI/CD + SageMaker Pipelines SDK or using your inhouse CI/CD setup (may be github, gitlab, cloud vendor provided tools ) </strong>without manual Studio work.</li></ul><p><strong>Pros:</strong></p><ul><li>Full parity across environments (infra consistency).</li><li>Easier to debug production issues if you need Studio.</li><li>Auditable, but limited access.</li></ul><p><strong>Option B: No Studio in QA/Prod (Lean Approach)</strong></p><ul><li>You <strong>do not create Studio in QA/Prod</strong>.</li><li>Only deploy <strong>SageMaker Pipelines, Processing Jobs, Endpoints, and ECR images</strong> via CI/CD. Because SMUS as combination of other aws services. So, you can promote the Jobs to production.</li><li>However, if it’s used as mesh architecture where data product publish and subscription is happening through the market place capability of SMUS, then you must promote it to production.</li><li>All jobs run in backend (triggered by API, Lambda, Step Functions, or CodePipeline).</li></ul><p><strong>Pros:</strong></p><ul><li>Cheaper, simpler (no Studio maintenance).</li><li>Clear separation: Dev = experimentation, QA/Prod = automation.</li></ul><p><strong>Cons:</strong></p><ul><li>Harder to debug if something fails in prod.</li><li>Some teams end up spinning up Studio later anyway.</li></ul><h4>In Summary:</h4><p>So, in summary, this is how you can take decsion on SMUS environment stragey:</p><ul><li><strong>Dev</strong> → Full SageMaker Studio (for development, visual ETL building).</li><li><strong>QA</strong> → Lightweight SageMaker Studio (optional, for validation/debugging).</li><li><strong>Prod</strong> → Not strictly needed, unless compliance/debugging requires it.</li><li>Instead, deploy pipelines/jobs with Terraform and CI/CD.</li><li>Keep Studio either <strong>disabled</strong> or <strong>restricted to admin users only</strong>.</li></ul><h4>In short:</h4><ul><li><strong>Dev = Studio for everyone</strong></li><li><strong>QA = maybe Studio, limited</strong></li><li><strong>Prod = pipelines only, Studio optional for admins</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a98b37f815e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How aws standard Glue ETL fetches data from cross aws account if sagemaker unified studio is used…]]></title>
            <link>https://medium.com/@kamal.maiti/how-aws-standard-glue-etl-fetches-data-from-cross-aws-account-if-sagemaker-unified-studio-is-used-bb20e2add597?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb20e2add597</guid>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[data-marketplace]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 07:21:20 GMT</pubDate>
            <atom:updated>2025-12-23T07:21:20.772Z</atom:updated>
            <content:encoded><![CDATA[<h3>How AWS standard Glue ETL fetches data from cross AWS account if SageMaker Unified Studio is used with LakeFormation</h3><h3>Problem</h3><p>It can be quite challenging to develop a clear conceptual understanding of how to run <strong>AWS Glue ETL jobs (non–SageMaker Glue ETL)</strong> alongside <strong>SageMaker Unified Studio (SMUS)</strong>.</p><p>While AWS has enabled <strong>Visual ETL</strong> within SMUS, it comes with certain limitations — specifically, it does not support highly complex or fully customized ETL logic. Because of this, teams often need to rely on a fallback approach by using <strong>standard AWS Glue ETL jobs</strong>.</p><p>However, additional challenges arise when attempting to access <strong>cross-account data</strong> under <strong>centralized SMUS governance</strong>, particularly when Lake Formation and DataZone–based permissions are involved.</p><h3>Pre Requisites</h3><ul><li><strong>SageMaker Unified Studio (SMUS)</strong> is set up as a <strong>Hub</strong> in a central AWS account, referred to as <strong>Account H (Hub)</strong>.</li><li>The <strong>data producer</strong> is configured as a <strong>spoke</strong> in a separate AWS account, referred to as <strong>Account P (Producer)</strong>.</li><li>The <strong>data consumer</strong> is configured as another <strong>spoke</strong> in a different AWS account, referred to as <strong>Account C (Consumer)</strong>.</li><li>All spoke accounts (<strong>Producer and Consumer</strong>) are <strong>associated with the Hub account</strong> through SMUS.</li><li>A <strong>main domain</strong> is created in the SMUS portal, for example: <strong>analyticspoc</strong>.</li><li>The <strong>Producer account</strong> is mapped to the domain unit <strong>analyticsproducer</strong></li><li>The <strong>Consumer account</strong> is mapped to the domain unit <strong>analyticsconsumer</strong></li><li>If an <strong>AWS Transit Gateway</strong> is enabled between these three accounts and network traffic must flow over a <strong>private network</strong>, ensure the following:</li><li>Each account uses a <strong>non-overlapping VPC CIDR range</strong></li><li><strong>Routing tables</strong> are correctly configured to allow traffic between VPCs via the transit gateway</li><li>Required security groups and network ACLs allow the necessary service communication</li></ul><p>In the <strong>Consumer account</strong>, create <strong>VPC endpoints</strong> for the following AWS services if transit gateway is used for private network connection:</p><ul><li><strong>AWS Glue</strong></li><li><strong>AWS Security Token Service (STS)</strong></li></ul><p>These VPC endpoints ensure that AWS Glue jobs can securely assume roles and access metadata and data <strong>without traversing the public internet</strong>, which is especially important in private or restricted network environments.</p><h3>Solution</h3><ul><li><strong>AWS Glue</strong> can fetch data from a <strong>cross-account data lake</strong> by integrating with <strong>AWS Lake Formation</strong> and <strong>AWS Resource Access Manager (AWS RAM)</strong>. These services manage permissions and enable secure data sharing <strong>without moving or copying the underlying data</strong>.</li><li>When used with <strong>SageMaker</strong>, the <strong>SageMaker execution role</strong> assumes the permissions that are delegated through Lake Formation.</li><li>In this setup, we assume that the data product is <strong>published from a producer AWS account</strong>.</li><li>In an <strong>SMUS consumer project</strong>, the user must first <strong>subscribe to the data product</strong>.</li><li>Once the data product owner approves the subscription request, the <strong>SMUS control plane automatically updates Lake Formation permissions</strong> so that the <strong>SMUS project role in the consumer account</strong> can access the data hosted in the producer account.</li><li>In addition, the <strong>SMUS control plane updates the consumer-side AWS Glue Data Catalog</strong>. Specifically, it creates the <strong>database and tables as reference links</strong>, which point to the producer account’s data source location rather than creating physical copies of the data.</li><li>It is <strong>critical</strong> that the <strong>AWS Glue job in the consumer account uses the SMUS project role as its execution role</strong>. Without this, cross-account data access will fail even if the subscription is approved.</li><li>Refer to the diagram below to understand the end-to-end flow — it is largely self-explanatory.</li><li>Lake Formation permissions are <strong>automatically managed through the subscription workflow</strong>, so manual configuration is generally not required. However, for clarity and troubleshooting purposes, the internal mechanics have been explained to show what happens behind the scenes.</li><li>On the <strong>producer account</strong>, the <strong>S3 bucket policy must explicitly allow the SMUS project role</strong> (typically named datazone_usr_role_XXX, which is also used as the Glue execution role) to access the underlying data. The required permissions are outlined at the bottom of this document. Policy is automatically taken care of by SMUS.</li><li>Finally, configure the AWS Glue job in the consumer account and run it. Additional configuration details and examples are provided in the <strong>Appendix</strong> for reference.</li></ul><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*V7HLPyJcKZ28wG9vivkHKw.png" /></figure><p>Following processes are involved:</p><h4><strong>1. Producer Account (Data Owner) Configuration</strong></h4><p><strong>a. Register S3 Location</strong>: Data lake administrator in the producer account registers the S3 data location with Lake Formation. This brings the data under the governance of Lake Formation.</p><p><strong>b. Grant Cross-Account Permissions</strong>: Administrator grants database and table permissions (e.g., SELECT, DESCRIBE) to the consumer AWS account (or specific IAM principals in that account) using Lake Formation&#39;s grant mechanism. This action uses AWS RAM to create a resource share.</p><p><strong>c.</strong> <strong>Approve RAM Share</strong>: If the accounts are not within the same AWS Organization, the consumer account administrator must accept the AWS RAM invitation.</p><p><strong>d. Allow ram.amazonaws.com Service Access:</strong> A statement in the producer account&#39;s Glue Data Catalog resource policy must allow the ram.amazonaws.com service to perform glue:ShareResource actions.</p><h4>2. <strong>Consumer Account (Data Consumer &amp; Glue User) Configuration</strong></h4><p><strong>a. Accept RAM Share</strong>: The data lake administrator in the consumer account accepts the resource share invitation through the AWS RAM console. This automatically happens, administrator doen’t need to do anything.</p><p><strong>b. Create Resource Links:</strong> Local resource link is created in Catalog that points to the shared database and table in the producer account. A resource link acts as a symbolic link to the shared resource metadata.</p><p><strong>c. Grant Permissions to SageMaker/Glue Role:</strong> Once data producer approves subscription, it automatically grants the necessary Lake Formation permissions (e.g., SELECT on the table and Describe on the resource link) to the specific AWS Glue job execution role or the SageMaker Studio execution role that will run the analytics or machine learning workloads.</p><h4><strong>3. Configure Trust and Permissions for Glue/SageMaker Role:</strong></h4><p>The execution role must have a trust policy allowing the respective services (e.g., glue.amazonaws.com, sagemaker.amazonaws.com) to assume it.</p><p>The role&#39;s IAM policy must include permissions like lakeformation:GetDataAccess and access to the underlying S3 data via Lake Formation credentials. This step is also automatically happens.</p><h4><strong>4. Data Fetching Mechanism</strong></h4><p>When a SageMaker job or Glue ETL job runs in the consumer account and accesses the shared data via the resource link:</p><p>a) The service (Glue or SageMaker) uses its execution role to request temporary, fine-grained credentials from Lake Formation.</p><p>b) Lake Formation checks the permissions associated with the role and the resource link, considering the policies in both the producer and consumer accounts.</p><p>c) If authorized, Lake Formation vends temporary S3 credentials that contain the precise access permissions to the underlying data in the producer account&#39;s S3 bucket.</p><p>d) Glue job then uses these temporary credentials to securely access and fetch the data directly from the S3 location in the producer account for processing.</p><p>This approach ensures centralized governance, fine-grained access control, and eliminates the need for managing complex S3 bucket policies or data copies across accounts.</p><h3>Appendix</h3><p>Sample Glue Execution role aka SMUS project role that I used for testing:</p><p>IAM Role Name used in consumer account: <strong>datazone_usr_role_bt2jrhjaa8xacn_bjnzugw33coo87</strong></p><p>It has following content for trust:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3cQXhergqP0oipTnbJA6OQ.png" /><figcaption>screenshot of trust relationship</figcaption></figure><p><strong>Full Trust Relationship Json:</strong></p><p>Note: There are few extra assume roles statements are present here for my other use cases. I have mentioned them additionally. This is a working copy.</p><p>Note: You should replace aws account ID wherever placeholder is mentioned.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;auth.datazone.amazonaws.com&quot;,<br>                    &quot;datazone.amazonaws.com&quot;<br>                ]<br>            },<br>            &quot;Action&quot;: [<br>                &quot;sts:AssumeRole&quot;,<br>                &quot;sts:TagSession&quot;,<br>                &quot;sts:SetContext&quot;,<br>                &quot;sts:SetSourceIdentity&quot;<br>            ],<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;aws:SourceAccount&quot;: &quot;&lt;consumer aws a/c id&gt;&quot;<br>                }<br>            }<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;quicksight.amazonaws.com&quot;,<br>                    &quot;glue.amazonaws.com&quot;,<br>                    &quot;scheduler.amazonaws.com&quot;,<br>                    &quot;lambda.amazonaws.com&quot;,<br>                    &quot;bedrock.amazonaws.com&quot;,<br>                    &quot;airflow-env.amazonaws.com&quot;,<br>                    &quot;airflow.amazonaws.com&quot;,<br>                    &quot;access-grants.s3.amazonaws.com&quot;,<br>                    &quot;emr-serverless.amazonaws.com&quot;,<br>                    &quot;sagemaker.amazonaws.com&quot;,<br>                    &quot;lakeformation.amazonaws.com&quot;<br>                ]<br>            },<br>            &quot;Action&quot;: [<br>                &quot;sts:AssumeRole&quot;,<br>                &quot;sts:TagSession&quot;,<br>                &quot;sts:SetContext&quot;,<br>                &quot;sts:SetSourceIdentity&quot;<br>            ],<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;aws:SourceAccount&quot;: &quot;&lt;consumer aws a/c id&gt;&quot;<br>                }<br>            }<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;redshift.amazonaws.com&quot;,<br>                    &quot;redshift-serverless.amazonaws.com&quot;<br>                ]<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringLike&quot;: {<br>                    &quot;sts:ExternalId&quot;: &quot;arn:aws:redshift:*:&lt;consumer aws a/c id&gt;:dbuser:*/*&quot;<br>                }<br>            }<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;redshift.amazonaws.com&quot;,<br>                    &quot;redshift-serverless.amazonaws.com&quot;<br>                ]<br>            },<br>            &quot;Action&quot;: [<br>                &quot;sts:TagSession&quot;,<br>                &quot;sts:SetContext&quot;,<br>                &quot;sts:SetSourceIdentity&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;arn:aws:iam::&lt;consumer aws a/c id&gt;:role/service-role/AmazonSageMakerProvisioning-&lt;hub aws a/c id&gt;&quot;<br>            },<br>            &quot;Action&quot;: [<br>                &quot;sts:AssumeRole&quot;,<br>                &quot;sts:TagSession&quot;,<br>                &quot;sts:SetContext&quot;,<br>                &quot;sts:SetSourceIdentity&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: &quot;glue.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}</pre><p>And permissions tab I have following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jomxp3VCMiWka5d5Ub0VCA.png" /></figure><p>Most of them are added by SMUS control plane itself. I have additionally added three for testing purpose. I have added AmazonS3FullAccess and AmazonS3TablesFullAccess. A custom one is also added. It(custom-glue-pass-role) has following content:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:ListBucket&quot;,<br>                &quot;s3:GetBucketLocation&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::&lt;S3 bucket name present on producer account&gt;&quot;,<br>                &quot;arn:aws:s3:::&lt;S3 bucket name present on producer account&gt;/*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;lakeformation:GetDataAccess&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;iam:PassRole&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;iam:PassedToService&quot;: &quot;glue.amazonaws.com&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><p>Note that “iam:PassRole” is important so that glue service can use this role that is being passed from glue job. Also, “lakeformation:GetDataAccess” very important one.</p><p><strong>Sample Screenshots:</strong></p><p><strong>AWS Glue job Settings:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*1Icqmh89E4BJQ2aWpzEZlw.png" /><figcaption><strong>AWS Glue job Settings</strong></figcaption></figure><p><strong>AWS Glue job running:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*78dz7-O8VDjzXZbw8Qku3g.png" /><figcaption><strong>AWS Glue job running:</strong></figcaption></figure><p><strong>Glue Job fetches data from producer account:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*cEZBbhsEZmwpnH0N5fgYlw.png" /><figcaption><strong>Glue Job fetches data</strong></figcaption></figure><p><strong>Sample Pyspark code used in Glue Job as a script:</strong></p><pre>import sys<br>from awsglue.context import GlueContext<br>from awsglue.job import Job<br>from awsglue.utils import getResolvedOptions<br>from pyspark.context import SparkContext<br><br># ---------------------------------------------------<br># Glue boilerplate<br># ---------------------------------------------------<br>args = getResolvedOptions(sys.argv, [&quot;JOB_NAME&quot;])<br><br>sc = SparkContext()<br>glueContext = GlueContext(sc)<br>spark = glueContext.spark_session<br><br>job = Job(glueContext)<br>job.init(args[&quot;JOB_NAME&quot;], args)<br><br># ---------------------------------------------------<br># Read DataZone subscribed table (READ ONLY)<br># ---------------------------------------------------<br>db_name = &quot;glue_db_43871vdibbzezr&quot;<br>table_name = &quot;sample_customer_data&quot;<br><br>df = spark.sql(f&quot;&quot;&quot;<br>    SELECT *<br>    FROM {db_name}.{table_name}<br>    LIMIT 10<br>&quot;&quot;&quot;)<br><br># ---------------------------------------------------<br># Show results<br># ---------------------------------------------------<br>df.show(truncate=False)<br>df.printSchema()<br><br>job.commit()</pre><p>Looking into the Storage descriptor of the table created in consumer side glue catalog using SMUS Query editor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPJ4AijsHyERhms6MpWqGA.png" /><figcaption>Storage descriptor</figcaption></figure><p><strong>Producer account S3 folder where actual data is present:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1cSYGE8PHQlIZ85aIWRmQ.png" /><figcaption><strong>Producer account S3 folder</strong></figcaption></figure><p><strong>Producer account side Lake Formation Data registry, Permissions:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOnCAhwHh_J2mT6zbR5w7g.png" /><figcaption><strong>Producer account side Lake Formation Data registry</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYKtP1kx-v_nOrY5vhFktQ.png" /><figcaption><strong>Producer account side Lake Formation Permissions</strong></figcaption></figure><p><strong>AWS RAM:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJ4K74Qm-yHovAr_L0npnQ.png" /><figcaption><strong>AWS RAM</strong></figcaption></figure><p><strong>S3 Bucket policy:</strong></p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;LakeFormationServiceRoleAccess&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: [<br>                    &quot;arn:aws:iam::&lt;Data producer aws account id&gt;:role/datazone_usr_role_c8tqbt62b43k13_dqip23pwqqczzb&quot;,<br>                    &quot;arn:aws:iam::&lt;Data consumer aws account id&gt;:role/datazone_usr_role_bt2jrhjaa8xacn_bjnzugw33coo87&quot;,<br>                    &quot;arn:aws:iam::&lt;Data producer aws account id&gt;:role/aws-service-role/lakeformation.amazonaws.com/AWSServiceRoleForLakeFormationDataAccess&quot;<br>                ]<br>            },<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:DeleteObject&quot;,<br>                &quot;s3:GetBucketLocation&quot;,<br>                &quot;s3:ListBucket&quot;,<br>                &quot;s3:ListBucketMultipartUploads&quot;,<br>                &quot;s3:ListMultipartUploadParts&quot;,<br>                &quot;s3:AbortMultipartUpload&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::&lt;S3 bucket name on producer&gt;&quot;,<br>                &quot;arn:aws:s3:::&lt;S3 bucket name on producer&gt;/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><p><strong>Challenges:</strong></p><p>You may encounter multiple errors related to access denied or end point reachability issues. what I encountered are mentioned below:</p><ol><li><strong>STS API call reachability issue:</strong></li></ol><pre>Unable to execute HTTP request: Connect to sts.us-east-1.amazonaws.com:443 [sts.us<br>-east-1.amazonaws.com/67.220.245.43] failed: Connect timed out</pre><p><strong>Solution:</strong> This tries to reach out over public IP i.e. traffic is routed through the Internet. You need to enable outgoing port 443 in security group, also make sure internet gateway is enabled. In our case, we used transit gateway, we had to create VPC endpoint for sts and glue.</p><p><strong>2. S3 Access denied issue:</strong></p><pre>An error occurred while calling o258.collectToPython.<br>: java.io.IOException: com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied</pre><p><strong>Solution: </strong>This was happening due to S3 bucket policy. We had to allow consumer principle to access the bucket.</p><p>Hope this helps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb20e2add597" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to locally run python code using pyflink]]></title>
            <link>https://medium.com/@kamal.maiti/how-to-locally-run-python-code-using-pyflink-847a3ef4a361?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/847a3ef4a361</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[batch-processing]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[apache-flink]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 05:11:08 GMT</pubDate>
            <atom:updated>2025-11-12T05:11:08.747Z</atom:updated>
            <content:encoded><![CDATA[<p>Testing pyflink locally</p><p><strong>PyFlink</strong> is the <strong>Python API for Apache Flink</strong>, a powerful, open-source framework for <strong>distributed stream and batch data processing</strong>.</p><p>PyFlink lets you <strong>write Flink jobs in Python</strong> instead of Java or Scala, while still taking advantage of Flink’s highly scalable and fault-tolerant data processing engine. Sometimes it is bit challenging to run pyflink based code locally. Here, we put the steps on how to do this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LfhZrN0iD7ofXdY1" /><figcaption>Photo by <a href="https://unsplash.com/@marekokon?utm_source=medium&amp;utm_medium=referral">Marek Okon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Installation &amp; Testing</h3><ul><li><strong>Ensure PyFlink is Installed</strong><br>Install PyFlink using pip if not already installed:</li></ul><pre>pip install apache-flink</pre><ul><li><strong>Create Your Python Job</strong><br>Write your Python Flink application in a .py file. For example, save this as my_flink_job.py:</li></ul><pre>from pyflink.datastream import StreamExecutionEnvironment<br><br>env = StreamExecutionEnvironment.get_execution_environment()<br>env.from_collection([1, 2, 3, 4, 5]).map(lambda x: x * 2).print()<br>env.execute(&quot;Simple PyFlink Job&quot;)</pre><ul><li><strong>Use </strong><strong>flink run with the </strong><strong>--python Option</strong><br>The flink run command expects a JAR file by default, but you can specify a Python file using the --python option:</li></ul><pre>./bin/flink run --python /path/to/my_flink_job.py</pre><p>Folder Structure:</p><pre>my_job.zip<br>├── main.py              # Your main Python script<br>└── lib/<br>    └── dependency.jar   # JAR dependency</pre><ul><li><strong>Optional: Add Additional Options</strong><br>If you have dependencies or specific configurations, you can use the following options:</li><li><strong>Add Python dependencies</strong>:</li></ul><pre>./bin/flink run --python /path/to/my_flink_job.py --pyFiles /path/to/dependency.zip</pre><ul><li><strong>Specify execution parameters</strong>:</li></ul><pre>./bin/flink run --python /path/to/my_flink_job.py --parallelism 4</pre><ul><li><strong>Verify Job Execution</strong><br>Check the logs to confirm that your Python job executed successfully. The output will appear in the terminal or in Flink’s web UI if running on a cluster.</li></ul><p>provide the JAR file as a separate dependency using the --classpath option:</p><pre>./bin/flink run \<br>  --python example.py \<br>  --pyFiles my_job.zip</pre><h3>Explanation</h3><ol><li><strong>--python example.py</strong>:</li></ol><ul><li>Specifies example.py as the entry-point Python script. Flink will run this file instead of assuming the default main.py.</li></ul><ol><li><strong>--pyFiles my_job.zip</strong>:</li></ol><ul><li>Includes the zipped dependencies (my_job.zip), which should also contain example.py and any other dependencies your script requires.</li></ul><h3>Alternative (Inside my_job.zip):</h3><p>If example.py is inside my_job.zip, you can still explicitly reference it:</p><pre>./bin/flink run \<br>  --python my_job.zip/example.py \<br>  --pyFiles my_job.zip<br>  --classpath my_job.zip/dependency.jar</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*yRvJhkN5HYLYVh1-zW5lxA.png" /></figure><h3>Flink Cluster Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*iM8s8gFZp-lAzcWNLnv5sA.png" /></figure><p>Reference: <a href="https://www.alibabacloud.com/blog/all-you-need-to-know-about-pyflink_600306">https://www.alibabacloud.com/blog/all-you-need-to-know-about-pyflink_600306</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=847a3ef4a361" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You’ll never forget Data Product Concept if you remember Pizza Business]]></title>
            <link>https://medium.com/@kamal.maiti/youll-never-forget-data-product-concept-if-you-remember-pizza-business-0aa27e77eb8d?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0aa27e77eb8d</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[metadata]]></category>
            <category><![CDATA[marketplaces]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[product-data]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 07:02:02 GMT</pubDate>
            <atom:updated>2025-09-16T07:02:02.317Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Products Explained Like a Pizza Shop</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AlE4LMPKRPwjcP3D" /><figcaption>Photo by <a href="https://unsplash.com/@adamgonzales?utm_source=medium&amp;utm_medium=referral">Adam Gonzales</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever come across a request to set up a data product in the cloud?<br>Whether you’re a data engineer, platform engineer, business analyst, implementation engineer, or program owner, you’ve probably found it confusing at times.</p><p>You might understand the basic idea of “publish and subscribe,” but what about the technologies that support it behind the scenes? Figuring out the relationships, governance, and how everything connects can be quite challenging.</p><p>To make things clearer, think of it like running a pizza shop — from sourcing raw ingredients to creating innovative pizzas. This analogy will help you understand each stage of the data product journey in a simple and memorable way.</p><p>Let’s explore it from a high-level perspective step by step.</p><h3>1. Setting Up the Pizza Shop (Data Domain in AWS DataZone)</h3><ul><li>Pizza Shop (Domain) → A business domain in AWS DataZone (e.g., “Sales Data Domain,” “Marketing Analytics Domain”).</li><li>Multiple Pizza Menus (Data Products) → Just like a pizza shop offers different types of pizzas (Margherita, Pepperoni, Veggie), a domain can have multiple data products (e.g., “Customer Analytics Dataset,” “Sales Forecast Model”).</li><li>Digital Menu Board (AWS Glue Catalog) → Displays all available pizzas (data products) with descriptions (metadata).</li></ul><h3>2. Sourcing Ingredients (Data Ingestion &amp; Storage)</h3><ul><li>Raw Ingredients (Data Sources) → Chicken, cheese, sauce (like S3, Redshift, RDS, APIs).</li><li>Supplier (Data Source Owner) → Ensures fresh ingredients (high-quality data) are available.</li><li>Storage (Data Lake/Warehouse) → Ingredients stored in fridge/freezer (S3, Redshift, Lake Formation).</li></ul><h3>3. Preparing the Pizza (ETL &amp; Data Processing)</h3><ul><li>Chef (Data Producer) → Transforms raw ingredients into pizza (raw data → curated dataset).</li><li>Recipe (ETL Pipeline in AWS Glue) → Defines how to prepare the pizza (cleaning, joining, transforming data).</li><li>Head Chef / Supervisor (Data Steward) → Ensures pizza meets quality standards (data quality checks, schema validation).</li></ul><h3>4. Publishing the Pizza Menu (Data Product Listing in DataZone)</h3><ul><li>Menu Board (AWS DataZone Catalog) → Lists available pizzas (data products).</li><li>Pizza Description (Metadata in Glue) → Lists toppings, spiciness, allergens (schema, PII tags, freshness).</li><li>Approval Process (Governance) → Before a new pizza is added, the head chef (data steward) checks if ingredients are available and meet standards.</li></ul><h3>5. Customers Ordering Pizza (Consuming Data Products)</h3><ul><li>Customer (Data Consumer) → Browses the menu (DataZone catalog), selects a pizza (data product), and orders (subscribes).</li><li>Delivery (Data Access via DataZone) → Pizza is served (data is shared via S3, Redshift, or Lake Formation access).</li><li>Feedback Loop (Data Usage Metrics) → Did the customer like the pizza? (Usage analytics in DataZone.)</li></ul><h3>6. Managing the Pizza Shop (Governance &amp; Operations)</h3><ul><li>Owner (Data Product Owner) → Decides which pizzas (data products) to offer based on demand.</li><li>Inventory Manager (Data Engineer) → Ensures ingredients (data pipelines) are always available.</li><li>Health Inspector (Compliance Team) → Ensures hygiene (GDPR, PII compliance) is maintained.</li></ul><h3>Data Quality → Pizza Quality Control</h3><p>Pizza Shop:</p><ul><li>The head chef (data steward) inspects every pizza before serving:</li><li>Is the cheese fresh? → <em>Is the data up-to-date? (timeliness)</em></li><li>Are toppings evenly spread? → <em>Is the data complete (no missing values)?</em></li><li>Does it taste right? → <em>Anomaly detection (unexpected values)</em></li><li>No burnt crust! → <em>Schema validation (correct structure)</em></li></ul><p>AWS Tools:</p><ul><li>AWS Glue Data Quality → Automated pizza inspections (data profiling, rules).</li><li>Amazon Deequ → Kitchen scales and thermometers (metrics for freshness, consistency).</li><li>AWS Macie → Detects “spoiled ingredients” (sensitive/PII data leaks).</li></ul><h3>Few important things before wrapping up:</h3><h4>Data Lineage → Pizza Ingredient Tracking</h4><p>Pizza Shop:</p><ul><li>A customer asks: <em>“Where does the pepperoni come from?”</em></li><li>Farm → Supplier → Kitchen → Pizza (Full traceability).</li><li>If a bad batch arrives, the shop knows exactly which pizzas are affected.</li></ul><p>AWS Tools:</p><ul><li>AWS Glue Lineage Tracking → The shop’s supplier ledger (tracks data from S3 → ETL → final dataset).</li><li>AWS Lake Formation → The ingredient certification board (tags data sources as “trusted” or “restricted”).</li><li>Amazon Neptune (Graph DB) → Maps the entire pizza recipe flow (visual lineage).</li></ul><h4>Monitoring → Kitchen Performance Dashboards</h4><p>Pizza Shop:</p><ul><li>The owner watches:</li><li>Oven temperature → <em>Is the ETL job running hot or failing? (CloudWatch Alarms)</em></li><li>Pizza delivery times → <em>Query performance (Redshift/Athena latency)</em></li><li>Ingredient waste → <em>Storage costs (S3 analytics for unused data)</em></li><li>Customer complaints → <em>Data consumer feedback (DataZone usage metrics)</em></li></ul><p>AWS Tools:</p><ul><li>Amazon CloudWatch → The kitchen’s digital thermometer and timer (real-time alerts).</li><li>AWS QuickSight → The daily sales report (dashboards for data usage trends).</li><li>AWS Cost Explorer → The inventory waste log (cost of stale/unused data).</li></ul><h4>Key AWS Services Mapped to Pizza Shop Roles</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DV-ZnSfiqFez_HwPEircVQ.png" /></figure><h4>At Very High Level</h4><p>✅ Raw Data → Ingredients (Must be fresh, well-organized).<br>✅ ETL → Recipe (Transforms raw data into something useful).<br>✅ Data Products → Pizzas (Different types for different needs).<br>✅ Data Steward → Head Chef (Ensures quality before serving).<br>✅ DataZone → Pizza Shop (A place to discover, order, and consume).</p><h3>In Conclusion</h3><p>Hope this gives you a quick perspective, clarifies your doubts, and strengthens your understanding of data products and how they work. As technology evolves, so do data products. What is called a data product today could be something else tomorrow. Keep learning and keep updating yourself as time flies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0aa27e77eb8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to adjust a composite API call when multiple external ID fields exist in the Account object?]]></title>
            <link>https://medium.com/@kamal.maiti/how-to-adjust-a-composite-api-call-when-multiple-external-id-fields-exist-in-the-account-object-17da6028a3c4?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/17da6028a3c4</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 16:36:52 GMT</pubDate>
            <atom:updated>2025-09-10T16:36:52.154Z</atom:updated>
            <content:encoded><![CDATA[<p>Composite call and upsert using external ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*la5hvd6-p52DOCdu" /><figcaption>Photo by <a href="https://unsplash.com/@tristone?utm_source=medium&amp;utm_medium=referral">Tristan Ramberg</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If multiple external ID fields are present on the Account object in Salesforce, the process for performing a Composite API call would change slightly.</p><h4>Points to be Considered:</h4><ul><li><strong>Matching by Specific External ID:</strong> Salesforce can only use one external ID field in a given API operation to match the record. If you have multiple external ID fields on the Account object, you need to specify which field to use for matching when performing the update.</li><li><strong>Specifying the Field in the API Call: </strong>Salesforce does not automatically decide which external ID field to use; <strong>you must explicitly reference the external ID field</strong> you want to use in the URL for the operation.</li></ul><h4>How to Modify the Composite API Call</h4><p>If you have multiple external ID fields on the Account object, such as:</p><blockquote><strong>External_Account_ID_1__c</strong></blockquote><blockquote><strong>External_Account_ID_2__c</strong></blockquote><p>You need to specify which one you want to use to find the record.</p><h4>Example Scenario</h4><p>Let’s assume you have two external ID fields on the Account object:</p><blockquote>External_Account_ID_1__c (First external ID field)</blockquote><blockquote>External_Account_ID_2__c (Second external ID field)</blockquote><p>If you want to update the Account record using <strong>External_Account_ID_1__c</strong>, your API call would look like this:</p><p><strong>Example API Call</strong></p><pre>{<br>  &quot;compositeRequest&quot;: [<br>    {<br>      &quot;method&quot;: &quot;PATCH&quot;,<br>      &quot;url&quot;: &quot;/sobjects/Account/External_Account_ID_1__c/987654321&quot;,<br>      &quot;referenceId&quot;: &quot;refAccount1&quot;,<br>      &quot;body&quot;: {<br>        &quot;Name&quot;: &quot;Updated Account Name&quot;,<br>        &quot;Phone&quot;: &quot;123-456-7890&quot;,<br>        &quot;Industry&quot;: &quot;Technology&quot;<br>      }<br>    }<br>  ]<br>}</pre><p>If you want to use <strong>External_Account_ID_2__c</strong> instead, you would modify the API call to:</p><pre>{<br>  &quot;compositeRequest&quot;: [<br>    {<br>      &quot;method&quot;: &quot;PATCH&quot;,<br>      &quot;url&quot;: &quot;/sobjects/Account/External_Account_ID_2__c/987654321&quot;,<br>      &quot;referenceId&quot;: &quot;refAccount1&quot;,<br>      &quot;body&quot;: {<br>        &quot;Name&quot;: &quot;Updated Account Name&quot;,<br>        &quot;Phone&quot;: &quot;123-456-7890&quot;,<br>        &quot;Industry&quot;: &quot;Technology&quot;<br>      }<br>    }<br>  ]<br>}</pre><h4>Take Away:</h4><ol><li><strong>Specify the Correct Field:</strong></li></ol><p>In the URL, you must specify the name of the external ID field you want to use. This is a Salesforce field name, like External_Account_ID_1__c or External_Account_ID_2__c.</p><p><strong>2. Use Case for Multiple External IDs:</strong></p><p>If you want to perform the update using a different external ID field, you just adjust the field in the URL accordingly.</p><p><strong>3. Composite API Limits:</strong></p><p>The Composite API allows multiple operations in a single call, so you could potentially perform different operations on different external ID fields in the same request. However, each individual operation must specify one external ID field to match on.</p><p>In conclusion, when there are multiple external ID fields, you need to modify your Composite API call to specify which external ID field should be used for matching records. Salesforce won’t automatically choose one for you; you must provide the correct field name in the URL. Hope this helps.</p><p>Share your thoughts how you manage such external IDs when one object holds multiple external IDs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17da6028a3c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Lookup field works in Salesforce behind the scene?]]></title>
            <link>https://medium.com/@kamal.maiti/how-lookup-field-works-in-salesforce-behind-the-scene-baedbdffb38f?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/baedbdffb38f</guid>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[integration]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 09:39:02 GMT</pubDate>
            <atom:updated>2025-09-02T09:39:02.967Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding lookup field in Salesforce</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r4VMN6zOl4ZowVoK" /><figcaption>Photo by <a href="https://unsplash.com/@cbarbalis?utm_source=medium&amp;utm_medium=referral">Chris Barbalis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Sometimes when you work in API and interact with Salesforce, the linking between two record is challenging. Specifically, while you develop composite API. If you don’t correctly map to the right SF ID of the record, it’ll not be functionally correct. Your BA team can press buzzer if it wrongly links to other object. This is also a part of security what developers overlook. Let’s understand this Lookup field, how it can used to store ID of other record and how it looks like in Salesforce.</p><p>Basically, <strong>Lookup field</strong> in Salesforce establishes a <strong>relationship between two objects by storing a reference to a record from another object</strong>. This relationship is implemented using a <strong>foreign key-like mechanism behind the scenes</strong>. Let’s break it down step-by-step, including how it works and how to establish this relationship using a REST API call.</p><p><strong>Data Structure:</strong></p><ul><li>Salesforce stores <strong>objects as database tables.</strong></li><li>When you create a Lookup field on an object (e.g., Child_Object__c) to reference another object (e.g., Parent_Object__c), Salesforce creates a foreign key column in the child object. This is loosely coupled relationship.</li><li>This column stores the unique Id (a 15- or 18-character Salesforce record ID) of the parent object record.</li></ul><p><strong>Relationship Creation:</strong></p><ul><li>A Lookup field is used to link records between two objects.</li></ul><p>For example:</p><ul><li>Child_Object__c has a Lookup field Parent_Record__c.</li><li>This field stores the Id of a record in Parent_Object__c.</li></ul><p><strong>Behavior in UI:</strong></p><ul><li>When creating or editing a record in the child object, users can select a related record from the parent object via the Lookup field.</li><li>If the Lookup field is populated, it shows the related record’s name (defined by the parent object’s Name or Auto Number field).</li></ul><p>Let’s walk through a <strong>real-world example</strong> where we link a Contact to an Account using the Salesforce REST API.</p><h3>Scenario</h3><p><strong>Parent Object</strong>: Account</p><ul><li>Example record: Account Name: Acme Corp, Id: 0012w00000XXXXXAAA</li></ul><p><strong>Child Object</strong>: Contact</p><ul><li>We want to create or update a Contact and link it to the Account above.</li></ul><pre>+---------------------+    Lookup Field    +-----------------------+<br>|      Account        | &lt;----------------&gt; |       Contact         |<br>|---------------------|                    |-----------------------|<br>| Id (Primary Key)    |                    | Id (Primary Key)      |<br>| Name: Acme Corp     |                    | FirstName: Emily      |<br>| Industry: Tech      |                    | LastName: Johnson     |<br>| Phone: 987-654-3210 |                    | Email: em@example.com |<br>|                     |                    | Phone: 123-456-7890   |<br>|                     |                    | AccountId (FK):       |<br>|                     |                    | 0012w00000XXXXXAAA    |<br>+---------------------+                    +-----------------------+</pre><h3>Explanation of the Diagram:</h3><ol><li><strong>Account (Parent Object):</strong></li></ol><ul><li>The Account object serves as the parent in this relationship.</li></ul><p>Fields in focus:</p><ul><li>Id: Unique identifier for the Account (e.g., 0012w00000XXXXXAAA).</li><li>Name: The name of the account (e.g., Acme Corp).</li><li>Other fields like Industry and Phone provide additional account details.</li></ul><p><strong>2. Contact (Child Object):</strong></p><ul><li>The Contact object serves as the child in this relationship.</li></ul><p>Fields in focus:</p><ul><li>Id: Unique identifier for the Contact (e.g., 0032w00000YYYYYAAA).</li><li>FirstName and LastName: Basic information about the contact (e.g., Emily Johnson).</li><li>AccountId: The Lookup field that links the Contact to the Account by storing the Account record’s Id.</li></ul><p><strong>3. Relationship (Lookup Field):</strong></p><ul><li>The AccountId field in the Contact object establishes the link to the Account object.</li><li>This field stores the Id of the related Account.</li></ul><h3>Link Representation:</h3><ul><li>The <strong>AccountId</strong> field in the Contact object acts as the <strong>foreign key</strong> that references the primary key (Id) of the Account object.</li></ul><h3>Example with REST API calls</h3><h3>1. Authentication</h3><p>Before making REST API calls, authenticate with Salesforce using OAuth 2.0 to get an access token. The token is required to authorize API requests.</p><h4>Example Response After Authentication:</h4><pre>{<br>  &quot;access_token&quot;: &quot;00DXXXXXXXXXXXX!AQoXXXXXXXXXXXXX&quot;,<br>  &quot;instance_url&quot;: &quot;https://yourInstance.salesforce.com&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;<br>}</pre><h3>2. Linking Records Using REST API</h3><h4>A. Create a New Contact Linked to an Account</h4><p><strong>Endpoint:</strong><br>https://yourInstance.salesforce.com/services/data/v57.0/sobjects/Contact</p><p><strong>Method:</strong> POST</p><p><strong>Headers:</strong></p><pre>Authorization: Bearer 00DXXXXXXXXXXXX!AQoXXXXXXXXXXXXX<br>Content-Type: application/json</pre><p>Request Body:</p><pre>{<br>  &quot;LastName&quot;: &quot;Johnson&quot;,<br>  &quot;FirstName&quot;: &quot;Emily&quot;,<br>  &quot;Email&quot;: &quot;emily.johnson@example.com&quot;,<br>  &quot;Phone&quot;: &quot;123-456-7890&quot;,<br>  &quot;AccountId&quot;: &quot;0012w00000XXXXXAAA&quot;<br>}</pre><p><strong>Explanation:</strong></p><ul><li>&quot;LastName&quot; and &quot;FirstName&quot;: Required fields for creating a Contact.</li><li>&quot;AccountId&quot;: The Id of the Account (Acme Corp) to link.</li></ul><p>Response (Success):</p><pre>{<br>  &quot;id&quot;: &quot;0032w00000YYYYYAAA&quot;,<br>  &quot;success&quot;: true,<br>  &quot;errors&quot;: []<br>}</pre><p>Here</p><blockquote>0032w00000YYYYYAAA</blockquote><p>is SF record ID in Contact object.</p><p>The response confirms the creation of the Contact and links it to the Account.</p><h4>B. Update an Existing Contact to Link to an Account</h4><p><strong>Endpoint:</strong><br>https://yourInstance.salesforce.com/services/data/v57.0/sobjects/Contact/0032w00000YYYYYAAA</p><p><strong>Method:</strong> PATCH</p><p>Note: Notice we used PATCH call to perform upsert.</p><p><strong>Headers:</strong></p><pre>Authorization: Bearer 00DXXXXXXXXXXXX!AQoXXXXXXXXXXXXX<br>Content-Type: application/json</pre><p><strong>Request Body:</strong></p><pre>{<br>  &quot;AccountId&quot;: &quot;0012w00000XXXXXAAA&quot;<br>}</pre><p><strong>Explanation:</strong></p><ul><li>The AccountId field is updated to link the Contact (0032w00000YYYYYAAA) with the Account (0012w00000XXXXXAAA).</li></ul><p><strong>Response (Success):</strong></p><pre>{<br>  &quot;id&quot;: &quot;0032w00000YYYYYAAA&quot;,<br>  &quot;success&quot;: true,<br>  &quot;errors&quot;: []<br>}</pre><p>Hope this helps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baedbdffb38f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does Salesforce determine which record to update in the Account object using an external ID?]]></title>
            <link>https://medium.com/@kamal.maiti/how-does-salesforce-determine-which-record-to-update-in-the-account-object-using-an-external-id-25efeacfeb1e?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/25efeacfeb1e</guid>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[salesforce]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Wed, 27 Aug 2025 04:59:37 GMT</pubDate>
            <atom:updated>2025-08-27T04:59:37.385Z</atom:updated>
            <content:encoded><![CDATA[<p>Does the object store the value of the external ID in a field and use it for match or search?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rf3E3-6EbAjd5zwH" /><figcaption>Photo by <a href="https://unsplash.com/@thommilkovic?utm_source=medium&amp;utm_medium=referral">Thom Milkovic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It can be confusing sometime when we deal with external field in Salesforce. The way how salesforce treats them and the way how it is used to search the record to perform various CURD operations is sometime misleading. Let’s understand in depth:</p><p>Salesforce uses External ID fields to match and identify records from external systems. When you set a field as an External ID in Salesforce, it tells Salesforce to treat that field as a <strong>unique identifier </strong>for records that may come from external sources (such as a third-party system).</p><h4>Here’s how it works:</h4><p><strong>External ID Field:</strong> In Salesforce, you can mark a custom or standard field as an “External ID” field. This field is typically used to store unique identifiers from external systems, like a customer ID, external system reference, etc. You can set this field to be indexed, meaning Salesforce will use this field to efficiently search for records based on the external ID.</p><p><strong>Matching by External ID:</strong> When you perform a DML operation (like UPDATE, UPSERT, DELETE, etc.) on an object (like Account), Salesforce uses the external ID field to identify the record. Instead of using Salesforce’s internal ID (which is the Salesforce Record ID), Salesforce will search for a record b<strong>ased on the value in the External ID field</strong>.</p><p><strong>Composite API or other API Calls:</strong> When using the Composite API or other APIs to perform an operation, if you provide the external ID value, Salesforce will automatically use that external ID field to search for the corresponding record. For example, in the case of updating an Account record, Salesforce will search the Account object for a record that has the matching value in the field marked as the External ID.</p><h4><strong>Example of Process:</strong></h4><p><strong>Define an External ID: </strong>Assume you have an Account object, and you’ve created a custom field External_Account_ID__c that is marked as an External ID.</p><p><strong>Use External ID in API Call:</strong> Instead of using the internal Salesforce Account record ID (which looks like 001XXXXXXXXXXXX), you can use the value in the external field (e.g., 987654321).</p><p><strong>Salesforce Search Logic:</strong> When you pass 987654321 in an API request, Salesforce will search the Account object for the record that has 987654321 in the External_Account_ID__c field and will perform the specified operation (e.g., update) on that record.</p><p><strong>Example API Call with External ID:</strong></p><p>In this example, we use the External ID (External_Account_ID__c) for the update:</p><pre>{<br>  &quot;compositeRequest&quot;: [<br>    {<br>      &quot;method&quot;: &quot;PATCH&quot;,<br>      &quot;url&quot;: &quot;/sobjects/Account/External_Account_ID__c/987654321&quot;,<br>      &quot;referenceId&quot;: &quot;refAccount1&quot;,<br>      &quot;body&quot;: {<br>        &quot;Name&quot;: &quot;Updated Account Name&quot;,<br>        &quot;Phone&quot;: &quot;123-456-7890&quot;,<br>        &quot;Industry&quot;: &quot;Technology&quot;<br>      }<br>    }<br>  ]<br>}</pre><h4>In this call:</h4><p>Salesforce uses External_Account_ID__c as the unique identifier to search for the Account record.</p><p>If a record is found with the value 987654321 in the External_Account_ID__c field, it will update that record with the provided field values (Name, Phone, Industry).</p><h4>Points to Remember:</h4><p><strong>External ID Field:</strong> You must first create a custom field (or use an existing field) on the Salesforce object and mark it as an External ID.</p><p><strong>Indexed:</strong> Salesforce automatically indexes external ID fields, making searches based on this field very efficient.</p><p><strong>Matching: </strong>When using APIs, Salesforce matches records based on the value of the external ID field, not the Salesforce record ID (ID).</p><p>In conclusion, Salesforce matches the record based on the External ID field value, which is treated as a <strong>unique key for identifying records.</strong> This allows for seamless integration with external systems where the external ID serves as a reference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25efeacfeb1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the underlying architecture of Salesforce objects, fields, and their mappings, and how do…]]></title>
            <link>https://medium.com/@kamal.maiti/what-is-the-underlying-architecture-of-salesforce-objects-fields-and-their-mappings-and-how-do-2b4f9d68f6bc?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b4f9d68f6bc</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[metadata]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 11:43:08 GMT</pubDate>
            <atom:updated>2025-08-22T11:43:08.682Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is the underlying architecture of Salesforce objects, fields, and their mappings, and how do they work behind the scenes?</h3><p>Understanding various important components of Salesforce</p><p>The architecture below aligns with modern LLMs and agentic AI, though some core components are not included.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4YVFaE1yExKch6_huVZo9A.png" /><figcaption>Salesforce Modern Architecture, Image Source: Salesforce</figcaption></figure><p>When I started working on a project where vendor patient information would be stored in a CRM platform like Salesforce, I was initially clueless about the relationships between the components. These components included: Salesforce Objects versus traditional tables, fields versus column-level attributes, relationships among tables, primary and secondary keys, lookup fields, updating records, and performing POST versus PATCH operations using API calls etc.</p><p>I often felt lost while browsing the Salesforce portal because navigating between various objects, finding fields under those objects, and understanding their relationships was challenging. The team managing Salesforce lacked a proper data model, which caused ambiguity and confusion at times.</p><p>I have tried to outline a few important components and how they correspond to various database objects. Let’s explore them:</p><h3>Core Structure</h3><ol><li><strong>Salesforce Objects:</strong></li></ol><ul><li><strong>Objects</strong> in Salesforce are comparable to <strong>database tables</strong>. They store data in a structured way, with <strong>rows</strong> representing <strong>records</strong> and <strong>columns</strong> representing <strong>fields</strong>.</li></ul><p>Two types of objects:</p><ul><li><strong>Standard Objects</strong>: Built-in objects like Account, Contact, Opportunity, etc.</li><li><strong>Custom Objects</strong>: User-defined objects created to handle specific business data needs.</li></ul><p><strong>2. Fields:</strong></p><ul><li><strong>Fields</strong> in Salesforce are analogous to database columns. They store specific types of data such as text, numbers, dates, etc.</li></ul><p>Types of fields:</p><ul><li><strong>Standard Fields</strong>: Predefined fields provided by Salesforce in standard objects.</li><li><strong>Custom Fields</strong>: User-defined fields in both standard and custom objects.</li><li><strong>Formula Fields</strong>: Dynamically calculated fields based on other field values.</li><li><strong>Relationship Fields</strong>: Fields like Lookup and Master-Detail that define relationships between objects.</li></ul><p><strong>3. Relationships:</strong></p><p>Salesforce supports multiple relationships to establish connections between objects:</p><ul><li><strong>Lookup Relationship</strong>: Loose association; records in related objects remain independent.</li><li><strong>Master-Detail Relationship</strong>: Tight association; child records depend on parent records.</li><li><strong>Junction Object</strong>: Used to create many-to-many relationships.</li></ul><p><strong>4. Mapping:</strong></p><p>Salesforce maps fields in objects to specific database tables and columns in its backend.</p><ul><li>Relationships (e.g., Master-Detail, Lookup) define how object records relate to each other.</li><li>Behind the scenes, Salesforce ensures these mappings are optimized for queries, updates, and integrations.</li></ul><h3>How It Works Behind the Scenes</h3><p>Salesforce abstracts much of the database complexity from end-users and developers by providing a <strong>declarative interface</strong> (via the Salesforce UI) and programmatic tools (like Apex, SOQL, etc.). Here’s how it works:</p><ol><li><strong>Metadata-Driven Architecture:</strong></li></ol><ul><li>Salesforce’s entire platform is built on <strong>metadata</strong>.</li><li>Objects, fields, relationships, and configurations are defined as metadata and stored in the Salesforce database.</li><li>This metadata-driven architecture allows Salesforce to be highly customizable without altering the core codebase.</li></ul><p><strong>2. Multitenant Architecture:</strong></p><ul><li>Salesforce operates on a <strong>multitenant architecture</strong>, where multiple organizations share the same physical infrastructure and database.</li><li>Each organization (tenant) has its own <strong>logical data structure</strong> (metadata) to segregate and secure data.</li></ul><p><strong>3. Virtualized Database Layer:</strong></p><ul><li>Salesforce uses a virtualized relational database under the hood.</li><li>Each Salesforce object (standard or custom) is mapped to database tables, and fields are mapped to columns.</li><li>Complex data retrieval and manipulation are handled by Salesforce’s engine (not directly by the user).</li></ul><p><strong>4. Dynamic Query Handling:</strong></p><ul><li>Salesforce provides tools like <strong>SOQL (Salesforce Object Query Language)</strong> and <strong>SOSL (Salesforce Object Search Language)</strong> for querying data.</li><li>Behind the scenes, these are converted into optimized SQL queries that interact with the underlying database.</li></ul><p><strong>5. Indexing and Performance:</strong></p><ul><li>Salesforce uses <strong>advanced indexing strategies</strong> to ensure fast data retrieval:</li><li><strong>Standard and custom fields</strong> are indexed.</li><li><strong>Relationship fields and key</strong> fields (like Id) are also indexed.</li><li>This allows queries to run efficiently, even on large datasets.</li></ul><p><strong>6. Governor Limits:</strong></p><p>To maintain performance and prevent resource abuse in the multitenant environment, Salesforce imposes <strong>governor limits</strong> on things like:</p><ul><li>SOQL queries.</li><li>DML operations.</li><li>API calls.</li><li>Execution time.</li></ul><h3>Key Components of the Architecture</h3><ol><li><strong>Application Layer:</strong></li></ol><ul><li>Contains the Salesforce UI (Lightning Experience, Salesforce Mobile, Apps) and API endpoints.</li><li>Allows users to interact with Salesforce data via browsers, mobile apps, or third-party integrations.</li></ul><p><strong>2. Platform Services:</strong></p><ul><li>Services like workflow automation, reporting, dashboards, and AI (Einstein).</li><li>These rely on metadata and the virtualized database to perform operations efficiently.</li></ul><p><strong>3. Database Layer:</strong></p><ul><li>Stores data and metadata in a relational format.</li><li>Uses <strong>PostgreSQL</strong>-based systems with custom enhancements to handle Salesforce’s unique requirements.</li><li>All user interactions are abstracted through the Salesforce Object Manager and ORM system.</li></ul><p><strong>4. API Layer:</strong></p><ul><li>Exposes data and functionality to external systems via REST, SOAP, and Bulk APIs.</li><li>Converts API requests into database operations behind the scenes.</li></ul><h3>Example: Saving a Record in Salesforce</h3><p>When a record is created or updated:</p><ol><li>The user enters data into fields (via UI or API).</li><li>The data is mapped to the appropriate Salesforce object and fields.</li><li>Validation rules, triggers, and workflows are executed as part of the save process.</li><li>Salesforce writes the data to its virtualized database, ensuring it adheres to the defined relationships and schema.</li><li>The database updates are logged and indexed for retrieval.</li></ol><h3>Advantages of This Architecture</h3><ul><li><strong>Scalability:</strong> Salesforce can handle millions of records across tenants with minimal performance degradation.</li><li><strong>Customizability:</strong> Businesses can easily add fields, objects, or workflows without impacting the core platform.</li><li><strong>Security:</strong> Data is isolated at the tenant level, and robust sharing rules and role hierarchies protect access at a granular level.</li><li><strong>Extensibility:</strong> Developers can build apps on top of Salesforce using Apex, Visualforce, and Lightning.</li></ul><p>This architecture is the backbone of Salesforce’s ability to deliver a highly customizable, scalable, and secure CRM platform. When you really perform tasks on Salesforce, you gain experience and confidence. Hope this helps.</p><p>Reference:</p><p><a href="https://trailhead.salesforce.com/content/learn/modules/starting_force_com/starting_understanding_arch">Salesforce Architecture Essentials Guide | Salesforce Trailhead</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b4f9d68f6bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Are the Common Transformations Available in Apache Flink’s Stream Processing Engine?]]></title>
            <link>https://medium.com/@kamal.maiti/what-are-the-common-transformations-available-in-apache-flinks-stream-processing-engine-8455e6bdb689?source=rss-2f5ffcb6b46e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8455e6bdb689</guid>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-flink]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Kamal Maiti]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 03:31:30 GMT</pubDate>
            <atom:updated>2025-08-13T03:31:30.035Z</atom:updated>
            <content:encoded><![CDATA[<p>Common transformation functions used in Apache Flink</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f_4J64Pyirpo5ilT" /><figcaption>Photo by <a href="https://unsplash.com/@scw1217?utm_source=medium&amp;utm_medium=referral">Suzanne D. Williams</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Here is a detailed explanation of common <strong>transformation operations</strong> in <strong>PyFlink</strong> (Python API for Apache Flink) with examples. These transformations allow you to process, modify, and analyze data in a Flink pipeline. PyFlink supports transformations on both <strong>DataStream API</strong> and <strong>Table API</strong>.</p><h3>A. DataStream API Transformations</h3><p>The DataStream API allows for low-level stream processing with fine-grained control.</p><h3>1. Map</h3><p>Transforms each element of the stream independently.</p><p><strong>Use Case</strong>: Convert data to a different format, extract fields, or apply calculations.</p><p><strong>Example</strong>:</p><pre>from pyflink.datastream import StreamExecutionEnvironment<br><br>env = StreamExecutionEnvironment.get_execution_environment()<br>data = env.from_collection([1, 2, 3, 4])<br>mapped = data.map(lambda x: x * 2)  # Multiply each element by 2<br>mapped.print()<br>env.execute(&quot;Map Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>2<br>4<br>6<br>8</pre><h3>2. FlatMap</h3><p>Splits an element into zero, one, or more elements.</p><p><strong>Use Case</strong>: Tokenizing strings or splitting data into smaller pieces.</p><p><strong>Example</strong>:</p><pre>data = env.from_collection([&quot;apple banana&quot;, &quot;cat dog&quot;])]<br>flattened = data.flat_map(lambda x: x.split(&quot; &quot;))  # Split strings into words<br>flattened.print()<br>env.execute(&quot;FlatMap Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>apple<br>banana<br>cat<br>dog</pre><h3>3. Filter</h3><p>Filters out elements based on a condition.</p><p><strong>Use Case</strong>: Retain only specific elements (e.g., filtering invalid data).</p><p><strong>Example</strong>:</p><pre>data = env.from_collection([1, 2, 3, 4, 5])<br>filtered = data.filter(lambda x: x % 2 == 0)  # Keep only even numbers<br>filtered.print()<br>env.execute(&quot;Filter Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>2<br>4</pre><h3>4. KeyBy</h3><p>Partitions the stream based on a key.</p><p><strong>Use Case</strong>: Group elements by a key for stateful operations like aggregations.</p><p><strong>Example</strong>:</p><pre>from pyflink.common.typeinfo import Types<br><br>data = env.from_collection([(&quot;apple&quot;, 2), (&quot;banana&quot;, 4), (&quot;apple&quot;, 3)], type_info=Types.TUPLE([Types.STRING(), Types.INT()]))<br>keyed = data.key_by(lambda x: x[0])  # Key by the first element (fruit name)<br>keyed.print()<br>env.execute(&quot;KeyBy Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>KeyedStream by &#39;apple&#39; and &#39;banana&#39;</pre><h3>5. Reduce</h3><p>Aggregates elements of the same key into a single value.</p><p><strong>Use Case</strong>: Summing or finding the minimum/maximum value for a group.</p><p><strong>Example</strong>:</p><pre>keyed = data.key_by(lambda x: x[0])  # Group by fruit name<br>reduced = keyed.reduce(lambda x, y: (x[0], x[1] + y[1]))  # Sum the values for each key<br>reduced.print()<br>env.execute(&quot;Reduce Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>(&#39;apple&#39;, 5)<br>(&#39;banana&#39;, 4)</pre><h3>6. Window</h3><p>Groups elements into windows for time-based or count-based aggregations.</p><p><strong>Use Case</strong>: Perform aggregations over fixed intervals.</p><p><strong>Example</strong>:</p><pre>from pyflink.datastream import TimeCharacteristic, TumblingProcessingTimeWindows<br>from pyflink.common.time import Time<br>env.set_stream_time_characteristic(TimeCharacteristic.ProcessingTime)<br>data = env.from_collection([(&quot;key1&quot;, 1), (&quot;key2&quot;, 2)], type_info=Types.TUPLE([Types.STRING(), Types.INT()]))<br>keyed = data.key_by(lambda x: x[0])<br>windowed = keyed.window(TumblingProcessingTimeWindows.of(Time.seconds(10)))  # Tumbling window of 10 seconds<br>aggregated = windowed.sum(1)  # Sum values within the window<br>aggregated.print()<br>env.execute(&quot;Window Transformation&quot;)</pre><h3>7. Union</h3><p>Combines two or more streams into one.</p><p><strong>Use Case</strong>: Merge streams from multiple sources.</p><p><strong>Example</strong>:</p><pre>data1 = env.from_collection([1, 2])<br>data2 = env.from_collection([3, 4])<br>unioned = data1.union(data2)  # Combine both streams<br>unioned.print()<br>env.execute(&quot;Union Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>1<br>2<br>3<br>4</pre><h3>8. Connect and CoMap</h3><p>Combines two streams but keeps their types separate.</p><p><strong>Use Case</strong>: Process streams with different types together.</p><p><strong>Example</strong>:</p><pre>stream1 = env.from_collection([1, 2])<br>stream2 = env.from_collection([&quot;a&quot;, &quot;b&quot;])<br>connected = stream1.connect(stream2)<br>mapped = connected.map(lambda x: x * 2, lambda y: y.upper())  # Process each stream separately<br>mapped.print()<br>env.execute(&quot;Connect and CoMap Transformation&quot;)</pre><p><strong>Output</strong>:</p><pre>2<br>4<br>A<br>B</pre><h3>9. Process Function</h3><p>Provides low-level access for advanced transformations.</p><p><strong>Use Case</strong>: Stateful or custom transformations.</p><p><strong>Example</strong>:</p><pre>from pyflink.datastream.functions import ProcessFunction<br>from pyflink.common.typeinfo import Types<br><br>class CustomProcessFunction(ProcessFunction):<br>    def process_element(self, value, ctx):<br>        self.output.collect(f&quot;Processed: {value}&quot;)<br>        data = env.from_collection([1, 2, 3])<br>        processed = data.process(CustomProcessFunction(), Types.STRING())<br>        processed.print()<br>        env.execute(&quot;Process Function Example&quot;)</pre><p><strong>Output</strong>:</p><pre>Processed: 1<br>Processed: 2<br>Processed: 3</pre><h3>B. Table API Transformations</h3><p>The Table API offers SQL-like operations for declarative transformations.</p><h3>1. Select</h3><p>Extract or transform columns.</p><p><strong>Example</strong>:</p><pre>from pyflink.table import EnvironmentSettings, TableEnvironment<br><br>env_settings = EnvironmentSettings.in_streaming_mode()<br>table_env = TableEnvironment.create(env_settings)<br>data = table_env.from_elements([(1, &#39;Alice&#39;), (2, &#39;Bob&#39;)], [&#39;id&#39;, &#39;name&#39;])<br>result = data.select(&quot;id, name.upper_case AS name_upper&quot;)<br>result.execute().print()</pre><h3>2. Filter</h3><p>Filter rows based on a condition.</p><p><strong>Example</strong>:</p><pre>filtered = data.filter(&quot;id &gt; 1&quot;)<br>filtered.execute().print()</pre><h3>3. GroupBy and Aggregate</h3><p>Aggregate rows based on a group.</p><p><strong>Example</strong>:</p><pre>grouped = data.group_by(&quot;name&quot;).select(&quot;name, COUNT(id) AS count&quot;)<br>grouped.execute().print()</pre><h3>4. Window Aggregations</h3><p>Perform aggregations on time windows.</p><p><strong>Example</strong>:</p><pre>from pyflink.table.window import Tumble<br>from pyflink.table import expressions as expr<br><br>windowed = data.window(Tumble.over(expr.lit(10).seconds).on(&quot;timestamp&quot;).alias(&quot;w&quot;)) \<br>    .group_by(&quot;w, name&quot;) \<br>    .select(&quot;name, COUNT(id) AS count&quot;)<br>windowed.execute().print()</pre><p>These transformation operations allow for diverse use cases, from simple filtering to complex aggregations and windowing. The <strong>DataStream API</strong> is more flexible and fine-grained, while the <strong>Table API</strong> provides SQL-like declarative capabilities for high-level stream processing. Choose the API based on your use case and requirements!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8455e6bdb689" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>