<?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 akhil anand on Medium]]></title>
        <description><![CDATA[Stories by akhil anand on Medium]]></description>
        <link>https://medium.com/@akhilanandkspa?source=rss-3eb6dce9541c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nUbKjPq62Q6zoiTgCzpcMg.png</url>
            <title>Stories by akhil anand on Medium</title>
            <link>https://medium.com/@akhilanandkspa?source=rss-3eb6dce9541c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:32:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akhilanandkspa/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[Kafka: A Deep Dive into Event-Driven Architecture]]></title>
            <link>https://akhilanandkspa.medium.com/kafka-a-deep-dive-into-event-driven-architecture-5b9f825b1041?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9f825b1041</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 30 Mar 2025 10:10:15 GMT</pubDate>
            <atom:updated>2025-03-30T10:10:15.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Xmz-x04VxWeReBr.jpg" /><figcaption><a href="https://www.google.com/search?sca_esv=44249e2b9fce9dc7&amp;sxsrf=AHTn8zodjBF6FfmaoacRMqT5sc65HsOyfA:1742412201942&amp;q=apache+kafka&amp;udm=2&amp;fbs=ABzOT_CWdhQLP1FcmU5B0fn3xuWpA-dk4wpBWOGsoR7DG5zJBjLjqIC1CYKD9D-DQAQS3Z44LBK6yTXN_5587Z3ya9D7DSaxM-14xIFnNO9Sk1S85Wotw2J1XpzcBzRSFgdOihKdV2e9H5EN7JLl-Zferp1h12XKIO44QVt_s8tMVfbhKNB26H2t0EdqohgNG0ZspWkbqTOpkndD5Q0VYi-gFNsVrxvlwQ&amp;sa=X&amp;ved=2ahUKEwiUi-Wi75aMAxWwhq8BHSgXDWEQtKgLegQIHRAB&amp;biw=1920&amp;bih=911&amp;dpr=1#vhid=C1ha5-vJil0xKM&amp;vssid=mosaic">Source</a></figcaption></figure><p><strong><em>Introduction</em></strong></p><p>Kafka is a distributed event streaming platform built to handle real-time data efficiently. It functions as a messaging system based on a publish-subscribe (pub-sub) architecture, where publishers send messages, and subscribers read those messages/records.</p><p><em>What is </em><strong><em>pub-sub</em></strong><em> architecture?</em><br><em>Imagine </em><strong><em>Akhil </em></strong><em>and </em><strong><em>Himanshu </em></strong><em>are chatting on a WhatsApp messaging app;</em></p><ul><li><em>Akhil sends a message: Akhil is a </em><strong><em>publisher </em></strong><em>because he generates the message.</em></li><li><strong><em>WhatsApp </em></strong><em>acts as Kafka, receives the message, and holds it for a temporary period (Kafka topic). Let’s assume you have activated the disappearing message setting, which holds the message for a day.</em></li><li><em>Himansu’s (</em><strong><em>consumer</em></strong><em>) phone receives the message and consumes the message</em></li></ul><p><em>What does distributed mean?</em></p><p>Kafka operates as a <strong>distributed system</strong>, meaning it runs across multiple nodes, often spread across different data centers. This enhances <strong>fault tolerance, scalability, and availability</strong>, ensuring data reliability even if some nodes fail.</p><p><em>What is a message in Kafka?</em></p><p><em>A </em><strong><em>message</em></strong><em> is an individual unit of data (or record) sent to the Kafka </em><strong><em>topic</em></strong><em> (a logical queue where messages are stored). Messages can be anything from logs, events, transactions, or real-time data stream applications used for processing.</em></p><pre># message/record<br><br>{&quot;Name&quot; : &quot;Akhil&quot;,<br> &quot;Gender&quot;: &quot;Male&quot;}</pre><p><em>What is a real-time data stream?<br></em>A continuous flow of records can be produced and consumed with minimal latency. Listing a few examples of real-time data;</p><ul><li>E-Commerce order</li><li>You can find cricket scores on any cricketing app.</li><li>Bank OTP, credit/debit event.</li></ul><p><em>What is Kafka not used for?</em></p><ul><li><em>Kafka is not a database, though it holds data for a temporary period. It’s been designed for streaming</em></li><li><em>It holds messages for a configurable period(the period can be days/weeks).</em></li><li><em>It doesn’t support relational data structure, but we can process data using ksqlDB.</em></li></ul><p><strong><em>Why Kafka?</em></strong><br>Kafka is a distributed system that retains data for a configurable period, providing fault tolerance and low latency due to its pub-sub architecture. Its distributed design enables efficient scalability, allowing it to handle massive volumes of data seamlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*vGx_NYoBLNpo9S_tW04gMw.png" /><figcaption>Figure : 1</figcaption></figure><p>The key parameters of Kafka are<strong> Producer </strong>and <strong>consumer.</strong> Don’t worry; we will understand all these things in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*6spaK-Ts_fmbAFoEnotwXg.png" /><figcaption>Diagramatic Representation of Kafka</figcaption></figure><p>Let’s understand each component of Kafka, as these components make it a unique tool in the market, widely used as an efficient real-time data streaming engine in the industry.</p><h4>1. Producer</h4><p>Producers are responsible for processing data in real time. There are many methods to send data to a Kafka queue, but the most popular and commonly used ones are:</p><p><strong><em>Synchronous Mode</em></strong></p><p>In synchronous mode, Kafka waits before sending the next message until it receives an acknowledgment that the previous message was successfully completed.</p><p><strong>Use Cases:</strong></p><ul><li>OTP messages for bank transactions, where message delivery must be guaranteed.</li></ul><p><strong><em>Asynchronous Mode</em></strong></p><p>Also known as fire-and-forget mode, this method does not wait for acknowledgment from the previous message and continuously sends new messages to Kafka. This leads to data loss and inconsistency.</p><p><strong>Use Cases:</strong></p><ul><li>Micro-level data, such as buyer impressions and clicks on an app, where inconsistency does not significantly impact decision-making.</li></ul><h4><strong>2. Broker</strong></h4><ul><li>In simple terms, <strong>Kafka Brokers</strong> are servers built on <strong>commodity hardware</strong> that store and manage data within a Kafka cluster. They act as the backbone of Kafka, enabling efficient data flow.</li><li><strong>Producers</strong> send messages to brokers, and <strong>consumers</strong> retrieve messages from them. (Although multiple components are involved in this process, they will be explained later in this blog.)</li><li>To ensure fault tolerance and high availability, Kafka replicates each partition across multiple brokers. One broker acts as the Leader, while the others serve as Followers.</li><li>If a Leader broker fails, one of the Follower brokers automatically takes over, ensuring that data processing continues without disruption.</li></ul><h4><strong>3. Topics</strong></h4><p>A Kafka Topic is similar to a YouTube channel — just as each channel provides specific content, a Kafka cluster can have multiple topics, each dedicated to a specific type of message.</p><h4><strong>Why Do We Need Multiple Topics?</strong></h4><ul><li>Suppose you have <strong>multiple OTT subscriptions.</strong></li><li>You use <strong>Netflix</strong> for Hollywood movies.</li><li>You use <strong>Amazon Prime</strong> for Bollywood content.</li><li>If you want to watch a <strong>Bollywood movie</strong>, you’ll go <strong>directly to Amazon Prime</strong>, saving time.</li></ul><p>Similarly, <strong>Kafka consumers subscribe to specific topics</strong>, knowing exactly where to read data from. Similarly, Kafka producers directly write to that topic. This results in:</p><ul><li><strong>Faster data access</strong></li><li><strong>Lower latency</strong>: quick message retrieval</li><li><strong>Efficient processing</strong>: each consumer reads only relevant messages.</li></ul><h4>4. Partitions</h4><p>Partition is like multiple playlists within a YouTube channel. You can go and watch a desired video ( Python Videos, DSA Videos, etc). Playlist, which consumes a very small amount of time to search for your video. This playlist is known as Kafka partitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*QxPS56u75_J8xeXEOxaZBQ.png" /><figcaption>Figure : Partition</figcaption></figure><p>Imagine you’re working at a giant e-commerce company where thousands of customers place orders simultaneously. All these order events are stored in a Kafka order Events topic.</p><p>If we were to process all events in a single queue, it would create bottlenecks and lead to latency issues. To solve this, Kafka divides the topic into multiple partitions, enabling the parallel processing of data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*xcTrQ3iyrAiWzmPAaMnT9g.png" /><figcaption>Figure : 2</figcaption></figure><ul><li>Partitions are configurable, the user can create any number of partitions.</li><li>It sequentially stores data. The records that would be generated first would be stored first in the offset.</li></ul><p><em>Each partition in Kafka is divided into multiple </em><em>offsets. An </em><em>offset is similar to an index in programming, where each offset uniquely identifies a record’s position within a partition.</em></p><h4>5. offset</h4><p>Offset is an index in Kafka, assigned sequentially with each partition. It starts from 0 , and the last pointer index would be n-1.</p><ul><li>It is immutable once the record is written in a particular offset, it can’t be changed.</li><li>Consumers track the offset to avoid processing the same record again and again, this is done by using Offset Commit .</li></ul><p><strong>Offset Commit</strong>:-<strong> </strong><em>Offset is the index and </em><em>Commit is the process where the consumer notifies the broker that it has successfully processed the message up to a certain offset.</em></p><ul><li>Offset Commit helps Kafka consumers keep track of the last processed message. It stores the pointer (offset) of the last successfully processed message so that if the system crashes and restarts, it doesn’t start reading from the beginning (Offset 0). Instead, it resumes processing from the last committed offset.</li></ul><p>Let’s look at a few scenarios of how you will understand the internals of offset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*70ahCkQ37qptVuFWfIGG-Q.png" /><figcaption>Figure : 3</figcaption></figure><p>As seen in the figure above, a Kafka topic consists of multiple <strong>partitions</strong>, and each partition has a <strong>sequence of offsets</strong>.</p><ul><li>In Partition 1, all the offsets are empty. If a partition does not contain any records, the offset = -1, indicating that no messages have been produced yet.</li><li>In Partition 2, only the first record is stored, the offset = 0.</li><li>In Partition 3, if there are two records, the offsets will be offset=1.</li></ul><h3>How does the Kafka Producer publish data on the Kafka topic?</h3><p>The role of the producer is to not only publish the data to the Kafka topic but also decide to which topics and partitions a message should be sent.</p><h4><strong>Message without key</strong></h4><p>As the name specifies, the producer will push the message to the Kafka topics without any key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*RkSXGa0GHYlsxPHLmAeSqA.png" /><figcaption>Figure : 4</figcaption></figure><p>Messages like <strong>Hi, Hello</strong> etc. do not have a key-value pair; they are simple messages without a key. In Kafka, such messages are distributed across partitions in a round-robin fashion.</p><ul><li>The <strong>0th offset</strong> of each partition is filled first.</li><li>Then, the <strong>1st offset</strong> of each partition is filled.</li><li>This process continues sequentially across all partitions.</li></ul><p>Since there is no key to determine partition assignment, Kafka ensures an even distribution of messages across available partitions.</p><p><strong>Message With Key</strong></p><p>When records contain key-value pairs, Kafka uses the concept of consistent hashing to distribute records across Kafka topic partitions.</p><p>Let’s consider a scenario where producers push multiple records with message keys into a Kafka topic that has been configured with three partitions. In this context, the question arises: <strong>How does Kafka determine the location of each record?</strong></p><p>The key plays a crucial role in identifying the partition and its offset. In this example, we will use the formula:</p><p><strong>partition = (key/number of partitions)</strong></p><p>Kafka records are fed sequentially. Suppose <strong>message 1</strong> and <strong>message 2</strong> are pushed at two different timestamps, 9:30 am and 9:31 am, respectively. If <strong>message 1</strong> is the first message pushed to a specific partition, it will be stored at <strong>offset 0</strong>.</p><pre># I have configured three partitions within the kafka topic<br>record 1 = {3,&quot;Akhil&quot;},    #partition=3%3=0th Parition<br>record 2={4,&quot;27&quot;}          #partition=4%3=1st Parition<br>record 3={5,&quot;Male&quot;}        #partition=5%3=2nd Parition<br>record 4={6,&quot;Anand&quot;}       #partition=6%3=0th Parition<br>record 5={7,&quot;Bihar&quot;}       #partition=7%3=1st Parition<br><br><br>Result :- <br>                      offset 0          offset 1       offset 2<br>Partition 0           Akhil             Anand<br>Partition 1           27                Bihar<br>Partition 2           Male</pre><h4>6. Consumer</h4><p>The consumer, also known as the subscriber, reads the data pushed by the producer into the Kafka queue. It retrieves data from Kafka topics.</p><p><em>A common question is how the consumer reads data from topics. Does it require a signal from the broker, or does it have its own mechanism to read data? </em><br>Both scenarios are possible, but the most efficient approach is the polling request concept. Instead of waiting for a signal from the broker, the consumer continuously reads data from Kafka topics using polling requests.</p><p><em>One major consideration is determining how the consumer reads data: does it start from the latest message or the oldest message? </em><br>This behavior is configurable when defining consumer properties. You must specify whether the consumer should start reading from the newest message or the oldest message. For the newest message, the configuration would be latest, while for the oldest message, it would be earliest.</p><p><em>How many consumers should be defined within a single Kafka topic?</em></p><p>The number of active consumers in a consumer group should always equal the number of Kafka partitions. If there are more consumers than partitions, the additional consumers will remain idle until a new partition is created or an existing consumer crashes.</p><p><strong>7. Backpressure</strong></p><p>Backpressure is a scenario in which the rate of producing the data inside Kafka topics exceeds the rate of reading the data from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2IJdnlYL0v1bsgG4.png" /><figcaption><a href="https://www.google.com/search?sca_esv=32d9cf6431c6c5c7&amp;sxsrf=AHTn8zqCfAaJm2CKiBGj5ZImOd6HYRt_Xw:1743326365928&amp;q=kafka+backpressure+image&amp;udm=2&amp;fbs=ABzOT_CWdhQLP1FcmU5B0fn3xuWpA-dk4wpBWOGsoR7DG5zJBjLjqIC1CYKD9D-DQAQS3Z44LBK6yTXN_5587Z3ya9D7DSaxM-14xIFnNO9Sk1S85Wotw2J1XpzcBzRSFgdOihKdV2e9H5EN7JLl-Zferp1h12XKIO44QVt_s8tMVfbhKNB26H2t0EdqohgNG0ZspWkbqTOpkndD5Q0VYi-gFNsVrxvlwQ&amp;sa=X&amp;ved=2ahUKEwj6-pLmvLGMAxUGTWwGHckNGIQQtKgLegQIFRAB&amp;biw=1920&amp;bih=911&amp;dpr=1#vhid=sWV8FHUSqGwRDM&amp;vssid=mosaic">Source</a></figcaption></figure><p>Let’s consider a YouTube scenario: You have subscribed to multiple YouTube channels, and all of them publish new videos at the same time. As a single person, you can’t watch all the videos simultaneously. Now, imagine that all these videos are important to you. <br><strong>What would you do?</strong><br>You might ask more people (like friends or family) to watch the videos for you, thereby distributing the load. By doing this, you effectively reduce the pressure on yourself by sharing the task.</p><p><em>Kafka similarly handles backpressure. When there is too much data for a single consumer to process, Kafka adds more consumers to the consumer group to distribute the load, thus reducing the pressure on individual consumers.</em></p><p><strong>8. Consumer Group</strong></p><p>Consumer Group is a collection of consumers that work together to read the message from a topic.</p><p>Let’s consider a real-life example: when you try to log in to your Amazon account, you receive a One-Time Password (OTP) via both email and SMS. In this scenario, the OTP is generated once but delivered through two different channels.<br>Similarly, in Kafka, a single topic can provide data to multiple consumer groups. For instance, the same Kafka topic containing OTP messages can be consumed by two different consumer groups: one responsible for sending OTPs via email and the other for sending OTPs via SMS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*J4DGZm073jhH912pQAmqpw.png" /><figcaption>Figure : 5</figcaption></figure><p><strong><em>Summary</em></strong></p><p>Kafka is a real-time event streaming system, efficiently handles high throughput, and is fault-tolerant. It works on Pub-Sub architecture, which makes it highly efficient for real-time analytics use cases. Linkeding, Netflix, Uber, etc, are some of the prominent names using Kafka to achieve scalability and fault tolerance.</p><p><strong><em>References</em></strong></p><p>A big shoutout to Aritra Das! His insightful blog<a href="https://medium.com/inspiredbrilliance/kafka-basics-and-core-concepts-5fd7a68c3193#:~:text=Kafka%20works%20as%20a%20cluster,available%2C%20and%20fault%2Dtolerant.&amp;text=Kafka%20stores%20data%20as%20a,be%20processed%20in%20different%20methods."> Kafka Basics and Core Concepts</a> inspired me to dive into learning Kafka.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9f825b1041" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hive Beyond Basics: Part I]]></title>
            <link>https://medium.datadriveninvestor.com/apache-hive-beyond-basics-part-i-1f2560e4f487?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2560e4f487</guid>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 17:04:56 GMT</pubDate>
            <atom:updated>2023-10-29T09:35:39.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GbbbcxG9X7JwSquu.jpeg" /><figcaption><a href="https://www.google.com/search?q=beyond+basics+mountaineer&amp;tbm=isch&amp;ved=2ahUKEwjTi8GEtcOBAxW9mmMGHSjMAssQ2-cCegQIABAA&amp;oq=beyond+basics+mountaineer&amp;gs_lcp=CgNpbWcQAzoECCMQJzoFCAAQgAQ6BggAEAgQHjoECAAQHjoHCAAQGBCABFDhAVjsFGD4FWgAcAB4AIAB3AGIAcUOkgEGMC4xMi4xmAEAoAEBqgELZ3dzLXdpei1pbWfAAQE&amp;sclient=img&amp;ei=1UEQZZPNL721juMPqJiL2Aw&amp;bih=1163&amp;biw=2400&amp;rlz=1C1VDKB_enIN1033IN1033#imgrc=HqPqemXJesbq1M">Source</a></figcaption></figure><blockquote><strong>Overview</strong></blockquote><p>Welcome back! I hope you enjoyed the previous article. Let&#39;s delve deeper into Apache Hive. One question on everyone&#39;s mind is why Hive, with its SQL-like functionality, is given such significant importance within the big data community. Apache Hive is indeed an exceptional tool, and it possesses special features that set it apart from others. These features include Hive&#39;s UDFs, partitioning, and bucketing. Don&#39;t worry, by the end of this article, you will be able to understand all the technical jargon.</p><blockquote><strong>Bucketing and Partitioning</strong></blockquote><h4><strong>Bucketing</strong></h4><p>When dealing with big data, a significant challenge is data skewness. If you’re processing a large dataset like 100GB, data skew can lead to uneven data distribution, causing some specific nodes to bear a disproportionate load. This results in two problems:</p><ol><li>The overloaded node takes too long to process its data.</li><li>The overloaded node might fail to handle the excessive data.</li></ol><p>To address this issue, bucketing is introduced. It clusters data in a manner that minimizes skewness, ensuring a more even data distribution among the nodes. The key to achieving this even distribution is hashing.</p><p><strong>How Hashing Works?<br></strong>Suppose you have an employee table, which consists of columns like employee ID, employee Name, State of belonging, and Age. Let’s see how bucketing works in this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*IHyCeccstR6W8BH8FvveGw.png" /><figcaption>Image 1</figcaption></figure><p>Let’s say I am selecting the <strong>State </strong>column for bucketing (you can choose any column based on your use case or observation). Suppose I want to create buckets using the modular division of the length of the state by 4. I have obtained the hashing/bucketing outcome as shown in the image below and have segmented it into different buckets. Don’t worry, In Hive, once you write the bucketing syntax, Hive will automatically perform all the operations for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*u7e44mOxz5f28zAD-5zzeA.png" /><figcaption>Image 2</figcaption></figure><p>Now, based on the provided data, Hive has successfully created four distinct clusters of data. These data clusters are nearly evenly distributed, ensuring that each node will receive almost an equal amount of data to process. Hence, processing times will be similar across all nodes, and the system will be less prone to faults or failures.</p><p>Bucketing helps in improving join operations on larger datasets. It ensures the even distribution of data. It does not store any metadata info and directly assigns the data to a bucket with the help of a hashing function.</p><h4>Partitioning</h4><p>Suppose you are working in an e-commerce company, if you have a dataset that contains day-wise sales data for each state over the past 7 years, and you need to extract information for the month of April 2022, using traditional filtering methods would require scanning the entire table to retrieve the desired results. To optimize this process and avoid the overhead of scanning the entire dataset, you can implement partitioning.</p><p>Partitioning is a technique used to organize and structure your data in a way that allows for faster and more efficient data retrieval. By partitioning the data, you can segregate it into distinct subsets, often based on a specific attribute like date or state in this case. With this approach, when you need data for April 2022, you can directly access the partition corresponding to that timeframe, rather than scanning the entire dataset, resulting in significantly improved query performance and reduced processing time.</p><blockquote><strong>Do and Don’t of Partitioning</strong></blockquote><p>Please consider the following common practices when implementing data partitioning:</p><ol><li>Avoid using Primary/Incremental IDs for partitioning: Primary or incremental keys are designed to store unique records. If you have 10 million rows of data and create 10 million partitions based on these keys, it can lead to performance issues.</li><li>columns with repeated values: In the example mentioned (please refer to Image 2), the ‘state’ column can be an excellent choice for partitioning. This is because it contains values that are repeated multiple times, making it suitable for organizing and optimizing data storage.</li></ol><p><strong>How does partitioning retrieve data quickly?</strong></p><ol><li><strong>Partition Column</strong>: Choose the column that you want to use as the partitioning column.</li><li><strong>Subdirectory Creation</strong>: A separate subdirectory is created for each partition.</li><li><strong>Metadata Information</strong>: Metadata keeps track of the location and timestamp for each partition. When performing partitioned queries, metadata efficiently skips irrelevant partitions and directs the query to the specific subdirectory where the desired partition is stored. This optimization reduces the time and space required to fetch and process data through partitioning.</li></ol><p>Partitioning in Hive</p><p><strong>Static Partition:</strong><br>i. Static partitioning is performed manually, where you define the partitions explicitly.<br>ii. It is generally faster than dynamic partitioning.<br>iii. It is suitable for ad hoc use cases where you have control over the partition values.</p><p><strong>Dynamic Partition:<br></strong>i. Dynamic partitioning is done automatically by Hive.<br>ii. Provide the partition column name to Hive, and Hive analyzes the data to extract unique values from the column and creates partitions accordingly<br>iii. Slower in Execution as compared to static Partition.</p><blockquote><strong>UDFs(User defined functions)</strong></blockquote><p>Talking about programming language, every language has its own built-in function to do some operations. Some common aggregate functions are Min(), Max(), Count(), add(), etc. The major concern is do all these inbuilt functions can solve our all business use cases the answer is a big no we need some flexibility to build custom functions that can fulfill the ad-hoc requirements. Here HQL UDFs function plays a pivotal role it gives the flexibility to write custom UDFs in multiple scripting languages (Python, java, etc) which is further utilized by hive query to get the desired result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*JUd-TMO5i49migra.png" /><figcaption><a href="https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2016/11/MapReduce-Anatomy-MapReduce-Tutorial-Edureka-1-768x286.png">Source</a></figcaption></figure><h3>Joins</h3><p>Joins help in combining two or more tables. Suppose you are working in an e-commerce organization, and the management wants to see the Current Month’s Gross Merchandise Value on the buyer and state levels. You have been provided with three tables: order_master, user_master, and state_master. You can achieve the above result by combining all three of the mentioned tables, and all these tables can be combined using joins.</p><h4>Reduce Side Join</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Twk0K1A5ZGQqCriaWmHAOQ.png" /><figcaption>Image 3</figcaption></figure><ol><li><strong>Mapper:</strong> In Mapper different datasets are mapped in Key Value Pairs. Let’s Say you have Dataset A and Dataset B each and every element of both datasets will be converted into a key : Value Pair.Key will be used in Joining the datasets. Please refer below image.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*UeXHxEsVrjP2wFy2XNUffg.png" /><figcaption>Image 4</figcaption></figure><p>2. <strong>Shuffling: </strong>The mapper splits each dataset into key-value pairs, but the system needs to group all similar datasets into one group. Here, shuffling comes into the picture, it makes a unique group of every unique record. Please refer below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/118/1*EqBGri7bEPSZO0NtkXY0yA.png" /><figcaption>Image 5</figcaption></figure><p>3. <strong>Reducer:</strong> As unique key-value pairs are generated earlier for both datasets, the reducer now combines all the unique keys present in both datasets.</p><p>What happens if some keys are not present in dataset A and some keys are not present in dataset B?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*R78ul8BE3EzoMC-WY7MinQ.png" /><figcaption>Image 6</figcaption></figure><p>Please refer the Image 6 , Keys 1 is present in dataset A but not present in dataset B and vice versa for Key 5. Let’s see step by step how join works;</p><ol><li>Keys 2, 3 &amp; 4 match in both datasets hence they will be combined together.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*mcXUNukC_63EwLvsNxu6MQ.png" /><figcaption>Image 7</figcaption></figure><ol><li>Key 1 is not present in dataset B, you need to create Key 1 an NA/NULL value in dataset B.Key 5is not present in dataset A, you need to create Key 5an NA/NULL value in dataset A.</li></ol><p>After emitting the NULL value in both datasets combine the datasets using reduce side join, the final outcome will look like below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*O4z_--6TKXc12eXM_Q_hUg.png" /><figcaption>Image 8</figcaption></figure><p><strong>Advantages &amp; Disadvantages</strong></p><ol><li>It handles a large set of data where the out-of-memory issue occurs.</li><li>fault tolerant in nature. Suppose reduce failers during the reduce phase the operation will start re-executing on another node.</li><li>It handles complex and non-equijoin (the key of two datasets does not match but still combines both the datasets as explained above).</li><li>Reduce side Joins are not a good choice for smaller datasets.</li></ol><p><strong>Ending Note</strong></p><p>Apache Hive developed by Meta, addresses coding-level challenges faced by analytics professionals to process batches of data. Many companies, including key players like Paytm and Amex, rely on Hive for their analytics tasks.</p><p>Thank you for reading this article. Happy learning🏫.</p><p>Subscribe to <em>DDIntel </em><a href="https://www.ddintel.com/">here</a>.</p><p>Submit your work to <em>DDIntel</em> <a href="https://datadriveninvestor.com/ddintelsubmission">here</a>.</p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/">here</a>.</p><p><a href="https://www.ddintel.com/"><em>DDIntel</em> </a>captures the more notable pieces from our <a href="https://www.datadriveninvestor.com/"><em>main site</em></a> and our popular <a href="https://medium.datadriveninvestor.com/"><em>DDI Medium publication</em></a>. Check us out for more insightful work from our community.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2560e4f487" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/apache-hive-beyond-basics-part-i-1f2560e4f487">Apache Hive Beyond Basics: Part I</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Apache Hive and Its Architecture]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/analytics-vidhya/an-introduction-to-apache-hive-and-its-architecture-15d511b52bd?source=rss-3eb6dce9541c------2"><img src="https://cdn-images-1.medium.com/max/1920/0*j1Piv9i5viLcn_bK.png" width="1920"></a></p><p class="medium-feed-snippet">Overview</p><p class="medium-feed-link"><a href="https://medium.com/analytics-vidhya/an-introduction-to-apache-hive-and-its-architecture-15d511b52bd?source=rss-3eb6dce9541c------2">Continue reading on Analytics Vidhya »</a></p></div>]]></description>
            <link>https://medium.com/analytics-vidhya/an-introduction-to-apache-hive-and-its-architecture-15d511b52bd?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/15d511b52bd</guid>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-warehousing]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 13:57:33 GMT</pubDate>
            <atom:updated>2023-09-24T13:57:33.049Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Machine Learning for SKU Sequencing: Improving E-commerce Listing Page]]></title>
            <link>https://ai.plainenglish.io/ranking-of-sku-on-plp-the-machine-learning-way-d5afacf2b701?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5afacf2b701</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 14 May 2023 18:25:12 GMT</pubDate>
            <atom:updated>2023-05-17T11:53:58.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SEps2G59ZZ1g7PFZ.png" /><figcaption><a href="https://pwpblog.wpengine.com/wp-content/uploads/2022/08/Ecommerce-Website-Promotion_Final.png">Source</a></figcaption></figure><blockquote><strong>Overview</strong></blockquote><p>Working in an e-commerce organization that operates in the B2B domain, we face the significant challenge of providing the most relevant products to our customers. When we refer to “most relevant,” we aim to offer products that align with current trends, have affordable prices, and cater to popular color choices, among other considerations.</p><p>The story begins when the strategy and marketing team were sitting together, having a rare moment of relaxation and camaraderie. The topic of product listing came up, and as we listened to the marketing team’s approach, we were shocked. Our reaction was <strong>What?????</strong></p><p>That casual conversation with the marketing team had now complicated our lives. We were compelled to reevaluate the product ranking logic and create something that would truly justify the way products were ranked. oring logic again and making something that will justify the product scoring.</p><blockquote><strong>Strategy team meeting</strong></blockquote><p>After the conversation with the marketing team, the entire strategy team, consisting of <a href="https://in.linkedin.com/in/himanshu-jaiswal-096a08a9"><strong>Himanshu Jaiswal</strong></a>, <a href="https://in.linkedin.com/in/sparsh-shah-28833259"><strong>Sparsh Shah</strong></a>, and myself, did a series of meetings to enhance the logic behind our product listing approach. We recognized the need to refine the system and ensure that it accurately reflected the value and relevance of each product.</p><blockquote><strong>Akhil’s Approach: Normalizing and Ranking Based on Sum of Normalized Scores ( Which was refuesed by whole team 😥😥😥😥..later i also agreed)</strong></blockquote><p>I personally am a great fan of the normalization approach for ranking. Let’s understand the working of normalization. Suppose I have three attributes Years of Experience, Age, and Salary will have to rank people based on the above three parameters then how can I do the ranking using Normalization?</p><p><strong>Step 1:</strong> We will convert all the columns into the same scale, which can be done via normalization. Normalization converts data in a column between values 0–1. As Age</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*HtuujQCayRp1WVh1rQlvjQ.png" /><figcaption>Normalization Fromula</figcaption></figure><p><strong>Step 2:</strong> Summing Normalized Columns for Career Performance Evaluation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*IDV-E6obDUke9EKdDM95Mg.png" /><figcaption>Figure: 2</figcaption></figure><p>If salary Would be given higher importance than age and years of experience, we can achieve the desired results by assigning different weights to each attribute. In product scoring, each attribute will have a specific weightage, and the score will be determined based on these weights. This is why normalization was not able to meet our requirements.</p><blockquote><strong>The Second Meeting, Himanshu Jaiswal’s Expertise</strong></blockquote><p>I was quite angry with Himanshu (well, he rejected my idea 🤣🤣🤣🤣). Before reaching a better conclusion Our discussion took a nonsensical turn, with questions like C<strong>an we do clustering? </strong>and <strong>Can we apply customized weights across every category?</strong> Directly or indirectly we were reaching near the marketing team approach. However, amidst all these conversations, a eureka moment occurred.</p><p><strong>Himanshu Jaiswal:</strong> Bhai, we need to approach product listing in a way that involves providing past data for each subcategory. Based on that data, a mathematical model can determine the significance of each attribute (The basic definition of Machine Learning 😁😁). Through our collective experience, we concluded that by using a supervised learning approach we cannot get the desired result.</p><p>After several discussions, we understood that we need to apply an approach that will set the weightage of each column by comparing a particular column with every other column and column itself and then assigning a score. Don’t worry if you are not able to digest it.</p><p>Before building the ML model, we had another major and important task to accomplish: the selection of attributes. Attributes play a crucial role in model building, as even one insignificant attribute can s reduce the overall performance of the model.</p><blockquote><strong>The Attribute Selection</strong></blockquote><p>After multiple rounds of discussion with the marketing team, we have reached a decision to select the following attributes.</p><ol><li><strong>Clicks:- </strong>Let’s take you as an example, imagine that you are browsing an eCommerce website in search of a knit t-shirt. As you scroll through the website, you come across a list of products, but you only click on those that meet your specific requirements. Factors such as color, price, and other considerations may influence your decision to click on a particular product. It’s important to note that the more clicks a product receives, the higher its chances of converting into actual orders.</li><li><strong>CTR(Click Through Rate):-</strong> <strong>If clicks are already taken why do we need to take the CTR?</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*5ZlXNURpWm07VurG3bftdg.png" /><figcaption>CTR Formula</figcaption></figure><p>Let’s consider the scenario of April 1, 2023. On that day, when users searched for sports shoes, there were a total of 100 clicks out of 1000 impressions. Additionally, Hawaii slippers received 95 clicks out of 800 impressions. If we only consider the number of clicks as a parameter, it may appear that the sports shoes performed well. However, when we consider the click-through rate (CTR) as a parameter, we find that Hawaiian slippers had a higher success rate on April 1, 2023. Therefore, it is important to take into account the CTR regardless of whether we have already considered the number of clicks or not.</p><p><strong>3. Conversion Rate:- </strong>Conversion is the focal point and ultimate objective of our efforts. The key to achieving conversions lies in ensuring that the clicks generated by users ultimately result in product orders. The higher the conversion rate, the greater the Gross Merchandise Value (GMV), which aligns with our ultimate goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*SFtMqPByNcstNJZbtvzbbA.png" /><figcaption>Conversion Rate</figcaption></figure><p>4. <strong>GMV:-</strong> The end goal is to achieve GMV from the listed product so this is one of the most important attributes of any product.</p><p>5. <strong>Wishlist Count:</strong>- Let’s consider a scenario where you encounter a product that captures your interest. However, due to certain circumstances, you are unable to make an immediate purchase. you decide to add the product to your wishlist, intending to buy it later.</p><p>During the analysis of our internal data, we discovered an interesting attribute. We observed a correlation between the number of wishlists a product receives and the corresponding Gross Merchandise Value (GMV) generated from that product. In other words, we found that products with a higher wishlist count, indicating a greater user desire to purchase, tend to yield a higher GMV. Based on this finding, we decided to incorporate the wishlist count as an attribute in our analysis.</p><p>6. <strong>VFM(Value for Money):- </strong>As a buyer, your satisfaction with a product can significantly influence your actions. If a product you purchased fails to meet your expectations, it can lead to frustration. You may express your dissatisfaction by contacting customer care or leaving a poor rating, indicating a lower value for money (VFM). Conversely, when a product exceeds your expectations, you are likely to give it a positive review with a 5-star rating. This suggests that higher ratings correlate with meeting buyers’ expectations, and there is a high probability that if one buyer is satisfied, others will be too. Thus, the concept of VFM plays a significant role in determining whether a product is perceived as good or not by the user.</p><p>7. <strong>Return:- </strong>The higher the number of returns, the greater the indication that the product is not meeting the needs or preferences of the buyers.</p><p>The model has been built with reverse scoring for returns. For instance, if product P1 has a return rate of 90%, then its return score would be 100% — 90% = 10%. On the other hand, if product P2 has a return rate of 0%, then its return score would be 100%.</p><p>After several meetings and a shared understanding between the marketing and strategy teams, we made the decision to proceed with the above-mentioned attributes for determining the rank of products. During these meetings, we clarified what should and should not be considered in our approach.</p><blockquote><strong>The Do’s and Don’t</strong></blockquote><p>Our organization mainly deals in the footwear and apparel segment, which are further divided into multiple categories. For example, footwear includes sports shoes, sneakers, slippers, sandals, and more. Similarly, apparel includes kurtis, t-shirts, and many more.</p><ol><li><strong>Avoid the Same Weightage across all categories:</strong> Previously, the product scores were distributed based on the platform level, disregarding the individual subcategories. However, we now recognize the need to assign scores on a category level.</li></ol><p><strong>Why do We need to distribute scores on the Category level?</strong></p><p>Distributing the product score on a category level is necessary due to the varying nature of attributes within each subcategory. For example, when users are browsing footwear, the click-through rate (CTR) may be lower compared to apparel. Consequently, the weightage of CTR should be different for footwear and apparel categories. This variation applies to other attributes as well. To ensure a more accurate ranking of products, it is essential to determine the weightage scores by subcategory, taking into account the specific characteristics and user behaviors within each category.</p><p><strong>2. Consideration of New Age parameter:-</strong> Initially<strong> </strong>We faced a dilemma when comparing newly introduced products, which struggled to find their target audience, with products that had been on the platform for 30 or 60 days. The latter had established influential factors such as conversion rate and GMV. However, it became apparent that the new products could potentially possess positive attributes such as a good wishlist count, high clicks, and impressive click-through rates. Despite these factors, their poor conversion rate and GMV resulted in a low ranking.</p><p>Himanshu Jaiswal(This guy has made my life difficult 😂😂😂😂), Expertise brought the idea of incorporating age as a factor in determining the product score. He suggested assigning higher age scores to newer products and lower age scores to older ones.</p><blockquote><strong>The Eureka Moment</strong></blockquote><p><a href="https://en.wikipedia.org/wiki/Principal_component_analysis#:~:text=Principal%20component%20analysis%20(PCA)%20is,the%20visualization%20of%20multidimensional%20data."><strong>PCA</strong></a>(principal component analysis) comes into the picture.</p><p><strong>Why Principal Component Analysis?<br></strong>We have Some Attributes like <strong>Clicks, Click through rate, Conversion, GMV, VFM</strong>, <strong>Wishlist Count</strong>, <strong>Age,</strong> and <strong>Return</strong> based on these attributes we want to provide a Score for each product<strong>. </strong>PCA helps in determining to score based on an interdependent and interdependent variation of a column.</p><p>Let’s Understand interdependency and interdependency. Suppose we have three columns Age, Weight, and Height I want to assign the weightage of each column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*cwHJtgYeutj5-GMdN1X0wQ.png" /><figcaption>Figure : 3</figcaption></figure><p>While observing the image provided above, it becomes evident that even a small variation in age can lead to a substantial change in both weight and height. Additionally, this slight age variation is also reflected in the intercolumnar dependencies between these attributes. Hence age will have a higher weightage as compared to the remaining column same way will get the weight of all the remaining columns.</p><p>One thing to keep in mind before applying PCA we need to standardize the data because columns with a large range of variations will dominate over the column with small variations.</p><p>Let’s assume we have obtained the weights from PCA, such as 0.55 for Age, 0.42 for Weight, and 0.38 for Height, the next steps would be as follows:</p><ol><li>Multiply the obtained weights with the actual values of each respective column. This step involves multiplying the weight of Age with the actual Age value, the weight of Weight with the actual Weight value, and the weight of Height with the actual Height value.</li><li>After multiplying with the significant weights, we obtain an actual score for each column. These scores represent the weighted contributions of each column to the overall analysis.</li><li>In order to ensure that the values are on a comparable scale, we need to normalize the scores(the Normalized Score varies from 0–1).</li><li>Once the scores have been normalized, sum up the normalized scores of all columns for each entry.</li><li>Finally, based on the normalized scores, we can rank the entries and determine their relative positions. The entries with higher normalized scores will be ranked higher, indicating their greater significance in the analysis.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YkMKPF1Hp8gS8klKcJl9bQ.png" /><figcaption>Figure: 4</figcaption></figure><blockquote><strong>Result</strong></blockquote><p>The significance of age determining factor in product scoring proved to be a game-changer for us. We observed that newer products achieved better rankings compared to older ones, despite the latter accumulating significant GMV and boasting higher conversion rates. considering the age of a product as a scoring factor provided valuable insights and allowed us to accurately assess its performance, ultimately reshaping our product ranking system. Attaching the snapshot of the original dataset’s outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzqwfkZiNpY07KcN3oTwhA.png" /><figcaption>Final Output</figcaption></figure><p>Upon reviewing the provided image, it is evident that the product with 0 GMV is ranked higher compared to the product with a significant amount of GMV. This observation raises concerns as it contradicts our expectations and the general understanding that higher GMV signifies better performance and success of a product.</p><blockquote><strong>Conlusion</strong></blockquote><ul><li>A big thanks to <a href="https://in.linkedin.com/in/himanshu-jaiswal-096a08a9"><strong>Himanshu Jaiswal</strong></a> for guiding me throughout the whole process.</li></ul><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5afacf2b701" width="1" height="1" alt=""><hr><p><a href="https://ai.plainenglish.io/ranking-of-sku-on-plp-the-machine-learning-way-d5afacf2b701">Machine Learning for SKU Sequencing: Improving E-commerce Listing Page</a> was originally published in <a href="https://ai.plainenglish.io/">Artificial Intelligence in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Warehouse Design For an E-Commerce Company]]></title>
            <link>https://akhilanandkspa.medium.com/data-warehouse-design-for-an-e-commerce-company-82f265050b25?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/82f265050b25</guid>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-warehousing]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 07:56:51 GMT</pubDate>
            <atom:updated>2023-03-19T07:56:51.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6MnNbj_rqhAhI0QU.jpg" /><figcaption><a href="https://www.google.com/search?q=mountain&amp;rlz=1C1VDKB_enIN1033IN1033&amp;sxsrf=AJOqlzUG351rT7INLKg-diqEbIgUTgWA1w:1678633976019&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=2ahUKEwi01OTu1tb9AhV1UGwGHcFBDTsQ_AUoAXoECAEQAw&amp;biw=1209&amp;bih=524&amp;dpr=1.13#imgrc=VvDLjQsY-3tsHM">Source</a></figcaption></figure><blockquote><strong>Introduction</strong></blockquote><p>Data Warehouse works as a centralized source for storing structured and unstructured data in a transformed form which further helps an organization to build better decisions out of those data. As it stores the cleaned and transformed data the storage cost(for current and historical data) is not that high. Google big query and Amazon Dynamo DB are some common examples of data warehouses.</p><blockquote><strong>Points to be considered before constructing data warehose.</strong></blockquote><p>Before constructing a data Warehouse you should keep these four points in your mind.<br>1. Understand the business process.<br>2. Define the grain (An individual row should explain the whole purpose of constructing a warehouse system).<br>3. Define the Dimensions (the static table which will help in deriving the insights out of data).<br>4. Define the Facts (the table which stores transactional data).</p><h3>Understanding the business process</h3><ol><li>Buyers will place the order &amp; the order would be placed from a particular seller.</li><li>Buyers can place multiple orders from multiple sellers.</li><li>The base price of the product.</li><li>Coupon amount if applied</li><li>Transaction type online or Cash on Delivery.</li><li>Logistics partner delivering the order.</li><li>Number of quantities ordered</li><li>Final status like delivered, RTO, DTO, or canceled.</li></ol><p><strong>When all the above pointers will be explained in a row we will be successfully able to define the grain.</strong></p><h3>Defining the Dimensions</h3><p>The Most important portion of warehouse modeling design, the Construction of the dimensional table will directly or indirectly help in making the better decision out of those data. Let’s understand each and every dimensional table in detail.</p><h4><strong>1. Buyer Info</strong></h4><p>Buyer info will store all the relevant information of buyers. i.e: Buyer Name, Buyer Phone, etc. for better optimization of data it’s better to construct another sub dimensional table that will store the buyer’s location info. Please See the below table for visual understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*KmmI-crv3ZvqwYIPBH5Y9Q.png" /><figcaption>Figure 1</figcaption></figure><h4>2. Seller Info</h4><p>In this table, we will store all the info about the seller like seller id, seller name, Seller Phone, products available, and location level info.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*oQhr5E36MX1_WLOb5wYLpQ.png" /><figcaption>Figure 2</figcaption></figure><h4>3. Status</h4><p>The status table stores relevant information about the order Journey. Suppose a buyer has ordered a product, the transaction can be either online payment or offline payment(COD), and you will construct a column that gives info about the payment type. once the order is placed it can either be delivered to the buyer or RTO (Return to Owner).<br>If the order will be delivered then it might be possible for the order to be returned from the buyer&#39;s end. so these different order statuses can be stored in the status column. This table will also store the order date info.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*DrOlZk_q98KfxuVHYU3sTQ.png" /><figcaption>Figure 3</figcaption></figure><h4>4. Logistics Partner</h4><p>Suppose a buyer has ordered a product and the seller has prepared the same order. Now it’s time for the logistics partner to deliver the order to the end user. So we need a separate dimensional table that will store info related to logistics partners. Each order will be associated with an individual Agent so we need to store the individual agent information in the sub dimensional table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*3WVWw2fz3gvlUz3aQW-9fw.png" /><figcaption>Figure 4</figcaption></figure><h3>Defining The Facts</h3><p>Facts store all the transactional data. The main aim is to construct the fact table to store the numerical data which is further combined with the dimensional table to give better data-driven info. Let’s see the pictorial representation of the facts Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*TsyH8NYsRrCbOBde_TX4sg.png" /><figcaption>Figure 5</figcaption></figure><p>Now you are able to define all the components needed to design a data warehouse model. Let’s Combine all these facts and dimensional table to construct the final data warehouse System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*Tk1zlRa5K2Z9GJtfvuM_FQ.png" /><figcaption>Figure 6</figcaption></figure><blockquote><strong>References</strong></blockquote><ul><li><a href="https://medium.com/geekculture/data-modeling-design-video-streaming-platform-e8aa4f121b1b">Data Modeling : Design Video Streaming Platform</a></li><li><a href="https://scandiweb.com/blog/data-warehouses-for-ecommerce-definition-examples-benefits/">eCommerce Data Warehouses: Definition, Examples &amp; Benefits</a></li></ul><p>That’s the end of the blog. Hope you enjoyed it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82f265050b25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Jargons Every Data Guy Should Know]]></title>
            <link>https://medium.com/geekculture/data-jargons-every-data-guy-should-know-283e01caa90b?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/283e01caa90b</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-engineering-101]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 12:45:04 GMT</pubDate>
            <atom:updated>2023-03-15T08:10:42.594Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nMbt8b_TV35eFDHd.jpg" /><figcaption><a href="https://www.google.com/search?q=thinking+image+of+a+person&amp;tbm=isch&amp;ved=2ahUKEwiI4Y3P-sT9AhXvndgFHShNAkEQ2-cCegQIABAA&amp;oq=thinking+image+of+a+person&amp;gs_lcp=CgNpbWcQAzIGCAAQCBAeMgYIABAIEB4yBggAEAgQHjIGCAAQCBAeOgQIIxAnOgUIABCABFDwDFjiHWC_H2gAcAB4AIABlgGIAdUMkgEEMC4xM5gBAKABAaoBC2d3cy13aXotaW1nwAEB&amp;sclient=img&amp;ei=iaEEZMj4Ou-74t4PqJqJiAQ&amp;bih=524&amp;biw=1209&amp;rlz=1C1VDKB_enIN1033IN1033#imgrc=ToY5oGm66FD3zM">Source</a></figcaption></figure><blockquote><strong>Introduction</strong></blockquote><p>If you are in Analytical Engineering Domain or Trying to make it, you must have heard some common data terminologies like ETL, ELT, Data Lake, Data Mart, etc. If you are not aware of all these terminologies then my friend this blog is for you, Let’s break all these terminologies into bits and pieces.</p><h3>1. ETL (Extract Transform &amp; Load)</h3><p>The most commonly found terminology in data-related job descriptions at LinkedIn😎.See the Figure below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*BWxNkXVlOQx8EH5txXb1kw.png" /><figcaption>Figure 1</figcaption></figure><p>Suppose You are working in an e-commerce Company &amp; the Finance Department of the company wants the purchase information of the last order for every buyer. Considering you need to do certain transformations to get the respective outcome. How will you do that?</p><ol><li><strong>Extract </strong><br>Your first &amp; foremost task will be to extract the data from the data source. Data Sources can be HDFS, NoSQL DB, etc. Now how will you Extract the data from the Data Sources don’t Worry I have a separate blog for this please click<a href="https://medium.com/ai-in-plain-english/mysql-python-connection-read-operations-c7cfbbd3830c"> <strong>here</strong></a>, Considering you will be using python for the data extraction.</li><li><strong>Transform<br></strong>Once data is extracted, it will be loaded into the temporary storage(As Shown in the above figure), Suppose you are using your local system to extract the data then extracted data would be loaded into your local device. After that, you will do certain transformations. Like applying the <strong>Max </strong>function to get the last purchase order date, <strong>Adding</strong> all the products amount present in a single order, etc. Now your transformation part is done then 😇 .</li><li><strong>Load<br></strong>We have loaded &amp; transformed the data now the next task will be to store the transformed data, here data warehouse comes into the picture. We load our cleaned &amp; transformed data into the data warehouse. Now, these cleaned data will be ready to give last order information to the Finance Department.</li></ol><p>Now you feel like wow ETL is fantastic stuff, hold on. ETL comes with certain limitations😥.</p><p><strong>What kind of limitations does ETL have?<br></strong>Suppose Finance &amp; Ops(Most Commonly Logistics) both come with ceratin requirements, i.e :-</p><ol><li>Finance wants the last order purchase date, Value &amp; number of products purchased in an order.</li><li>Ops Wants all the dispositions (message delivered on your phone about order Journey eg:- order picked, arrived in the city, delivered, etc) for the last two orders.</li></ol><p>Ideally, you have to make two ETL pipelines for the Separate use case (Finance &amp; Ops) and data is approximately the same in both cases. Loading the same data multiple times and storing them in different segments in a data warehouse will become a time-consuming &amp; Costly process to avoid this we use ELT.</p><h3>2. ELT (Extract Load &amp; Transform)</h3><ol><li><strong>Extract &amp; Load</strong></li></ol><p>Considering the above Finance &amp; Ops Use Case, Suppose Marketing &amp; Strategy teams will also come with certain requirements, instead of extracting data for a particular use case you will load the whole data from the data source &amp; load it into a target System. The target system is Data Lake.</p><p><strong>What is Data Lake? <br>Data Lake </strong>is a suitable place to store all the data. In simpler terms, you can say it’s a data dump where you can load structured &amp; unstructured data from different-different data sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*t1Gx0pvHFOb6qws28TMFHg.png" /><figcaption>Figure 2</figcaption></figure><p><strong>2. Transform<br></strong>Once the data is loaded then the transformation part comes into the picture. Data transformation(based on multiple use cases) will be done on data stored in the data lake &amp; then these transformed data would be stored in the data warehouse for further analytical operations.</p><h3><strong>3. Data Warehouse</strong></h3><p>Data Warehousing is the process of holding transformed data that would help the analytical team to perform various analyses &amp; predictions.<br>eg:- Hive and Redshift are common examples of data warehousing.</p><h3><strong>4. Data Marts</strong></h3><p>Whenever you are building ETL or ELT pipeline your job is not only to store the transformed data, but the storage of data should be in an optimized / Segmented Fashion.</p><p><strong>What does Optimization of storage mean here?<br></strong>Assuming the above Example, You have loaded all the data related to the Buyer’s last purchase date, order value &amp; number of products ordered instead of loading all these data into a single table in the data warehouse you will create multiple facts &amp; dimensional ( Will discuss in some time).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*0DUllV6UaDvn-o4IHY6gmg.png" /><figcaption>Figure 3</figcaption></figure><h3><strong>5. Facts Table</strong></h3><p>The facts table is storing the data which changes in near real-time, Suppose you are working in an e-commerce company and store all the orders placed till now on an hourly basis, this orders table will be a Facts table.<br>In a simpler way any table which changes continuously and stores numerical data eg:- daily Sales, Daily Users Active, and Daily orders Placed are known as a Facts table.</p><h3>6. Dimensional Table</h3><p>The data table does not continuously changes. Suppose a table contains a list of states in India. This won’t be changed daily once the data is stored we are ready to go. So dimensional table store almost static data. <br><strong>What is the need of storing static data/Dimensional Tables?</strong></p><p>Dimensional tables help in giving better insight. It plays a pivotal role in analytical use cases. Suppose you have yesterday’s sale(using Facts Table), how can you get to know the insight, as the dimensional table contains static data like state, city, etc once you will find yesterday’s sale, then with the help of the dimensional table you can also identify which state had highest sale &amp; which one had the lowest.</p><h3>7. OLTP(Online Transaction Processing)</h3><p>OLTP is used for processing transactional data.<br><strong>what does transactional data mean?<br></strong>when large numbers of data processed concurrently over real-time are known as transactional data.</p><p>a. Main Goal of OLTP is to capture data in real-time.<br>b. It is being Used for faster CRUD operations(e.g:- read,write,delete etc.)<br>c. Data present here in normalized form.<br>d. Preferably not used in analytical use cases as data is normalized &amp; needs more and more join which makes querying costly.</p><h3><strong>8. OLAP(Online Analytical Processing)</strong></h3><p>a. Preferable for analytical use cases. Data here are present in denormalized form.<br>b. As data are present in the denormalized form it supports heavy analytical queries. <br>c. OLAP creates very fast aggregation and Calculations of the underlying datasets which makes it more suitable for analytical use cases.<br>d. Work can be done in lesser joins which makes queries less complex and more economical than OLTP.</p><h3>9. Star Schema</h3><p>Star schema helps in designing the data warehouse, i.e:- how many facts tables &amp; dimensional tables are needed to construct the data warehouse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*zxbL_upotfQF-z1x" /><figcaption><a href="https://www.google.com/search?q=star&amp;rlz=1C1VDKB_enIN1033IN1033&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=2ahUKEwjDmZjvkNP9AhU0V2wGHTpZBecQ_AUoAXoECAEQAw&amp;biw=1209&amp;bih=524&amp;dpr=1.13#imgrc=E__mvRikhPNoFM">Source</a></figcaption></figure><p>As the name indicates the schema design looks similar to the star structure. Where the central portion of the star schema are facts tables &amp; the edges are dimensional tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*gKBQxpXSMKR0k2Tgixw2bg.png" /><figcaption>Figure 4</figcaption></figure><h3>10. Snowflake Schema</h3><p>Snowflake schema is an extension of the star schema. In the snowflake schema, the dimensional table is further broken into sub-dimensional tables, which makes data more and more normalized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*Lsg1FLs2DDp4EX5LMY8JnQ.png" /><figcaption>Figure 5</figcaption></figure><p>The key difference between star and snowflake schema you should know:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N_0BsspgDMjY7MY_HhO4qw.png" /><figcaption>Figure 6</figcaption></figure><p>That’s it, my friend, thanks for reading if you want to read more data-related content you can explore it <a href="https://akhilanandkspa.medium.com/"><strong>here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=283e01caa90b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/data-jargons-every-data-guy-should-know-283e01caa90b">Data Jargons Every Data Guy Should Know</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Cassandra]]></title>
            <link>https://akhilanandkspa.medium.com/an-introduction-to-cassandra-260770b29a0a?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/260770b29a0a</guid>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 10:57:43 GMT</pubDate>
            <atom:updated>2023-01-10T10:07:07.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*mivf68V5iUsf4BeGLhHWvg.png" /><figcaption>Image 1</figcaption></figure><blockquote><strong>Overview</strong></blockquote><p>Cassandra is a No-SQL Database management system designed to handle a large amount of data. It is beneficial for faster read and write operations, developed by Facebook which was later on released as an open-source system. Whenever we talk about a No-SQL database system it should follow the <strong>CAP theorem</strong>.</p><h4><strong>CAP Theorem</strong></h4><p><strong>C:- Consistency </strong><br>What does consistency mean?<br>Suppose <strong>User A</strong> and <strong>User B</strong> both are firing the same query then the result will be different for both users if the database does not follow the consistency part. Attaching a simple query for reference.</p><pre>Select Count(Distinct userid)<br>from users </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*AKLo7oiiQtHrwK1TvFp33A.png" /><figcaption>Image 2</figcaption></figure><p><strong>A:- Availability<br></strong>The system should be available 24*7. It should also be important for the system to be fault-tolerant. A single point of failure should not be responsible for the loss of the whole operation.<strong> Cassandra</strong> has this feature which helps it to do faster read and write operations.</p><p><strong>P:- Partition Tolerance </strong><br>Suppose a Cluster has multiple nodes connected with the network and if the network would be broken then the system should still operate and serve the request. <strong>Cassandra</strong> has this partition tolerance feature.</p><p>Cassandra does not support the Join &amp; aggregate operations. It is not being used to drive analytical operations. It is used for the construction of real-time data pipelines where data comes at a very high velocity.</p><blockquote><strong>Let’s Dig Dipper into Cassandra</strong></blockquote><p>As Cassandra is a NO-SQL database we can add a column at any instance of time it does not matter whether the column has been previously defined or not. Cassandra fills the data row-wise where each row is uniquely identified by the primary key.</p><ol><li><strong>Keyspace</strong>:- Keyspace is similar to a data container in the Cassandra database which is similar to a schema in the database. Keyspace consists of core objects e.g:- column families, rows indexed by keys(primary key), data types, data center, and replications factors.</li></ol><h4>2. Keys in Cassandra</h4><p><strong>Partition Key</strong>:- It helps Cassandra to uniquely identify the rows and also helps in data placement at a Particular Node.<br>Suppose the user has fired a write query in a multi-node cluster(Consider the below figure) then its partition key’s responsibility is to assign the hash value which further results in the placement of data into an appropriate node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*SowDX6mLEfuSFuOjdTtghw.png" /><figcaption>Image: Cassandra Cluster</figcaption></figure><pre>/* Simple example to assign partition key */<br>create table application_log( id int,<br>                               user_name varchar,<br>                               user_age as int,<br>                               user_login as timstamp <br>                               user_ordered as varchar<br>                               Primary Key(user_name)<br>);</pre><p><strong>Composite Partition Key:- </strong>When a single column is not helpful to identify the unique partition key, then with the help of more than one column partition key is formed.</p><pre>/* Simple example to assign composite partition key */<br>create table application_log( id int,<br>                               user_name varchar,<br>                               user_age as int,<br>                               user_login as timstamp <br>                               user_ordered as varchar<br>                               Primary Key(user_name,user_age)<br>);</pre><p><strong>Clustering Key:- </strong>Suppose a user has written data in the Cassandra cluster but the same user wants the latest data to be on top and the oldest at the bottom, this arrangement of the data in ascending/descending order is possible because of the clustering key.</p><pre>/* Simple example to assign composite partition key */<br>create table application_log( id int,<br>                               user_name varchar,<br>                               user_age as int,<br>                               user_login as timstamp <br>                               user_ordered as varchar<br>                               Primary Key((user_name,user_age),user_ordered)<br>)<br>with clustering order by (user_ordered desc);</pre><p><strong>Primary Key</strong>:- Primary key consists of one or more partition keys and zero or more clustering keys. It uniquely identifies each row which becomes helpful in further read and write operations.</p><h4>3. Data Replication in Cassandra</h4><p>Cassandra needs replicas of the data to ensure availability and fault tolerance. Suppose the user has sent a read query to the node but due to some reason node has crashed, then, in that case, the user won’t be able to read data, and the system is not considered fault-tolerant. To avoid this issue whenever the user fires a write query the Cassandra cluster makes replicas of the data on different nodes with the help of the replication factor.<br><strong>i.e:- Replication Factor =3 </strong>means three data replicas will be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*WEmzxETl7teKx6WgnuoloA.png" /><figcaption>Image 3</figcaption></figure><p><strong>Simple Strategy:</strong>- When the Cassandra cluster with a single data center is present then we use a simple strategy to create the replica.<br>Suppose a user fires the write request, the coordinator node will direct the request to the node with a relevant hash value, and then replicas will be created in the clockwise direction to the corresponding nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*94eXRp1xsqazD4ye_-eJiQ.png" /><figcaption>Image: Simple Replication Strategy</figcaption></figure><p><strong>Network Topology:</strong>- In Network topology, the Cassandra cluster has more than one data center. Each data center has its individual replication factor means once the write operation would be initiated one data center can make only two replicas and the other can make 4 replicas or vice versa.<br>In the Network topology, the coordinator node, and replicas of the data center are created in such a manner that replication would continue after completing once data center.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*wT0wBkv1toVQvldqAXcC8w.png" /><figcaption>Image: Network topology Replication Strategy</figcaption></figure><p><strong>4. Coordinator Node</strong>:- Coordinator node helps the read and write request to land on the appropriate node, Based on the hash value range assigned to each node.<br><strong>5. Commit Log</strong>:- With every read operation there is a log written, so in the future, if the system crashes the commit log helps to recover the data.<br><strong>6. Memtable:</strong>- Once the data write operation becomes successful the data is stored inside the RAM(in Memory).<br><strong>7. SST (Sorted String Table):</strong>- Once the data storage reaches a threshold level in the memtable, the data would be flushed into SS Table.</p><blockquote><strong>Conclusion</strong></blockquote><p>If you are interested in more data-related content you can visit <a href="https://medium.com/@akhilanandkspa"><strong>here</strong></a>. If you have any suggestions or stuck somewhere kindly comment below.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=260770b29a0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySql →Python Connection: Read Operation]]></title>
            <link>https://ai.plainenglish.io/mysql-python-connection-read-operations-c7cfbbd3830c?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7cfbbd3830c</guid>
            <category><![CDATA[business-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Fri, 30 Dec 2022 14:18:01 GMT</pubDate>
            <atom:updated>2023-04-05T18:56:34.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*3HyzivFv94ZovQn5cdwabg.png" /><figcaption>Image</figcaption></figure><blockquote><strong>Overview</strong></blockquote><p>If you are working in the data industry then you must have come to the stage where you need the python and SQL connection to fetch data for analysis/prediction. This blog will help you to make the connection between python with MySQL. Let’s get started….</p><blockquote><strong>Python &amp; MySql Affair</strong></blockquote><p>Python needs a MySql driver to establish the connection with MySql Database.<br><strong>1. Installation of Mysql Driver in python environment</strong></p><pre>pip install mysql #installation of mysql Connector</pre><p>Importing the installed driver in python and setting up the connection.</p><pre>import mysql.connector<br>mydb=mysql.connector.connect(host=&#39;endpoints provided by your tech team&#39;<br>                             userName=&#39;provide the user name&#39;<br>                             password=&#39;password&#39;)<br>print(mydb)</pre><p>By filling above credentials you will set up your python connection with the MySQL database. Now we need to execute the query in python using MySQL database. The primary step would be setting up the cursor for the query(to extract data from MySql Database).</p><blockquote><strong>Reading the data and converting it into the pandas data frame</strong></blockquote><pre>cursor=mydb.cursor() # setting up the cursor<br>cursor.execute(&#39;&#39;&#39; Select * from akhil_db.users as u limit 10&#39;&#39;&#39;) # it will return first 10 rows</pre><p>Now we need to form a Data Frame in python, by using the data we fetched from the MySQL database. For this, we need rows and columns.</p><pre>rows=cursor.fetchall()<br>columns=[i[o] for i in range cursor.description] #we need column name present on index 0 </pre><p>cursor.fetchall It will fetch all the rows and return the data as a list of tuples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pjjwylWTUTOk19U5mvxY2w.png" /><figcaption>Result of cursor.fetchall</figcaption></figure><p>cursor.description It gives a description of the columns present in the result set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*iUH04BVsKigLmgOFKDinrA.png" /><figcaption>Result of cursor.description</figcaption></figure><pre>import pandas as pd<br>df=pd.DataFrame(rows=rows,columns=columns)<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*o43zBVprmiz5ptiZymZD0g.png" /><figcaption>Final Data Frame</figcaption></figure><blockquote><strong>Conclusion</strong></blockquote><p>Thanks for reading this blog. You can access more data-related content <a href="https://medium.com/@akhilanandkspa"><strong>here</strong></a><strong>.</strong></p><h4>More content at <a href="https://plainenglish.io/">PlainEnglish.io</a>.</h4><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><strong><em>, </em></strong><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><strong><em>, and</em></strong><em> </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><h4>Looking to scale awareness and adoption for your tech startup? Check out <a href="https://circuit.ooo/?utm=publication-post-cta">Circuit</a>.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7cfbbd3830c" width="1" height="1" alt=""><hr><p><a href="https://ai.plainenglish.io/mysql-python-connection-read-operations-c7cfbbd3830c">MySql →Python Connection: Read Operation</a> was originally published in <a href="https://ai.plainenglish.io/">Artificial Intelligence in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference Between Discard and Remove Function In Python.]]></title>
            <link>https://medium.datadriveninvestor.com/difference-between-discard-and-remove-function-in-python-46d36eb5ac75?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/46d36eb5ac75</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 04:51:15 GMT</pubDate>
            <atom:updated>2022-12-10T02:58:26.278Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*7lULDKReB0v4F5Gq" /><figcaption><a href="https://www.google.com/search?q=thinking&amp;rlz=1C1CHBF_enIN998IN998&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=2ahUKEwil25Pm3p36AhWocGwGHbr0DQgQ_AUoAXoECAIQAw&amp;biw=1280&amp;bih=601&amp;dpr=1#imgrc=nX4tOAH64YZROM">Source</a></figcaption></figure><blockquote><strong>Overview</strong></blockquote><p>Discard and Remove both functions remove a specific value from the dictionary. Then the major question is which function should we use and why? It’s better to use the <strong>discard</strong> function.</p><p>Suppose you have a set s={‘Apple’,’Elephant’,’orange’} let’s try both functions.</p><pre>1. s={‘Apple’,’Elephant’,’orange’}<br>   s.remove(&#39;Elephant&#39;)<br>   print(s)</pre><pre>[out]&gt;&gt; {&#39;Apple&#39;,&#39;orange&#39;}</pre><pre>2. s={‘Apple’,’Elephant’,’orange’}<br>   s.remove(&#39;ele&#39;)<br>   print(s)</pre><pre>[out]&gt;&gt; Traceback (most recent call last):<br>             File &quot;./prog.py&quot;, line 3, in &lt;module&gt; KeyError: &#39;ban&#39;</pre><p>If we want to eliminate a specific value using the <strong>remove</strong> function and that value is not present in the <strong>set</strong> then it will throw an error. But in the case of the <strong>discard</strong> function, if the value we want to eliminate is not present in the set, it will print the set as it is it won’t show any error.</p><pre>1. s={‘Apple’,’Elephant’,’orange’}<br>   s.discard(&#39;Elephant&#39;)<br>   print(s)</pre><pre>[out]&gt;&gt; {&#39;Apple&#39;,&#39;orange&#39;}</pre><pre>2. s={‘Apple’,’Elephant’,’orange’}<br>   s.discard(&#39;ele&#39;)<br>   print(s)</pre><pre>[out]&gt;&gt; {&#39;Apple&#39;,&#39;Elephant&#39;,&#39;orange&#39;}</pre><p>Subscribe to DDIntel <a href="https://ddintel.datadriveninvestor.com/">Here</a>.</p><p>Visit our website here: <a href="https://www.datadriveninvestor.com/">https://www.datadriveninvestor.com</a></p><p>Join our network here: <a href="https://datadriveninvestor.com/collaborate">https://datadriveninvestor.com/collaborate</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46d36eb5ac75" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/difference-between-discard-and-remove-function-in-python-46d36eb5ac75">Difference Between Discard and Remove Function In Python.</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Hadoop]]></title>
            <link>https://akhilanandkspa.medium.com/an-introduction-to-hadoop-2f3e08528259?source=rss-3eb6dce9541c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f3e08528259</guid>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[akhil anand]]></dc:creator>
            <pubDate>Sun, 04 Dec 2022 17:09:58 GMT</pubDate>
            <atom:updated>2022-12-06T18:24:40.652Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ah09B8usVj9mSLb-kiDeKQ.png" /><figcaption>Figure 1</figcaption></figure><blockquote><strong>Introduction</strong></blockquote><p>When we are dealing with Big Data, our system would be handling a large set of data i.e. Gigabytes and Petabytes. To deal with these large chunks of data nowadays data engineers use Hadoop,(clusters of multiple systems) Hadoop helps analyze massive chunks of data in a parallel and more quick manner.</p><p>Suppose you are a Youtuber and you have a laptop that can store 1 Tb of data. Assuming you are posting your content on a regular basis. After a certain period of time, you have uploaded the 1TB of content on youtube now you need an additional storage system for Backup, You can do this in two ways either you will replace your existing system(Scale Up), with the more powerful system(System with 5Tb of Storage) or you can purchase an additional hard disk (scale out)to store more data.</p><p>Scaling Up(Replacing the old system with a new system) will be costlier than scaling Out(addition of commodity hardware). Hadoop is also using the scale-out technique to process large chunks of data.</p><blockquote><strong>H.D.F.S 1.X</strong></blockquote><p><strong>H.D.F.S :- Hadoop distributed file system.</strong></p><p>HDFS 1. X works as a Master-Slave Architecture. It consists of a single master and multiple slaves. Suppose You are working in an organization you will have one manager and 5–10 team members, the main task of the manager is to allocate the task between different team members, the same way HDFS 1.X works, The manager is the <strong>Master</strong> and team members are <strong>slaves</strong>.</p><p><strong>Now the question is what does Hadoop distributed file system mean?</strong></p><p>Suppose you want to process 1GB of data and you have 4 systems available to process the requested data. The system will equally divide the data(<strong>250 Mb</strong>) among all four systems(considering all the systems are available with their full potential). The parallel processing &amp; distribution of data is done by the distributed file system.<br>Let’s Understand the Hadoop 1.X Architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*dcmuygPePgEBB_GrTojURg.png" /><figcaption>Figure 2:- Hadoop 1.X</figcaption></figure><h3><strong>The Master Node</strong></h3><p>The master node consists of the <strong>Name Node</strong> and <strong>Job tracker</strong>.</p><h4>a. The Name Node :</h4><p>1. The main task of the name node is to store the <strong>metadata</strong> information.</p><p><strong>What does metadata mean?<br></strong>It stores information related to available systems. for example<br>i&gt; Availability of system.<br>ii&gt; System Configuration (Ram, Storage)<br>iii&gt; Processing power of the system<br>iv&gt; Checkpointing.<br>v&gt; Assign work to the slave node</p><p><strong>Note:-</strong> Name Node does not store the data but it stores the metadata information of the data node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*rn35VR_m5doqMpSfUr9ZJg.png" /><figcaption>Figure 3</figcaption></figure><p>Name Node is also divided into two parts. i.e:- <strong>Primary</strong> Name Node and <strong>Secondary</strong> Name Node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*7mfBobrnSW0FSsrID-nRrw.png" /><figcaption>Figure 4</figcaption></figure><p>i.&gt; <strong>Primary Name Node</strong>:- When the system starts, it stores the metadata information about the available systems at Oth second, which is known as <strong>fs_image</strong> (file system image). It Gives the first response to any kind of execution.<br><strong>fs_image </strong>:- file system image stores the information of the device like configuration, processing power, and the kind of data that will be processed by the system.</p><p>ii.&gt; <strong>Secondary Name Node:-</strong> Suppose you commute regularly from your home to your office. You leave your home at a particular time let’s say 8:30 AM and you do your lunch at 2:30 PM and leave the office at 7:00 PM these timings are the logs of your life same way when a machine does any kind of operation it records some logs, with the help of these logs we can conclude the success of any task. Those logs are recorded in the secondary Name Node. Suppose Admin has set the time to update the log every 50 seconds and then at every 50th second the <strong>edit_log</strong> file will be created and the <strong>fs_image+edit_log</strong> combined to form the updated fs_image_2.0 which will again be<strong> sent back to Primary Name Node</strong>. once the fs_image information will be updated in the secondary name node, then the secondary name node sends the flag to PNN(primary name node) once PNN will be free it will store the updated <strong>fs_image</strong> file. The above process will happen until the task would be done.</p><p>The process of updating the fs_image_2.0 is known as <strong>checkpointing</strong> and always remember checkpointing only happens in the secondary name node.</p><h4>b. Job Tracker:</h4><p>It works on the Cluster level. When a client requests the data, the Job tracker starts pinging the task to different clusters(Slave Nodes). Whichever cluster will respond to the job tracker the task will be assigned to that specific cluster.<br> Job tracker chooses the cluster on a first come first serve basis. Below are some important tasks the job tracker does;<br>i&gt; Job Scheduling <br>ii&gt; Resource Management<br>iii&gt; Job Monitoring.</p><h3>The Slave Node :</h3><p>One Master Node can have multiple slave nodes. The slave node consists of Task Tracker &amp; Data Node.</p><h4><strong>a. Task Tracker</strong></h4><p>Task tracker and job tracker both have similar work. The only major difference is that the job tracker works on a cluster level and the task tracker works on a node level.<br>Task Tracker gives the response to the job tracker about the available resources present for the task.</p><h4>b. Data Node</h4><p>It initiates the task. It is responsible for storing the actual data in HDFS. It configures a lot of hardware space because the actual data-level work happens in the data node.</p><p><strong>Conclusion:- </strong><br>If you have any questions in your mind kindly comment below. Keep learning keep exploring.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f3e08528259" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>