<?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 Dmitriy Fingerman on Medium]]></title>
        <description><![CDATA[Stories by Dmitriy Fingerman on Medium]]></description>
        <link>https://medium.com/@dmitriy.fingerman?source=rss-cf1bd18bb0f9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6y4FWWoRIKmH53SN</url>
            <title>Stories by Dmitriy Fingerman on Medium</title>
            <link>https://medium.com/@dmitriy.fingerman?source=rss-cf1bd18bb0f9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:43:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dmitriy.fingerman/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[Bringing Iceberg Native Views to Apache Hive]]></title>
            <link>https://medium.com/@dmitriy.fingerman/bringing-iceberg-native-views-to-apache-hive-f56145cec004?source=rss-cf1bd18bb0f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f56145cec004</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[apache-hive]]></category>
            <dc:creator><![CDATA[Dmitriy Fingerman]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 21:09:44 GMT</pubDate>
            <atom:updated>2026-07-03T21:09:44.591Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A new feature lets Hive create and query native Iceberg logical views, closing a critical gap for REST catalog architectures and improving interoperability across the lakehouse.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IIQajAsBRvdbBmSem3kx3w.png" /></figure><p>For years, Apache Hive has offered <strong>logical views</strong>: named SQL queries stored in the Hive Metastore (HMS). They are a familiar abstraction for simplifying access to underlying tables. As Iceberg adoption grows, especially alongside the <a href="https://medium.com/@dmitriy.fingerman/expanding-the-hive-ecosystem-with-iceberg-rest-f51da5019fe6">Iceberg REST Catalog API</a> — a new question arises: <em>where do views live when there is no HMS?</em></p><p>Apache Iceberg defines its own <strong>logical views</strong>: metadata objects stored in an Iceberg catalog, with a SQL definition, schema, and version history — similar in spirit to Iceberg tables, but without physical data files. Recent support in Apache Hive (tracked as <a href="https://issues.apache.org/jira/browse/HIVE-29578">HIVE-29578</a>) lets you create, replace, query, and drop these native Iceberg views using familiar Hive SQL.</p><p>This matters whether you run Hive against a standalone REST catalog <strong>or</strong> a traditional Hive Metastore backed by HiveCatalog.</p><h3>Why Iceberg Logical Views Matter</h3><h3>The REST catalog gap</h3><p>When Hive connects to an Iceberg REST catalog (via the HiveRESTCatalogClient described in our <a href="https://medium.com/@dmitriy.fingerman/expanding-the-hive-ecosystem-with-iceberg-rest-f51da5019fe6">previous article</a>), table metadata is managed entirely by the REST Catalog. There is no HMS database behind the scenes.</p><p>A classic Hive view persists its definition in HMS. In a pure REST catalog setup, there is no HMS — so such a view (without Iceberg opt-in) has nowhere to persist that metadata.</p><p><strong>Iceberg logical views bridge this gap.</strong> The view definition is committed through Iceberg’s ViewCatalog API and stored alongside your Iceberg tables in the same catalog. Hive reads and writes views through the same catalog connection it already uses for tables.</p><h3>Beyond REST: benefits with Hive + HMS too</h3><p>Even when you use the traditional Hive Metastore with HiveCatalog, Iceberg views still add value:</p><ul><li><strong>Cross-engine interoperability</strong> — Spark, Flink, Trino, and other Iceberg-aware engines that support the view spec can read the same logical view definition. HMS-only virtual views are Hive-specific.</li><li><strong>Catalog-native metadata</strong> — View definitions live in Iceberg metadata (with metadata_location, schema evolution, and catalog versioning), etc.</li><li><strong>Consistent semantics</strong> — Iceberg views follow the open Iceberg view specification, aligning Hive with the broader lakehouse ecosystem.</li><li><strong>Familiar query and lifecycle SQL</strong> — SELECT, DROP VIEW, and DESCRIBE FORMATTED work as they do for any other view. Creating an Iceberg view reuses CREATE VIEW with either a new view-format table property or a session-level storage-handler setting (see Syntax below).</li></ul><h3>Iceberg view vs. classic Hive view</h3><p>Both are <em>logical</em> (non-materialized) views — neither stores data on disk. The difference is <strong>where metadata is stored</strong>:</p><pre>|                         | Classic Hive view | Iceberg logical view             |<br>| ----------------------- | ------------------| ---------------------------------|<br>| View storage location   | HMS only          | Iceberg catalog (`ViewCatalog`)  |<br>| Works with HMS          | Yes               | Yes                              |<br>| Works with REST catalog | No                | Yes                              |<br>| Cross-engine visibility | Limited           | Yes (Iceberg-compatible engines) |</pre><h3>How It Works</h3><p>When you create an Iceberg view, Hive’s CREATE VIEW analyzer detects that the view should be owned by an external catalog rather than stored purely in HMS.</p><p>Two signals trigger this:</p><ol><li><strong>Explicit table property:</strong> TBLPROPERTIES (&#39;view-format&#39;=&#39;iceberg&#39;)</li><li><strong>Default storage handler:</strong> hive.default.storage.handler.class set to the Iceberg storage handler</li></ol><p>Hive validates that the configured Iceberg catalog implements ViewCatalog, then commits the view through IcebergViewSupport: schema, SQL text, and properties are written to the catalog via the standard Iceberg view API.</p><p><strong>With HiveCatalog (HMS):</strong> Iceberg stores the authoritative view metadata; HMS stores a lightweight shell that identifies the Iceberg native view that the Iceberg storage handler enriches in-memory on read (SQL, schema, table_type=ICEBERG-VIEW).</p><p><strong>With a REST catalog client:</strong> HiveRESTCatalogClient routes CREATE VIEW directly to the REST catalog’s ViewCatalog. On getTable, if a name is not an Iceberg table but exists as a view, Hive builds a minimal in-memory HMS-compatible view object and enriches it from the catalog — so existing Hive query paths work unchanged.</p><p>The result: Hive reuses existing view DDL and DML; Iceberg owns the view metadata. Creating an Iceberg view requires an explicit opt-in (see Syntax).</p><h3>Syntax for Iceberg Views</h3><p>Iceberg views build on Hive’s existing CREATE VIEW statement. <strong>Querying, describing, and dropping</strong> a view use unchanged Hive SQL. <strong>Creating</strong> an Iceberg logical view requires you to opt in so metadata is stored in the Iceberg catalog — not as a classic HMS-only virtual view (in HMS deployments) or, in REST-only setups, where no HMS exists at all.</p><p>HIVE-29578 extends Hive QL with a new table property, view-format, on CREATE VIEW. Alternatively, you can skip that property and rely on session configuration instead.</p><h3>Two ways to create an Iceberg logical view</h3><p><strong>Option A — extended Hive syntax with</strong> view-format<strong>:</strong></p><p>Use regular CREATE VIEW grammar plus the new TBLPROPERTIES (&#39;view-format&#39;=&#39;iceberg&#39;) clause:</p><pre>CREATE [OR REPLACE] VIEW [IF NOT EXISTS] view_name<br>TBLPROPERTIES (&#39;view-format&#39; = &#39;iceberg&#39;)<br>AS<br>SELECT columns FROM src_table WHERE condition;</pre><p>Example:</p><pre>CREATE VIEW active_employees<br>TBLPROPERTIES (&#39;view-format&#39; = &#39;iceberg&#39;)<br>AS<br>SELECT first_name, last_name<br>FROM employees<br>WHERE dept_id IN (1, 2);</pre><p><strong>Option B — regular Hive</strong> CREATE VIEW <strong>syntax + session config:</strong></p><p>Set the default storage handler to one that supports external logical views, then use plain CREATE VIEW with no view-format property:</p><pre>SET hive.default.storage.handler.class =<br>  org.apache.iceberg.mr.hive.HiveIcebergStorageHandler;</pre><pre>CREATE [OR REPLACE] VIEW [IF NOT EXISTS] view_name<br>AS<br>SELECT columns FROM src_table WHERE condition;</pre><p>Example:</p><pre>SET hive.default.storage.handler.class =<br>  org.apache.iceberg.mr.hive.HiveIcebergStorageHandler;</pre><pre>CREATE VIEW team_roster<br>AS<br>SELECT first_name, last_name<br>FROM employees<br>WHERE team_id IN (20, 30);</pre><p>To go back to classic HMS views for a session:</p><pre>SET hive.default.storage.handler.class=;</pre><p>If neither option is set, CREATE VIEW produces a <strong>classic HMS logical view</strong> (stored only in the Metastore).</p><h3>Full CREATE VIEW grammar (with optional Iceberg extension)</h3><pre>CREATE [OR REPLACE] VIEW [IF NOT EXISTS] [db_name.]view_name<br>  [(column_name [COMMENT &#39;col_comment&#39;], ...)]<br>  [COMMENT &#39;view_comment&#39;]<br>  [TBLPROPERTIES (&#39;property_name&#39;=&#39;property_value&#39;, ...)]   -- include (&#39;view-format&#39;=&#39;iceberg&#39;) for Option A<br>AS<br>  select_statement;</pre><p>Notes:</p><ul><li>OR REPLACE and IF NOT EXISTS are mutually exclusive.</li><li>Column aliases and view/column comments use the same syntax as classic Hive views.</li><li>Additional TBLPROPERTIES (beyond view-format) are passed through to the Iceberg view metadata.</li><li>view-format <strong>is the new Hive QL extension</strong> introduced by HIVE-29578; it is not required when Option B (session config) is in effect.</li></ul><h3>Switching between Iceberg and classic Hive views</h3><p>In <strong>HMS deployments</strong>, you can replace an existing view with a different kind by changing the opt-in signal:</p><pre>-- Replace an Iceberg logical view with a classic HMS view<br>CREATE OR REPLACE VIEW my_view AS<br>SELECT col1 FROM my_table;<br>-- (no view-format, default handler unset)</pre><pre>-- Replace a classic HMS view with an Iceberg logical view<br>CREATE OR REPLACE VIEW my_view<br>TBLPROPERTIES (&#39;view-format&#39; = &#39;iceberg&#39;)<br>AS<br>SELECT col1 FROM my_table;</pre><h3>Inspecting Iceberg view metadata</h3><pre>DESCRIBE FORMATTED my_iceberg_view;</pre><p>Key properties for an Iceberg logical view:</p><pre>Table Type:          VIRTUAL_VIEW<br>table_type           ICEBERG-VIEW<br>view-format          iceberg<br>storage_handler      org.apache.iceberg.mr.hive.HiveIcebergStorageHandler<br>metadata_location    ...<br>current-schema       {...}<br>Original Query:      ...<br>Expanded Query:      ...</pre><h3>Putting It Together</h3><p>Iceberg views require <strong>no additional configuration</strong> beyond your existing Iceberg catalog setup. If you use a REST catalog, follow the <a href="https://medium.com/@dmitriy.fingerman/expanding-the-hive-ecosystem-with-iceberg-rest-f51da5019fe6">REST catalog client setup</a>; with HMS + HiveCatalog, your usual iceberg.catalog.* settings apply.</p><p>Here is a complete workflow: create an Iceberg table, define a logical view with Option A (view-format), query it, inspect metadata, and drop it.</p><pre>CREATE DATABASE demo;<br>USE demo;<br><br>CREATE TABLE employees (<br>    first_name STRING,<br>    last_name  STRING,<br>    dept_id    BIGINT<br>)<br>STORED BY ICEBERG STORED AS ORC<br>TBLPROPERTIES (&#39;iceberg.catalog&#39; = &#39;ice01&#39;);<br><br>INSERT INTO employees VALUES<br>  (&#39;Alice&#39;, &#39;Smith&#39;, 1),<br>  (&#39;Bob&#39;,   &#39;Jones&#39;, 2);<br><br>CREATE VIEW active_employees (<br>    first_name COMMENT &#39;Given name&#39;,<br>    last_name  COMMENT &#39;Family name&#39;<br>)<br>COMMENT &#39;Employees in selected departments&#39;<br>TBLPROPERTIES (&#39;view-format&#39; = &#39;iceberg&#39;)<br>AS<br>SELECT first_name, last_name<br>FROM employees<br>WHERE dept_id IN (1, 2);<br><br>SELECT * FROM active_employees;<br>DESCRIBE FORMATTED active_employees;<br><br>CREATE OR REPLACE VIEW active_employees<br>TBLPROPERTIES (&#39;view-format&#39; = &#39;iceberg&#39;)<br>AS<br>SELECT first_name || &#39;-&#39; || dept_id AS label<br>FROM employees<br>WHERE dept_id = 1;<br><br>DROP VIEW active_employees;</pre><h3>Conclusion</h3><p>Iceberg logical views fill an important gap in modern Hive deployments. For <strong>REST catalog architectures</strong>, where there is no HMS to store classic virtual views, they provide a catalog-native view abstraction stored in the Iceberg catalog alongside your tables. For <strong>traditional Hive + Iceberg setups</strong>, they improve portability and align Hive with the open Iceberg ecosystem.</p><p>Combined with the <a href="https://medium.com/@dmitriy.fingerman/expanding-the-hive-ecosystem-with-iceberg-rest-f51da5019fe6">Hive Iceberg REST Catalog Client</a>, this feature makes Hive a more complete participant in catalog-centric lakehouse designs — tables <em>and</em> views, managed through one standard interface, queryable with familiar Hive SQL once views are created.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f56145cec004" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expanding the Hive Ecosystem with Iceberg REST]]></title>
            <link>https://medium.com/@dmitriy.fingerman/expanding-the-hive-ecosystem-with-iceberg-rest-f51da5019fe6?source=rss-cf1bd18bb0f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f51da5019fe6</guid>
            <dc:creator><![CDATA[Dmitriy Fingerman]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 16:54:25 GMT</pubDate>
            <atom:updated>2025-09-25T17:22:30.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qX9fMdC7cY7yH6HofnwqRg.png" /></figure><h3>A new feature adds support for the Iceberg REST API, giving you more flexibility in your data architecture.</h3><p>For years, the Apache Hive Metastore (HMS) has been the de facto metadata standard in the data lake ecosystem. Its stability and widespread adoption have made it the central catalog for countless data platforms. As the ecosystem evolves, the requirements for greater interoperability evolve as well. The Apache Iceberg project, with its OpenAPI specification for a REST-based catalog, has paved the way for a new generation of metadata services.</p><p>Now, Apache Hive is embracing this modern standard. A recently introduced feature, the <strong>HMS Iceberg REST Catalog Client</strong>, provides a direct bridge to this new ecosystem. This allows Hive to work seamlessly with any Iceberg REST-compliant catalog, giving you more choice and flexibility in your data architecture.</p><h3>Why a Direct REST Catalog Connection Matters</h3><p>The traditional method of using Hive with Iceberg relies on the Hive Metastore to manage all metadata. This is a robust and proven approach. However, many modern data platforms are now being built around a diverse ecosystem of standalone REST catalogs that are purpose-built for Iceberg and offer broader interoperability.</p><p>This new feature in Hive creates a direct bridge to that ecosystem. By allowing Hive’s metastore client to speak the Iceberg REST API, it unlocks several key benefits:</p><ul><li><strong>Architectural Flexibility:</strong> You now have the choice to use Hive in architectures where a standalone Iceberg REST catalog is the central source of truth, simplifying integration with other tools.</li><li><strong>Enhanced Interoperability:</strong> Hive can now seamlessly interact with Iceberg tables managed by a variety of powerful, open-source catalog services.</li><li><strong>Future-Proofing:</strong> This adapter positions Hive to work directly with the growing ecosystem of tools and services being built around the Iceberg Open API standard.</li></ul><h3>How It Works</h3><p>The magic lies in a new client adapter that implements Hive’s IMetaStoreClient interface. This allows the new HiveRESTCatalogClient to act as a &quot;translator,&quot; converting Hive&#39;s internal metadata calls into standard Iceberg REST API requests.</p><p>Because it conforms to a standard Hive interface, it can be plugged in as a drop-in replacement for the traditional ThriftHiveMetaStoreClient, requiring only a few configuration changes to get started.</p><h3>Getting Started: Configuration</h3><p>To enable this feature, you need to update your Hive configuration (e.g., in hive-site.xml) to point to the new client implementation and your REST catalog endpoint.</p><pre>&lt;property&gt;<br>  &lt;name&gt;metastore.client.impl&lt;/name&gt;<br>  &lt;value&gt;org.apache.iceberg.hive.client.HiveRESTCatalogClient&lt;/value&gt;<br>&lt;/property&gt;<br><br>&lt;property&gt;<br>  &lt;name&gt;metastore.catalog.default&lt;/name&gt;<br>  &lt;value&gt;ice01&lt;/value&gt;<br>&lt;/property&gt;<br><br>&lt;property&gt;<br>  &lt;name&gt;iceberg.catalog.ice01.type&lt;/name&gt;<br>  &lt;value&gt;rest&lt;/value&gt;<br>&lt;/property&gt;<br><br>&lt;property&gt;<br>  &lt;name&gt;iceberg.catalog.ice01.uri&lt;/name&gt;<br>  &lt;value&gt;http://your-rest-catalog-host:port&lt;/value&gt;<br>&lt;/property&gt;</pre><h3>Practical Example</h3><p>You also have the flexibility to specify the catalog on a per-table basis using table properties. This is useful in environments where you might be interacting with multiple different Iceberg catalogs.</p><p>For example, you can create a table like this:</p><pre>CREATE TABLE ice_orc (<br>    first_name STRING,<br>    last_name STRING<br>)<br>STORED BY ICEBERG STORED AS ORC<br>TBLPROPERTIES(&#39;iceberg.catalog&#39;=&#39;ice01&#39;);</pre><p>For this to work, your global Hive configuration must still contain the uri and type properties for the ice01 catalog so that Hive knows where to find it.</p><h3>Supported Iceberg Catalogs</h3><p>This new client opens the door for Hive to work with any catalog that implements the Iceberg REST API specification. This includes a growing number of popular and powerful open-source projects:</p><ul><li><strong>Gravitino:</strong> An open-source, high-performance, and unified metadata lake that can manage Iceberg, Hive, and relational database catalogs under one roof.</li><li><strong>AWS Glue:</strong> Amazon’s fully managed ETL service, whose data catalog can be exposed via an Iceberg REST interface.</li><li><strong>Nessie:</strong> An open-source catalog that brings Git-like semantics (branching, merging, tagging) to your data lake, enabling atomic multi-table transactions.</li><li><strong>Tabular:</strong> A managed Iceberg catalog service that provides a ready-to-use REST endpoint.</li></ul><h3>What’s Next: Future Work</h3><p>This initial release of the HMS Iceberg REST Catalog Client provides the core functionality for connecting Hive to the modern Iceberg ecosystem. The next major step on our roadmap is to build out more enterprise-focused features.</p><p>Our immediate priority is to add robust <strong>authentication support</strong>. This will ensure that connections from Hive to a REST catalog server are secure, which is a critical requirement for production environments. Stay tuned for more updates as we continue to enhance Hive’s interoperability and security.</p><h3>Conclusion</h3><p>The introduction of the Hive Iceberg REST Catalog Client is a significant step forward for the data lake ecosystem. It <strong>enhances Hive by adding a direct connection</strong> to the growing world of modern data catalogs. This new option gives users greater flexibility, enables simpler architectures where desired, and provides seamless interoperability with the next generation of data catalog technologies. This change ensures that Apache Hive will continue to be a powerful and relevant engine in the modern, open-standards-based data platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f51da5019fe6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hive Iceberg Compaction: An In-Depth Look at Improving Table Performance]]></title>
            <link>https://medium.com/@dmitriy.fingerman/hive-iceberg-compaction-an-in-depth-look-at-improving-table-performance-11c717bb6f8b?source=rss-cf1bd18bb0f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/11c717bb6f8b</guid>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-hive]]></category>
            <dc:creator><![CDATA[Dmitriy Fingerman]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 20:17:05 GMT</pubDate>
            <atom:updated>2025-06-01T20:17:05.927Z</atom:updated>
            <content:encoded><![CDATA[<p><em>by </em><a href="https://www.linkedin.com/in/dmitriy-fingerman-494aa915"><em>Dmitriy Fingerman</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwOEUAc7322vKAuc-bLFRQ.png" /></figure><p>Apache Hive has introduced an <strong>Iceberg compaction feature</strong>, specifically designed to <strong>boost</strong> <strong>query performance</strong> on Iceberg tables, especially when using <strong>merge-on-read mode</strong>. This new capability optimizes both data storage and query execution. In this article, we will delve into the <strong>core functionality </strong>and <strong>various types of Hive Iceberg Compaction</strong>, demonstrating its impact on query performance.</p><h3>Table of Contents</h3><p><a href="#6ef1"><strong>Prerequisites</strong></a><br><a href="#2dd0"><strong>Why is Hive Iceberg Compaction Needed?</strong></a><br><a href="#87cf"><strong>What is Hive Iceberg Compaction?</strong></a><br><a href="#ae14"><strong>High Level Hive Iceberg Compaction Flow</strong></a><br> — <a href="#8a97">Managing Disk Space: Snapshots and File Deletion</a><br><a href="#31a1"><strong>Iceberg Compaction Syntax</strong></a><br> — <a href="#e42a">ALTER TABLE Syntax</a><br> — <a href="#5698">OPTIMIZE TABLE syntax</a><br><a href="#e5b6"><strong>Compaction Types</strong></a><br><a href="#5c1f"><strong>Executing Iceberg Compaction Commands</strong></a><br> — <a href="#b6e6">Full Table Compaction</a><br> — <a href="#3267">Compaction Command with a Filter</a><br> — <a href="#1770">Compaction Command with a Partition Specification</a><br> — <a href="#c7c6">Compaction Command with a Sort Order Specification</a><br> — <a href="#922a">Compaction Command with a Custom Pool</a><br><a href="#eb9d"><strong>Iceberg Compaction Evaluation</strong></a><br> — <a href="#61b4">Amoro Compaction Evaluation: Key Concepts</a><br> — <a href="#b7b1">Hive Iceberg Minor Compaction Conditions</a><br> — <a href="#637c">Major Compaction Conditions</a><br> — <a href="#b19b">Hive Iceberg Table-Level Properties for Compaction Evaluator</a><br><a href="#2365"><strong>Performance Testing Results: Compaction in Action</strong></a><br> — <a href="#62e3">Compaction Execution Time</a><br> — <a href="#1f19">Query Used for Performance Measurement</a><br> — <a href="#8a99">The Dramatic Impact of Compaction: Key Table Statistics</a><br> — <a href="#0612">Performance Comparison: Query Speed</a><br><a href="#5507"><strong>Key Observations</strong></a><br><a href="#7c24"><strong>Conclusion</strong></a></p><h3>Prerequisites</h3><p>This article assumes a basic understanding of <strong>Apache Hive</strong> and <strong>Apache Iceberg</strong>. If you’re new to these tools, you can start with the following resources:</p><ul><li><a href="https://cwiki.apache.org/confluence/display/Hive/GettingStarted">Introduction to Apache Hive</a></li><li><a href="https://iceberg.apache.org/docs/latest/">Apache Iceberg Quickstart</a></li><li><a href="https://medium.com/@ayushtkn/apache-hive-4-x-with-apache-iceberg-part-i-355e7a380725">Working knowledge of Apache Hive with Apache Iceberg</a></li></ul><h3>Why is Hive Iceberg Compaction Needed?</h3><p>Hive Iceberg query performance can <strong>degrade</strong> in the following scenarios:</p><ul><li><strong>A large number of small data files</strong> within an unpartitioned table or partition. This <strong>proliferation of small files</strong> significantly increases the number of I/O operations during query execution, negatively impacting efficiency.</li><li><strong>The presence of delete files.</strong> In <strong>merge-on-read mode</strong>, Iceberg tables manage record deletions by storing information in positional delete files. While this approach is efficient for write-heavy workloads, it can substantially impact query performance, as each query execution must scan these delete files for every data split, <strong>introducing significant overhead.</strong></li></ul><h3>What is Hive Iceberg Compaction?</h3><p>Hive Iceberg Compaction <strong>mitigates both of these issues</strong> by rewriting existing data and delete files into <strong>new, optimized data files that are larger, fewer in number, and have the positional delete records removed </strong>from the active dataset.</p><h3>High Level Hive Iceberg Compaction Flow</h3><p>The compaction process unfolds in a few key steps:</p><ol><li><strong>Compaction Request Submission:</strong> Upon a user’s <strong>manual submission of an Iceberg compaction command</strong>, Hive parses and analyzes it to initiate the process.</li><li><strong>Compaction Requests Generation &amp; Queuing:</strong> Hive then generates the necessary compaction requests. For unpartitioned tables, a single request covers the entire table, while for partitioned tables, separate requests are created for each partition. Importantly, if a <strong>partition evolution</strong> has occurred on the Iceberg table, Hive also creates an additional compaction request to cover all partitions corresponding to past partition specifications. These requests are subsequently queued within the <strong>Hive Metastore (HMS)</strong> for processing.</li><li><strong>Execution Steps:</strong> Each queued compaction request is executed through a systematic process:<br><br>∙ <strong>Criteria Evaluation:</strong> The system first assesses whether the target table or partition meets the predefined compaction criteria (e.g., excessive small files, presence of numerous delete files).<br> <br>∙ <strong>SQL Query Construction:</strong> If compaction is deemed necessary, Hive dynamically constructs a specialized INSERT OVERWRITE SQL query. This query is designed to rewrite and optimize the data for the required table or partition.<br> <br>∙ <strong>Query Execution:</strong> Finally, the generated SQL query is executed by the Hive driver, performing the actual data consolidation and optimization.</li></ol><h4>Managing Disk Space: Snapshots and File Deletion</h4><p>While compaction efficiently rewrites data and removes deleted records from the active dataset, it’s crucial to understand how disk space is reclaimed in Iceberg tables. Iceberg tables utilize a <strong>snapshot-based architecture</strong>, where each update (including compaction) generates a new snapshot referencing the current, active set of data files.</p><p><strong>The old data files and positional delete files from previous snapshots are NOT immediately removed from disk during the compaction process itself.</strong> Instead, they are retained as part of the table’s history, enabling features like <strong>time travel</strong> where you can query past states of the table.</p><p>To truly reclaim disk space and physically remove these old files, you must explicitly run an <strong>Iceberg snapshot expiration</strong> command. This operation allows you to remove outdated snapshots, typically based on their age (timestamp) or specific snapshot IDs. <strong>Only after all snapshots referencing these files have been expired are these unreferenced files then physically removed from storage.</strong></p><h3>Iceberg Compaction Syntax</h3><p>Hive Iceberg compaction supports two <strong>distinct</strong> syntaxes: the standard ALTER TABLE command (typically used for Hive-ACID compaction) and the newly introduced OPTIMIZE TABLE syntax.</p><h4>ALTER TABLE Syntax</h4><p>The ALTER TABLE syntax for Hive Iceberg compaction reuses and extends the traditional Hive-ACID syntax.</p><pre>ALTER TABLE &lt;table_name&gt; [PARTITION &lt;partitionSpec&gt;] <br>COMPACT &#39;MAJOR&#39;|&#39;MINOR&#39;|&#39;SMART_OPTIMIZE&#39; [AND WAIT] [POOL &lt;poolName&gt;] <br>[WHERE &lt;condition&gt;] [ORDER BY &lt;orderBySpec&gt; [DESC]]</pre><h4>OPTIMIZE TABLE syntax</h4><p>A new, dedicated syntax for Iceberg compaction in Hive <strong>has been introduced</strong>, aligning with the compaction syntax found in other engines such as Trino and Impala.</p><pre>OPTIMIZE TABLE &lt;table_name&gt; REWRITE DATA [POOL &lt;poolName&gt;] <br>[WHERE &lt;condition&gt;] [ORDER BY &lt;orderBySpec&gt; [DESC]]</pre><h3>Compaction Types</h3><p>Hive supports three Iceberg compaction types, each designed for s<strong>pecific optimization scenarios</strong>:</p><ul><li><strong>MINOR Compaction<br></strong>This type focuses on replacing <strong>numerous</strong> small data files with fewer, larger, and <strong>more efficient</strong> ones. It specifically rewrites data files whose size falls below a set threshold.</li><li><strong>MAJOR Compaction<br></strong>This type is executed when a table or partition has accumulated a sufficient number of moderately sized files for consolidation, or a significant volume of delete files. It rewrites all files in the table or partition to optimize its structure.</li><li><strong>SMART_OPTIMIZE Compaction</strong><br>Automatically and <strong>intelligently assesses</strong> the current state and <strong>characteristics</strong> of the table or partition to determine whether a <strong>MAJOR</strong> or <strong>MINOR</strong> compaction is <strong>most appropriate.</strong></li></ul><h3>Executing Iceberg Compaction Commands</h3><h4>Full Table Compaction</h4><p>When no partition specification is provided in your compaction command, the compaction process is applied to the <strong>entire table</strong>, triggering the standard <strong>compaction</strong> <strong>requests generation and execution flow</strong> for <strong>all its relevant data</strong>.</p><p>For example:</p><pre>ALTER TABLE &#39;store_sales&#39; COMPACT &#39;MAJOR&#39;;</pre><h4>Compaction Command with a Filter</h4><p>Hive Iceberg compaction supports specifying a filter directly within the WHERE<strong> </strong>clause of the compaction command. When a filter is provided, Hive <strong>intelligently identifies </strong>and generates compaction requests <strong>only for partitions that contain data matching the specified criteria.</strong> It&#39;s <strong>crucial to note</strong> that the filter can only reference columns present in the table&#39;s <strong>partition specification</strong>.</p><p>For example:</p><pre>ALTER TABLE store_sales COMPACT &#39;MAJOR&#39; AND WAIT<br>WHERE (channel IN (&#39;A&#39;, &#39;B&#39;) AND sold_date &lt; &#39;2024–09–01&#39;)<br>OR (channel IN (&#39;C&#39;, &#39;D&#39;) AND sold_date &gt; &#39;2024–08–01&#39;);</pre><h4>Compaction Command with a Partition Specification</h4><p>A compaction command that includes a <strong>partition specification</strong> will compact only the single, specified partition. This allows for granular control over which parts of your table are optimized.</p><p>For example:</p><pre>ALTER TABLE &#39;store_sales&#39; <br>PARTITION(region=&#39;NA&#39;, channel=1, sold_date=&#39;2025-03-20&#39;) COMPACT &#39;MAJOR&#39;;</pre><h4>Compaction Command with a Sort Order Specification</h4><p>Compaction in Hive Iceberg allows for <strong>sorting the data as an integrated step</strong> of the optimization process. This means the sorting happens <em>during</em> the data rewriting performed by compaction, and it can significantly improve query performance for workloads that benefit from ordered data access, such as range scans or joins.</p><p>For example:</p><pre>ALTER TABLE store_sales COMPACT &#39;MINOR&#39; ORDER BY sale_timestamp;</pre><h4>Compaction Command with a Custom Pool</h4><p>Hive Iceberg compaction also supports utilizing <strong>custom compaction pools</strong>, a functionality inherited from Hive-ACID compaction. This functionality allows users to execute <strong>specific</strong> compaction requests on a designated set of compaction workers. This enables better <strong>resource management</strong> and <strong>isolation of compaction workloads from other critical operations</strong>.</p><p>A custom compaction pool can be configured either directly within a compaction command or through a Hive table or database property.</p><p>Here’s an example of a custom pool specified directly in the compaction command:</p><pre>ALTER TABLE store_sales COMPACT &#39;MINOR&#39; POOL &#39;iceberg&#39;;</pre><p>Alternatively, you can assign a custom compaction pool at the database level. Once configured, all tables within that database (unless overridden by a table-level property) will use this pool for compaction:</p><pre>CREATE DATABASE ice_test WITH DBPROPERTIES(&#39;hive.compactor.worker.pool&#39;=&#39;iceberg&#39;);<br>USE ice_test; -- Assuming you want to use the newly created &#39;ice_test&#39; database</pre><p>Here’s an example of assigning a custom compaction pool at the table level:</p><pre>create table ice_orc (<br> first_name string, <br> last_name string<br> )<br>stored by iceberg stored as orc <br>tblproperties (&#39;hive.compactor.worker.pool&#39;=&#39;iceberg&#39;);</pre><p>For more detailed information on compaction pools, please refer to the <a href="https://hive.apache.org/docs/latest/compaction-pooling_240884493/"><strong>Hive Compaction Pooling documentation</strong></a>.</p><h3>Iceberg Compaction Evaluation</h3><p>Compaction evaluation is the <strong>first step during the execution of an Iceberg compaction request</strong>. During this stage, the system checks if the specified compaction type (<strong>MAJOR</strong>, <strong>MINOR</strong>, or <strong>SMART_OPTIMIZE</strong>) is truly necessary for the target table or partition. If the compaction is deemed unnecessary, the request is simply refused.</p><p>Under the hood, this <strong>critical evaluation </strong>is performed using <strong>compaction evaluator code inherited from the Apache Amoro project</strong>. Specifically, Hive Iceberg determines a <strong>Major compaction</strong> is needed if the Amoro compaction evaluator indicates the table or partition requires a MAJOR OPTIMIZE action. Similarly, a <strong>Minor compaction</strong> is triggered if the evaluator signals a MINOR OPTIMIZE is necessary.</p><p>For a deeper dive into the principles and logic behind Amoro’s Minor Optimize and Major Optimize strategies, you can consult the <a href="https://amoro.apache.org/docs/latest/self-optimizing/"><strong>Apache Amoro Self-Optimizing documentation</strong></a><strong>.</strong></p><h4>Amoro Compaction Evaluation: Key Concepts</h4><p>The Amoro compaction evaluator, which powers Hive Iceberg’s intelligent compaction, relies on specific definitions for file types based on size thresholds to make its decisions:</p><ul><li><strong>Fragment File:</strong> An Iceberg data file considered very small, specifically if its size is less than compactor.threshold.target.size multiplied by compactor.threshold.fragment.ratio (defaulting to <strong>16 MB</strong>). These are prime candidates for merging.</li><li><strong>Min Target Size Threshold:</strong> A calculated size threshold (compactor.threshold.target.size multiplied by compactor.threshold.min.target.size.ratio, default <strong>96 MB</strong>) that defines the lower bound for optimally sized <strong>Segment Files</strong>.</li><li><strong>Undersized Segment File:</strong> A data file that is larger than a <strong>Fragment File</strong> but still falls below the <strong>Min Target Size Threshold</strong> (e.g., between 16 MB and 96 MB by default). These files are not optimal and may need consolidation.</li><li><strong>Segment File:</strong> An Iceberg data file that meets or exceeds the <strong>Min Target Size Threshold</strong> (e.g., 96 MB or larger by default), generally considered well-sized.</li></ul><h4>Hive Iceberg Minor Compaction Conditions</h4><p>Minor compaction is primarily triggered to consolidate smaller data files:</p><ul><li>When the total count of <strong>Fragment Files</strong> exceeds compactor.threshold.min.input.files (default <strong>12</strong>). This indicates an accumulation of numerous tiny data files that benefit from merging.</li></ul><h4>Major Compaction Conditions</h4><p>Major compaction performs a more comprehensive rewrite to address larger-scale inefficiencies and significant delete accumulation:</p><ul><li>When the total size of all <strong>Undersized Segment Files</strong> collectively exceeds the compactor.threshold.target.size (default <strong>128 MB</strong>), indicating a significant volume of sub-optimally sized files.</li><li>Alternatively, if the combined size of the two smallest <strong>Undersized Segment Files</strong> is less than the compactor.threshold.target.size (default <strong>128 MB</strong>), suggesting they can be efficiently merged into a single optimal file.</li><li>When any data files (larger than the fragment size threshold) have a number of associated <strong>positional delete records</strong> that is greater than compactor.threshold.delete.file.ratio (default <strong>10%</strong>) of the data file’s total records. This signifies a high proportion of deletions within a data file, making it inefficient to query without a full rewrite.</li></ul><h4>Hive Iceberg Table-Level Properties for Compaction Evaluator</h4><p>The behavior of the Amoro Compaction Evaluator can be customized through the following Hive table (or database-level) properties:</p><ul><li>compactor.threshold.target.size: Defines the ideal target size for data files after Iceberg compaction. (Default: 128 MB)</li><li>compactor.threshold.fragment.ratio: Specifies the ratio of the target size used to identify &quot;fragment&quot; files (those significantly smaller than the target). For example, a default of ⅛ means files smaller than 16 MB will be considered fragments.</li><li>compactor.threshold.min.target.size.ratio: Sets the minimum size ratio relative to the target.size which defines the threshold for &quot;segment&quot; files. For instance, a default of ¾ results in a 96 MB threshold for segments.</li><li>compactor.threshold.min.input.files: The minimum number of small files required to trigger a minor compaction. (Default: 12)</li><li>compactor.threshold.delete.file.ratio: The ratio of delete files to data files that, if exceeded, will trigger a major compaction. (Default: 10%)</li></ul><h3>Performance Testing Results: Compaction in Action</h3><p>To demonstrate the <strong>real-world benefits</strong> of Hive Iceberg Compaction, we conducted performance tests, comparing query execution times before and after compaction. But the results go beyond simple speed improvements.</p><h4>Compaction Execution Time</h4><p>The compaction process itself took:</p><ul><li><strong>Compaction Runtime:</strong> 84 seconds</li><li><strong>Total Time (Including Queue Wait Time):</strong> 127 seconds (Note: This may vary based on system load and available resources)</li></ul><p>While the compaction process has a runtime, the benefits heavily outweigh the cost.</p><h4>Query Used for Performance Measurement</h4><p>We used a COUNT(*) query with WHERE clauses to measure read performance:</p><pre>SELECT count(*)<br>FROM &lt;table_name&gt; ss<br>WHERE &#39;col1&#39; = &#39;value1&#39; AND &#39;col2&#39; = &#39;value2&#39;</pre><p><em>(Note: This type of query is sensitive to the number of files and the overhead of processing delete information.)</em></p><h4>The Dramatic Impact of Compaction: Key Table Statistics</h4><p>The following table highlights the <em>before-and-after</em> state of our test table. The changes are striking:</p><pre>| Metric                  | Before Compaction | After Compaction |<br>|-------------------------|-------------------|------------------|<br>| Data Records            |     8,655,041     |    7,648,151     |<br>| Positional Deletes      |     1,006,890     |            0     |<br>| Data Files              |         1,114     |            1     |<br>| Positional Delete Files |             8     |            0     |</pre><h4>Performance Comparison: Query Speed</h4><p>The table below shows the query execution time with and without compaction, and with different configurations of positional delete caching.</p><pre>| Scenario                                 | DAG Run Time (seconds) |<br>|------------------------------------------|------------------------|<br>| Before Compaction, Caching Disabled      |          92.5          |<br>| Before Compaction, Caching Enabled       |           5.3          |<br>| After Major Compaction, Caching Disabled |           2.2          |<br>| After Major Compaction, Caching Enabled  |           2.2          |</pre><h3>Key Observations</h3><p>Our testing yielded several significant insights:</p><ul><li><strong>Compaction Eliminates Delete Overhead:</strong> Compaction completely removed all positional deletes (1,006,890) and positional delete files, <strong>resulting in a clean active dataset</strong> and faster reads.</li><li><strong>Massive File Reduction:</strong> Compaction consolidated 1,114 data files into a single, optimized file. This drastically reduces the I/O required for queries.</li><li><strong>Physical Data Cleanup:</strong> Compaction didn’t just merge files; it <strong>applied and resolved</strong> over 1 million deleted records within the newly written data, <strong>resulting in a smaller, optimized active dataset.</strong> The table shows a reduction from 8,655,041 to 7,648,151 data records, <strong>reflecting the accurate current count after logical deletions have been physically addressed.</strong></li><li><strong>Compaction Outperforms Caching Alone:</strong> While Iceberg positional delete caching provides a significant initial boost, the subsequent <strong>Major Compaction</strong> further reduces query time to just 2.2 seconds. This demonstrates that compaction provides benefits beyond what caching alone can achieve.</li></ul><p><strong>In summary,</strong> these results clearly show that Hive Iceberg Compaction delivers substantial performance improvements by consolidating files, <strong>resolving deleted data within the active dataset</strong>, and optimizing the overall table structure. The dramatic reduction in data files and the elimination of delete overhead translate directly into faster and more efficient queries.</p><h3>Conclusion</h3><p><strong>Hive Iceberg Compaction</strong> is a powerful and essential feature for optimizing query performance and efficiently managing large datasets within Iceberg tables. By intelligently combining small files, <strong>resolving positional deletes within the active dataset</strong>, and strategically leveraging compaction types like <strong>Minor</strong>, <strong>Major</strong>, and <strong>SMART_OPTIMIZE</strong>, users can significantly reduce query times and improve storage efficiency. The integral <strong>Amoro Compaction Evaluator</strong> further contributes to this process by intelligently determining if a compaction is necessary based on configurable parameters.</p><p>As demonstrated by our performance testing results, compaction can <strong>drastically enhance query performance</strong>, translating directly into faster data access and more responsive analytical workloads. This makes Hive Iceberg Compaction a critical and indispensable tool for maintaining optimal performance in demanding, large-scale data environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11c717bb6f8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>