<?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 Omid Ebrahimi | TheCodeZ on Medium]]></title>
        <description><![CDATA[Stories by Omid Ebrahimi | TheCodeZ on Medium]]></description>
        <link>https://medium.com/@thecodez?source=rss-e81cb537b7ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BQ4JGxsSCjMN1F0KwtMIkw.jpeg</url>
            <title>Stories by Omid Ebrahimi | TheCodeZ on Medium</title>
            <link>https://medium.com/@thecodez?source=rss-e81cb537b7ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 28 May 2026 02:26:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thecodez/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[Different type of Read Modes and Write Modes in spark?]]></title>
            <link>https://thecodez.medium.com/different-type-of-read-modes-and-write-modes-in-spark-a2939830a71b?source=rss-e81cb537b7ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2939830a71b</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[spark-sql]]></category>
            <category><![CDATA[data-engineer]]></category>
            <category><![CDATA[spark-streaming]]></category>
            <category><![CDATA[schema]]></category>
            <dc:creator><![CDATA[Omid Ebrahimi | TheCodeZ]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 19:06:32 GMT</pubDate>
            <atom:updated>2025-04-03T19:08:16.127Z</atom:updated>
            <content:encoded><![CDATA[<p>In <strong>Apache Spark</strong>, when working with <strong>DataFrames</strong>, we need to define the type of data in each column, which is done using something called <strong>Schema</strong>. There are three ways to define a schema:</p><h3><strong>1. InferSchema (Automatically Inferring Data Types)</strong></h3><p>In this method, Spark automatically analyzes the data and tries to guess the type of each column. For example, if a column contains numbers, Spark will determine whether it should be an Integer or a Double. This method is easy to use but not always 100% accurate.</p><pre>df = spark.read.option(&quot;inferSchema&quot;, &quot;true&quot;).csv(&quot;data.csv&quot;)</pre><p>Here, Spark automatically determines the type of each column.</p><h3><strong>2. Implicit Schema (Schema Already Defined in the File Format)</strong></h3><p>Some file formats, like <strong>JSON</strong> and <strong>Parquet</strong>, already contain schema information. When loading these files, Spark automatically uses the existing schema, so you don’t need to define the data types manually.</p><pre>df = spark.read.json(&quot;data.json&quot;)</pre><p>Since JSON files already have a structured format, Spark can infer the schema from the file itself.</p><h3><strong>3. Explicit Schema (Manually Defining the Schema)</strong></h3><p>Sometimes, it’s better to explicitly define the schema, especially if the data is not standardized or you want to have full control over the data types. There are two main ways to do this:</p><h4><strong>3.1. Programmatically Specified Schema</strong></h4><p>In this method, we use StructType and StructField to manually define the type of each column.</p><pre>from pyspark.sql.types import StructType, StructField, StringType, IntegerType<br><br>schema = StructType([<br>    StructField(&quot;name&quot;, StringType(), True),<br>    StructField(&quot;age&quot;, IntegerType(), True)<br>])<br><br>df = spark.read.schema(schema).csv(&quot;data.csv&quot;)</pre><p>Here, we explicitly set the &quot;name&quot; column as a <strong>String</strong> and the &quot;age&quot; column as an <strong>Integer</strong>.</p><h4><strong>3.2. DDL String Schema</strong></h4><p>Instead of using StructType, we can define the schema as a simple <strong>string</strong>.</p><pre>df = spark.read.schema(&quot;name STRING, age INT&quot;).csv(&quot;data.csv&quot;)</pre><p>This quickly defines &quot;name&quot; as a <strong>String</strong> and &quot;age&quot; as an <strong>Integer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OvHEHC5HoyNXjQGCibPluQ.png" /><figcaption>ALL IN One</figcaption></figure><h3>Summary</h3><ol><li><strong>InferSchema</strong> → Spark automatically guesses the data types.</li><li><strong>Implicit Schema</strong> → If the file format (like JSON or Parquet) already has a schema, Spark will use it automatically.</li><li><strong>Explicit Schema</strong> → You manually define the data types for better accuracy and control.</li></ol><p>💡 <strong>Tip:</strong> Most developers prefer using <strong>Explicit Schema</strong> because it provides more control and is considered best practice for working with real-world data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2939830a71b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case Study : How to quickly and accurately locate specific Telegram messages within a massive…]]></title>
            <link>https://thecodez.medium.com/case-study-how-to-quickly-and-accurately-locate-specific-telegram-messages-within-a-massive-f2de6c55aed0?source=rss-e81cb537b7ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2de6c55aed0</guid>
            <category><![CDATA[etl-pipeline]]></category>
            <category><![CDATA[freelance]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[thecodez]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Omid Ebrahimi | TheCodeZ]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 15:01:07 GMT</pubDate>
            <atom:updated>2025-01-19T15:01:07.541Z</atom:updated>
            <content:encoded><![CDATA[<h3>Case Study : How to quickly and accurately locate specific Telegram messages within a massive volume of data?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9vzC88HlS7DatIFyFfWIg.png" /><figcaption>Post Hunter ETL PipeLine</figcaption></figure><p>My client managed several large Telegram groups, each generating thousands of messages daily. They needed a system to identify <strong>specific messages</strong> containing certain <strong>keywords, phrases, or content</strong> amidst this overwhelming volume.<br>The manual approach they had been using was highly time-consuming, inefficient, and error-prone. Additionally, the client required a <strong>graphical and user-friendly interface</strong> to interact with the results easily. Their main needs included:</p><ul><li>Finding key messages at different times.</li><li>Quickly and accurately analyzing data for better decision-making.</li><li>A system that could display the results in a simple interface, accessible to users without technical expertise.</li></ul><p>Solution: Designing and Implementing the Post Hunter Pipeline to Search and Display Messages</p><p>To address this challenge, I designed an integrated and flexible system with the following components:</p><ol><li><strong>Data Extraction from Telegram:</strong><br>I developed a scraper using the Telegram API and Python to extract messages from specific groups and channels. The scraper was designed to retrieve targeted data with high speed and accuracy.</li><li><strong>Data Processing with Kafka:</strong><br>The extracted messages were sent to <strong>Apache Kafka</strong> for efficient transfer and real-time processing of large volumes of data. Kafka also facilitated seamless coordination between various components of the system.</li><li><strong>Storage and Search in ElasticSearch:</strong><br>The processed messages were stored in <strong>ElasticSearch</strong>, enabling <strong>advanced querying capabilities</strong> to locate specific messages. This feature allowed the client to quickly find desired messages using filters and defined keywords.</li><li><strong>Graphical User Interface (GUI):</strong><br>To present the messages to the client, I developed a simple and user-friendly graphical application. This application allowed users to view and analyze the queried messages in detail. The interface was intuitive, making it accessible even to non-technical users.</li></ol><h3>Results and Achievements:</h3><p>This system effectively resolved the client’s challenges, delivering the following outcomes:</p><ul><li><strong>Reduced Search Time:</strong> The time required to find specific messages dropped from hours to minutes.</li><li><strong>High Accuracy in Results:</strong> With ElasticSearch and advanced queries, specific messages were located without errors.</li><li><strong>Increased Efficiency:</strong> The client could focus on analysis and decision-making instead of manual searches.</li><li><strong>Simple User Interface:</strong> The tool allowed the client to interact with the data effortlessly, even without technical expertise.</li></ul><h3>Key Takeaways and Project Highlights:</h3><p>This project showcases my ability to design and implement advanced data-driven systems that solve complex challenges for clients. <strong>Post Hunter</strong> is now a powerful tool that enables the client to locate and analyze specific Telegram messages with speed, accuracy, and efficiency.</p><p>If you’re facing similar challenges and need a data engineer to build customized solutions, I’d love to collaborate with you. 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2de6c55aed0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>