<?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 BigDataEnthusiast on Medium]]></title>
        <description><![CDATA[Stories by BigDataEnthusiast on Medium]]></description>
        <link>https://medium.com/@bigdataenthusiast?source=rss-fb864bd67c5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zSCEpDp_W2_GlmjMCwescw.jpeg</url>
            <title>Stories by BigDataEnthusiast on Medium</title>
            <link>https://medium.com/@bigdataenthusiast?source=rss-fb864bd67c5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:40:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bigdataenthusiast/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[Deletion Vectors in Apache Iceberg V3: What problem do they actually solve?]]></title>
            <link>https://bigdataenthusiast.medium.com/deletion-vectors-in-apache-iceberg-v3-what-problem-do-they-actually-solve-224e6859322e?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/224e6859322e</guid>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[iceberg-table]]></category>
            <category><![CDATA[open-table-format]]></category>
            <category><![CDATA[iceberg-table-v3]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Sun, 23 Aug 2026 07:58:14 GMT</pubDate>
            <atom:updated>2026-08-23T18:44:23.310Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding the limitations of position deletes, how Deletion Vectors work in Iceberg V3, and why they can make row-level deletes more efficient.</h4><p>Row-level deletes in Iceberg have always worked the same way at a high level: instead of rewriting a data file every time a row is removed, the engine writes a small “delete marker” file that tells readers which rows to skip. This is what makes merge-on-read fast to write. The catch is that the <em>shape</em> of that marker file changed significantly between format version 2 and format version 3, and that change is what Deletion Vectors (DVs) are about.</p><p>I ran a small proof of concept comparing the two formats side by side on the same workload, and the difference in file layout is a lot more visible than I expected. This post walks through why position deletes in V2 get expensive, how DVs in V3 fix it, and what that looks like in practice.</p><h3>The problem with position deletes (V2)</h3><p>In format version 2, a DELETE statement under merge-on-read doesn&#39;t touch the original Parquet data files. It writes a <strong>position delete file</strong>: a small <strong>Parquet </strong>file listing (file_path, position) pairs for every row that should be treated as deleted. At read time, the engine has to open each relevant data file <em>and</em> merge-join it against one or more of these delete files to figure out which rows to skip.</p><p>Nothing in the V2 spec obligates a writer to update an existing delete file in place when new deletes come in for the same data file - unlike deletion vectors, there’s no “at most one per data file” rule. Depending on the writer/version, a single data file can end up with several separate delete files pointing at it over time, and readers have to reconcile all of them before returning results. This is the classic “small file” and “read amplification” problem that shows up in Iceberg V2 tables with frequent deletes, updates, or CDC-style merges: write performance stays fine, but reads and eventual compaction get progressively more expensive.</p><h3>What changes in V3: Deletion Vectors</h3><p>Format version 3 replaces position delete files with <strong>Deletion Vectors</strong> -binary bitmaps that mark deleted row positions directly against a single data file. Instead of a list of (file, position) rows in Parquet file, a DV is a bitmap where a set bit at position <em>P</em> means &quot;row <em>P</em> in this file is deleted.&quot; Iceberg optimizes this using Roaring Bitmaps: 64-bit positions are split into a 32-bit &quot;key&quot; and a 32-bit sub-position, so lookups stay cheap even at scale.</p><p>Two rules make DVs behave very differently from position deletes:</p><ul><li><strong>At most one deletion vector per data file, per snapshot.</strong> New deletes against a file get merged into the existing vector rather than piling up as a new file.</li><li><strong>DVs are stored in Puffin files</strong>, Iceberg’s general-purpose blob format (also used for statistics and sketches), rather than as standalone Parquet delete files. Refer below blog for more details.</li></ul><p><a href="https://bigdataenthusiast.medium.com/decoding-puffin-file-apache-iceberg-bee79f0bc11c">Decoding Puffin File | Apache Iceberg</a></p><p>Because there’s a strict 1:1 relationship between a data file and its deletion vector, the delete-file per data-file explosion that plagues V2 simply can’t happen the same way in V3. Deletes for the same file get consolidated into one bitmap instead of accumulating as separate files, and a single Puffin file can hold the vectors for several data files at once, which further reduces the number of physical files the table has to track.</p><h3>The POC</h3><p>To see this in practice, I created two identical Iceberg tables on a catalog - one at format-version = 2, one at format-version = 3both configured for merge-on-read deletes and updates:</p><pre>CREATE TABLE rest.demo.dv_test_v2 (<br>    id BIGINT, name STRING, email STRING<br>) USING iceberg<br>TBLPROPERTIES (<br>    &#39;format-version&#39; = &#39;2&#39;,<br>    &#39;write.delete.mode&#39; = &#39;merge-on-read&#39;,<br>    &#39;write.update.mode&#39; = &#39;merge-on-read&#39;<br>);<br><br>CREATE TABLE rest.demo.dv_test_v3 (<br>    id BIGINT, name STRING, email STRING<br>) USING iceberg<br>TBLPROPERTIES (<br>    &#39;format-version&#39; = &#39;3&#39;,<br>    &#39;write.delete.mode&#39; = &#39;merge-on-read&#39;,<br>    &#39;write.update.mode&#39; = &#39;merge-on-read&#39;<br>);</pre><p>I loaded 100,000 rows into each table (split across 12 data files), then ran the same three DELETE statements against both tables, each removing 10,000 rows:</p><pre>DELETE FROM rest.demo.dv_test_v2 WHERE id BETWEEN 10000 AND 19999;<br>DELETE FROM rest.demo.dv_test_v2 WHERE id BETWEEN 30000 AND 39999;<br>DELETE FROM rest.demo.dv_test_v2 WHERE id BETWEEN 50000 AND 59999;<br>-- (same three statements against dv_test_v3)</pre><h3>What the V2 table produced</h3><p>Querying dv_test_v2.delete_files after the three deletes shows <strong>six separate position delete files</strong>, none of which reference a referenced_data_file at all because position deletes work by listing (file_path, position) pairs inside the delete parquet file, not by attaching to one file:</p><pre>file_format record_count<br>PARQUET 8333<br>PARQUET 1667<br>PARQUET 3333<br>PARQUET 6667<br>PARQUET 6666<br>PARQUET 3334</pre><p>Each of the three DELETE statements produced two new delete files (because the deleted id ranges spanned two of the underlying 12 data files), and none of them got merged with the others. The table&#39;s snapshot summary confirms it: by the third delete, total-delete-files had climbed to <strong>6</strong>, holding <strong>30,000 total position deletes </strong>- one accumulating pile of small files that a reader has to reconcile against the 12 data files at scan time.</p><h3>What the V3 table produced</h3><p>The same three deletes against dv_test_v3 also produced six Puffin blobs - but the key difference is in the referenced_data_file column, which is populated for every row:</p><pre>file_format record_count   referenced_data_file<br>PUFFIN       8333           ...00006-...parquet<br>PUFFIN       1667           ...00007-...parquet<br>PUFFIN       6667           ...00004-...parquet<br>PUFFIN       3333           ...00003-...parquet<br>PUFFIN       6666           ...00001-...parquet<br>PUFFIN       3334           ...00002-...parquet<br></pre><p>Each Puffin blob is tied explicitly to one data file via referenced_data_file, content_offset, and content_size_in_bytesthe exact byte range of that file&#39;s bitmap inside the Puffin blob. If any of these three deletes had overlapped the <em>same</em> underlying data file, the bitmap for that file would have been updated in place rather than adding a seventh file, since only one DV is allowed per data file per snapshot.</p><p>The snapshot summaries make the storage difference obvious. Compare added-files-size for the second delete on each table:</p><ul><li><strong>V2</strong> (added-position-delete-files): 18,763 bytes added for 10,000 deletes</li><li><strong>V3</strong> (added-dvs): 78 bytes added for 10,000 deletes</li></ul><p>That’s roughly 240x smaller for the same number of logical deletes, because a Roaring Bitmap over a range of positions compresses down to almost nothing, whereas a Parquet delete file carries its own footer, schema, and row-group overhead for what is fundamentally a list of integers.</p><h3>Why this is actually more efficient</h3><p>Putting the POC numbers together with how the two formats work, three things stand out:</p><ol><li><strong>No accumulation guarantee* for V2.</strong> The spec never requires a writer to merge new deletes into an existing position delete file for the same data file, so depending on the engine and version, repeated deletes against one file can pile up as separate files. V3 removes that uncertainty entirely: the spec caps DVs at one per data file per snapshot, so a compliant writer on any engine must update the existing bitmap in place rather than add a new file - that’s a format-level guarantee, not an implementation choice.</li><li><strong>Cheaper storage per delete.</strong> A bitmap over row positions is dramatically smaller than a Parquet file encoding the same positions as rows, especially for small numbers of deletes this shows up directly in the added-files-size metric in the POC above.</li><li><strong>Cheaper reads.</strong> Because the DV is directly addressable by offset and length within its Puffin file (via content_offset / content_size_in_bytes), a reader can fetch exactly the bytes it needs for a given data file instead of scanning and merge-joining against a separate delete file that may cover many files or need position-based binary search.</li></ol><h3>Reference</h3><p><a href="https://iceberg.apache.org/spec/#deletion-vectors">Iceberg Table Spec</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=224e6859322e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding Puffin File | Apache Iceberg]]></title>
            <link>https://bigdataenthusiast.medium.com/decoding-puffin-file-apache-iceberg-bee79f0bc11c?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bee79f0bc11c</guid>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[iceberg-table]]></category>
            <category><![CDATA[puffin]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 01:17:50 GMT</pubDate>
            <atom:updated>2026-08-17T01:20:51.480Z</atom:updated>
            <content:encoded><![CDATA[<p>Please refer below blog for initial environment setup &amp; analysis.</p><p><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-b4cfdb0c9b6b">Apache Iceberg | Table Format Version 3</a></p><p>In this blog, we’ll go beyond Iceberg’s metadata and <strong>decode a Puffin file at the byte level</strong>. We’ll start with the file’s magic number, then explore its structure, blob metadata, offsets, and the actual bytes that make up deletion-vector data.</p><p>According to the Apache Iceberg Puffin spec, the overall file layout is:</p><pre>Magic<br>Blob 1<br>Blob 2<br>...<br>Blob N<br>Footer</pre><p>The footer itself has this structure:</p><pre>Footer<br>│<br>├── Magic                 4 bytes<br>├── Footer Payload        variable<br>├── Footer Payload Size   4 bytes<br>├── Flags                 4 bytes<br>└── Magic                 4 bytes</pre><h3>Magic Number</h3><p>Every Puffin file begins with a <strong>4-byte magic number</strong> that identifies the file format. In Puffin, these bytes are 50 46 41 31 in hexadecimal, which correspond to the ASCII string <strong>PFA1</strong>. This signature appears at byte offset 0 and allows readers to recognize that the file is a valid Puffin file before decoding its contents.</p><p>Magic is four bytes 0x50, 0x46, 0x41, 0x31 (short for: Puffin <em>Fratercula arctica</em>, version 1). See below scala code.</p><p>For example:</p><pre>Parquet → PAR1<br>Puffin   → PFA1</pre><pre>docker exec -it spark /opt/spark/bin/spark-shell<br><br>import org.apache.iceberg.hadoop.HadoopFileIO<br><br>val io = new HadoopFileIO()<br>val inputFile = io.newInputFile(&quot;file:///workspace/test.puffin&quot;)<br>val in = inputFile.newStream()<br>val magic = new Array[Byte](4)<br>val n = in.read(magic)<br>println(s&quot;Magic bytes: ${magic.map(b =&gt; f&quot;${b &amp; 0xff}%02X&quot;).mkString(&quot; &quot;)}&quot;)<br>in.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ohrip-LQrafVaUZcaWQj0g.png" /></figure><h3>Exploring Blobs and Their Metadata</h3><p>After identifying the Puffin file using its magic number, the next step is to inspect the <strong>blob metadata stored in the Puffin footer</strong>. A Puffin file acts as a container for one or more blobs, and the footer contains metadata describing each blob, including its type, location, size, and other attributes. By examining this metadata, we can understand how Iceberg organizes data such as <strong>deletion vectors</strong> within the Puffin file.</p><pre>Puffin File<br>    │<br>    ├── Blob data<br>    │<br>    └── Footer<br>          │<br>          └── FileMetadata<br>                │<br>                └── BlobMetadata<br>                      ├── type<br>                      ├── offset<br>                      ├── length<br>                      └── properties</pre><pre>import org.apache.iceberg.hadoop.HadoopFileIO<br>import org.apache.iceberg.puffin.Puffin<br>import scala.jdk.CollectionConverters._<br><br>val io = new HadoopFileIO()<br><br>val inputFile = io.newInputFile(&quot;file:///workspace/test3.puffin&quot;)<br>println(s&quot;File size: ${inputFile.getLength} bytes&quot;)<br>val reader = Puffin.read(inputFile).build()<br>val metadata = reader.fileMetadata()<br>val blobs = metadata.blobs()<br>println(s&quot;Number of blobs = ${blobs.size()}&quot;)<br><br>blobs.asScala.zipWithIndex.foreach {<br>  case (b, i) =&gt;<br>    println(s&quot;========== Blob #$i ==========&quot;)<br>    println(s&quot;Type          : ${b.`type`()}&quot;)<br>    println(s&quot;Snapshot ID   : ${b.snapshotId()}&quot;)<br>    println(s&quot;Sequence      : ${b.sequenceNumber()}&quot;)<br>    println(s&quot;Input fields  : ${b.inputFields()}&quot;)<br>    println(s&quot;Properties    : ${b.properties()}&quot;)<br>    println(s&quot;Offset        : ${b.offset()}&quot;)<br>    println(s&quot;Length        : ${b.length()}&quot;)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-lFEVl8bm4S5pJJGGPGGA.png" /></figure><p>Physical layout: (example)</p><pre>Puffin file<br>│<br>├── PFA1                  ← bytes 0-3<br>│<br>├── Blob #0               ← bytes 4-58<br>│   ├── Type: deletion-vector-v1<br>│   ├── Data file: 00006-6-...parquet<br>│   ├── Deleted positions: 15<br>│   ├── Offset: 4<br>│   └── Length: 55 bytes<br>│<br>├── Blob #1               ← bytes 59-100<br>│   ├── Type: deletion-vector-v1<br>│   ├── Data file: 00002-2-...parquet<br>│   ├── Deleted positions: 1<br>│   ├── Offset: 59<br>│   └── Length: 42 bytes<br>│<br>└── ...</pre><h3>Inspecting the Deletion Vector Data</h3><p>Now that we know where each deletion-vector-v1 blob is located, the next step is to read the <strong>actual blob contents</strong>. Using the blob&#39;s offset and length, we can seek directly to its bytes in the Puffin file and inspect the encoded deletion vector.</p><p>For example, Blob #0 tells us:</p><pre>Offset = 4<br>Length = 55 bytes<br>Cardinality = 15</pre><p>So we can read those 55 bytes directly from the Puffin file and examine how the <strong>15 deleted row positions</strong> are physically encoded.</p><h4>Code</h4><ol><li><strong>Open the Puffin file</strong> and read its metadata.</li><li><strong>Select the first blob</strong>, which contains the deletion-vector-v1.</li><li><strong>Read the blob’s binary payload</strong> into a ByteBuffer.</li><li><strong>Extract the Roaring bitmap</strong> from the DV payload.</li><li><strong>Deserialize the bitmap</strong> using Iceberg’s RoaringPositionBitmap.</li><li><strong>Read each position</strong> from the bitmap and store the deleted row positions.</li><li><strong>Print the result</strong> in four simple sections: file information, blob information, deleted vector details, and additional metadata.</li></ol><pre>import org.apache.iceberg.hadoop.HadoopFileIO<br>import org.apache.iceberg.puffin.Puffin<br><br>import java.nio.{ByteBuffer, ByteOrder}<br>import java.util.function.LongConsumer<br>import scala.collection.mutable.ArrayBuffer<br><br>val io = new HadoopFileIO()<br>val filePath = &quot;file:///workspace/test.puffin&quot;<br>val inputFile = io.newInputFile(filePath)<br>val reader = Puffin.read(inputFile).build()<br>val metadata = reader.fileMetadata()<br><br>val blobs = metadata.blobs()<br>val dvBlob = blobs.get(0)<br>val result = reader.readAll(java.util.Arrays.asList(dvBlob))<br>val blob = result.iterator().next()<br>val dvBytes = blob.second()<br><br>// Decode the Roaring bitmap<br>val bitmapClass =<br>  Class.forName(&quot;org.apache.iceberg.deletes.RoaringPositionBitmap&quot;)<br><br>val deserialize =<br>  bitmapClass.getDeclaredMethod(<br>    &quot;deserialize&quot;,<br>    classOf[ByteBuffer]<br>  )<br>deserialize.setAccessible(true)<br><br>val roaringBytes = dvBytes.duplicate()<br>roaringBytes.position(8)<br>roaringBytes.limit(dvBytes.limit() - 4)<br><br>val roaring = roaringBytes.slice()<br>roaring.order(ByteOrder.LITTLE_ENDIAN)<br><br>val bitmap = deserialize.invoke(null, roaring)<br><br>// Extract deleted positions<br>val positions =<br>  ArrayBuffer[Long]()<br><br>val forEach =<br>  bitmapClass.getDeclaredMethod(<br>    &quot;forEach&quot;,<br>    classOf[LongConsumer]<br>  )<br><br>forEach.setAccessible(true)<br><br>forEach.invoke(<br>  bitmap,<br>  new LongConsumer {<br>    override def accept(position: Long): Unit =<br>      positions += position<br>  }<br>)<br><br>// Print everything<br>println()<br>println(&quot;========================================&quot;)<br>println(&quot;Puffin File&quot;)<br>println(&quot;========================================&quot;)<br>println(s&quot;File        : $filePath&quot;)<br>println(s&quot;File size   : ${inputFile.getLength} bytes&quot;)<br>println(&quot;========================================&quot;)<br>println(&quot;Blob&quot;)<br>println(&quot;========================================&quot;)<br>println(s&quot;Blob        : #0&quot;)<br>println(s&quot;Type        : ${dvBlob.`type`()}&quot;)<br>println(s&quot;Data file   : ${dvBlob.properties().get(&quot;referenced-data-file&quot;)}&quot;)<br>println(s&quot;Offset      : ${dvBlob.offset()}&quot;)<br>println(s&quot;Length      : ${dvBlob.length()} bytes&quot;)<br>println(&quot;========================================&quot;)<br>println(&quot;Deleted Vector Details&quot;)<br>println(&quot;========================================&quot;)<br>println(s&quot;Deleted rows: ${positions.size}&quot;)<br>println(s&quot;Positions   : [${positions.sorted.mkString(&quot;, &quot;)}]&quot;)<br>println(&quot;========================================&quot;)<br>println(&quot;Other Metadata&quot;)<br>println(&quot;========================================&quot;)<br>println(s&quot;Cardinality : ${dvBlob.properties().get(&quot;cardinality&quot;)}&quot;)<br>println(s&quot;Snapshot ID : ${dvBlob.snapshotId()}&quot;)<br>println(s&quot;Sequence    : ${dvBlob.sequenceNumber()}&quot;)<br>println(s&quot;Input fields: ${dvBlob.inputFields()}&quot;)<br>println(s&quot;Payload size: ${dvBytes.remaining()} bytes&quot;)<br>println(s&quot;Properties  : ${dvBlob.properties()}&quot;)<br>println(&quot;========================================&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WE3K31Y0J923M4TGi-c8bg.png" /></figure><pre>scala&gt; ========================================<br>scala&gt; Deleted Vector Details<br>scala&gt; ========================================<br><br>scala&gt; Deleted rows: 15<br>scala&gt; Positions   : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 8000]</pre><h3>Examining the Puffin Footer</h3><p>The footer is located at the end of the Puffin file and contains metadata about the blobs stored in the file. At the byte level, the footer comes after all the blob data and ends with the Puffin magic bytes PFA1.</p><p>The footer contains a FileMetadata structure with a list of BlobMetadata entries. Each entry describes a blob using fields such as type, offset, length, snapshot-id, sequence-number, and properties such as referenced-data-file and cardinality.</p><p>In our example, the Puffin file contains <strong>10 </strong><strong>deletion-vector-v1 blobs</strong>. Their offsets and lengths show that the blobs are stored sequentially:</p><pre>Puffin File<br>│<br>├── PFA1<br>├── Blob #0  → offset 4,   length 55<br>├── Blob #1  → offset 59,  length 42<br>├── Blob #2  → offset 101, length 42<br>├── ...<br>├── Blob #9  → offset 395, length 44<br>│<br>└── Footer<br>    └── FileMetadata<br>        └── BlobMetadata for all 10 blobs</pre><p>This gives us an important distinction:</p><blockquote><em>The blob contains the actual deletion-vector binary data, while the footer contains metadata that tells us how to locate and interpret each blob.</em></blockquote><p>Once the footer provides the blob’s offset and length, we can seek directly to those bytes and decode the deletion-vector-v1 payload as a Roaring bitmap to obtain the deleted row positions.</p><pre>import org.apache.iceberg.hadoop.HadoopFileIO<br>import java.nio.charset.StandardCharsets<br><br>val io = new HadoopFileIO()<br>val inputFile = io.newInputFile(&quot;file:///workspace/test.puffin&quot;)<br>val fileSize = inputFile.getLength<br>val in = inputFile.newStream()<br><br>// Read last 12 bytes<br>val trailer = new Array[Byte](12)<br>in.seek(fileSize - 12)<br>in.read(trailer)<br><br>// Decode 4-byte little-endian integer<br>def littleEndianInt(bytes: Array[Byte], offset: Int): Long = {<br>  (bytes(offset) &amp; 0xffL) |<br>  ((bytes(offset + 1) &amp; 0xffL) &lt;&lt; 8) |<br>  ((bytes(offset + 2) &amp; 0xffL) &lt;&lt; 16) |<br>  ((bytes(offset + 3) &amp; 0xffL) &lt;&lt; 24)<br>}<br><br>// Footer trailer<br>val payloadSize = littleEndianInt(trailer, 0)<br>val flags = littleEndianInt(trailer, 4)<br><br>val endingMagic = trailer.slice(8, 12)<br><br>// Footer starts 16 bytes + payload before EOF<br>val footerStart = fileSize - payloadSize - 16<br><br>// Read footer<br>in.seek(footerStart)<br><br>val startingMagic = new Array[Byte](4)<br>in.read(startingMagic)<br><br>val payload = new Array[Byte](payloadSize.toInt)<br>in.read(payload)<br><br>in.close()<br><br>println(&quot;========================================&quot;)<br>println(&quot;Puffin Footer&quot;)<br>println(&quot;========================================&quot;)<br>println(s&quot;File size      : $fileSize bytes&quot;)<br>println(s&quot;Footer start   : $footerStart&quot;)<br>println(s&quot;Payload size   : $payloadSize bytes&quot;)<br>println(s&quot;Flags          : $flags&quot;)<br><br>println()<br>println(<br>  s&quot;Starting magic : ${startingMagic.map(b =&gt; f&quot;${b &amp; 0xff}%02X&quot;).mkString(&quot; &quot;)}&quot;<br>)<br><br>println(<br>  s&quot;Ending magic   : ${endingMagic.map(b =&gt; f&quot;${b &amp; 0xff}%02X&quot;).mkString(&quot; &quot;)}&quot;<br>)<br><br>println()<br>println(&quot;Footer Payload&quot;)<br>println(&quot;----------------------------------------&quot;)<br><br>if ((flags &amp; 1L) == 0) {<br>  println(new String(payload, StandardCharsets.UTF_8))<br>} else {<br>  println(&quot;Footer payload is LZ4 compressed&quot;)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fUKbUIKZwXiBnuMy6O_1g.png" /></figure><p>Refrences</p><p><a href="https://iceberg.apache.org/puffin-spec/">Puffin Spec - Apache Iceberg™</a></p><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bee79f0bc11c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Iceberg | Table Format Version 3 | Puffin file DV blobs]]></title>
            <link>https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-puffin-file-9b12a9cd0e94?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b12a9cd0e94</guid>
            <category><![CDATA[open-table-format]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[puffin-file]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 23:24:05 GMT</pubDate>
            <atom:updated>2026-08-23T07:17:03.509Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring Puffin file DV blobs</h4><p>Please refer below blog for initial setup.</p><p><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-b4cfdb0c9b6b?source=post_page-----726b757dd7a9---------------------------------------">Apache Iceberg | Table Format Version 3</a></p><p>Please refer below blog for Part 1.</p><p><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-puffin-file-726b757dd7a9?postPublishedType=repub">Apache Iceberg | Table Format Version 3 | Puffin File</a></p><p>In this blog, I’ll continue exploring <strong>Apache Iceberg v3 deletion vectors (DVs)</strong> and how they are stored inside <strong>Puffin files</strong>.</p><p>In my previous experiment, I created an Iceberg v3 table containing <strong>100,000 records</strong>, which were written into <strong>12 Parquet data files</strong>. I then performed a couple of DELETE operations targeting a small number of records.</p><p>Although multiple delete statements were executed, the deletes affected records within the same underlying data file. As a result, Iceberg generated a <strong>single deletion vector (DV) blob</strong> in the Puffin file.</p><p>For example, I performed deletes such as:</p><pre>DELETE FROM rest.demo.dv_test<br>WHERE id BETWEEN 50000 AND 50010;<br><br>DELETE FROM rest.demo.dv_test<br>WHERE id IN (50015, 50020, 50025);</pre><p>This raised an interesting question:</p><blockquote>What happens when a DELETE operation affects multiple underlying Parquet data files?</blockquote><h3>Scenarion 1: Generating Multiple DV Blobs</h3><p>To explore this further, I performed another DELETE operation using IDs distributed across the table:</p><pre>DELETE FROM rest.demo.dv_test<br>WHERE id IN (<br>    1000,<br>    9000,<br>    17000,<br>    25000,<br>    33000,<br>    41000,<br>    50000,<br>    58000,<br>    66000,<br>    74000,<br>    82000,<br>    90000<br>);</pre><p>Because these records were distributed across multiple Parquet data files, Iceberg generated multiple deletion vectors.</p><h4><strong>Snapshots</strong></h4><pre>scala&gt; spark.sql(&quot;&quot;&quot;<br>  SELECT *<br>  FROM rest.demo.dv_test.snapshots<br>&quot;&quot;&quot;).show(false)<br><br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|committed_at           |snapshot_id        |parent_id          |operation|manifest_list                                                                                            |summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |<br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|2026-08-14 06:08:27.529|7847232009777615853|NULL               |append   |s3://warehouse/demo/dv_test/metadata/snap-7847232009777615853-1-453f267a-29c3-40d4-b27b-6b0a01fe2f88.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 1, manifests-kept -&gt; 0, manifests-replaced -&gt; 0, added-data-files -&gt; 12, added-records -&gt; 100000, added-files-size -&gt; 247360, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247360, total-data-files -&gt; 12, total-delete-files -&gt; 0, total-position-deletes -&gt; 0, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}                                                                                                                              |<br>|2026-08-14 06:08:49.513|8344233785701471619|7847232009777615853|delete   |s3://warehouse/demo/dv_test/metadata/snap-8344233785701471619-1-e65db625-adc3-4cc9-8c7c-90e825034623.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 1, manifests-kept -&gt; 1, manifests-replaced -&gt; 0, added-delete-files -&gt; 1, added-dvs -&gt; 1, added-files-size -&gt; 39, added-position-deletes -&gt; 11, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247399, total-data-files -&gt; 12, total-delete-files -&gt; 1, total-position-deletes -&gt; 11, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}                                                                                                           |<br>|2026-08-14 06:10:22.273|8530516058209286540|8344233785701471619|delete   |s3://warehouse/demo/dv_test/metadata/snap-8530516058209286540-1-24b13214-0706-4db3-94cb-70c74202abb0.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 2, manifests-kept -&gt; 1, manifests-replaced -&gt; 1, added-delete-files -&gt; 1, removed-delete-files -&gt; 1, added-dvs -&gt; 1, removed-dvs -&gt; 1, added-files-size -&gt; 51, removed-files-size -&gt; 39, added-position-deletes -&gt; 14, removed-position-deletes -&gt; 11, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247411, total-data-files -&gt; 12, total-delete-files -&gt; 1, total-position-deletes -&gt; 14, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}    |<br>|2026-08-16 22:40:12.747|1985306550114814857|8530516058209286540|delete   |s3://warehouse/demo/dv_test/metadata/snap-1985306550114814857-1-20eabf21-1f06-430c-993c-277bd9b9e248.avro|{spark.app.id -&gt; local-1786919576373, manifests-created -&gt; 2, manifests-kept -&gt; 1, manifests-replaced -&gt; 1, added-delete-files -&gt; 10, removed-delete-files -&gt; 1, added-dvs -&gt; 10, removed-dvs -&gt; 1, added-files-size -&gt; 435, removed-files-size -&gt; 51, added-position-deletes -&gt; 25, removed-position-deletes -&gt; 14, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247795, total-data-files -&gt; 12, total-delete-files -&gt; 10, total-position-deletes -&gt; 25, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786919576373, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}|<br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+</pre><h4>Summary of the Last Snapshot</h4><ul><li><strong>Snapshot ID:</strong> 1985306550114814857</li><li><strong>Operation:</strong> DELETE</li><li><strong>Parent Snapshot:</strong> 8530516058209286540</li><li>The table still contains <strong>100,000 records across 12 Parquet data files</strong>.</li><li>The DELETE affected multiple underlying Parquet files.</li><li>Iceberg added <strong>10 deletion vectors (</strong><strong>added-dvs = 10)</strong></li><li><strong>10 delete-file entries</strong> were added, while the previous <strong>1 DV was replaced</strong>.</li><li>added-position-deletes = 25 means the current table has <strong>25 deleted positions</strong> represented by DVs.</li><li>The previous snapshot had <strong>14 deleted positions</strong>, so <strong>11 new positions</strong> were added by this DELETE.</li><li>The 10 DV blobs are stored inside a single physical Puffin file.</li><li>Each DV blob references a different Parquet data file using referenced_data_file.</li><li>The content_offset and content_size_in_bytes columns identify the individual blobs within the Puffin file.</li><li>This demonstrates that <strong>one Puffin file can contain multiple DV blobs</strong>, with each blob associated with a different data file.</li></ul><p>Puffin File (Latest)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-iJRN-11W86lB0o26khRA.png" /></figure><p>warehouse/demo/dv_test/data/00000–5-e1e3d6ee-845f-46e6–8bef-65f8f4437134–00001-deletes.puffin</p><pre>scala&gt; spark.sql(&quot;&quot;&quot;<br>SELECT<br>    file_path,<br>    file_format,<br>    record_count,<br>    referenced_data_file,<br>    content_offset,<br>    content_size_in_bytes<br>FROM rest.demo.dv_test.delete_files<br>&quot;&quot;&quot;).show(false)<br>+--------------------------------------------------------------------------------------------------+-----------+------------+----------------------------------------------------------------------------------------------+--------------+---------------------+<br>|file_path                                                                                         |file_format|record_count|referenced_data_file                                                                          |content_offset|content_size_in_bytes|<br>+--------------------------------------------------------------------------------------------------+-----------+------------+----------------------------------------------------------------------------------------------+--------------+---------------------+<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |15          |s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |4             |55                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00002-2-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |59            |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00010-10-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet|101           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00008-8-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |143           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00004-4-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |185           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00000-0-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |227           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00009-9-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |269           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00007-7-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |311           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |1           |s3://warehouse/demo/dv_test/data/00001-1-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |353           |42                   |<br>|s3://warehouse/demo/dv_test/data/00000-5-e1e3d6ee-845f-46e6-8bef-65f8f4437134-00001-deletes.puffin|PUFFIN     |2           |s3://warehouse/demo/dv_test/data/00003-3-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet |395           |44                   |<br>+--------------------------------------------------------------------------------------------------+-----------+------------+----------------------------------------------------------------------------------------------+--------------+---------------------+</pre><p>Check Puffin file contetnt</p><pre>scala&gt; println(s&quot;Number of blobs = ${blobs.size()}&quot;)<br>Number of blobs = 10<br><br>scala&gt; blobs.asScala.foreach { b =&gt;<br>  println(&quot;================================&quot;)<br>  println(s&quot;Type          : ${b.`type`()}&quot;)<br>  println(s&quot;Snapshot ID   : ${b.snapshotId()}&quot;)<br>  println(s&quot;Sequence      : ${b.sequenceNumber()}&quot;)<br>  println(s&quot;Input fields  : ${b.inputFields()}&quot;)<br>  println(s&quot;Properties    : ${b.properties()}&quot;)<br>  println(s&quot;Offset        : ${b.offset()}&quot;)<br>  println(s&quot;Length        : ${b.length()}&quot;)<br>}<br><br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=15}<br>Offset        : 4<br>Length        : 55<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00002-2-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 59<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00010-10-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 101<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00008-8-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 143<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00004-4-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 185<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00000-0-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 227<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00009-9-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 269<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00007-7-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 311<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00001-1-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=1}<br>Offset        : 353<br>Length        : 42<br>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00003-3-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=2}<br>Offset        : 395<br>Length        : 44</pre><h3>Scenario 2:</h3><p>Three DELETE Transactions on an Iceberg V3 Table.</p><p>I created an Iceberg <strong>V3</strong> table and loaded <strong>100,000 records</strong>. The initial table contained <strong>12 Parquet data files</strong>, with approximately 8,333 records per file.</p><pre><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>DROP TABLE IF EXISTS rest.demo.dv_test_v3<br>&quot;&quot;&quot;)     |      |<br>res36: org.apache.spark.sql.DataFrame = []<br><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>CREATE TABLE rest.demo.dv_test_v3 (<br>    id BIGINT,<br>    name STRING,<br>    email STRING<br>)<br>USING iceberg<br>TBLPROPERTIES (<br>    &#39;format-version&#39; = &#39;3&#39;,<br>    &#39;write.delete.mode&#39; = &#39;merge-on-read&#39;,<br>    &#39;write.update.mode&#39; = &#39;merge-on-read&#39;<br>)<br>&quot;&quot;&quot;)     |      |      |      |      |      |      |      |      |      |      |      |<br>res37: org.apache.spark.sql.DataFrame = []<br><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>INSERT INTO rest.demo.dv_test_v3<br>SELECT<br>    id,<br>    concat(&#39;user-&#39;, id),<br>    concat(&#39;user-&#39;, id, &#39;@example.com&#39;)<br>FROM range(0, 100000)<br>&quot;&quot;&quot;)     |      |      |      |      |      |      |<br>res38: org.apache.spark.sql.DataFrame = []<br><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>SELECT<br>    file_path,<br>    record_count,<br>    file_size_in_bytes<br>FROM rest.demo.dv_test_v3.files<br>WHERE content = 0<br>&quot;&quot;&quot;).show(100, false)     |      |      |      |      |      |      |<br>+-------------------------------------------------------------------------------------------------+------------+------------------+<br>|file_path                                                                                        |record_count|file_size_in_bytes|<br>+-------------------------------------------------------------------------------------------------+------------+------------------+<br>|s3://warehouse/demo/dv_test_v3/data/00000-54-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |28013             |<br>|s3://warehouse/demo/dv_test_v3/data/00001-55-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |21341             |<br>|s3://warehouse/demo/dv_test_v3/data/00002-56-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8334        |19910             |<br>|s3://warehouse/demo/dv_test_v3/data/00003-57-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19936             |<br>|s3://warehouse/demo/dv_test_v3/data/00004-58-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19869             |<br>|s3://warehouse/demo/dv_test_v3/data/00005-59-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8334        |19555             |<br>|s3://warehouse/demo/dv_test_v3/data/00006-60-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19552             |<br>|s3://warehouse/demo/dv_test_v3/data/00007-61-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19904             |<br>|s3://warehouse/demo/dv_test_v3/data/00008-62-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8334        |19912             |<br>|s3://warehouse/demo/dv_test_v3/data/00009-63-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19938             |<br>|s3://warehouse/demo/dv_test_v3/data/00010-64-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8333        |19873             |<br>|s3://warehouse/demo/dv_test_v3/data/00011-65-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|8334        |19557             |<br>+-------------------------------------------------------------------------------------------------+------------+------------------+</pre><p>I then executed three <strong>separate DELETE transactions</strong>: Each DELETE removed <strong>10,000 records</strong>.</p><pre>scala&gt; spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test_v3<br>WHERE id BETWEEN 10000 AND 19999<br>&quot;&quot;&quot;)     |      |      |<br>res40: org.apache.spark.sql.DataFrame = []<br><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test_v3<br>WHERE id BETWEEN 30000 AND 39999<br>&quot;&quot;&quot;)     |      |      |<br>res41: org.apache.spark.sql.DataFrame = []<br><br>scala&gt;<br>spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test_v3<br>WHERE id BETWEEN 50000 AND 59999<br>&quot;&quot;&quot;)<br>scala&gt;      |      |      |<br>res42: org.apache.spark.sql.DataFrame = []<br></pre><p>What happened?</p><p>The three DELETE operations affected different Parquet data files and generated <strong>six Deletion Vector blobs</strong> in total.</p><p>The delete_files metadata showed:</p><pre>| Puffin file | Data file  | Deleted records | DV offset |<br>| ----------- | ---------- | --------------: | --------: |<br>| Puffin #1   | Parquet #6 |           8,333 |         4 |<br>| Puffin #1   | Parquet #7 |           1,667 |        43 |<br>| Puffin #2   | Parquet #4 |           6,667 |         4 |<br>| Puffin #2   | Parquet #3 |           3,333 |        43 |<br>| Puffin #3   | Parquet #2 |           3,334 |         4 |<br>| Puffin #3   | Parquet #1 |           6,666 |        43 |</pre><pre>scala&gt; spark.sql(&quot;&quot;&quot;<br>SELECT<br>    file_path,<br>    file_format,<br>    record_count,<br>    referenced_data_file,<br>    content_offset,<br>    content_size_in_bytes<br>FROM rest.demo.dv_test_v3.delete_files<br>&quot;&quot;&quot;).show(false)     |      |      |      |      |      |      |      |      |<br>+------------------------------------------------------------------------------------------------------+-----------+------------+-------------------------------------------------------------------------------------------------+--------------+---------------------+<br>|file_path                                                                                             |file_format|record_count|referenced_data_file                                                                             |content_offset|content_size_in_bytes|<br>+------------------------------------------------------------------------------------------------------+-----------+------------+-------------------------------------------------------------------------------------------------+--------------+---------------------+<br>|s3://warehouse/demo/dv_test_v3/data/00000-72-9f4b25e7-15aa-45a8-bc6f-e309bdf4b83e-00001-deletes.puffin|PUFFIN     |8333        |s3://warehouse/demo/dv_test_v3/data/00006-60-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|4             |39                   |<br>|s3://warehouse/demo/dv_test_v3/data/00000-72-9f4b25e7-15aa-45a8-bc6f-e309bdf4b83e-00001-deletes.puffin|PUFFIN     |1667        |s3://warehouse/demo/dv_test_v3/data/00007-61-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|43            |39                   |<br>|s3://warehouse/demo/dv_test_v3/data/00000-70-cb801fdb-09de-402b-8e30-87f89a54f486-00001-deletes.puffin|PUFFIN     |6667        |s3://warehouse/demo/dv_test_v3/data/00004-58-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|4             |39                   |<br>|s3://warehouse/demo/dv_test_v3/data/00000-70-cb801fdb-09de-402b-8e30-87f89a54f486-00001-deletes.puffin|PUFFIN     |3333        |s3://warehouse/demo/dv_test_v3/data/00003-57-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|43            |39                   |<br>|s3://warehouse/demo/dv_test_v3/data/00000-68-3bec0c83-33c2-4ecb-8d6a-db4825e31a81-00001-deletes.puffin|PUFFIN     |3334        |s3://warehouse/demo/dv_test_v3/data/00002-56-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|4             |39                   |<br>|s3://warehouse/demo/dv_test_v3/data/00000-68-3bec0c83-33c2-4ecb-8d6a-db4825e31a81-00001-deletes.puffin|PUFFIN     |6666        |s3://warehouse/demo/dv_test_v3/data/00001-55-5f0f9f21-b990-4250-b524-34f98f36fe35-0-00001.parquet|43            |39                   |<br>+------------------------------------------------------------------------------------------------------+-----------+------------+-------------------------------------------------------------------------------------------------+--------------+---------------------+<br><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>SELECT<br>    committed_at,<br>    snapshot_id,<br>    parent_id,<br>    operation,<br>    summary<br>FROM rest.demo.dv_test_v3.snapshots<br>ORDER BY committed_at<br>&quot;&quot;&quot;).show(100, false)      |      |      |      |      |      |      |      |      |<br>+-----------------------+-------------------+-------------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|committed_at           |snapshot_id        |parent_id          |operation|summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |<br>+-----------------------+-------------------+-------------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|2026-08-23 07:10:24.141|5705057551663524036|NULL               |append   |{spark.app.id -&gt; local-1787428397436, manifests-created -&gt; 1, manifests-kept -&gt; 0, manifests-replaced -&gt; 0, added-data-files -&gt; 12, added-records -&gt; 100000, added-files-size -&gt; 247360, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247360, total-data-files -&gt; 12, total-delete-files -&gt; 0, total-position-deletes -&gt; 0, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1787428397436, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}                         |<br>|2026-08-23 07:10:47.428|8683482672212498873|5705057551663524036|delete   |{spark.app.id -&gt; local-1787428397436, manifests-created -&gt; 1, manifests-kept -&gt; 1, manifests-replaced -&gt; 0, added-delete-files -&gt; 2, added-dvs -&gt; 2, added-files-size -&gt; 78, added-position-deletes -&gt; 10000, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247438, total-data-files -&gt; 12, total-delete-files -&gt; 2, total-position-deletes -&gt; 10000, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1787428397436, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}|<br>|2026-08-23 07:10:53.171|3192775834671474488|8683482672212498873|delete   |{spark.app.id -&gt; local-1787428397436, manifests-created -&gt; 1, manifests-kept -&gt; 2, manifests-replaced -&gt; 0, added-delete-files -&gt; 2, added-dvs -&gt; 2, added-files-size -&gt; 78, added-position-deletes -&gt; 10000, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247516, total-data-files -&gt; 12, total-delete-files -&gt; 4, total-position-deletes -&gt; 20000, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1787428397436, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}|<br>|2026-08-23 07:10:59.754|30421117055154375  |3192775834671474488|delete   |{spark.app.id -&gt; local-1787428397436, manifests-created -&gt; 1, manifests-kept -&gt; 3, manifests-replaced -&gt; 0, added-delete-files -&gt; 2, added-dvs -&gt; 2, added-files-size -&gt; 78, added-position-deletes -&gt; 10000, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247594, total-data-files -&gt; 12, total-delete-files -&gt; 6, total-position-deletes -&gt; 30000, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1787428397436, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}|<br>+-----------------------+-------------------+-------------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br><br>scala&gt;</pre><p>This experiment demonstrates that:</p><blockquote><strong><em>One DELETE transaction can produce multiple DV blobs, and those blobs can be stored together in a single Puffin file.</em></strong></blockquote><p>But when the deletes happen as <strong>separate transactions</strong>, Iceberg/Spark can create separate Puffin files for those commits</p><p>A Puffin file is simply the physical container for one or more DV blobs. The referenced_data_file, content_offset, and content_size_in_bytes fields tell us which data file each DV belongs to and where that DV blob lives inside the Puffin file.</p><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b12a9cd0e94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Iceberg | Table Format Version 3 | Puffin File]]></title>
            <link>https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-puffin-file-726b757dd7a9?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/726b757dd7a9</guid>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[puffin-file]]></category>
            <category><![CDATA[iceberg-table]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 08:15:08 GMT</pubDate>
            <atom:updated>2026-08-23T06:57:50.365Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring Puffin File &amp; Metadata Files</h4><p>Please refer below blog for initial setup.</p><p><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-b4cfdb0c9b6b">Apache Iceberg | Table Format Version 3</a></p><p>In this blog, I’ll explore the Puffin file. In my previous blog, I deleted the records shown below. The following query was used to delete them:</p><pre>spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test<br>WHERE id BETWEEN 50000 AND 50010<br>&quot;&quot;&quot;)</pre><p>Puffin File Content:</p><pre>TYPE          : deletion-vector-v1<br>SNAPSHOT ID   : -1<br>SEQUENCE      : -1<br>INPUT FIELDS  : [2147483645]<br>PROPERTIES    : {<br>    referenced-data-file=s3://warehouse/demo/dv_test/data/00006-6-62f50e23-2fdc-45c3-9f2d-f86bae9e3733-0-00001.parquet,<br>    cardinality=11<br>}<br>OFFSET        : 4<br>LENGTH        : 39</pre><p>After that, I deleted few more records from the table. The query used for this deletion is shown below:</p><pre>spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test<br>WHERE id IN (50015, 50020, 50025)<br>&quot;&quot;&quot;)</pre><p>So in total I have performed three operations, let’s check snapshot.</p><pre>scala&gt; spark.sql(&quot;&quot;&quot;<br>  SELECT *<br>  FROM rest.demo.dv_test.snapshots<br>&quot;&quot;&quot;).show(false)   <br><br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|committed_at           |snapshot_id        |parent_id          |operation|manifest_list                                                                                            |summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |<br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<br>|2026-08-14 06:08:27.529|7847232009777615853|NULL               |append   |s3://warehouse/demo/dv_test/metadata/snap-7847232009777615853-1-453f267a-29c3-40d4-b27b-6b0a01fe2f88.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 1, manifests-kept -&gt; 0, manifests-replaced -&gt; 0, added-data-files -&gt; 12, added-records -&gt; 100000, added-files-size -&gt; 247360, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247360, total-data-files -&gt; 12, total-delete-files -&gt; 0, total-position-deletes -&gt; 0, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}                                                                                                                          |<br>|2026-08-14 06:08:49.513|8344233785701471619|7847232009777615853|delete   |s3://warehouse/demo/dv_test/metadata/snap-8344233785701471619-1-e65db625-adc3-4cc9-8c7c-90e825034623.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 1, manifests-kept -&gt; 1, manifests-replaced -&gt; 0, added-delete-files -&gt; 1, added-dvs -&gt; 1, added-files-size -&gt; 39, added-position-deletes -&gt; 11, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247399, total-data-files -&gt; 12, total-delete-files -&gt; 1, total-position-deletes -&gt; 11, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}                                                                                                       |<br>|2026-08-14 06:10:22.273|8530516058209286540|8344233785701471619|delete   |s3://warehouse/demo/dv_test/metadata/snap-8530516058209286540-1-24b13214-0706-4db3-94cb-70c74202abb0.avro|{spark.app.id -&gt; local-1786687546356, manifests-created -&gt; 2, manifests-kept -&gt; 1, manifests-replaced -&gt; 1, added-delete-files -&gt; 1, removed-delete-files -&gt; 1, added-dvs -&gt; 1, removed-dvs -&gt; 1, added-files-size -&gt; 51, removed-files-size -&gt; 39, added-position-deletes -&gt; 14, removed-position-deletes -&gt; 11, changed-partition-count -&gt; 1, total-records -&gt; 100000, total-files-size -&gt; 247411, total-data-files -&gt; 12, total-delete-files -&gt; 1, total-position-deletes -&gt; 14, total-equality-deletes -&gt; 0, engine-version -&gt; 3.5.6, app-id -&gt; local-1786687546356, engine-name -&gt; spark, iceberg-version -&gt; Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9), app-name -&gt; Spark shell}|<br>+-----------------------+-------------------+-------------------+---------+---------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+</pre><pre>| Snapshot              | Operation | Key change                                               |<br>| --------------------- | --------- | -------------------------------------------------------- |<br>| `7847232009777615853` | `append`  | 100,000 records, 12 Parquet files                        |<br>| `8344233785701471619` | `delete`  | Added 1 DV, 11 position deletes                          |<br>| `8530516058209286540` | `delete`  | Replaced previous DV with a new DV containing 14 deletes |</pre><p>The most interesting part is the <strong>third snapshot</strong>.</p><pre>added-delete-files       -&gt; 1<br>removed-delete-files     -&gt; 1<br>added-dvs                -&gt; 1<br>removed-dvs              -&gt; 1<br>added-position-deletes   -&gt; 14<br>removed-position-deletes -&gt; 11<br>added-files-size         -&gt; 51<br>removed-files-size       -&gt; 39<br>total-delete-files       -&gt; 1<br>total-position-deletes   -&gt; 14</pre><p>So two Puffin files existing physically does not mean two active deletion vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0vG-P_fR9eMZsUsdFtlKw.png" /></figure><p>Active Delete Vector &amp; its Puffin File</p><blockquote>At most one deletion vector is allowed per data file in a snapshot.</blockquote><pre><br>scala&gt; spark.sql(&quot;&quot;&quot;<br>SELECT<br>    file_path,<br>    file_format,<br>    record_count,<br>    referenced_data_file,<br>    content_offset,<br>    content_size_in_bytes<br>FROM rest.demo.dv_test.delete_files<br>&quot;&quot;&quot;).show(false)<br><br>+---------------------------------------------------------------------------------------------------+-----------+------------+---------------------------------------------------------------------------------------------+--------------+---------------------+<br>|file_path                                                                                          |file_format|record_count|referenced_data_file                                                                         |content_offset|content_size_in_bytes|<br>+---------------------------------------------------------------------------------------------------+-----------+------------+---------------------------------------------------------------------------------------------+--------------+---------------------+<br>|s3://warehouse/demo/dv_test/data/00000-16-71bbb11e-ff17-46f6-93b6-383373f84a1c-00001-deletes.puffin|PUFFIN     |14          |s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet|4             |51                   |<br>+---------------------------------------------------------------------------------------------------+-----------+------------+---------------------------------------------------------------------------------------------+--------------+---------------------+</pre><pre>================================<br>Type          : deletion-vector-v1<br>Snapshot ID   : -1<br>Sequence      : -1<br>Input fields  : [2147483645]<br>Properties    : {referenced-data-file=s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet, cardinality=14}<br>Offset        : 4<br>Length        : 51<br><br>scala&gt;</pre><p><strong>cardinality = 14</strong> this deletion vector represents <strong>14 deleted rows/positions</strong> in that Parquet file.</p><p>Latest metadata.json</p><pre>{<br>  &quot;format-version&quot;: 3,<br>  &quot;table-uuid&quot;: &quot;1eea91d8-010a-49ad-a89a-6863921f1a7c&quot;,<br>  &quot;location&quot;: &quot;s3://warehouse/demo/dv_test&quot;,<br>  &quot;last-sequence-number&quot;: 3,<br>  &quot;last-updated-ms&quot;: 1786687822283,<br>  &quot;last-column-id&quot;: 3,<br>  &quot;current-schema-id&quot;: 0,<br>  &quot;schemas&quot;: [<br>    {<br>      &quot;type&quot;: &quot;struct&quot;,<br>      &quot;schema-id&quot;: 0,<br>      &quot;fields&quot;: [<br>        {<br>          &quot;id&quot;: 1,<br>          &quot;name&quot;: &quot;id&quot;,<br>          &quot;required&quot;: false,<br>          &quot;type&quot;: &quot;long&quot;<br>        },<br>        {<br>          &quot;id&quot;: 2,<br>          &quot;name&quot;: &quot;name&quot;,<br>          &quot;required&quot;: false,<br>          &quot;type&quot;: &quot;string&quot;<br>        },<br>        {<br>          &quot;id&quot;: 3,<br>          &quot;name&quot;: &quot;email&quot;,<br>          &quot;required&quot;: false,<br>          &quot;type&quot;: &quot;string&quot;<br>        }<br>      ]<br>    }<br>  ],<br>  &quot;default-spec-id&quot;: 0,<br>  &quot;partition-specs&quot;: [<br>    {<br>      &quot;spec-id&quot;: 0,<br>      &quot;fields&quot;: []<br>    }<br>  ],<br>  &quot;last-partition-id&quot;: 999,<br>  &quot;default-sort-order-id&quot;: 0,<br>  &quot;sort-orders&quot;: [<br>    {<br>      &quot;order-id&quot;: 0,<br>      &quot;fields&quot;: []<br>    }<br>  ],<br>  &quot;properties&quot;: {<br>    &quot;owner&quot;: &quot;spark&quot;,<br>    &quot;write.update.mode&quot;: &quot;merge-on-read&quot;,<br>    &quot;write.delete.mode&quot;: &quot;merge-on-read&quot;,<br>    &quot;write.parquet.compression-codec&quot;: &quot;zstd&quot;<br>  },<br>  &quot;current-snapshot-id&quot;: 8530516058209286540,<br>  &quot;next-row-id&quot;: 100000,<br>  &quot;refs&quot;: {<br>    &quot;main&quot;: {<br>      &quot;snapshot-id&quot;: 8530516058209286540,<br>      &quot;type&quot;: &quot;branch&quot;<br>    }<br>  },<br>  &quot;snapshots&quot;: [<br>    {<br>      &quot;sequence-number&quot;: 1,<br>      &quot;snapshot-id&quot;: 7847232009777615853,<br>      &quot;timestamp-ms&quot;: 1786687707529,<br>      &quot;summary&quot;: {<br>        &quot;operation&quot;: &quot;append&quot;,<br>        &quot;spark.app.id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;manifests-created&quot;: &quot;1&quot;,<br>        &quot;manifests-kept&quot;: &quot;0&quot;,<br>        &quot;manifests-replaced&quot;: &quot;0&quot;,<br>        &quot;added-data-files&quot;: &quot;12&quot;,<br>        &quot;added-records&quot;: &quot;100000&quot;,<br>        &quot;added-files-size&quot;: &quot;247360&quot;,<br>        &quot;changed-partition-count&quot;: &quot;1&quot;,<br>        &quot;total-records&quot;: &quot;100000&quot;,<br>        &quot;total-files-size&quot;: &quot;247360&quot;,<br>        &quot;total-data-files&quot;: &quot;12&quot;,<br>        &quot;total-delete-files&quot;: &quot;0&quot;,<br>        &quot;total-position-deletes&quot;: &quot;0&quot;,<br>        &quot;total-equality-deletes&quot;: &quot;0&quot;,<br>        &quot;engine-version&quot;: &quot;3.5.6&quot;,<br>        &quot;app-id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;engine-name&quot;: &quot;spark&quot;,<br>        &quot;iceberg-version&quot;: &quot;Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9)&quot;,<br>        &quot;app-name&quot;: &quot;Spark shell&quot;<br>      },<br>      &quot;manifest-list&quot;: &quot;s3://warehouse/demo/dv_test/metadata/snap-7847232009777615853-1-453f267a-29c3-40d4-b27b-6b0a01fe2f88.avro&quot;,<br>      &quot;schema-id&quot;: 0,<br>      &quot;first-row-id&quot;: 0,<br>      &quot;added-rows&quot;: 100000<br>    },<br>    {<br>      &quot;sequence-number&quot;: 2,<br>      &quot;snapshot-id&quot;: 8344233785701471619,<br>      &quot;parent-snapshot-id&quot;: 7847232009777615853,<br>      &quot;timestamp-ms&quot;: 1786687729513,<br>      &quot;summary&quot;: {<br>        &quot;operation&quot;: &quot;delete&quot;,<br>        &quot;spark.app.id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;manifests-created&quot;: &quot;1&quot;,<br>        &quot;manifests-kept&quot;: &quot;1&quot;,<br>        &quot;manifests-replaced&quot;: &quot;0&quot;,<br>        &quot;added-delete-files&quot;: &quot;1&quot;,<br>        &quot;added-dvs&quot;: &quot;1&quot;,<br>        &quot;added-files-size&quot;: &quot;39&quot;,<br>        &quot;added-position-deletes&quot;: &quot;11&quot;,<br>        &quot;changed-partition-count&quot;: &quot;1&quot;,<br>        &quot;total-records&quot;: &quot;100000&quot;,<br>        &quot;total-files-size&quot;: &quot;247399&quot;,<br>        &quot;total-data-files&quot;: &quot;12&quot;,<br>        &quot;total-delete-files&quot;: &quot;1&quot;,<br>        &quot;total-position-deletes&quot;: &quot;11&quot;,<br>        &quot;total-equality-deletes&quot;: &quot;0&quot;,<br>        &quot;engine-version&quot;: &quot;3.5.6&quot;,<br>        &quot;app-id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;engine-name&quot;: &quot;spark&quot;,<br>        &quot;iceberg-version&quot;: &quot;Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9)&quot;,<br>        &quot;app-name&quot;: &quot;Spark shell&quot;<br>      },<br>      &quot;manifest-list&quot;: &quot;s3://warehouse/demo/dv_test/metadata/snap-8344233785701471619-1-e65db625-adc3-4cc9-8c7c-90e825034623.avro&quot;,<br>      &quot;schema-id&quot;: 0,<br>      &quot;first-row-id&quot;: 100000,<br>      &quot;added-rows&quot;: 0<br>    },<br>    {<br>      &quot;sequence-number&quot;: 3,<br>      &quot;snapshot-id&quot;: 8530516058209286540,<br>      &quot;parent-snapshot-id&quot;: 8344233785701471619,<br>      &quot;timestamp-ms&quot;: 1786687822273,<br>      &quot;summary&quot;: {<br>        &quot;operation&quot;: &quot;delete&quot;,<br>        &quot;spark.app.id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;manifests-created&quot;: &quot;2&quot;,<br>        &quot;manifests-kept&quot;: &quot;1&quot;,<br>        &quot;manifests-replaced&quot;: &quot;1&quot;,<br>        &quot;added-delete-files&quot;: &quot;1&quot;,<br>        &quot;removed-delete-files&quot;: &quot;1&quot;,<br>        &quot;added-dvs&quot;: &quot;1&quot;,<br>        &quot;removed-dvs&quot;: &quot;1&quot;,<br>        &quot;added-files-size&quot;: &quot;51&quot;,<br>        &quot;removed-files-size&quot;: &quot;39&quot;,<br>        &quot;added-position-deletes&quot;: &quot;14&quot;,<br>        &quot;removed-position-deletes&quot;: &quot;11&quot;,<br>        &quot;changed-partition-count&quot;: &quot;1&quot;,<br>        &quot;total-records&quot;: &quot;100000&quot;,<br>        &quot;total-files-size&quot;: &quot;247411&quot;,<br>        &quot;total-data-files&quot;: &quot;12&quot;,<br>        &quot;total-delete-files&quot;: &quot;1&quot;,<br>        &quot;total-position-deletes&quot;: &quot;14&quot;,<br>        &quot;total-equality-deletes&quot;: &quot;0&quot;,<br>        &quot;engine-version&quot;: &quot;3.5.6&quot;,<br>        &quot;app-id&quot;: &quot;local-1786687546356&quot;,<br>        &quot;engine-name&quot;: &quot;spark&quot;,<br>        &quot;iceberg-version&quot;: &quot;Apache Iceberg 1.11.0 (commit 6976e020b894f6a6777704df2b8c4458cb291ae9)&quot;,<br>        &quot;app-name&quot;: &quot;Spark shell&quot;<br>      },<br>      &quot;manifest-list&quot;: &quot;s3://warehouse/demo/dv_test/metadata/snap-8530516058209286540-1-24b13214-0706-4db3-94cb-70c74202abb0.avro&quot;,<br>      &quot;schema-id&quot;: 0,<br>      &quot;first-row-id&quot;: 100000,<br>      &quot;added-rows&quot;: 0<br>    }<br>  ],<br>  &quot;statistics&quot;: [],<br>  &quot;partition-statistics&quot;: [],<br>  &quot;snapshot-log&quot;: [<br>    {<br>      &quot;timestamp-ms&quot;: 1786687707529,<br>      &quot;snapshot-id&quot;: 7847232009777615853<br>    },<br>    {<br>      &quot;timestamp-ms&quot;: 1786687729513,<br>      &quot;snapshot-id&quot;: 8344233785701471619<br>    },<br>    {<br>      &quot;timestamp-ms&quot;: 1786687822273,<br>      &quot;snapshot-id&quot;: 8530516058209286540<br>    }<br>  ],<br>  &quot;metadata-log&quot;: [<br>    {<br>      &quot;timestamp-ms&quot;: 1786687692776,<br>      &quot;metadata-file&quot;: &quot;s3://warehouse/demo/dv_test/metadata/00000-0cfc6cf8-5e98-450a-a583-09df6779a17b.metadata.json&quot;<br>    },<br>    {<br>      &quot;timestamp-ms&quot;: 1786687707575,<br>      &quot;metadata-file&quot;: &quot;s3://warehouse/demo/dv_test/metadata/00001-3c7480fd-4626-4125-8ef2-6040c3150f48.metadata.json&quot;<br>    },<br>    {<br>      &quot;timestamp-ms&quot;: 1786687729526,<br>      &quot;metadata-file&quot;: &quot;s3://warehouse/demo/dv_test/metadata/00002-83d4b344-ae54-4c87-950e-36d69520a502.metadata.json&quot;<br>    }<br>  ]<br>}</pre><p>Latest “manifest-list”: “s3://warehouse/demo/dv_test/metadata/snap-8530516058209286540–1–24b13214–0706–4db3–94cb-70c74202abb0.avro”</p><pre>[<br>  {<br>    &quot;manifest_path&quot;: &quot;s3://warehouse/demo/dv_test/metadata/453f267a-29c3-40d4-b27b-6b0a01fe2f88-m0.avro&quot;,<br>    &quot;manifest_length&quot;: 8415,<br>    &quot;partition_spec_id&quot;: 0,<br>    &quot;content&quot;: 0,<br>    &quot;sequence_number&quot;: 1,<br>    &quot;min_sequence_number&quot;: 1,<br>    &quot;added_snapshot_id&quot;: 7847232009777615853,<br>    &quot;added_files_count&quot;: 12,<br>    &quot;existing_files_count&quot;: 0,<br>    &quot;deleted_files_count&quot;: 0,<br>    &quot;added_rows_count&quot;: 100000,<br>    &quot;existing_rows_count&quot;: 0,<br>    &quot;deleted_rows_count&quot;: 0,<br>    &quot;partitions&quot;: [],<br>    &quot;key_metadata&quot;: null,<br>    &quot;first_row_id&quot;: 0<br>  },<br>  {<br>    &quot;manifest_path&quot;: &quot;s3://warehouse/demo/dv_test/metadata/24b13214-0706-4db3-94cb-70c74202abb0-m1.avro&quot;,<br>    &quot;manifest_length&quot;: 7916,<br>    &quot;partition_spec_id&quot;: 0,<br>    &quot;content&quot;: 1,<br>    &quot;sequence_number&quot;: 3,<br>    &quot;min_sequence_number&quot;: 3,<br>    &quot;added_snapshot_id&quot;: 8530516058209286540,<br>    &quot;added_files_count&quot;: 1,<br>    &quot;existing_files_count&quot;: 0,<br>    &quot;deleted_files_count&quot;: 0,<br>    &quot;added_rows_count&quot;: 14,<br>    &quot;existing_rows_count&quot;: 0,<br>    &quot;deleted_rows_count&quot;: 0,<br>    &quot;partitions&quot;: [],<br>    &quot;key_metadata&quot;: null,<br>    &quot;first_row_id&quot;: null<br>  },<br>  {<br>    &quot;manifest_path&quot;: &quot;s3://warehouse/demo/dv_test/metadata/24b13214-0706-4db3-94cb-70c74202abb0-m0.avro&quot;,<br>    &quot;manifest_length&quot;: 7918,<br>    &quot;partition_spec_id&quot;: 0,<br>    &quot;content&quot;: 1,<br>    &quot;sequence_number&quot;: 3,<br>    &quot;min_sequence_number&quot;: 3,<br>    &quot;added_snapshot_id&quot;: 8530516058209286540,<br>    &quot;added_files_count&quot;: 0,<br>    &quot;existing_files_count&quot;: 0,<br>    &quot;deleted_files_count&quot;: 1,<br>    &quot;added_rows_count&quot;: 0,<br>    &quot;existing_rows_count&quot;: 0,<br>    &quot;deleted_rows_count&quot;: 11,<br>    &quot;partitions&quot;: [],<br>    &quot;key_metadata&quot;: null,<br>    &quot;first_row_id&quot;: null<br>  }<br>]<br></pre><pre>To read the manifest files, we should see the status of datafile. Refer below table.<br><br>status : 0=EXISTING, aka rewrite, 1= ADDED, 2 =DELETED<br><br>+--------+-------------------------+<br>| status |  description            |<br>+--------+-------------------------+<br>| 0      | 0=EXISTING, aka rewrite | <br>| 1      | ADDED                   |<br>| 2      | DELETED                 | <br>+--------+-------------------------+</pre><pre>24b13214-0706-4db3-94cb-70c74202abb0-m0.avro<br><br>[<br>  {<br>    &quot;status&quot;: 2,<br>    &quot;snapshot_id&quot;: 8530516058209286540,<br>    &quot;sequence_number&quot;: 2,<br>    &quot;file_sequence_number&quot;: 2,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 1,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00000-14-fb2f8f8b-533c-4cdd-986e-3ba32f438859-00001-deletes.puffin&quot;,<br>      &quot;file_format&quot;: &quot;PUFFIN&quot;,<br>      &quot;partition&quot;: {},<br>      &quot;record_count&quot;: 11,<br>      &quot;file_size_in_bytes&quot;: 438,<br>      &quot;column_sizes&quot;: null,<br>      &quot;value_counts&quot;: null,<br>      &quot;null_value_counts&quot;: null,<br>      &quot;nan_value_counts&quot;: null,<br>      &quot;lower_bounds&quot;: null,<br>      &quot;upper_bounds&quot;: null,<br>      &quot;key_metadata&quot;: null,<br>      &quot;split_offsets&quot;: null,<br>      &quot;equality_ids&quot;: null,<br>      &quot;sort_order_id&quot;: null,<br>      &quot;first_row_id&quot;: null,<br>      &quot;referenced_data_file&quot;: &quot;s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;content_offset&quot;: 4,<br>      &quot;content_size_in_bytes&quot;: 39<br>    }<br>  }<br>]</pre><pre>24b13214-0706-4db3-94cb-70c74202abb0-m1.avro<br><br>[<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 8530516058209286540,<br>    &quot;sequence_number&quot;: null,<br>    &quot;file_sequence_number&quot;: null,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 1,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00000-16-71bbb11e-ff17-46f6-93b6-383373f84a1c-00001-deletes.puffin&quot;,<br>      &quot;file_format&quot;: &quot;PUFFIN&quot;,<br>      &quot;partition&quot;: {},<br>      &quot;record_count&quot;: 14,<br>      &quot;file_size_in_bytes&quot;: 450,<br>      &quot;column_sizes&quot;: null,<br>      &quot;value_counts&quot;: null,<br>      &quot;null_value_counts&quot;: null,<br>      &quot;nan_value_counts&quot;: null,<br>      &quot;lower_bounds&quot;: null,<br>      &quot;upper_bounds&quot;: null,<br>      &quot;key_metadata&quot;: null,<br>      &quot;split_offsets&quot;: null,<br>      &quot;equality_ids&quot;: null,<br>      &quot;sort_order_id&quot;: null,<br>      &quot;first_row_id&quot;: null,<br>      &quot;referenced_data_file&quot;: &quot;s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;content_offset&quot;: 4,<br>      &quot;content_size_in_bytes&quot;: 51<br>    }<br>  }<br>]</pre><p>status = 2 in 24b13214–0706–4db3–94cb-70c74202abb0-m0.avro indicates that the referenced delete file is marked as <strong>deleted/removed from the current manifest state</strong>. In this example, Iceberg is replacing the previous 11-row deletion vector with a new deletion vector containing 14 position deletes.</p><pre>453f267a-29c3-40d4-b27b-6b0a01fe2f88-m0.avro</pre><p>This manifest file contains information about all the data files created during the first snapshot.</p><pre>[<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00000-0-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 28013<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00001-1-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 21341<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00002-2-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8334,<br>      &quot;file_size_in_bytes&quot;: 19910<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00003-3-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19936<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00004-4-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19869<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00005-5-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8334,<br>      &quot;file_size_in_bytes&quot;: 19555<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00006-6-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19552<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00007-7-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19904<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00008-8-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8334,<br>      &quot;file_size_in_bytes&quot;: 19912<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00009-9-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19938<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00010-10-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8333,<br>      &quot;file_size_in_bytes&quot;: 19873<br>    }<br>  },<br>  {<br>    &quot;status&quot;: 1,<br>    &quot;snapshot_id&quot;: 7847232009777615853,<br>    &quot;data_file&quot;: {<br>      &quot;content&quot;: 0,<br>      &quot;file_path&quot;: &quot;s3://warehouse/demo/dv_test/data/00011-11-8b485e61-eb3f-4570-8b4d-42196c8541ee-0-00001.parquet&quot;,<br>      &quot;file_format&quot;: &quot;PARQUET&quot;,<br>      &quot;record_count&quot;: 8334,<br>      &quot;file_size_in_bytes&quot;: 19557<br>    }<br>  }<br>]</pre><p>Avro to JSON</p><pre>import json<br>from fastavro import reader<br><br>input_file = &quot;24b13214-0706-4db3-94cb-70c74202abb0-m1.avro&quot;<br>output_file = &quot;output.json&quot;<br><br>records = []<br><br>with open(input_file, &quot;rb&quot;) as f:<br>    avro_reader = reader(f)<br><br>    for record in avro_reader:<br>        records.append(record)<br><br>with open(output_file, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br>    json.dump(records, f, indent=2, default=str)<br><br>print(f&quot;Converted {input_file} -&gt; {output_file}&quot;)<br>print(f&quot;Records: {len(records)}&quot;)</pre><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=726b757dd7a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Iceberg | Table Format Version 3 | Docker Setup]]></title>
            <link>https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-b4cfdb0c9b6b?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4cfdb0c9b6b</guid>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[iceberg-table]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[open-table-format]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Sun, 09 Aug 2026 19:45:45 GMT</pubDate>
            <atom:updated>2026-08-22T19:45:53.031Z</atom:updated>
            <content:encoded><![CDATA[<h4>Setup docker based Iceberg env &amp; create v3 Iceberg table</h4><p>Exploring Apache Iceberg V3 with Apache Spark.</p><p>For this exploration, I built a small Docker based Iceberg environment using Apache Spark 3.5.6, Apache Iceberg 1.11.0, an Iceberg REST Catalog, and MinIO as the S3-compatible object store.</p><p>My local project is organized as follows:</p><pre>iceberg-local/<br>│<br>├── docker-compose.yml<br>│<br>└── spark/<br>    │<br>    ├── Dockerfile<br>    │<br>    └── conf/<br>        └── spark-defaults.conf</pre><p>docker-compose</p><pre>services:<br><br>  spark:<br>    build:<br>      context: ./spark<br>    container_name: spark<br><br>    depends_on:<br>      - iceberg-rest<br>      - minio<br><br>    environment:<br>      AWS_ACCESS_KEY_ID: admin<br>      AWS_SECRET_ACCESS_KEY: admin123<br>      AWS_REGION: us-east-1<br><br>    ports:<br>      - &quot;4040:4040&quot;<br><br>    volumes:<br>      - ./spark:/workspace<br>      - ./spark/conf/spark-defaults.conf:/opt/spark/conf/spark-defaults.conf<br><br>    networks:<br>      - iceberg<br><br>    command:<br>      - /bin/bash<br>      - -c<br>      - |<br>        echo &quot;Spark container ready&quot;<br>        /opt/spark/bin/spark-submit --version<br>        echo &quot;Keeping Spark container alive...&quot;<br>        tail -f /dev/null<br><br><br>  iceberg-rest:<br>    image: apache/iceberg-rest-fixture:latest<br>    container_name: iceberg-rest<br><br>    depends_on:<br>      - minio<br><br>    ports:<br>      - &quot;8181:8181&quot;<br><br>    environment:<br>      AWS_ACCESS_KEY_ID: admin<br>      AWS_SECRET_ACCESS_KEY: admin123<br>      AWS_REGION: us-east-1<br><br>      CATALOG_WAREHOUSE: s3://warehouse/<br>      CATALOG_IO__IMPL: org.apache.iceberg.aws.s3.S3FileIO<br>      CATALOG_S3_ENDPOINT: http://minio:9000<br>      CATALOG_S3_PATH__STYLE__ACCESS: &quot;true&quot;<br>      CATALOG_S3_ACCESS__KEY__ID: admin<br>      CATALOG_S3_SECRET__ACCESS__KEY: admin123<br><br>    networks:<br>      - iceberg<br><br><br>  minio:<br>    image: minio/minio:latest<br>    container_name: minio<br><br>    command:<br>      - server<br>      - /data<br>      - --console-address<br>      - &quot;:9001&quot;<br><br>    ports:<br>      - &quot;9000:9000&quot;<br>      - &quot;9001:9001&quot;<br><br>    environment:<br>      MINIO_ROOT_USER: admin<br>      MINIO_ROOT_PASSWORD: admin123<br><br>    volumes:<br>      - minio-data:/data<br><br>    networks:<br>      - iceberg<br><br><br>  minio-init:<br>    image: minio/mc:latest<br>    container_name: minio-init<br><br>    depends_on:<br>      - minio<br><br>    networks:<br>      - iceberg<br><br>    entrypoint:<br>      - /bin/sh<br>      - -c<br>      - |<br>        until mc alias set local http://minio:9000 admin admin123; do<br>          echo &quot;Waiting for MinIO...&quot;<br>          sleep 2<br>        done<br><br>        mc mb --ignore-existing local/warehouse<br><br>        echo &quot;Warehouse bucket ready&quot;<br><br><br>networks:<br>  iceberg:<br>    driver: bridge<br><br><br>volumes:<br>  minio-data:</pre><p>Spark Dockerfile</p><pre>FROM apache/spark:3.5.6<br><br>USER root<br><br># Install Java 17<br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y openjdk-17-jdk &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/*<br><br>ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64<br><br>ARG ICEBERG_VERSION=1.11.0<br><br># Iceberg Spark 3.5 runtime<br>RUN curl -fL \<br>    -o /opt/spark/jars/iceberg-spark-runtime-3.5_2.12-${ICEBERG_VERSION}.jar \<br>    https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-spark-runtime-3.5_2.12/${ICEBERG_VERSION}/iceberg-spark-runtime-3.5_2.12-${ICEBERG_VERSION}.jar<br><br># Iceberg AWS bundle<br>RUN curl -fL \<br>    -o /opt/spark/jars/iceberg-aws-bundle-${ICEBERG_VERSION}.jar \<br>    https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-aws-bundle/${ICEBERG_VERSION}/iceberg-aws-bundle-${ICEBERG_VERSION}.jar<br><br>RUN mkdir -p /workspace &amp;&amp; \<br>    chown -R spark:spark /workspace<br><br>WORKDIR /workspace<br><br>USER spark</pre><p>spark-default.conf</p><pre>spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions<br><br>spark.sql.catalog.rest=org.apache.iceberg.spark.SparkCatalog<br>spark.sql.catalog.rest.type=rest<br>spark.sql.catalog.rest.uri=http://iceberg-rest:8181<br>spark.sql.catalog.rest.warehouse=s3://warehouse/<br><br>spark.sql.catalog.rest.io-impl=org.apache.iceberg.aws.s3.S3FileIO<br><br>spark.sql.catalog.rest.s3.endpoint=http://minio:9000<br>spark.sql.catalog.rest.s3.path-style-access=true<br>spark.sql.catalog.rest.s3.access-key-id=admin<br>spark.sql.catalog.rest.s3.secret-access-key=admin123</pre><p>Run docker compose up -d . Check if containers are in running state or not using docker ps command.</p><pre>docker compose build --no-cache<br>docker compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__VlKOjQpmGd_UhIPzx2Dw.png" /></figure><p>Start Spark Shell with Iceberg REST Catalog</p><pre>docker exec -it spark /opt/spark/bin/spark-shell `<br>  --conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions `<br>  --conf spark.sql.catalog.rest=org.apache.iceberg.spark.SparkCatalog `<br>  --conf spark.sql.catalog.rest.type=rest `<br>  --conf spark.sql.catalog.rest.uri=http://iceberg-rest:8181 `<br>  --conf spark.sql.catalog.rest.warehouse=s3://warehouse/ `<br>  --conf spark.sql.catalog.rest.io-impl=org.apache.iceberg.aws.s3.S3FileIO `<br>  --conf spark.sql.catalog.rest.s3.endpoint=http://minio:9000 `<br>  --conf spark.sql.catalog.rest.s3.path-style-access=true `<br>  --conf spark.sql.catalog.rest.s3.access-key-id=admin `<br>  --conf spark.sql.catalog.rest.s3.secret-access-key=admin123</pre><p>Iceberg v3 Table</p><pre>spark.sql(&quot;&quot;&quot;<br>CREATE TABLE rest.demo.dv_test (<br>    id BIGINT,<br>    name STRING,<br>    email STRING<br>)<br>USING iceberg<br>TBLPROPERTIES (<br>    &#39;format-version&#39; = &#39;3&#39;,<br>    &#39;write.delete.mode&#39; = &#39;merge-on-read&#39;,<br>    &#39;write.update.mode&#39; = &#39;merge-on-read&#39;<br>)<br>&quot;&quot;&quot;)<br><br>spark.sql(&quot;&quot;&quot;<br>SHOW TBLPROPERTIES rest.demo.dv_test<br>&quot;&quot;&quot;).show(false)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nz56Rhjx_l0HC8zrSDi3Q.png" /></figure><p>Let’s insert some data in v3 table.</p><pre>spark.sql(&quot;&quot;&quot;<br>INSERT INTO rest.demo.dv_test<br>SELECT<br>    id,<br>    concat(&#39;user-&#39;, id),<br>    concat(&#39;user-&#39;, id, &#39;@example.com&#39;)<br>FROM range(0, 100000)<br>&quot;&quot;&quot;)<br><br>--check data files<br>spark.sql(&quot;&quot;&quot;<br>SELECT<br>    file_path,<br>    file_format,<br>    record_count,<br>    file_size_in_bytes<br>FROM rest.demo.dv_test.files<br>&quot;&quot;&quot;).show(false)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJ5Q_scigPR0UYX2TDd6Jg.png" /></figure><p>Let’s perform delete operation.</p><pre>spark.sql(&quot;&quot;&quot;<br>DELETE FROM rest.demo.dv_test<br>WHERE id BETWEEN 50000 AND 50010<br>&quot;&quot;&quot;)</pre><p>After executing a row-level DELETE, Iceberg did not simply rewrite the original Parquet data file. Instead, the table produced a Puffin file containing a deletion-vector-v1 blob.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2qBds2qPMCowzRc8USO3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Js6pV5YAXIIsMHdgA379lg.png" /></figure><p>It has created a Puffin format file. <strong>Puffin</strong> is a binary file format introduced in Apache Iceberg for storing <strong>auxiliary metadata/statistics</strong>, rather than normal table rows.</p><p>Inspected the Puffin file directly and found:</p><pre>TYPE          : deletion-vector-v1<br>SNAPSHOT ID   : -1<br>SEQUENCE      : -1<br>INPUT FIELDS  : [2147483645]<br>PROPERTIES    : {<br>    referenced-data-file=s3://warehouse/demo/dv_test/data/00006-6-62f50e23-2fdc-45c3-9f2d-f86bae9e3733-0-00001.parquet,<br>    cardinality=11<br>}<br>OFFSET        : 4<br>LENGTH        : 39</pre><p>Interesting part is the referenced-data-file property. It points to the specific Parquet file to which the deletion vector applies, while cardinality=11 indicates that the deletion vector represents <strong>11 deleted rows</strong>.</p><p>Final output (MOR)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*aNCGPg7WhECjrWMC8YFzmw.png" /></figure><p>Part 1 &amp; Part 2</p><ul><li><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-puffin-file-726b757dd7a9?postPublishedType=repub">Apache Iceberg | Table Format Version 3 | Puffin File</a></li><li><a href="https://bigdataenthusiast.medium.com/apache-iceberg-table-format-version-3-puffin-file-9b12a9cd0e94?postPublishedType=repub">Apache Iceberg | Table Format Version 3 | Puffin File</a></li></ul><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4cfdb0c9b6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trino + Iceberg REST + MinIO | Docker Setup]]></title>
            <link>https://bigdataenthusiast.medium.com/trino-iceberg-rest-minio-docker-setup-1ecd3e7e0e5f?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ecd3e7e0e5f</guid>
            <category><![CDATA[minio]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[trinos]]></category>
            <category><![CDATA[data-lake]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Sat, 17 Jan 2026 20:50:36 GMT</pubDate>
            <atom:updated>2026-01-24T19:08:26.405Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prerequisites</h3><ul><li>Docker — Make sure Dockerdaemon is running.</li><li>Optional<strong>:</strong> Trino CLI. We can use docker exec -it trino trino to run queries.</li></ul><h4>Step 1:</h4><p>Setup the docker-compose.yml &amp; iceberg.properties</p><p>docker-compose.yml</p><pre>version: &quot;3.9&quot;<br>services:<br>  trino:<br>    image: trinodb/trino:440<br>    container_name: trino<br>    ports:<br>      - &quot;8080:8080&quot;<br>    volumes:<br>      - ./trino/catalog:/etc/trino/catalog<br>    depends_on:<br>      - iceberg-rest<br>      - minio<br>      <br>  iceberg-rest:<br>    image: tabulario/iceberg-rest:latest<br>    container_name: iceberg-rest<br>    ports:<br>      - &quot;8181:8181&quot;<br>    environment:<br>      CATALOG_WAREHOUSE: s3://warehouse/<br>      CATALOG_IO__IMPL: org.apache.iceberg.aws.s3.S3FileIO<br>      CATALOG_S3_ENDPOINT: http://minio:9000<br>      CATALOG_S3_PATH__STYLE__ACCESS: &quot;true&quot;<br>      CATALOG_S3_ACCESS__KEY__ID: admin<br>      CATALOG_S3_SECRET__ACCESS__KEY: admin123<br>      AWS_REGION: us-east-1<br>    depends_on:<br>      - minio<br>      <br>  minio:<br>    image: minio/minio<br>    container_name: minio<br>    command: server /data --console-address &quot;:9001&quot;<br>    ports:<br>      - &quot;9000:9000&quot;<br>      - &quot;9001:9001&quot;<br>    environment:<br>      MINIO_ROOT_USER: admin<br>      MINIO_ROOT_PASSWORD: admin123<br>    volumes:<br>      - minio-data:/data<br>      <br>volumes:<br>  minio-data:</pre><p>\trino\catalog\iceberg.properties</p><pre>connector.name=iceberg<br>iceberg.catalog.type=rest<br>iceberg.rest-catalog.uri=http://iceberg-rest:8181<br>iceberg.rest-catalog.warehouse=s3://warehouse/<br><br>fs.native-s3.enabled=true<br>s3.endpoint=http://minio:9000<br>s3.path-style-access=true<br>s3.aws-access-key=admin<br>s3.aws-secret-key=admin123<br>s3.region=us-east-1</pre><h4>Step 2:</h4><p>Run docker compose up -d . Check if containers are in running state or not using docker ps command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BQOZofvHekAwFBDoeQ_C-Q.png" /></figure><p>Wait for sometime, once all containers shows status = up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIqb-IvPoSaXySpusfQgYQ.png" /></figure><p>In case of any failure, check logs of failed container using command docker logs trino — tail 10</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPg-b_ZaFhLqESFSC88VhA.png" /></figure><p>Check iceberg-rest logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyvnWM0yk3M5pwpNDX0H7w.png" /></figure><h4>Step 3:</h4><p>Check services from UI.</p><p>Trino — <a href="http://localhost:8080/ui/">http://localhost:8080/ui/</a></p><p><strong>MinIO</strong></p><ul><li><a href="http://localhost:9001/browser">http://localhost:9001/browser</a></li><li>Login MinIO: admin / admin123</li><li>Create a bucket named: warehouse</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fgd85yVeGhgyQ8V6JWM6Cg.png" /></figure><h4>Step 4:</h4><p>If everything is running fine, then test connectivity via Trino.</p><pre>docker exec -it trino trino</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4LBG-pC_INQScecUNl2eQ.png" /></figure><p>Create a schema &amp; table.</p><pre>CREATE SCHEMA IF NOT EXISTS iceberg.sales<br>WITH (location = &#39;s3://warehouse/sales&#39;);<br><br>CREATE TABLE iceberg.sales.sales_rep (<br>  sales_id BIGINT,<br>  sales_person_name VARCHAR<br>)<br>WITH (format = &#39;PARQUET&#39;);<br><br>INSERT INTO iceberg.sales.sales_rep VALUES<br>(1, &#39;X&#39;),<br>(2, &#39;Y&#39;);<br><br>SELECT * FROM iceberg.sales.sales_rep;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfZ562bK95FLafZ0N_aNMQ.png" /></figure><p>Optionally you can use some CLI to connect via jdbc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_RGX69dw4R5ah3hHXGOPg.png" /></figure><p>Running queries using DBeaver</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khhZPcyOWqSIxD-MjtTJXw.png" /></figure><h4>Connect trino using Python:</h4><p>pip install sqlalchemy pandastrino sqlalchemy-trino</p><pre>from sqlalchemy import create_engine<br>import pandas as pd<br><br># Example connection to local Trino<br>trino_engine = create_engine(<br>    &quot;trino://trino@localhost:8080/iceberg/sales&quot;  # adjust catalog/schema<br>)<br><br># Test query<br>query = &quot;SELECT * FROM sales_rep LIMIT 5&quot;<br>df = pd.read_sql(query, trino_engine)<br>print(df.head())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvQ09s7uIEEXK03zWRxrcQ.png" /></figure><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ecd3e7e0e5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Cloud — Professional Data Engineer | Guide]]></title>
            <link>https://bigdataenthusiast.medium.com/google-cloud-professional-data-engineer-guide-ae650b2b190b?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae650b2b190b</guid>
            <category><![CDATA[gcp-data-engineer]]></category>
            <category><![CDATA[gcp-data-engineering]]></category>
            <category><![CDATA[gcp-certification]]></category>
            <category><![CDATA[professionaldataengineers]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 01:06:11 GMT</pubDate>
            <atom:updated>2026-01-14T01:11:33.616Z</atom:updated>
            <content:encoded><![CDATA[<h3>GCP Data Engineer Certification | Google Cloud — <strong>Professional Data Engineer | Guide &amp; Glossary</strong></h3><p>Sharing some of my GCP Data Engineer notes here — hope they help with your studies.</p><p><a href="https://cloud.google.com/learn/certification/data-engineer">Professional Data Engineer Certification | Learn | Google Cloud</a></p><p>Exam Guide: <a href="https://services.google.com/fh/files/misc/professional_data_engineer_exam_guide_english.pdf">https://services.google.com/fh/files/misc/professional_data_engineer_exam_guide_english.pdf</a></p><h4>Glossary</h4><p>Some high level list of services for Data Engineer role.</p><pre><br>1. Application Platform &amp; Serverless Functions:<br>----------------------------------------------<br>  App Engine<br>  Cloud Run<br>  Cloud Run Functions<br><br>2. Storage &amp; Data Warehousing:<br>-----------------------------<br>  Block Storage (disks or volume)<br>    Temporary &amp; Durable Block Storage <br>  Structured(SQL):<br>    Cloud SQL<br>    Cloud Spanner<br>    AlloyDb (Postgres compatible)<br>  Semi-Structured(NoSQL):<br>    Firestore as Native (MongoDB compatible also)<br>    Firestore as Datastore<br>  Un-Structured(Object Store): <br>    Cloud Storage<br>  In-MemoryDB: <br>    Memorystore (Memcached, Redis etc.)<br>  Data Warehouse: BigQuery<br>  Key-Value DB: Bigtable (Based on HBase)<br>  BigLake (Data Lake + Datawarehosue + Metastore + Governance)<br>  File Storage (Network Attached Storage - NFS/SMB Protocol):<br>    Filestore<br>    NetApp Volumes<br><br>3. Data Ingestion, Processing &amp; BI:<br>------------------------------<br>  Cloud Data Fusion (no-code ETL pipeline )<br>  Dataflow<br>  Dataform<br>  Pub/Sub<br>  Dataproc<br>  Database Migration Service (DB to DB)<br>  Datastream - CDC, data replication  <br>  Storage Transfer Service - GCS<br>  Transfer Appliance<br>  Looker (BI Tool - Semantic Layer - data modeling)<br>  Looker Studio (visualization, dashboards and reports)<br>  Connected Sheets - Google Sheets<br>  Analytics Hub (Sharing) - BigQuery<br>  Dataprep (Alteryx Designer Cloud)<br><br>4. Data Governance &amp; Catalog:<br>----------------------------<br>  Data Catalog<br>  Dataplex<br>  Dataplex Universal Catalog<br>  Cloud DLP<br><br>5. Job Automation, Orchestration &amp; CI/CD:<br>----------------------------------------<br>  Cloud Scheduler<br>  Batch<br>  Workflows<br>  Cloud Composer<br>  Cloud Build<br>  Cloud Deploy<br>  Artifact Registry<br><br>6. Machine Learning &amp; AI:<br>------------------------<br>  BigQueryML<br>  Vertex AI<br>  Dialogflow - (low-code chatbot framework for text and speech inputs)<br><br>7. Monitoring:<br>-------------<br>  Cloud Monitoring<br>  Cloud Logging<br>  Cloud Trace<br>  Cloud Profiler<br><br>8. Networking: <br>-------------<br>  PGA - Private Google Access <br>  PSC - Private Service Connect</pre><h4>General Information</h4><p>Let’s first understand the memory size notations.</p><ul><li>Decimal Notation: MB and GB — standard for marketing <strong>storage devices</strong> like hard drives (HDD) and solid-state drives (SSD)</li><li>Binary Notation: MiB and GiB — used to measure memory and is how operating systems like <strong>Windows</strong> calculate file and disk sizes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UaTn6wnw3kfi3fv2heXfzw.png" /></figure><p>Let’s first see the difference of SSD vs. HDD.</p><p><strong>SSDs</strong></p><ul><li>Consist of electrical parts e.g.. Integrated Chips ICs. Hence all data stored in ICs only.</li><li>Expensive</li><li>Recommended for <strong>Random read/writes</strong>. For frequent accessed files.</li><li>IOPS in SSD always higher compared to HDDs.</li></ul><p><strong>HDDs</strong></p><ul><li>Consist of moving mechanical parts. Spinning disk where data is stored magnetically.</li><li>Lower in cost. Legacy Technology.</li><li>Recommended for data that does not need to be accessed frequently. For <strong>Sequential read/writes.</strong></li></ul><p>What is IOPS &amp; Throughput ?</p><ul><li><strong>IOPS </strong>— Input Output per second. Measure of no of I/O operations a drive will handle per second. With each block being read/written from <strong>random </strong>location of disk.</li><li><strong>Throughput </strong>: Sequential transfer rate which an SSD/HDD will maintain continuously. Measured in KB/s MB/s etc.</li></ul><h3>1. Application Platform &amp; Serverless Functions</h3><h4><strong>1.1 App Engine</strong></h4><ul><li>Fully managed, serverless <strong>Platform-as-a-Service (PaaS)</strong></li><li>We just deploy <strong>source code</strong>, and Google handles rest of things like server, scaling etc.</li><li>Can scale to <strong>zero</strong> when idle.</li><li>Standard — Some runtime and OS limitations.</li><li>Flexible — Runs in Docker containers on Compute Engine. More control over OS and dependencies. Slower scaling, higher cost.</li></ul><p>Refer sample code here <a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/appengine/standard/hello_world/app.yaml">standard </a>&amp; <a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/appengine/flexible/hello_world/app.yaml">flexible</a></p><h4><strong>1.2 Cloud Run (Serverless Containers)</strong></h4><ul><li>Fully managed serverless compute service that lets you run <strong>containerized applications</strong> without managing servers or K8S.</li></ul><p><strong>Services</strong></p><ul><li>Deploy Container — Package your app as a Docker container. Use Artifact Registry (Container Image).</li><li>Connect Repo — Continuous deploy from repo. Use GitHub (Cloud Build)</li><li>Function — Inline Editor to create a function. Can have Trigger (Optional)</li></ul><p><strong>Jobs</strong>: A Cloud Run job executes containers to completion. Job name and region cannot be changed later.</p><h4><strong>1.3 Cloud Run Functions</strong></h4><ul><li>Function-as-a-Service (FaaS) built on top of Cloud Run.</li><li>Event Driven</li><li><strong>Trigger </strong>— HTTP, Pub/Sub, Cloud Storage, Firestore, Eventrac.</li><li>Supports many popular languages (Node.js, Python, Go, Java, .NET, Ruby, and PHP)</li></ul><h3>2. Storage</h3><h4>2.1 Block Storage (disk/volume)</h4><p>Use block storage for boot and data volumes for all compute instances, including virtual machines (VMs), containers, and bare metal instances.</p><p><strong>Temporary (ephemeral)</strong></p><ul><li>Fastest performance among all block storage types</li><li>Tradeoff that the stored data is <em>lost </em>if the VM stops for any reason.</li><li>Use only scratch data, caches such as tempdb</li><li>Local SSD, including Titanium SSD — offerings in Google Cloud.</li></ul><p><strong>Durable (persistent)</strong></p><ul><li>For data that you want to preserve after you stop, suspend or delete the VM, or even if the VM crashes or fails.</li><li>Hyperdisk &amp; Persistent Disk — offerings in Google Cloud.</li></ul><p>Persistent disk types</p><ul><li><strong>Balanced Persistent Disk (SSD)</strong>— Balance of performance and cost</li><li><strong>SSD Persistent Disk —</strong>Suitable for enterprise applications and high-performance databases that require lower latency and more IOPS than standard Persistent Disk provides.</li><li><strong>Standard Persistent Disk (HDD)— </strong>Suitable for large data processing workloads that primarily use sequential I/Os.</li><li><strong>Extreme Persistent Disk (</strong>SSD<strong>)— </strong>Offers consistently high performance for both random access workloads and bulk throughput. We can provision target IOPS.</li></ul><p><a href="https://docs.cloud.google.com/compute/docs/disks">Choose a disk type | Compute Engine | Google Cloud Documentation</a></p><h4><strong>2.2 Cloud SQL</strong></h4><ul><li>Regional, general purpose relational SQL DB.</li><li>MySQL, Postgres, SQL Server</li><li>DB is under <strong>64 TB</strong> and does not require massive horizontal scaling.</li><li>Google Cloud SQL can <strong>automatically scale storage</strong>, but it does <strong>not</strong> natively support automatic scaling for compute resources (CPU and RAM).</li></ul><p><strong>Cloud SQL Auth Proxy:</strong> A secure way to connect to instances from local machines or external environments without manual IP allow listing.</p><p><strong>Replication in Cloud SQL</strong></p><p><strong>Read Replica</strong></p><p>Copy of your primary instance within the <strong>same Google Cloud region</strong>, typically in a different zone for high availability within that region. Provides a low-latency, in-region solution for scaling reads.</p><ul><li>Read replicas are read-only;</li><li>A primary instance can failover to a replica only if the replica is a DR replica. Read replicas are unable to failover in any way during an outage. Read replicas don’t provide failover capability.</li><li><strong>Manual Process</strong>: Promoting a replica is a manual, intentional action, not an automatic failover like high availability (HA)</li></ul><p><strong>Cross-region Replica (DR)</strong></p><p>This is a read replica created in a <strong>different Google Cloud region</strong> from the primary instance.</p><p><strong>Cascading</strong></p><ul><li>A cascading replica is a <strong>read replica of another read replica</strong> (rather than the original primary instance).</li><li>It can be in the same or a different region.</li><li>Offloads the replication burden from the primary instance.</li><li>Enhances DR by maintaining replica hierarchy upon promotion.</li></ul><p>Postgres, SQLServer — Read replicas, Cross-region, Cascading</p><p>MySQL — Read replicas, Cross-region, Cascading, External Read replica (like MySQL on VM), replicating from an external server.</p><p>When referring to an on-premises database, the replication scenario is called <em>replicating from an external server</em>. Copies that reside in Cloud SQL are called <em>Cloud SQL replicas</em></p><p><a href="https://docs.cloud.google.com/sql/docs/mysql/replication">About replication in Cloud SQL | Cloud SQL for MySQL | Google Cloud Documentation</a></p><p><strong>HA</strong></p><p>Cloud SQL instance configured for HA is also called a <em>regional instance</em> and has a primary and secondary zone within the configured region.</p><p>Through synchronous replication to each zone’s persistent disk, all writes made to the primary instance are replicated to disks in both zones before a transaction is reported as committed. In the event of an instance or zone failure, the standby instance becomes the new primary instance. Users are then rerouted to the new primary instance. This process is called a <em>failover</em>.</p><p><a href="https://docs.cloud.google.com/sql/docs/mysql/high-availability">https://docs.cloud.google.com/sql/docs/mysql/high-availability</a></p><p><a href="https://docs.cloud.google.com/sql/docs/mysql/configure-ha">https://docs.cloud.google.com/sql/docs/mysql/configure-ha</a></p><h4><strong>2.3 Cloud Spanner (SQL)</strong></h4><ul><li>Global, Multi region, Petabyte scale relational DB.</li><li>Massive horizontal scalability</li><li>Strong consistency across regions</li></ul><p><strong>Primary Key:</strong></p><ul><li>Must be designed carefully to ensure even data distribution and prevent performance <strong>hotspots</strong>.</li><li>Recommended approach is to use a <strong>Universally Unique Identifier Version 4 (UUIDv4)</strong> or <strong>bit-reversed integer sequences</strong>, avoiding monotonically increasing keys.</li></ul><p><a href="https://docs.cloud.google.com/spanner/docs/schema-and-data-model">Schemas overview | Spanner | Google Cloud Documentation</a></p><p><strong>Stale Reads — </strong>Optimized for high-performance applications that can tolerate slightly outdated information. Unlike “eventual consistency” in other databases, Spanner’s stale reads are still <strong>consistent </strong>as of a specific point in time, ensuring readers never see a state that didn’t exist.</p><p><strong>Locking Read-Write Transactions —(ACID) </strong>External consistency, atomicity. Use case — Banking, Inventory.</p><h4><strong>2.4 AlloyDb </strong>(<strong>SQL — Postgres compatible</strong>)</h4><ul><li>Regional, fully managed relational database service</li><li>High performance, handle massive, enterprise-level workloads.</li><li>Scale up to 128 TB</li><li>Decoupled compute/storage</li></ul><h4><strong>2.5 Firestore (NoSQL)</strong></h4><p>Fully managed, serverless NoSQL document database, designed for scalable, real-time applications.</p><p><strong>Standard Edition —</strong></p><ol><li>Firestore in Native Mode (Enables Firestore’s native server-side, web, and mobile SDKs)</li><li>Firestore with Datastore compatibility (Enables Firestore’s implementation of Datastore compatibility for server-side SDKs.)</li></ol><p><strong>Enterprise Edition </strong>— Firestore with MongoDB compatibility</p><p>Native — recommended for</p><ul><li>New applications (Web Apps, Mobile), Modern App.</li><li>Strong consistency, Direct data access</li><li>Real-time updates</li><li>Document database (Collections, docs)</li></ul><p>Datastore— recommended for</p><ul><li>Compatible with legacy <strong>Cloud Datastore.</strong></li><li>Server side backend, App engine compatibility</li><li>No real time</li><li>Entities &amp; Kind</li></ul><p><strong>Index</strong></p><p>When the same property is repeated multiple times, Firestore in Datastore mode can detect exploding indexes and suggest an alternative index. However, in all other circumstances, a Datastore mode database will generate an exploding index. In this case, you can circumvent the exploding index by manually configuring an index in your index configuration file.</p><pre>indexes:<br>- kind: Task<br>  properties:<br>  - name: tags           # List property<br>  - name: priority       # Single-value property<br>- kind: Task<br>  properties:<br>  - name: collaborators  # List property<br>  - name: priority       # Single-value property</pre><p><a href="https://docs.cloud.google.com/datastore/docs/concepts/indexes#datastore-datastore-properties-gql">https://docs.cloud.google.com/datastore/docs/concepts/indexes#datastore-datastore-properties-gql</a></p><h4><strong>2.6 Memorystore (In-Memory)</strong></h4><p>Fully managed, in-memory data store service used mainly for caching and fast data access.</p><p><strong>Redis</strong></p><ul><li>Feature rich, versatile</li><li>Complex use cases. Advanced datatypes.</li><li>Automatic failover</li></ul><p><strong>Memcached</strong></p><ul><li>Simpler, high performance</li><li>Simple key-value</li><li>Only string of 1 MB.</li><li>Manual failover, no persistence</li></ul><p><strong>Manual failover</strong></p><p>The two available data protection modes are:</p><ul><li>limited-data-loss mode (default).</li><li>force-data-loss mode. (aggressively execute the failover)</li></ul><p><a href="https://docs.cloud.google.com/memorystore/docs/redis/about-manual-failover">https://docs.cloud.google.com/memorystore/docs/redis/about-manual-failover</a></p><h4><strong>2.7 BigTable (Apache HBase)</strong></h4><p>Fully managed, wide-column NoSQL database, built for massive scale, very high throughput, and low-latency access.</p><ul><li>Bigtable has a limit of 1,000 tables per instance.</li><li>Column families per table: 100 (recommended limit)</li><li>Create as many columns as you need in the table. As long as no row exceeds the maximum limit of 256 MB per row.</li><li>Row keys are sorted lexicographically.</li><li>Routing — Single Cluster (Guaranteed Consistency) vs Multi Cluster (Eventual Consistency)</li><li><strong>Key Visualizer</strong> — Analyze usage patterns by visualizing how data is accessed across your row keys. Useful for troubleshooting performance issues like hotspots</li><li>Time Series — Narrow &amp; Tall vs Wide</li></ul><p>Narrow — A large number of rows with very few columns. Each event or measurement is stored in its own row.</p><p>A wide schema stores multiple events or measurements related to the same entity within a single row by using many columns or column versions.</p><p>One event per row simplifies queries &amp; scales.</p><p><strong>Best Practice</strong></p><ul><li>To get good performance from Bigtable, it’s essential to design a schema that makes it possible to distribute reads and writes evenly across each table. Because all tables in an instance are stored on the same <a href="https://docs.cloud.google.com/bigtable/docs/overview#architecture">tablets</a>, a schema design that results in hotspots in one table can affect the latency of other tables in the same instance.</li><li>Design row keys that start with a common value and end with a granular value.</li><li><strong>Frequently updated identifiers:</strong> Avoid using a single row key to identify a value that must be updated frequently. Instead, store each new reading in a new row.</li><li><strong>Sequential numeric IDs : </strong>A safer approach is to use a reversed version of the user’s numeric ID.</li><li><strong>Row keys that start with a timestamp</strong>. This pattern causes sequential writes to be pushed onto a single node, creating a hotspot. If you put a timestamp in a row key, precede it with a high-cardinality value like a user ID to avoid hotspots.</li><li>Use human-readable values instead of hashed values.</li></ul><ul><li><a href="https://docs.cloud.google.com/bigtable/docs/schema-design">Schema design best practices | Bigtable | Google Cloud Documentation</a></li><li><a href="https://docs.cloud.google.com/bigtable/docs/performance">Understand performance | Bigtable | Google Cloud Documentation</a></li></ul><h4><strong>2.8 Google Cloud Storage (GCS) — Object Store like AWS S3</strong></h4><ul><li>Multi Region (HA)</li><li>Dual Region (HA — low latency 2 regions)</li><li>Regional (low latency)</li></ul><p><strong>Classes</strong></p><ul><li>Standard — Multiple times access per month</li><li>Nearline — Access once a month (Min Storage Duration: 30 days). charges a retrieval fee.</li><li>Coldline — Once a quarter or less (Min Storage Duration: 90 days). Has higher retrieval fees than Nearline.</li><li>Archive — Once a year or less (Min Storage Duration: 365 days). Highest retrieval costs.</li></ul><p><strong>Autoclass </strong>— is a managed, bucket-level setting that automatically moves objects between storage classes based on their last access time.</p><ul><li>Your data access patterns are <strong>unpredictable</strong> or unknown.</li><li>You want to automate cost optimization without writing custom Lifecycle Management rules.</li><li>You want <strong>predictable pricing</strong>: Autoclass removes retrieval fees and early deletion charges, replacing them with a flat management fee</li><li>Avoid when very large number of small objects (under 128 KiB).</li><li>Avoid access patterns are <strong>predictable </strong>and can be managed using static Lifecycle Management rules.</li></ul><p><strong>Data Protection:</strong></p><ul><li>Enable data retention — For preventing the deletion or modification of the bucket’s objects for a specified period of time.</li><li>Set bucket retention policy/ Enable object retention</li></ul><p>Turbo replication is a premium feature for Google Cloud Storage <strong>dual-region buckets</strong> designed for high-availability and disaster recovery</p><p><strong>rsync </strong>— synchronize a local directory with a bucket or vice versa. Best for &lt; 1 TB.</p><p><a href="https://docs.cloud.google.com/storage/docs/working-with-big-data">Use Cloud Storage with big data | Google Cloud Documentation</a></p><h4><strong>2.9 BigQuery</strong></h4><p>Fully managed, <strong>serverless data warehouse</strong> designed to help you store and analyze massive datasets — from gigabytes to petabytes — using standard SQL.</p><ul><li>Columnar storage</li><li>Regional &amp; Multi Region — Dataset</li><li>In BigQuery, a single table, query result, or view definition can have a maximum of <strong>10k columns.</strong></li></ul><p><strong>Partition Settings:</strong></p><ul><li>Partition by ingestion time — Supports day, hour, month, year</li></ul><p><strong>_PARTITIONTIME</strong> is a pseudo-column used specifically for ingestion-time partitioned tables</p><pre>SELECT * FROM `project-id.test_ds.test_table2` WHERE TIMESTAMP_TRUNC(_PARTITIONTIME, DAY) = TIMESTAMP(&quot;2025-12-22&quot;) LIMIT 1000;</pre><pre>SELECT * FROM `project-id.test_ds.test_table1` WHERE TIMESTAMP_TRUNC(_PARTITIONTIME, HOUR) = TIMESTAMP(&quot;2025-12-22T13:00:00&quot;) LIMIT 1000</pre><ul><li>Partition by field — Support for integer field, timestamp, date.</li></ul><p>For Integer — If you set <strong>Start: 0</strong>, <strong>End: 100</strong>, and <strong>Interval: 10</strong>, BigQuery will create:</p><ul><li>10 partitions covering values from 0 to 99 (each partition containing 10 integers).</li><li>One __NULL__ partition — Contains rows where the partitioning column is null.</li><li>One __UNPARTITIONED__ partition for any value &lt; 0 or ≥ 100.</li></ul><pre>SELECT * FROM `your_project.your_dataset.your_table` WHERE customer_id BETWEEN 30 AND 50</pre><p><strong>Cluster Settings:</strong></p><ul><li>Up to <strong>4 columns allowed</strong>. Column order matters.</li><li>Clustering order determines the sort order of the data.</li><li>Sorting collocates rows with similar values into the same physical storage blocks.</li><li>When you filter or aggregate by clustered columns, BigQuery only scans the relevant storage blocks instead of the entire table.</li></ul><p><strong>BigQuery materialized view</strong></p><p>max_staleness —if last refresh is older than the interval, BigQuery reads the materialized view and combines it with delta changes from the base table to ensure the result is no older than the max_staleness setting.</p><pre>CREATE MATERIALIZED VIEW `project.dataset.my_mv`<br>OPTIONS (<br>  enable_refresh = true,<br>  refresh_interval_minutes = 60,<br>  max_staleness = INTERVAL &quot;4:0:0&quot; HOUR TO SECOND<br>) AS<br>SELECT ... FROM `project.dataset.base_table`;</pre><p>Incremental vs. Non-Incremental Processing</p><p><strong>Incremental Refresh:</strong> (default) BigQuery identifies changes (deltas) in the base table since the last refresh and appends only those changes to the view, saving cost and time.</p><p><strong>Non-Incremental Refresh: </strong>allow_non_incremental_definition = true complex queries that do not support incremental updates, BigQuery may perform a full recompute.</p><p><strong>BigQuery Backup:</strong></p><p><strong>Dataset Level (Time Travel) Automatic—</strong></p><p>Time Travel Window:</p><ul><li>Specifies the duration in days of the time travel window.</li><li>Must be a value between 2 and 7.</li><li>If not specified, it will be set to the project or organization default, or the system default of 7 days, as applicable.</li></ul><p><strong>Table Level (Snapshots) </strong>Manual/Scheduled Backups<strong>—</strong></p><ul><li>Preserves the data of a table at a particular time.</li><li>A table snapshot can have an expiration;</li><li>Table snapshots are read-only.</li><li>Can create a standard table from a table snapshot.</li></ul><p><strong>Copy Dataset:</strong></p><ul><li>Can copy a dataset within a region, or from one region to another, without having to move, and reload data into BigQuery.</li><li>Not incremental, one time.</li><li>Customized recurring schedule.</li></ul><p><strong>Export to GCS:</strong></p><ul><li>BigQuery allows you to export the data into Google Cloud Storage.</li><li>This can serve as a backup of your tables in BigQuery, and the exported data can be loaded back to BigQuery in case the original tables are corrupted/deleted.</li></ul><p><strong>BQ Export Options:</strong></p><ul><li>Only GCS as target</li><li>With only gzip compression supported</li><li>4 format — AVRO, Parquet, JSON, CSV</li></ul><p><strong>Disaster Recovery:</strong></p><ul><li>Write data in at least 2 BigQuery datasets in multiple regions.</li><li>Export data to GCS in another region/dual region or multi region bucket. (<strong>Cost effective</strong> as we can compress data)</li></ul><p><a href="https://cloud.google.com/blog/topics/developers-practitioners/backup-disaster-recovery-strategies-bigquery/">Backup &amp; Disaster Recovery strategies for BigQuery | Google Cloud Blog</a></p><p><strong>Unnest:</strong></p><p>Repeated field: Array of Struct</p><pre>WITH example_data AS (<br>  SELECT 1 as order_id, [STRUCT(&quot;A1&quot; as id, 10.00 as price), STRUCT(&quot;B5&quot; as id, 5.50 as price)] as items<br>)<br>SELECT order_id, item.id, item.price<br>FROM example_data, UNNEST(items) AS item</pre><p><strong>Struct</strong>:</p><pre>WITH example_data AS (<br>  SELECT 1 as order_id, STRUCT(&quot;A1&quot; as id, 10.00 as price) as items<br>)<br>SELECT order_id, items.id, items.price<br>FROM example_data<br>where items.id =&#39;A1&#39;</pre><p><strong>BigQuery Pricing:</strong></p><p><a href="https://cloud.google.com/bigquery/pricing?hl=en#bigquery-pricing">BigQuery</a></p><ul><li>BQ is a serverless, so we don’t need to provision individual instances or virtual machines.</li><li>BQ automatically allocates computing resources.</li><li>We can also reserve compute capacity ahead of time in the form of <strong>slots</strong>, which represent virtual CPUs.</li></ul><p>BigQuery pricing has two main components:</p><ul><li><strong>Compute </strong>— cost to process queries, including SQL queries, user-defined functions, scripts, DML/DDL.</li><li><strong>Storage </strong>— cost to store data</li></ul><p><strong>Pricing Model:</strong></p><ul><li><strong>On-Demand</strong> — (per TiB) charged for the number of bytes processed by each query.</li><li><strong>Capacity Pricing</strong> — (per slots) charged for compute capacity used to run queries, measured in slots (virtual CPUs) over time. BigQuery auto-scaler or purchase slot commitments, which are dedicated capacity that is always available for your workloads, at a lower price.</li></ul><p>User level &amp; project level cost control — quota limit usage QueryUsagePerDay, QueryUsagePerUserPerDay . Refer for more details : <a href="https://docs.cloud.google.com/bigquery/docs/custom-quotas">https://docs.cloud.google.com/bigquery/docs/custom-quotas</a></p><p>The default limit for the QueryUsagePerDay quota is 200 Tebibytes (TiB) of data processed per project per day. The default limit for the QueryUsagePerUserPerDay is unlimited.</p><p><strong>Slot Contention</strong></p><p>It<strong> </strong>occurs when a query has more tasks ready to execute than there are available slots to process them. This creates a bottleneck where query work is forced to wait in a queue rather than running in parallel.</p><p>To investigate slot contention in BigQuery, you can use built-in monitoring tools, system tables, and visual execution graphs to identify resource bottlenecks.</p><ul><li>Administrative Resource Charts</li><li>Via INFORMATION_SCHEMA</li><li>Visual execution graphs</li></ul><p><strong>BigQuery Caching:</strong></p><ul><li>By default, <a href="https://cloud.google.com/bigquery">BigQuery</a> saves all query results to a temporary table for approximately <strong>24 hours</strong>.</li><li>No charges for retrieving results from this cache, and no storage fees for the temporary table.</li><li>Query text must be an exact match (including whitespace and comments), and the underlying data must not have changed.</li><li><strong>Non-deterministic Functions:</strong> Queries using functions like CURRENT_TIMESTAMP() or RAND() are never cached.</li><li>Queries against external sources — does not support caching.</li><li><strong>Disable Cache:</strong> set use_query_cache to false in your <a href="https://docs.cloud.google.com/bigquery/docs/samples/bigquery-query-no-cache">q</a>uery job config or uncheck &quot;Use cached results&quot; in the Console.</li></ul><p><strong>BigQuery Temporary Table:</strong></p><ul><li>Use of CREATE TEMPORARY TABLE requires a script (Multi-Statement Query begin end block) or session.</li><li>Temporary tables exist only within the scope of the current multi-statement query or session and are automatically deleted when that scope terminates.</li></ul><p>Multi-Statement Query (begin end block).</p><pre>BEGIN<br>  -- Create a temporary table named &#39;Flights&#39;<br>  CREATE TEMP TABLE Flights(total INT64) AS<br>    SELECT * FROM UNNEST([10, 23, 3, 14, 55]) AS a;<br>-- Use the temporary table in another statement within the same script<br>  SELECT * FROM Flights LIMIT 2;<br>END;</pre><p>Enable session management from query settings, and run query.</p><pre>CREATE TEMP TABLE top_names(name STRING) AS<br>SELECT name<br>FROM `bigquery-public-data.usa_names.usa_1910_current`<br>WHERE year = 2017<br>ORDER BY number DESC<br>LIMIT 100;</pre><p><strong>BigQuery Row-level &amp; Column-level security</strong></p><ul><li><a href="https://docs.cloud.google.com/bigquery/docs/column-level-security-intro">column-level security</a> through <strong>policy tags</strong></li><li>row level — access policy</li></ul><pre>CREATE ROW ACCESS POLICY<br>  apac_filter<br>ON<br>  dataset1.table1 GRANT TO (&quot;group:sales-apac@example.com&quot;)<br>FILTER USING<br>  (region=&quot;APAC&quot; );</pre><p>Also we can use the SESSION_USER() function restricts access only to rows that belong to the user running the query, based on their user email address.</p><pre>CREATE ROW ACCESS POLICY<br>  salary_personal<br>ON<br>  dataset1.table1 GRANT TO (&quot;domain:example.com&quot;)<br>  FILTER USING<br>  (Email=SESSION_USER());</pre><h4>2.10 BigLake</h4><p><strong>BigLake</strong> is a storage engine that unifies data warehouses and data lakes by providing a single interface to analyze data across different storage systems and formats. It allows you to run BigQuery-style analytics on data stored in Google Cloud Storage (GCS), Amazon S3, and Azure Blob Storage without moving or duplicating the data.</p><ul><li>Fine grained security</li><li>Open format support — Apache Iceberg</li><li>Multi cloud via BigQuery Omni</li><li>BigLake Metastore</li></ul><p>Which database should i use? — Refer below blog by <a href="https://www.thecloudgirl.dev/">https://www.thecloudgirl.dev/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fivnu5rMTEgWft7suHbmHA.jpeg" /><figcaption><a href="https://storage.googleapis.com/gweb-cloudblog-publish/images/Which-Database_v03-22-23.max-2000x2000.jpg">https://storage.googleapis.com/gweb-cloudblog-publish/images/Which-Database_v03-22-23.max-2000x2000.jpg</a></figcaption></figure><h3>3. Ingesting &amp; Processing</h3><h4><strong>3.1 Cloud Data Fusion</strong></h4><p>Fully managed, cloud-native enterprise data integration service for quickly building and managing data pipelines (ETL/ELT).</p><ul><li>Visual pipeline builder — low-code/no-code</li><li>Wide connector support — including SaaS applications (Salesforce, SAP), GCP natives.</li><li>Powered by CDAP (Cask Data Application Platform) open-source.</li><li><strong>Execution:</strong> Behind the scenes, it converts these visual designs into <strong>Apache Spark</strong> or MapReduce jobs.</li><li><strong>Infrastructure:</strong> It automatically provisions ephemeral <strong>Cloud Dataproc</strong> clusters to execute these jobs and then deletes the clusters once the task is finished to save costs.</li></ul><h4><strong>3.2 Dataform</strong></h4><ul><li>Fully managed, serverless framework for managing and orchestrating SQL-based transformations in BigQuery.</li><li>Used to develop, test &amp; version control transformations.</li><li>SQL based development — uses <strong>Dataform Core</strong>, an open-source meta-language that extends SQL.</li><li>Cloud-based IDE with integrated Git version control.</li><li>Manage dependencies b/w table and views.</li><li>Schedule via built-in configuration using cron.</li></ul><h4><strong>3.3 Dataproc — Hadoop ecosystem like AWS EMR</strong></h4><p>Fully managed and highly scalable service for running Apache Spark, Apache Hadoop, Apache Flink, Presto, and 30+ open source tools and frameworks.</p><ul><li>Dataproc Workflows Template</li><li>Serverless</li></ul><p>Cluster Types —</p><ul><li>Single Node — 1 Master 0 Worker</li><li>Standard — 1 Master N Worker</li><li>HA — 3 Master N Worker</li></ul><p>Secondary worker nodes — HDFS does not run on secondary worker nodes. Secondary worker VMs are preemptible by default.</p><p><strong>Preemptible limitation</strong></p><ul><li>Compute Engine might stop preemptible instances at any time due to system events</li><li>Always stops preemptible instances after they run for 24 hours</li><li>Cant live migrate to regular VM.</li><li>Shutdown period for a preemption notice is best effort and up to 30 seconds</li></ul><p><strong>Best Practice:</strong></p><ul><li><strong>Ephemeral Clusters — </strong>Create a cluster, run a job, and delete it immediately upon completion to avoid idle costs</li><li>Store your primary data in Cloud Storage (GCS) rather than HDFS on the cluster. This allows you to delete clusters without losing data and scales storage independently of compute.</li><li><strong>Scheduled deletion — </strong>To help avoid incurring Google Cloud charges for an inactive cluster. Fixed time schedule/cluster idle time period.</li><li>EFM (<strong>Enhanced Flexibility Mode</strong>) — Spark jobs using autoscaling or Spot/Preemptible VMs, enable EFM to prevent job failures caused by the loss of shuffle data when nodes are removed.</li></ul><p>Cloud Storage connector — open source Java library lets you run Apache Hadoop or Apache Spark jobs directly on data in Cloud Storage.</p><p><a href="https://docs.cloud.google.com/dataproc/docs/concepts/connectors/cloud-storage">https://docs.cloud.google.com/dataproc/docs/concepts/connectors/cloud-storage</a></p><h4>3.4 PubSub</h4><p>Fully managed, serverless messaging service.</p><p><strong>Topics</strong></p><p>Pub/Sub offers <strong>Single Message Transforms</strong> (SMTs) to simplify data transformations for streaming pipelines. SMTs enable lightweight modifications to message data and attributes directly within Pub/Sub.</p><p>We have options while topic creation —</p><ul><li>Enable ingestion — Kinesis, GCS, Azure event hubs, AWS MSK</li><li>Message retention</li><li>Export message to BQ</li><li>Backup message to GCS</li></ul><p><strong>Subscriptions</strong></p><p>Supported Delivery Types:</p><ul><li>Pull</li><li>Push — Endpoint URL</li><li>Write to BigQuery or Cloud Storage</li></ul><p>If Pull, subscribers must request delivery. For other subscription types, Pub/Sub delivers messages as soon as they are published.</p><p>Message Retention — Duration is from 10 minutes to 31 days.</p><p><strong>Ack Deadline</strong>: How long Pub/Sub waits for the subscriber to acknowledge receipt before resending the message</p><p><strong>Exactly once delivery</strong>: When enabled, messages sent to the subscription are guaranteed not to be resent before the message’s acknowledgement deadline expires. Acknowledged messages will not be resent to the subscription. Default acknowledgement deadline will be increased to the recommended minimum of 60 seconds. Enabling exactly once delivery may significantly increase publish-to-subscribe latency</p><p><strong>Message Ordering: </strong>When enabled, messages tagged with the same ordering key will be received in the order they are published.</p><p><strong>Dead Lettering</strong> : Subscriptions may configure a maximum number of delivery attempts. When a message cannot be delivered, it is republished to the specified dead letter topic.</p><p><strong>Retry Policy: </strong>Retry Immediately or Exponential Backoff delay.</p><p>In Google Cloud Pub/Sub, a <strong>snapshot</strong> is a point-in-time copy of a subscription’s message acknowledgment state. It captures the exact “backlog” of <strong>unacknowledged messages</strong> at the moment of creation, allowing you to later “seek” back to that state to replay or skip messages.</p><h4>3.5 Dataflow (Apache Beam)</h4><p>Fully managed, serverless data processing service that supports both stream and batch processing.</p><p>Dataflow supports several different ways to create and execute pipelines, depending on your needs:</p><p><strong>No-code &amp; Low-code:</strong></p><ul><li><strong>Dataflow Template —</strong> Create job from google provided<strong> </strong>or custom template.</li><li><strong>Dataflow job builder </strong>— Create custom batch and streaming jobs using the Dataflow job builder and YAML editor. You can transform, filter and combine data using Python and SQL.</li><li><strong>Dataflow Workbench </strong>— <strong>Vertex AI Workbench</strong>, which provides a managed Jupyter notebook environment used for interactive Dataflow pipeline development.</li></ul><p><strong>Dataflow Data pipelines</strong> — With this we can run batch jobs on a schedule and see the history of job runs. Data Pipelines are managed end-to-end transformations that utilize Dataflow and Apache Beam.</p><p><strong>Apache Beam SDK:</strong> The most flexible option for developers to write custom logic in <strong>Java, Python, or Go</strong>. This is ideal for complex pipelines that require sophisticated strategies for handling late data or custom transforms.</p><p><strong>Core Beam Transformation:</strong></p><ul><li>ParDo — like map in map/reduce style framework. When you apply a ParDo transform, you’ll need to provide user code in the form of a DoFn object.</li><li>GroupByKey — processing collections of key/value pairs</li><li>CoGroupByKey — performs a relational join of two or more key/value PCollections that have the same key type.</li><li>Combine is a Beam transform for combining collections of elements or values in your data.</li><li>Flatten is a Beam transform for PCollection objects that store the same data type. Flatten merges multiple PCollection objects into a single logical PCollection.</li><li>Partition is a Beam transform for PCollection objects that store the same data type. Partition splits a single PCollection into a fixed number of smaller collections.</li></ul><p><strong>Windowing:</strong></p><p><strong>Window</strong> is a logical boundary used to divide continuous, unbounded streams of data into finite “chunks” based on time or other criteria. This allows you to perform aggregations, such as sums or averages, on a data stream that otherwise never ends.</p><p>Beam’s default windowing behavior is to assign all elements of a PCollection to a single, global window and discard late data, <em>even for unbounded </em><em>PCollection .</em></p><p>Before you use a grouping transform such as GroupByKey on an unbounded PCollection, you must do at least one of the following:</p><ul><li>Set a non-global windowing function.</li><li>Set a non-default <a href="https://beam.apache.org/documentation/programming-guide/#triggers">trigger</a>. This allows the global window to emit results under other conditions, since the default windowing behavior (waiting for all data to arrive) will never occur.</li></ul><p>Pipeline will generate error if we don&#39;t set one of these for unbounded <em>PCollection </em>and subsequently use a grouping transform such as GroupByKey or Combine.</p><ul><li><strong>Tumbling (Fixed time windows) — </strong>consistent duration, non overlapping time interval in the data stream.</li></ul><pre>from apache_beam import window<br>fixed_windowed_items = (<br>    items | &#39;window&#39; &gt;&gt; beam.WindowInto(window.FixedWindows(60)))</pre><ul><li><strong>Hopping (Sliding window) — </strong>Represents overlapping time intervals. Useful for taking running averages of data.</li></ul><pre>from apache_beam import window<br>sliding_windowed_items = (<br>    items | &#39;window&#39; &gt;&gt; beam.WindowInto(window.SlidingWindows(30, 5)))</pre><ul><li><strong>Session window — </strong>groups data based on periods of activity followed by a “gap duration” of inactivity. Useful for data that is irregularly distributed with respect to time.</li></ul><pre>from apache_beam import window<br>session_windowed_items = (<br>    items | &#39;window&#39; &gt;&gt; beam.WindowInto(window.Sessions(10 * 60)))</pre><ul><li><strong>Single global window</strong> — By default, all data in a PCollection is assigned to the single global window.</li></ul><pre>from apache_beam import window<br>global_windowed_items = (<br>    items | &#39;window&#39; &gt;&gt; beam.WindowInto(window.GlobalWindows()))</pre><p><strong>Watermark &amp; late data:</strong></p><p>Beam tracks a <em>watermark</em>, which is the system’s notion of when all data in a certain window can be expected to have arrived in the pipeline. Once the watermark progresses past the end of a window, any further element that arrives with a timestamp in that window is considered <strong>late data</strong>.</p><pre># Example in Python<br>pcoll | beam.WindowInto(<br>    window.FixedWindows(60),<br>    allowed_lateness=Duration(seconds=300) # Process data up to 5 mins late<br>)</pre><p><a href="https://beam.apache.org/documentation/programming-guide/#windowing">https://beam.apache.org/documentation/programming-guide/#windowing</a></p><p><strong>Trigger:</strong></p><p>Mechanism that determines exactly when to emit the aggregated results (a “pane”) of a window. While windowing groups data logically by time, triggers control the timing of the actual output.</p><ul><li><strong>Event-Time Triggers</strong>: Operated by the system <strong>watermark</strong>; the default trigger fires once it estimates all data for a window has arrived. AfterWatermark trigger operates on <em>event time.</em></li><li><strong>Processing-Time Triggers</strong>: Fire based on the real-world clock time when data is being processed. AfterProcessingTime trigger emits a window after a certain amount of processing time has passed since data was received.</li><li><strong>Data-Driven Triggers</strong>: Fire after a specific property of the data is met, most commonly an <strong>element count</strong>. Beam provides one data-driven trigger, AfterCount .</li><li><strong>Composite Triggers</strong>: Combine multiple conditions using logic like AfterFirst (OR) or AfterAll (AND).</li></ul><p>When a window triggers multiple times (due to early or late data), accumulation modes define how subsequent outputs relate to previous ones. set accumulation_mode = ACCUMULATING / DISCARDING</p><p><a href="https://beam.apache.org/documentation/programming-guide/#triggers">https://beam.apache.org/documentation/programming-guide/#triggers</a></p><p><strong>Prevent Fusion </strong>— Dataflow usually prevents fusion of the steps before and after the Redistribute transform, and shuffles the data so that the steps downstream of the Redistribute transform have more optimal parallelism.</p><p><a href="https://docs.cloud.google.com/dataflow/docs/pipeline-lifecycle">Pipeline lifecycle | Cloud Dataflow | Google Cloud Documentation</a></p><p>Other methods —</p><ul><li>Place a GroupByKey after a ParDo or transform that produces many outputs from one input (high fan-out). Immediately follow the GroupByKey with a <a href="https://www.google.com/search?q=ParDo&amp;rlz=1C1ONGR_enUS1190US1190&amp;oq=dataflow+gcp+prevent+fusion&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigATIHCAIQIRigATIHCAMQIRifBdIBCTE0OTQwajBqN6gCALACAA&amp;sourceid=chrome&amp;ie=UTF-8&amp;mstk=AUtExfCHSpFiC_E1uYjq5-6PKRkt4lwEVZFmm8Cr5X-jg9uBWpqDAuzslBsWcGV-Hf7OhAJ_aWFiw7G9DMQkz8FV3sdgDJThBBKssuJnFoV22eEm9sVxuF7-o4AOeiiqYVKulbJ-1gT9GWiRwZAB15Nl4Kv4rnzBDHJjB-TUEf7Jzjzi4K8&amp;csui=3&amp;ved=2ahUKEwifzLyXutSRAxVoC0QIHYMFHp4QgK4QegQIAxAD">ParDo</a> to ungroup.</li></ul><p><strong>Drain</strong></p><p>When a job is stopped using Drain, Dataflow waits for all in-flight data to be processed before gracefully shutting down your job.</p><p><strong>Cancel</strong></p><p>Canceling a pipeline causes the job to stop and frees all resources associated with it. When a job is canceled, the pipeline stops immediately; all in-flight or buffered data is lost.</p><p><strong>Update</strong></p><p>It’s possible to replace an existing pipeline in-place with the new one and preserve Dataflow’s <em>exactly-once</em> processing guarantee. Two pipelines must meet some compatibility requirements. If you’ve renamed or removed any pipeline steps in your new pipeline, you must provide a mapping between transform names in the old and new pipelines. If the new job is incompatible, it doesn’t start and the old job continues running.</p><p><a href="https://cloud.google.com/blog/products/gcp/managing-streaming-pipelines-in-google-cloud-dataflow-just-got-better">Managing streaming pipelines in Google Cloud Dataflow just got better | Google Cloud Blog</a></p><p><strong>Max No. of Workers</strong></p><p>Dataflow dynamically scales the number of workers (VMs) for a job, balancing cost and performance, but you control this with pipeline options like — maxNumWorkers (defaulting to 1000 for batch, 100 for streaming) or — numWorkers for fixed counts, with options to set min/max for autoscaling to handle data spikes efficiently. The service automatically adjusts workers based on load, using options like THROUGHPUT_BASED autoscaling, scaling from 1 up to your specified maximum.</p><h4><strong>3.6 Storage Transfer Service</strong></h4><p>Fully managed service for moving or synchronizing large volumes of data into Google Cloud Storage (GCS) from other storage systems.</p><ul><li>Move data from on-premises or other clouds</li><li>Perform scheduled or incremental transfers</li><li>handle extremely large datasets, including petabytes of data</li><li>Source: AWS S3, Azure Blob Storage or ADLS Gen2, GCS, URL list</li><li>Source: (require agent pool setup)— Hadoop, POSIX filesystem, S3 compatible</li><li><strong>Destination</strong>: GCS</li><li>Best for &gt; 1 TB</li></ul><p>For most use cases, STS is designed to work over the public internet, and <strong>Cloud Interconnect</strong> is an optional upgrade for performance and security.</p><p>Other options:</p><ul><li>Transfers to BigQuery use BigQuery Data Transfer Service. Transfers can be once-off, as well as ongoing or scheduled.</li><li>Have a lot of data but <strong>low bandwidth</strong>? Consider <strong>Transfer Appliance.</strong> 40 TB, 300 TB, 480 TB.</li><li>rsync <strong>— </strong>synchronize a local directory with a bucket or vice versa. Requires custom scripts. Best for &lt; 1 TB</li></ul><h4>3.7 DataStream — CDC data &amp; replication</h4><ul><li>Serverless, easy-to-use <strong>Change Data Capture (CDC)</strong> and replication service.</li><li>Designed to synchronize data from various operational databases into Google Cloud destinations with minimal latency.</li><li>Supported source — Oracle, MySQL, Postgres, Salesforce, SQL Server, MongoDB.</li><li>Supported Destination — Cloud Storage, BigQuery, BigLake Managed Tables in BQ.</li></ul><h4><strong>3.8 Database Migration Service (DMS)</strong></h4><p>Fully managed, serverless tool designed to migrate databases to Google Cloud with minimal downtime.</p><ul><li>Destinations — Cloud SQL &amp; Alloy DB</li><li>Migration job type — Continuous, One time</li><li><strong>Homogeneous — </strong>Moving between the same database engines.</li><li><strong>Heterogeneous — </strong>Moving between different database engines</li></ul><h4>3.9 Looker</h4><ul><li>Enterprise BI platform (Business intelligence), Analytics, and visualization</li><li>Centralized Data Modelling, metric definitions, reusable logic.</li><li>Self-service analytics for business users.</li><li>Semantic layer (LookML) — lets users ask <strong>business questions</strong> without needing to know <strong>SQL</strong>, joins, or table structures</li><li>Governance &amp; Security</li><li>Designed for massive datasets; handles 10TB+ with high performance.</li></ul><h4>3.10 Looker Studio</h4><ul><li>Fast, easy dashboards, visualization</li><li>Multiple data sources (Ads, Sheets, BigQuery)</li><li>No reusable data model, weak governance</li><li>Can struggle with performance on very large, complex datasets.</li></ul><h4>3.11 Connected Sheets</h4><p>You can access, analyze, visualize, and share billions of rows of data from your spreadsheet with Connected Sheets, the new BigQuery data connector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*zgS73ZxUktAGr4kL57BUlQ.png" /></figure><ul><li>Single Source of Truth</li><li><strong>Governance &amp; Security — </strong>Inherits the security and access controls</li></ul><p><a href="https://docs.cloud.google.com/bigquery/docs/connected-sheets">Using Connected Sheets | BigQuery | Google Cloud Documentation</a></p><h4>3.12 BigQuery Sharing (Analytics Hub)</h4><p>Discover, subscribe to and share data assets within your organization or with <strong>external partners. </strong>For sensitive data collaboration, data clean rooms provide a secure environment where multiple parties can share, join and analyze data assets without compromising privacy or moving the underlying data.</p><h4>3.13 Dataprep (Alteryx Designer Cloud)</h4><p>Provided by third-party company Trifacta.</p><ul><li>Provides a no-code, drag-and-drop graphical user interface (GUI) that allows users to transform data.</li><li>Uses machine learning to automatically identify data quality issues.</li><li>Users create “recipes” (sequences of transformation steps) that can be reused and automated for future datasets.</li><li>Seamlessly connects with other GCP services, including Cloud Storage, BigQuery, and Cloud Dataflow.</li></ul><p><a href="https://docs.trifacta.com/Dataprep/en/product-overview.html">Product Overview</a></p><h4>4. Data Governance &amp; Catalog</h4><h4><strong>4.1 Dataplex</strong></h4><p>Build intelligent data fabric to enable decentralized data ownership with centralized governance, treating data as products, by creating Dataplex Lakes for domains, Zones (like raw/curated) for data stages. Attach assets (BigQuery/GCS) for data. Leveraging Dataplex Catalog for discovery, metadata, and unified access controls across your distributed data landscape, achieving domain autonomy while maintaining organizational oversight.</p><p>We can also build a Data Mesh.</p><p><strong>Key Concepts &amp; Steps:</strong></p><p><strong>Decentralized Domain Ownership</strong>: It allows assigning ownership and managing data products (e.g., Sales, Marketing) within separate Lakes, giving domain teams control.</p><ol><li>Define a <strong>Dataplex Lake</strong> for each business domain (e.g., Sales_Domain_Lake, Finance_Data_Lake .</li><li>Define <strong>Zones</strong>: Within each Lake, create Zones (e.g., raw, processed, curated) to structure data stages.</li><li><strong>Register Assets</strong>: Attach your data (BigQuery tables, Cloud Storage files) as Assets to the appropriate Zone, linking them to their actual location.</li><li><strong>Metadata &amp; Discovery</strong>: Use Dataplex Universal Catalog to automatically harvest metadata, apply business terms, and create Tag Templates (e.g., for PII, data sensitivity).</li><li><strong>Security &amp; Access</strong>: Apply fine-grained access permissions at the Lake, Zone, or Asset level for domain teams and consumers, with inherited permissions.</li><li><strong>Data Quality</strong>: Implement data quality rules and monitors directly within Dataplex for your data products.</li></ol><p><a href="https://cloud.google.com/blog/products/data-analytics/build-a-data-mesh-on-google-cloud-with-dataplex-now-generally-available">Build a data mesh on Google Cloud with Dataplex | Google Cloud Blog</a></p><h4>4.2 Cloud DLP</h4><p>Fully managed service designed to discover, classify, and mask sensitive data.</p><ul><li><strong>Redaction</strong>: Deleting the sensitive text entirely.</li><li>Mask</li><li>Tokenization</li><li>Encrypt (FPE — Format Preserving Encryption)</li></ul><h3>5. Job Automation, Orchestration &amp; CI/CD</h3><h4>5.1 Cloud Scheduler</h4><ul><li>Google Cloud’s fully managed, serverless enterprise-grade <strong>cron job service</strong></li><li>Supported Targets:<br>- HTTPS endpoints <strong>— </strong>Any web service such as Cloud Run.<br>- Pub/Sub Topic — Publishes a message to a topic<br>-<strong> </strong>App Engine via HTTP<br>- Workflows via HTTP</li><li>If a job does not complete successfully, it is retried, with exponential backoff, according to the settings in retry config</li></ul><h4>5.2 Batch</h4><ul><li>Fully managed service (<strong>VM Based </strong>— Compute Engine resource). Executables — shell scripts or containers.</li><li>Designed to schedule, queue, and execute high-scale, run-to-completion workloads on Google Cloud infrastructure.</li><li>Highly customizable (any VM type/GPU).</li><li>Unlike Cloud Run Jobs, which have specific timeout limits (typically 24 hours to 7 days), Batch is designed for massive, <strong>long-running tasks </strong>that can take weeks to complete.</li><li>Choose Spot to get discounted, preemptible VMs. Otherwise, opt for Standard.</li><li><strong>Trigger</strong> — It does not have a trigger, it is a run-to-completion service, creating the job <em>is</em> the start signal.</li></ul><h4>5.3 Workflows</h4><ul><li><strong>Serverless </strong>orchestration platform (Regional)</li><li>Microservices/API Chaining</li><li>Designed to combine microservices, Google Cloud services (like BigQuery or Cloud Run), and any HTTP-based API into a single automated process.</li><li>Uses a YAML or JSON-based syntax.</li><li>Use service account to call Google Cloud API (Make sure appropriate IAM Roles)</li><li><strong>Trigger</strong> — Cloud Scheduler/ Eventarc or PubSub.</li></ul><h4>5.4 Cloud Composer</h4><ul><li>Managed <strong>Apache Airflow</strong> (workflow automation)</li><li><strong>Python</strong>-based orchestrator for enterprise-grade data pipelines that involve many cross-service dependencies.</li><li>Workflows are defined as <strong>Directed Acyclic Graphs (DAGs)</strong>.</li><li>Environments are self-contained Airflow deployments based on Google Kubernetes Engine, and they work with other Google Cloud services using connectors built into Airflow.</li><li>Resilience mode: High vs Standard (Zonal). <br>- Highly resilient environments use built-in redundancy and failover mechanisms that reduce the environment’s susceptibility to zonal failures.</li></ul><p><strong>Airflow REST API — </strong>Standard way to trigger DAGs programmatically from external systems. For Cloud Composer 2 and 3, you make a POST request to the environment’s web server URL.</p><ul><li>Enable <strong>Airflow REST API</strong></li><li><strong>Endpoint:</strong> POST <a href="https://[WEB_SERVER_URL]/api/v1/dags/[DAG_ID]/dagRuns">https://[WEB_SERVER_URL]/api/v1/dags/[DAG_ID]/dagRuns</a></li><li><strong>Authentication:</strong> You must include a Google-issued <strong>ID token</strong> in the Authorization: Bearer header. This token is typically obtained for a Service Account with the <strong>Composer User</strong> role.</li><li><strong>Configuration:</strong> You can pass a JSON payload (e.g., {&quot;conf&quot;: {&quot;key&quot;: &quot;value&quot;}}) to provide parameters to the DAG.</li></ul><p>A common architectural pattern is to have Cloud Scheduler trigger a <strong>Cloud Run Function</strong>, which then uses the Airflow client library or REST API to trigger the DAG.</p><p><strong>Pod evictions</strong></p><p>In Cloud Composer, tasks frequently fail due to <strong>pod evictions</strong> when workers exceed their allocated memory or storage limits. When a pod is evicted, all tasks running on it are terminated immediately, often leaving behind no logs in the Airflow UI.</p><ul><li><strong>Increase Worker Memory: </strong>Adjust your environment configuration to provide more memory per worker pod</li><li><strong>Reduce Worker Concurrency:</strong> Lower the number of tasks a single worker can run at once.</li><li>Increase the <strong>maximum number of workers</strong> to maintain throughput if you have reduced the concurrency per worker</li><li>If the issue is related to ephemeral storage, increase the worker storage limit.</li></ul><h4>5.5 Cloud Build</h4><p>General-purpose CI; executes scripts to build, test, and push images.</p><h4>5.6 Cloud Deploy</h4><p>Purpose-built CD; manages releases, promotions, and environment progressions.</p><h4>5.7 Artifact Registry</h4><ul><li><strong>Multi-Format Support</strong>: Supports much more than just Docker images.</li><li>Docker, npm, Maven, Python, etc.</li></ul><h3>6. Machine Learning &amp; AI:</h3><h4>Supervised Learning:</h4><p>Type of machine learning where a model is trained using <strong>labeled data</strong></p><p><strong>Regression </strong>—Used when the output is a <strong>continuous value</strong></p><ul><li>Linear</li><li>Polynomial</li><li>Ridge / Lasso Regression</li><li>Decision Tree Regressor, Random Forest Regressor</li></ul><p><strong>Classification </strong>— Used when the output is a <strong>category</strong></p><ul><li>Logistic Regression</li><li>SVM (Support Vector Machines)</li><li>ANN (Neural Network)</li><li>Decision Tree</li><li>Random Forest,</li><li>KNN, Naive Bayes Classifier</li><li>Deep Learning — CNN, RNN</li></ul><h4>Unsupervised Learning:</h4><p>Type of machine learning where the model is trained on<strong> unlabeled data</strong> — there are no predefined outputs or answers.</p><ul><li>Clustering (Groups similar data points together) — K-Means, GMM, Hierarchical Clustering</li><li>Dimension Reduction — Reduces the number of features while preserving important information. PCA (Principal Component Analysis)</li><li>Anomaly Detection — Identifies rare or unusual data points.</li></ul><h4><strong>Reinforcement</strong></h4><p>Reinforcement Learning revolves around the idea that an agent (the learner or decision-maker) interacts with an environment to achieve a goa</p><ul><li>Decision Making</li></ul><h4><strong>Overfitting</strong></h4><p>Model performs poorly on new, unseen data.</p><ul><li>Model is <strong>too complex</strong> (too many parameters)</li><li>Small training dataset</li><li>Too many features (high dimensionality)</li><li>No or weak <strong>regularization</strong></li></ul><p><strong>Fix</strong></p><p><strong>Regularization </strong>technique designed to prevent <strong>overfitting — </strong>when less complex model is needed</p><ul><li><strong>L1 (Lasso)</strong> — feature selection — effectively removing less important features. Best for sparse data, when you suspect many features are irrelevant.</li><li><strong>L2 (Ridge)</strong> — shrinks weights — reduces the model’s complexity without eliminating any features completely. Best for High-dimensional data, multicollinearity, creating a stable model where all features contribute slightly.</li></ul><p>L1 sets some weights to zero; L2 keeps all features but reduces their influence. L1 reduces features; L2 smooths all weights.</p><p><strong>Early Stopping</strong> — Stop training when validation performance starts to degrade.</p><p><strong>Cross-validation</strong> — Ensures the model performs well across multiple data splits.</p><p><strong>Dropout</strong> is a regularization technique used to <strong>prevent overfitting</strong>, especially in <strong>neural networks</strong>. It works by <strong>randomly turning off (dropping)</strong> a fraction of neurons during training so the model doesn’t rely too heavily on any single neuron.</p><h4>Underfitting</h4><p>Machine learning where a model is <strong>too simple </strong>to capture the underlying pattern in the data, resulting in poor performance on both training and unseen data.</p><ul><li>Model is <strong>too simple</strong></li><li>Too few features</li><li>Excessive regularization</li><li>Training stopped too early</li></ul><p><strong>Fix</strong></p><ul><li>Add more features</li><li><strong>Increase model complexity:</strong> Switch from a simple linear model to a more complex one.</li><li>Reduce Regularization, dropouts</li><li>Feature Engineering</li></ul><h4>6.1 BigQueryML</h4><p>Brings ML capabilities to your data warehouse. SQL Based ML.</p><p>Model Types— Regression, classification, clustering, time series etc.</p><pre>-- Create Model<br>CREATE OR REPLACE MODEL my_model<br>OPTIONS(model_type=&#39;linear_reg&#39;) AS<br>SELECT feature1, feature2, target<br>FROM my_dataset.my_table;<br><br>-- Evaluate <br>SELECT * FROM<br>ML.EVALUATE(MODEL my_model, (<br>    SELECT feature1, feature2, target<br>    FROM my_dataset.my_table<br>  ));<br><br>--Predict<br>SELECT *<br>FROM ML.PREDICT(MODEL my_model, (<br>    SELECT feature1, feature2<br>    FROM my_dataset.new_data<br>));</pre><h4>6.2 Vertex AI</h4><p>End-to-end machine learning (ML) platform that lets you build, deploy, and manage ML models at scale.</p><p>Support various ML model</p><ul><li>AutoML</li><li>Custom — your own TensorFlow, PyTorch, or scikit-learn models</li><li>Pre-trained — vision, language, video models.</li></ul><p>Vertex AI brings together several tools:</p><ul><li>Vertex AI Studio — Environment for rapidly prototyping, testing, and refining Generative AI models.</li><li>Model Garden — <strong>200+ models</strong>, including Google’s models (such as <strong>Gemini 3</strong>), open-source models (like Llama and Gemma)</li><li>Vertex AI Agent Builder — building and scaling enterprise AI agents</li><li>MLOPs Tools — <strong>Pipelines</strong> for orchestrating complex workflows, <strong>Model Registry</strong> for version control, and <strong>Feature Store</strong> (powered by BigQuery) for managing data used in models</li><li>Notebooks</li></ul><p><strong>Cloud Vision API</strong></p><p>Cloud Vision API allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.</p><p><a href="https://docs.cloud.google.com/vision/docs">Cloud Vision API documentation | Google Cloud Documentation</a></p><ul><li>For a customized solution — Use AutoML model for computer vision objectives like image classification and object detection.</li></ul><h3>7. Monitoring:</h3><h4>7.1 Cloud Monitoring</h4><p>Observability service that provides visibility into the performance, uptime, and overall health of your cloud-powered applications.</p><ul><li>Track health &amp; performance</li></ul><p>Metric Collection &amp; Visualization:</p><ul><li><strong>System metrics</strong> (CPU, memory, latency)</li><li><strong>Service metrics</strong> (request count, error rate)</li><li>Custom</li></ul><p>Alerting:</p><ul><li>Thresholds are exceeded</li><li>error spike, latency increase</li></ul><p>Uptime:</p><ul><li>Monitor endpoints (HTTP/HTTPS/TCP)</li><li>Measure availability and response time</li></ul><h4>7.2 Cloud Logging</h4><p>For real-time log management and analysis.</p><ul><li>Debugging logs</li></ul><p><strong>Sink</strong></p><p><strong>Aggregated export sink</strong> is a log routing configuration created at the organization or folder level that centralizes logs from all child resources (projects, folders, and billing accounts) into a single destination.</p><p>— include-children option</p><p><a href="https://docs.cloud.google.com/logging/docs/export/aggregated_sinks_overview">https://docs.cloud.google.com/logging/docs/export/aggregated_sinks_overview</a></p><h4>7.3 Cloud Trace</h4><p>For distributed tracing to identify latency bottlenecks.</p><h4>7.4 Cloud Profiler</h4><p>For continuous profiling of resource consumption to optimize code performance.</p><h3>8. Networking</h3><h4><strong>8.1 Private Google Access(PGA)</strong></h4><p>Google Cloud networking feature that allows Virtual Machine (VM) instances with only internal (private) IP addresses to reach the public IP addresses of Google APIs and services.</p><ul><li>No Internet Exposure</li><li>Subnet level control. Specifically benefits VMs that lack external IP addresses.</li><li>For traffic to destinations like googleapis.com, your VPC network requires a route whose next hop is the <strong>Default Internet Gateway.</strong></li><li>Google Cloud’s network recognizes that the destination IPs belong to Google APIs and services and intercepts the traffic before it actually goes out to the public internet, directing it internally instead.</li><li>No IP translation (No NAT) — VM’s <strong>original internal IP address</strong></li></ul><p><a href="https://docs.cloud.google.com/vpc/docs/private-google-access">Private Google Access | Virtual Private Cloud | Google Cloud Documentation</a></p><h4><strong>8.2 Private Service Connect (PSC)</strong></h4><p>Google Cloud networking capability that allows for private, secure communication between independent VPC networks or between a VPC and Google services.</p><ul><li>No Internet Exposure</li><li><strong>Service-Centric Connectivity:</strong> Instead of connecting entire networks (like VPC Peering), PSC connects to specific services via a single internal IP address, maintaining strict isolation.</li><li>Network Address Translation (NAT), consumers and producers can have overlapping IP ranges without conflict.</li></ul><p><a href="https://docs.cloud.google.com/vpc/docs/private-service-connect">Private Service Connect | Virtual Private Cloud | Google Cloud Documentation</a></p><p>Key Differences: PGA vs. PSC</p><ul><li><strong>Private Google Access (PGA):</strong> Uses standard Google public IP ranges but routes them internally. It is easier to set up but gives less control over the specific internal IP used.</li><li><strong>Private Service Connect (PSC):</strong> Allows you to assign a <strong>specific internal IP</strong> from your VPC to the Google API endpoint, providing better visibility and control for strict firewall auditing.</li></ul><p>Private Google Access (PGA) requires a route in your VPC with a next hop of the <strong>“Default Internet Gateway”</strong>. However, this does not mean the traffic goes out to the public internet.</p><p>Unlike <strong>Private Google Access (PGA)</strong>, which requires a route to the “default-internet-gateway” (even though traffic stays internal), PSC uses a dedicated internal IP address that you manage within your own VPC.</p><ul><li>If you have a strict environment where you have <strong>deleted the default route</strong> (0.0.0.0/0), you must manually add a custom static route for the Google API IP ranges (e.g., 199.36.153.8/30 for private.googleapis.com) with the <strong>default-internet-gateway</strong> as the next hop for PGA to function.</li></ul><h4>8.3 Cloud Interconnect</h4><p>Professional-grade networking service that establishes a dedicated, private connection between your external network (on-premises or another cloud) and Google’s global network. Unlike a standard internet connection or VPN, it bypasses the public internet entirely, offering lower latency, higher availability, and more consistent performance.</p><p><strong>Cloud Interconnect</strong> provides the <strong>physical “highway”</strong> (Layer 2 or Layer 3) between your on-premises data center and your Google Virtual Private Cloud (VPC). It establishes broad, high-bandwidth network connectivity.</p><p><strong>Private Service Connect (PSC)</strong> provides <strong>service-specific access</strong> (Layer 7/Service Layer). It allows you to create a private IP address (endpoint) within your VPC that points specifically to a Google API (like BigQuery).</p><h3>References</h3><ul><li>Google Docs</li><li>ChatGPT</li><li>Google Search (AI Mode)</li><li><a href="https://storage.googleapis.com/gweb-cloudblog-publish/images/Which-Database_v03-22-23.max-2000x2000.jpg">https://storage.googleapis.com/gweb-cloudblog-publish/images/Which-Database_v03-22-23.max-2000x2000.jpg</a></li></ul><ul><li><a href="https://play.beam.apache.org/?path=SDK_PYTHON_ParDoDoFn&amp;sdk=python">Apache Beam Playground</a></li><li><a href="https://docs.cloud.google.com/dataflow/docs/concepts/beam-programming-model?_gl=1*9pydbi*_ga*ODg1OTMxODM2LjE3NjQ0NTY4NDU.*_ga_WH2QY8WWF5*czE3NjQ3Mzk3MTMkbzkkZzEkdDE3NjQ3NDAzOTIkajU4JGwwJGgw">Programming model for Apache Beam | Cloud Dataflow | Google Cloud Documentation</a></li></ul><p>Thanks!</p><p>Happy Learning! Your feedback would be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae650b2b190b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create StructType schema from JSON schema | PySpark]]></title>
            <link>https://bigdataenthusiast.medium.com/how-to-create-structtype-schema-from-json-schema-pyspark-92470d7dfe7b?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/92470d7dfe7b</guid>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pyspark-dataframes]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pyspark]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 02:45:53 GMT</pubDate>
            <atom:updated>2024-11-25T02:45:53.479Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Apache Spark class <strong>pyspark.sql.types.StructType </strong>method <strong>fromJson </strong>we can create<strong> StructType </strong>schema using a defined JSON schema.</p><p>Refer official documentation <a href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.types.StructType.html#pyspark.sql.types.StructType.fromJson">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7t8kO-dZflhw794LaAThXA.png" /></figure><pre>classmethod fromJson(json: Dict[str, Any]) → pyspark.sql.types.StructType</pre><p>Here is the simple example of converting a JSON schema to StructType. In order to get the correct StructType, we have adhere the syntax of json schema.</p><pre>from pyspark.sql import SparkSession<br>from pyspark.sql.types import StructType<br>import json<br><br>spark = SparkSession.builder.getOrCreate()<br><br>json_schema = &quot;&quot;&quot;<br>{<br> &quot;fields&quot;: [<br>  {<br>   &quot;metadata&quot;: {},<br>   &quot;name&quot;: &quot;age&quot;,<br>   &quot;nullable&quot;: true,<br>   &quot;type&quot;: &quot;long&quot;<br>  },<br>  {<br>   &quot;metadata&quot;: {},<br>   &quot;name&quot;: &quot;firstName&quot;,<br>   &quot;nullable&quot;: true,<br>   &quot;type&quot;: &quot;string&quot;<br>  },<br>  {<br>   &quot;metadata&quot;: {},<br>   &quot;name&quot;: &quot;lastName&quot;,<br>   &quot;nullable&quot;: true,<br>   &quot;type&quot;: &quot;string&quot;<br>  }<br> ],<br> &quot;type&quot;: &quot;struct&quot;<br>}<br>&quot;&quot;&quot;<br><br>structType_schema = StructType.fromJson(json.loads(json_schema))<br>print(structType_schema)</pre><p>Output:</p><pre>StructType(List(StructField(age,LongType,true),StructField(firstName,StringType,true),StructField(lastName,StringType,true)))</pre><p>Another example, here reading a complex json file using spark.read and printing its json schema. As we know that DataFrame.schema return StructType &amp;StructType.json() method return json schema.</p><pre>import json<br>from pyspark.sql import SparkSession<br>from pyspark.sql.types import StructType<br><br>spark = SparkSession.builder.getOrCreate()<br><br>df = spark.read.option(&#39;multiLine&#39;, True).json(&quot;data/cust.json&quot;)<br>json_schema = df.schema.json()</pre><pre>{<br>   &quot;fields&quot;:[<br>      {<br>         &quot;metadata&quot;:{<br>            <br>         },<br>         &quot;name&quot;:&quot;address&quot;,<br>         &quot;nullable&quot;:true,<br>         &quot;type&quot;:{<br>            &quot;fields&quot;:[<br>               {<br>                  &quot;metadata&quot;:{<br>                     <br>                  },<br>                  &quot;name&quot;:&quot;city&quot;,<br>                  &quot;nullable&quot;:true,<br>                  &quot;type&quot;:&quot;string&quot;<br>               },<br>               {<br>                  &quot;metadata&quot;:{<br>                     <br>                  },<br>                  &quot;name&quot;:&quot;postalCode&quot;,<br>                  &quot;nullable&quot;:true,<br>                  &quot;type&quot;:&quot;string&quot;<br>               },<br>               {<br>                  &quot;metadata&quot;:{<br>                     <br>                  },<br>                  &quot;name&quot;:&quot;state&quot;,<br>                  &quot;nullable&quot;:true,<br>                  &quot;type&quot;:&quot;string&quot;<br>               },<br>               {<br>                  &quot;metadata&quot;:{<br>                     <br>                  },<br>                  &quot;name&quot;:&quot;streetAddress&quot;,<br>                  &quot;nullable&quot;:true,<br>                  &quot;type&quot;:&quot;string&quot;<br>               }<br>            ],<br>            &quot;type&quot;:&quot;struct&quot;<br>         }<br>      },<br>      {<br>         &quot;metadata&quot;:{<br>            <br>         },<br>         &quot;name&quot;:&quot;age&quot;,<br>         &quot;nullable&quot;:true,<br>         &quot;type&quot;:&quot;long&quot;<br>      },<br>      {<br>         &quot;metadata&quot;:{<br>            <br>         },<br>         &quot;name&quot;:&quot;firstName&quot;,<br>         &quot;nullable&quot;:true,<br>         &quot;type&quot;:&quot;string&quot;<br>      },<br>      {<br>         &quot;metadata&quot;:{<br>            <br>         },<br>         &quot;name&quot;:&quot;lastName&quot;,<br>         &quot;nullable&quot;:true,<br>         &quot;type&quot;:&quot;string&quot;<br>      },<br>      {<br>         &quot;metadata&quot;:{<br>            <br>         },<br>         &quot;name&quot;:&quot;phoneNumber&quot;,<br>         &quot;nullable&quot;:true,<br>         &quot;type&quot;:{<br>            &quot;containsNull&quot;:true,<br>            &quot;elementType&quot;:{<br>               &quot;fields&quot;:[<br>                  {<br>                     &quot;metadata&quot;:{<br>                        <br>                     },<br>                     &quot;name&quot;:&quot;number&quot;,<br>                     &quot;nullable&quot;:true,<br>                     &quot;type&quot;:&quot;string&quot;<br>                  },<br>                  {<br>                     &quot;metadata&quot;:{<br>                        <br>                     },<br>                     &quot;name&quot;:&quot;type&quot;,<br>                     &quot;nullable&quot;:true,<br>                     &quot;type&quot;:&quot;string&quot;<br>                  }<br>               ],<br>               &quot;type&quot;:&quot;struct&quot;<br>            },<br>            &quot;type&quot;:&quot;array&quot;<br>         }<br>      }<br>   ],<br>   &quot;type&quot;:&quot;struct&quot;<br>}</pre><p>This we can use this to build more complex schemas.</p><h3>References:</h3><ul><li><a href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.types.StructType.html#pyspark.sql.types.StructType.fromJson">StructType - PySpark 3.5.3 documentation</a></li><li><a href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.types.StructType.html#pyspark.sql.types.StructType.json">StructType - PySpark 3.5.3 documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92470d7dfe7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PySpark — Log Parsing using regexp_extract]]></title>
            <link>https://bigdataenthusiast.medium.com/pyspark-log-parsing-using-regexp-extract-4aa9a91a4ea3?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4aa9a91a4ea3</guid>
            <category><![CDATA[pyspark-dataframes]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Tue, 28 May 2024 00:13:23 GMT</pubDate>
            <atom:updated>2024-05-28T00:13:23.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>PySpark — Log Parsing using regexp_extract</h3><p>Apache Spark built-in function regexp_extract that takes input as an column object, regex expression as string and group index &amp; extract a specific group matched by a Java regex, from the specified string column. If the regex did not match, or the specified group did not match, an empty string is returned.</p><p>Refer official documentation <a href="https://spark.apache.org/docs/3.1.2/api/python/reference/api/pyspark.sql.functions.regexp_extract.html">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*v4oP6vzTlD9P2sqYp31JPA.png" /></figure><p>Suppose you have a file with unstructured data that we have to parse &amp; process using PySpark. For example: refer below web server access logs sample data. (<em>data courtesy ~ kaggle</em>)</p><pre>54.36.149.41 USERID1 [22/Jan/2019:03:56:14 +0330] &quot;GET /filter/27|13%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,27|%DA%A9%D9%85%D8%AA%D8%B1%20%D8%A7%D8%B2%205%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,p53 HTTP/1.1&quot; 200 30577 &quot;-&quot; &quot;Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)&quot; &quot;-&quot;<br>31.56.96.51 USERID2 [22/Jan/2019:03:56:16 +0330] &quot;GET /image/60844/productModel/200x200 HTTP/1.1&quot; 200 5667 &quot;https://www.zanbil.ir/m/filter/b113&quot; &quot;Mozilla/5.0 (Linux; Android 6.0; ALE-L21 Build/HuaweiALE-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Mobile Safari/537.36&quot; &quot;-&quot;<br>31.56.96.51 USERID3 [22/Jan/2019:03:56:16 +0330] &quot;GET /image/61474/productModel/200x200 HTTP/1.1&quot; 200 5379 &quot;https://www.zanbil.ir/m/filter/b113&quot; &quot;Mozilla/5.0 (Linux; Android 6.0; ALE-L21 Build/HuaweiALE-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Mobile Safari/537.36&quot; &quot;-&quot;<br>40.77.167.129 USERID4 [22/Jan/2019:03:56:17 +0330] &quot;GET /image/14925/productModel/100x100 HTTP/1.1&quot; 200 1696 &quot;-&quot; &quot;Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)&quot; &quot;-&quot;<br>91.99.72.15 USERID5 [22/Jan/2019:03:56:17 +0330] &quot;GET /product/31893/62100/%D8%B3%D8%B4%D9%88%D8%A7%D8%B1-%D8%AE%D8%A7%D9%86%DA%AF%DB%8C-%D9%BE%D8%B1%D9%86%D8%B3%D9%84%DB%8C-%D9%85%D8%AF%D9%84-PR257AT HTTP/1.1&quot; 200 41483 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0)Gecko/16.0 Firefox/16.0&quot; &quot;-&quot;</pre><p>First you have to build a regex for your unstructured data. After that we can use the regex with this function regexp_extract to extract the specific groups. Refer below sample code.</p><pre>from pyspark.sql import SparkSession<br>from pyspark.sql.functions import col,regexp_extract<br><br>spark = SparkSession.builder.getOrCreate()<br><br>regex = &quot;&quot;&quot;^(\S+)\s+(\S+)\s+\[([^\]]+)\]\s+&quot;([A-Z]+)\s+(\S+)\s+HTTP/([0-9.]+)&quot;\s+([0-9]{3})\s+([0-9]+)\s+&quot;([^&quot;]+)&quot;\s+&quot;([^&quot;]+)&quot;\s+&quot;([^&quot;]+)&quot;$&quot;&quot;&quot;<br><br>df = spark.read.text(&quot;data/webserver_logs.txt&quot;)<br><br>final_df = df.select(<br>    regexp_extract(col(&quot;value&quot;), regex, 1).alias(&quot;host&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 2).alias(&quot;userid&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 3).alias(&quot;datetime&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 4).alias(&quot;method&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 5).alias(&quot;request&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 6).alias(&quot;http_version&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 7).alias(&quot;status&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 8).alias(&quot;size&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 9).alias(&quot;other_data&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 10).alias(&quot;referer&quot;),<br>    regexp_extract(col(&quot;value&quot;), regex, 11).alias(&quot;user_agent&quot;)<br>  )<br><br>final_df.select(<br>      &quot;host&quot;,&quot;userid&quot;,&quot;datetime&quot;,&quot;method&quot;,&quot;http_version&quot;,&quot;status&quot;,&quot;size&quot;<br>    ).show(5,truncate=False)</pre><p><strong>Output</strong>:</p><pre>+-------------+-------+--------------------------+------+------------+------+-----+<br>|host         |userid |datetime                  |method|http_version|status|size |<br>+-------------+-------+--------------------------+------+------------+------+-----+<br>|54.36.149.41 |USERID1|22/Jan/2019:03:56:14 +0330|GET   |1.1         |200   |30577|<br>|31.56.96.51  |USERID2|22/Jan/2019:03:56:16 +0330|GET   |1.1         |200   |5667 |<br>|31.56.96.51  |USERID3|22/Jan/2019:03:56:16 +0330|GET   |1.1         |200   |5379 |<br>|40.77.167.129|USERID4|22/Jan/2019:03:56:17 +0330|GET   |1.1         |200   |1696 |<br>|91.99.72.15  |USERID5|22/Jan/2019:03:56:17 +0330|GET   |1.1         |200   |41483|<br>+-------------+-------+--------------------------+------+------------+------+-----+</pre><p>For Scala code — refer ths blog <a href="https://medium.com/@bigdataenthusiast/apache-spark-log-parsing-using-regexp-extract-dae2de03674a">https://medium.com/@bigdataenthusiast/apache-spark-log-parsing-using-regexp-extract-dae2de03674a</a></p><h3>References:</h3><ul><li><a href="https://spark.apache.org/docs/3.0.0/api/scala/org/apache/spark/sql/functions$.html#regexp_extract(e:org.apache.spark.sql.Column,exp:String,groupIdx:Int):org.apache.spark.sql.Column">https://spark.apache.org/docs</a></li><li><a href="https://www.kaggle.com/datasets/eliasdabbas/web-server-access-logs">https://www.kaggle.com/datasets/eliasdabbas/web-server-access-logs</a></li><li><a href="https://regex101.com/">https://regex101.com/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aa9a91a4ea3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polars Dataframe — SQL Interface]]></title>
            <link>https://bigdataenthusiast.medium.com/polars-dataframe-sql-interface-d96652d8c358?source=rss-fb864bd67c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d96652d8c358</guid>
            <category><![CDATA[dataframes]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[dataframes-python]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[polar]]></category>
            <dc:creator><![CDATA[BigDataEnthusiast]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 03:40:49 GMT</pubDate>
            <atom:updated>2024-04-15T03:40:49.403Z</atom:updated>
            <content:encoded><![CDATA[<h3>Polars Dataframe — SQL Interface</h3><p>While dealing with polars dataframes in Python, instead of using dataframes APIs (eg. fiter, select, join etc.) for data transformation, we can simply use polars SQL Interface to register dataframes as table and execute SQL queries against those dataframes.</p><p>Like we have spark.sql for Apache Spark, similarly in polars we haveSQLContext provide SQL interface for dataframes.</p><p>Let’s explore, first we have to register the dataframes using SQLContext</p><p>Refer below the signature of constructor of SQLContext class. It accepts parameters like frames i.e. mapping of dataframes,eager_execution, also keyword arguments for dataframes.</p><pre>def __init__(self,<br>             frames: Mapping[str, DataFrame | LazyFrame | None] | None = None,<br>             *,<br>             register_globals: bool | int = False,<br>             eager_execution: bool = False,<br>             **named_frames: DataFrame | LazyFrame | None) -&gt; None</pre><p><strong>Example</strong>: In this example we are registering dataframes using mapping of identifier name to dataframe.</p><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext(frames={&quot;trip_apr_table&quot;: df1, &quot;trip_may_table&quot;: df2})<br><br>query = &quot;&quot;&quot; <br>            SELECT VendorID, Count(VendorID) as cnt<br>            FROM   (SELECT VendorID<br>                    FROM   trip_apr_table<br>                    UNION ALL<br>                    SELECT VendorID<br>                    FROM   trip_may_table) t<br>            GROUP  BY VendorID <br>        &quot;&quot;&quot;<br><br>print(ctx.execute(query,eager=True))<br><br>┌──────────┬─────────┐<br>│ VendorID ┆ cnt     │<br>│ ---      ┆ ---     │<br>│ i64      ┆ u32     │<br>╞══════════╪═════════╡<br>│ 6        ┆ 13541   │<br>│ 1        ┆ 2100369 │<br>│ 5        ┆ 37      │<br>│ 2        ┆ 5074268 │<br>└──────────┴─────────┘</pre><p>Other ways to register dataframes.</p><ul><li>Register all polars datafarme/lazyframe present in global namespace.</li></ul><pre>ctx = pl.SQLContext(register_globals=True)</pre><ul><li>Using keyword arguments:</li></ul><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext(trip_apr_table= df1, trip_may_table= df2)</pre><h4>Pandas Dataframe</h4><p>We can also register Pandas dataframes, first we have to convert them to Polars dataframes using from_padas. Refer below example.</p><pre>import pandas as pd<br>import polars as pl<br><br>df1 = pd.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pd.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext(trip_apr_table=pl.from_pandas(df1), trip_may_table=pl.from_pandas(df2))<br><br>query = &quot;&quot;&quot; <br>            SELECT VendorID, Count(VendorID) as cnt<br>            FROM   (SELECT VendorID<br>                    FROM   trip_apr_table<br>                    UNION ALL<br>                    SELECT VendorID<br>                    FROM   trip_may_table) t<br>            GROUP  BY VendorID <br>        &quot;&quot;&quot;<br><br>print(ctx.execute(query,eager=True))</pre><h4>Lazy Evaluation</h4><p>SQL queries always executed in lazy evaluation mode, in order go get the best performance optimization. So to collect the final output, we have these options.</p><ul><li>Set eager_execution=True in SQLContext :</li></ul><p>Polars automatically collects the lazyframe results from execute.</p><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext( eager_execution=True, frames={&quot;trip_apr_table&quot;: df1, &quot;trip_may_table&quot;: df2})<br><br>query = &quot;&quot;&quot; &lt;query&gt; &quot;&quot;&quot;<br><br>print(ctx.execute(query))</pre><ul><li>Set eager_execution=False in SQLContext : We have to collect the final result using collect.</li></ul><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext( eager_execution=False, frames={&quot;trip_apr_table&quot;: df1, &quot;trip_may_table&quot;: df2})<br><br>query = &quot;&quot;&quot; &lt;query&gt; &quot;&quot;&quot;<br><br>print(ctx.execute(query).collect())</pre><ul><li>Set eager=True in execute</li></ul><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext(frames={&quot;trip_apr_table&quot;: df1, &quot;trip_may_table&quot;: df2})<br><br>query = &quot;&quot;&quot; &lt;query&gt; &quot;&quot;&quot;<br><br>print(ctx.execute(query, eager=True))</pre><p>If we provide eager_execution=False and doesn&#39;t collect explicitly. It will just provide the plan.</p><pre>import polars as pl<br><br>df1 = pl.read_parquet(&quot;data/yellow_tripdata_2022-04.parquet&quot;)<br>df2 = pl.read_parquet(&quot;data/yellow_tripdata_2022-05.parquet&quot;)<br><br>ctx = pl.SQLContext(eager_execution=False,frames={&quot;trip_apr_table&quot;: df1, &quot;trip_may_table&quot;: df2})<br><br>query = &quot;&quot;&quot; <br>            SELECT VendorID, Count(VendorID) as cnt<br>            FROM   (SELECT VendorID<br>                    FROM   trip_apr_table<br>                    UNION ALL<br>                    SELECT VendorID<br>                    FROM   trip_may_table) t<br>            GROUP  BY VendorID <br>        &quot;&quot;&quot;<br><br>print(ctx.execute(query))<br><br>naive plan: (run LazyFrame.explain(optimized=True) to see the optimized plan)<br><br> SELECT [col(&quot;VendorID&quot;), col(&quot;cnt&quot;)] FROM<br>  AGGREGATE<br>   [col(&quot;VendorID&quot;).count().alias(&quot;cnt&quot;)] BY [col(&quot;VendorID&quot;)] FROM<br>    UNION<br>      PLAN 0:<br>         SELECT [col(&quot;VendorID&quot;)] FROM<br>          DF [&quot;VendorID&quot;, &quot;tpep_pickup_datetime&quot;, &quot;tpep_dropoff_datetime&quot;, &quot;passenger_count&quot;]; PROJECT */19 COLUMNS; SELECTION: &quot;None&quot;<br>      PLAN 1:<br>         SELECT [col(&quot;VendorID&quot;)] FROM<br>          DF [&quot;VendorID&quot;, &quot;tpep_pickup_datetime&quot;, &quot;tpep_dropoff_datetime&quot;, &quot;passenger_count&quot;]; PROJECT */19 COLUMNS; SELECTION: &quot;None&quot;<br>    END UNION</pre><h4>SQL Queries — Multiple Source</h4><p>SQL queries can be executed using multiple different sources. Refer below example — here we are registering 3 dataframes from different sources like csv, parquet &amp; pandas and using them in SQL join query.</p><pre>import polars as pl<br>from datetime import datetime<br>import pandas as pd<br><br># pandas dataframe<br>data = [[1, &#39;Credit Card&#39;], [2, &#39;Cash&#39;], [3, &#39;No Charge&#39;], [4, &#39;Dispute&#39;], [5, &#39;Unknown&#39;], [6, &#39;Voided Trip&#39;],]<br>df_payment_type = pd.DataFrame(data, columns=[&#39;payment_type&#39;, &#39;description&#39;])<br><br>with pl.SQLContext(<br>    trip_data=pl.scan_parquet([&quot;data/yellow_tripdata_2022-04.parquet&quot;,<br>                               &quot;data/yellow_tripdata_2022-05.parquet&quot;,<br>                               &quot;data/yellow_tripdata_2022-05.parquet&quot;]),<br>    zone_lookup=pl.scan_csv(&quot;data/taxi_zone_lookup.csv&quot;),<br>    payment_type_data=pl.from_pandas(df_payment_type),<br>    eager_execution=False<br>) as ctx:<br>    query = &quot;&quot;&quot;<br>        SELECT<br>            CASE<br>                WHEN VendorID = 1 THEN &#39;Creative Mobile Technologies, LLC&#39;<br>                WHEN VendorID = 2 THEN &#39;VeriFone Inc.&#39;<br>                ELSE VendorID<br>            END as vendor_name,<br>            pt.description as payment_desc,<br>            zlpu.Zone as pickuop_zone,<br>            zldo.Zone as drop_zone,<br>            passenger_count,<br>            fare_amount<br>        FROM<br>            trip_data td<br>        LEFT JOIN payment_type_data pt ON pt.payment_type = td.payment_type <br>        LEFT JOIN zone_lookup zlpu ON zlpu.LocationID = td.PULocationID<br>        LEFT JOIN zone_lookup zldo ON zldo.LocationID = td.DOLocationID<br>        where payment_type in (1,2) and fare_amount&gt;50<br>        &quot;&quot;&quot;<br>    finalDF = ctx.execute(query)<br>    print(finalDF.limit(5).collect())<br><br><br>--output--<br>shape: (5, 6)<br>┌───────────────────┬──────────────┬──────────────┬─────────────┬─────────────────┬─────────────┐<br>│ vendor_name       ┆ payment_desc ┆ pickuop_zone ┆ drop_zone   ┆ passenger_count ┆ fare_amount │<br>│ ---               ┆ ---          ┆ ---          ┆ ---         ┆ ---             ┆ ---         │<br>│ str               ┆ str          ┆ str          ┆ str         ┆ f64             ┆ f64         │<br>╞═══════════════════╪══════════════╪══════════════╪═════════════╪═════════════════╪═════════════╡<br>│ VeriFone Inc.     ┆ Credit Card  ┆ JFK Airport  ┆ JFK Airport ┆ 3.0             ┆ 52.0        │<br>│ Creative Mobile   ┆ Credit Card  ┆ JFK Airport  ┆ JFK Airport ┆ 3.0             ┆ 52.0        │<br>│ Technologies, LL… ┆              ┆              ┆             ┆                 ┆             │<br>│ Creative Mobile   ┆ Credit Card  ┆ JFK Airport  ┆ JFK Airport ┆ 1.0             ┆ 52.0        │<br>│ Technologies, LL… ┆              ┆              ┆             ┆                 ┆             │<br>│ VeriFone Inc.     ┆ Credit Card  ┆ JFK Airport  ┆ JFK Airport ┆ 2.0             ┆ 52.0        │<br>│ Creative Mobile   ┆ Credit Card  ┆ JFK Airport  ┆ JFK Airport ┆ 1.0             ┆ 52.0        │<br>│ Technologies, LL… ┆              ┆              ┆             ┆                 ┆             │<br>└───────────────────┴──────────────┴──────────────┴─────────────┴─────────────────┴─────────────┘</pre><h4>Compatibility</h4><ul><li>Support most of SQL statement, follows PostgreSQL syntax mainly.</li><li>Support wide range of SQL functions eg. string functions, aggregation etc.</li><li>Support Common Table Expression (CTE).</li><li>Support “EXPLAIN SELECT…” also to get explain plan details.</li></ul><p>Please refer polars documentation for complete compatibility list &amp; other details.</p><h3>References &amp; Links</h3><ul><li>Data Courtesy — <a href="https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page">https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page</a></li><li><a href="https://github.com/pola-rs/polars">https://github.com/pola-rs/polars</a></li><li><a href="https://docs.pola.rs/">https://docs.pola.rs/</a></li><li>Compatibility — <a href="https://docs.pola.rs/user-guide/sql/intro/#compatibility">https://docs.pola.rs/user-guide/sql/intro/#compatibility</a></li><li>Functions — <a href="https://docs.pola.rs/user-guide/sql/select/#functions">https://docs.pola.rs/user-guide/sql/select/#functions</a></li><li>CTE — <a href="https://docs.pola.rs/user-guide/sql/cte/">https://docs.pola.rs/user-guide/sql/cte/</a></li><li><a href="https://docs.rs/polars-sql/latest/src/polars_sql/keywords.rs.html">https://docs.rs/polars-sql/latest/src/polars_sql/keywords.rs.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d96652d8c358" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>