<?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 Okumin on Medium]]></title>
        <description><![CDATA[Stories by Okumin on Medium]]></description>
        <link>https://medium.com/@okumin?source=rss-abdae02be436------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bfSHAfRtZbrLbJymP3Q-yQ.png</url>
            <title>Stories by Okumin on Medium</title>
            <link>https://medium.com/@okumin?source=rss-abdae02be436------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:22:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@okumin/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[Iceberg REST Catalog in No Time: A Quickstart with Hive Metastore and PyIceberg]]></title>
            <link>https://medium.com/@okumin/iceberg-rest-catalog-in-no-time-a-quickstart-with-hive-metastore-and-pyiceberg-ecf82da7a983?source=rss-abdae02be436------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecf82da7a983</guid>
            <category><![CDATA[open-table-format]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <dc:creator><![CDATA[Okumin]]></dc:creator>
            <pubDate>Wed, 06 May 2026 10:05:05 GMT</pubDate>
            <atom:updated>2026-05-06T10:05:05.591Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*eoBXO0rVsFjNJ6PWSn0T4A.png" /><figcaption>Tutorial Environment</figcaption></figure><p>The <a href="https://iceberg.apache.org/rest-catalog-spec/">Iceberg REST Catalog</a> is the standard REST protocol for exposing catalog operations as REST API endpoints. Today, it is becoming an important part of Apache Iceberg, with adoption growing across open-source projects and cloud services.</p><p>Many people may have heard of it, but may not yet have had a chance to try it hands-on. In practice, trying the Iceberg REST Catalog usually requires setting up a few moving parts first.</p><p>In this tutorial, we will use the Iceberg REST Catalog built into Hive Metastore and perform end-to-end operations with curl and PyIceberg. This lets you experience the Iceberg REST Catalog locally with minimal setup.</p><p>Original Japanese version: <a href="https://blog.okumin.com/entry/2026/05/06/163714">https://blog.okumin.com/entry/2026/05/06/163714</a></p><h3>What is the Iceberg Catalog?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A-Hbcc72SHmwhPzt.png" /></figure><p>Apache Iceberg stores data files and most table metadata as files in object storage or a distributed filesystem, including table schemas, partition specifications, snapshots, and data file lists.</p><p>That said, Iceberg users still need a mechanism to resolve the current metadata file location for a given table name and to update that mapping safely. In the Iceberg world, this mechanism is called a “catalog.” The Iceberg REST Catalog standardizes catalog-related operations as HTTP API endpoints. In recent years, it has gained traction as a common interface that lets clients such as Apache Spark, Trino, and PyIceberg work with Iceberg tables through the same REST API.</p><h3>Hive Metastore and Iceberg REST Catalog</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*8fUYZWl5wiqp4Mtm.png" /><figcaption>Hive Catalog and REST Catalog</figcaption></figure><p>Seasoned Iceberg users might find the combination of Hive Metastore and Iceberg REST Catalog a little confusing.</p><p>Hive Metastore predates Apache Iceberg and has long been a de facto standard metadata repository. Through its widely adopted Thrift API, it can manage metadata for many kinds of tables, not just Iceberg tables. In Iceberg, managing Iceberg tables through this Thrift API is known as the Hive Catalog.</p><p>Additionally, the Apache Hive project has implemented an Iceberg-native REST Catalog API in Hive Metastore to enhance integration with Apache Iceberg. This initiative allows Iceberg-native clients to talk to Hive Metastore via the REST protocol, vendors and services to interoperate with Iceberg tables registered in Hive Metastore, and Hive Metastore to provide Iceberg-specific features. For example, <a href="https://github.com/apache/hive/pull/6458">temporary credential vending</a> and <a href="https://github.com/apache/hive/pull/6461">Iceberg-specific metrics reporting</a> are currently under development.</p><p>In short, Hive Metastore now supports not only the traditional Thrift API but also the Iceberg REST Catalog API. In this tutorial, we use the REST API.</p><h3>Tutorial Environment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*eoBXO0rVsFjNJ6PWSn0T4A.png" /><figcaption>Tutorial Environment</figcaption></figure><p>We use <a href="https://hub.docker.com/r/apache/hive">the official Apache Hive Docker image</a>. Using an image with the standalone-metastore- prefix, we can run the Iceberg REST Catalog built into Hive Metastore without additional configuration. As metadata and data files are stored in the local filesystem by default, we will run curl and PyIceberg in the same container. This helps us test the Iceberg REST Catalog without provisioning object storage or a shared volume.</p><h3>Tutorial</h3><h4>Start the Iceberg REST Catalog</h4><p>We will start a Hive Metastore container. The Iceberg REST Catalog listens on port 9001 in the container.</p><pre>$ docker run --rm --name hms apache/hive:standalone-metastore-4.2.0</pre><h4>Create a table with curl</h4><p>We can log in to the container using docker exec.</p><pre>$ docker exec -it --user root hms /bin/bash</pre><p>Let’s create a table with the id and name columns.</p><pre>$ curl -X POST \<br>  http://localhost:9001/iceberg/v1/namespaces/default/tables \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{<br>    &quot;name&quot;: &quot;test&quot;,<br>    &quot;schema&quot;: {<br>      &quot;type&quot;: &quot;struct&quot;,<br>      &quot;fields&quot;: [<br>        {&quot;id&quot;: 1, &quot;name&quot;: &quot;id&quot;, &quot;type&quot;: &quot;long&quot;, &quot;required&quot;: false},<br>        {&quot;id&quot;: 2, &quot;name&quot;: &quot;name&quot;, &quot;type&quot;: &quot;string&quot;, &quot;required&quot;: false}<br>      ]<br>    },<br>    &quot;write-disposition&quot;: &quot;create&quot;<br>  }&#39;<br>{&quot;metadata-location&quot;:&quot;file:/opt/hive/data/warehouse/test/metadata/00000-854efeae-f861-4735-b1c1-74913975ce74.metadata.json&quot;,...}</pre><p>We can see the table entry and related metadata files.</p><pre>$ curl http://localhost:9001/iceberg/v1/namespaces/default/tables/test<br>{&quot;metadata-location&quot;:&quot;file:/opt/hive/data/warehouse/test/metadata/00000-854efeae-f861-4735-b1c1-74913975ce74.metadata.json&quot;,...}<br><br>$ ls -lR /opt/hive/data/warehouse/test/<br>/opt/hive/data/warehouse/test/:<br>total 4<br>drwxr-xr-x 2 hive hive 4096 May  5 04:18 metadata<br><br>/opt/hive/data/warehouse/test/metadata:<br>total 4<br>-rw-r--r-- 1 hive hive 724 May  5 04:18 00000-854efeae-f861-4735-b1c1-74913975ce74.metadata.json</pre><p>The metadata file contains various pieces of information, such as schema information.</p><pre>$ cat /opt/hive/data/warehouse/test/metadata/00000-854efeae-f861-4735-b1c1-74913975ce74.metadata.json <br>{&quot;format-version&quot;:2,&quot;table-uuid&quot;:&quot;cc014a2f-c920-4562-80dc-f5e88a9bc147&quot;,&quot;location&quot;:&quot;file:/opt/hive/data/warehouse/test&quot;,...}</pre><h4>Append Data Using PyIceberg</h4><p>We will use <a href="https://py.iceberg.apache.org/">PyIceberg</a> for further operations. PyIceberg provides a more convenient interface for working with Iceberg tables than raw HTTP requests with curl.</p><p>We need to install the PyIceberg package first.</p><pre>microdnf update -y<br>microdnf install -y python3 python3-pip<br>pip install --upgrade pip<br>pip install &#39;pyiceberg[pandas]&#39;<br>python -c &quot;import pyiceberg; print(pyiceberg.__version__)&quot;</pre><p>Then, we can start the Python REPL and access the Iceberg REST Catalog.</p><pre>$ python<br>&gt;&gt;&gt; from pyiceberg.catalog import load_catalog<br>&gt;&gt;&gt; import pandas as pd<br>&gt;&gt;&gt; import pyarrow as pa<br>&gt;&gt;&gt; catalog = load_catalog(type=&quot;rest&quot;, uri=&quot;http://localhost:9001/iceberg&quot;)<br>&gt;&gt;&gt; catalog.list_tables(namespace=&quot;default&quot;)<br>[(&#39;default&#39;, &#39;test&#39;)]</pre><p>Let’s add a few records to the test table created with curl.</p><pre>&gt;&gt;&gt; table = catalog.load_table(&quot;default.test&quot;)<br>&gt;&gt;&gt; df = pd.DataFrame({&quot;id&quot;: [1, 2, 3], &quot;name&quot;: [&quot;alice&quot;, &quot;bob&quot;, &quot;carol&quot;]})<br>&gt;&gt;&gt; table.append(pa.Table.from_pandas(df, preserve_index=False))<br>&gt;&gt;&gt; table.scan().to_arrow()<br>pyarrow.Table<br>id: int64<br>name: string<br>----<br>id: [[1,2,3]]<br>name: [[&quot;alice&quot;,&quot;bob&quot;,&quot;carol&quot;]]</pre><p>We can see new data and metadata files.</p><pre>$ ls -lR /opt/hive/data/warehouse/test/<br>/opt/hive/data/warehouse/test/:<br>total 8<br>drwxr-xr-x 2 root root 4096 May  5 04:25 data<br>drwxr-xr-x 2 hive hive 4096 May  5 04:25 metadata<br><br>/opt/hive/data/warehouse/test/data:<br>total 4<br>-rw-r--r-- 1 root root 950 May  5 04:25 00000-0-106bcea1-a4cf-4d1a-ba8c-f87009a910e8.parquet<br><br>/opt/hive/data/warehouse/test/metadata:<br>total 20<br>-rw-r--r-- 1 hive hive  724 May  5 04:18 00000-854efeae-f861-4735-b1c1-74913975ce74.metadata.json<br>-rw-r--r-- 1 hive hive 1493 May  5 04:25 00001-0240b423-d07c-4451-bf3a-155060a46219.metadata.json<br>-rw-r--r-- 1 root root 4279 May  5 04:25 106bcea1-a4cf-4d1a-ba8c-f87009a910e8-m0.avro<br>-rw-r--r-- 1 root root 1777 May  5 04:25 snap-7865978314307043386-0-106bcea1-a4cf-4d1a-ba8c-f87009a910e8.avro</pre><h3>Wrapping Up</h3><p>We have tried Iceberg REST Catalog using Hive Metastore and PyIceberg. Hive Metastore allows us to test the Iceberg REST Catalog without setting up a cloud service or distributed filesystem. Since the Iceberg REST API can be called directly with curl, it also serves as a good entry point for understanding how Iceberg clients interact with catalogs.</p><p>Beyond tutorials, the Iceberg REST Catalog API in Hive Metastore also supports <a href="https://hive.apache.org/docs/latest/admin/iceberg-rest-catalog/">production-grade configurations, including authentication and authorization</a>. In production, you would typically combine it with OAuth 2.0, Apache Ranger, or similar components, depending on your environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecf82da7a983" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hive and Iceberg: Spring 2025]]></title>
            <link>https://medium.com/@okumin/apache-hive-and-iceberg-spring-2025-7ed588992eee?source=rss-abdae02be436------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ed588992eee</guid>
            <category><![CDATA[apache-hadoop]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <dc:creator><![CDATA[Okumin]]></dc:creator>
            <pubDate>Fri, 30 May 2025 09:56:13 GMT</pubDate>
            <atom:updated>2025-06-02T13:43:15.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*T8xEqwekxLOiYFRY.png" /></figure><p>In April, I saw an interesting proposal, “<a href="https://lists.apache.org/thread/cfwxjd8tjt2wwz54crdjy2qsgzjnfxfm">[DISCUSS] Changing Default Table Format to Iceberg in Upcoming Releases</a>”, in the Hive mailing list. The Hive community allocates as many resources to Apache Iceberg or Data Lakehouse integrations as it doesn’t sound so unreasonable.</p><p>This article introduces some interesting Iceberg-related features that we’re trying to ship in future releases. Disclaimer: All the contents here are highly depend on my personal thoughts and desires.</p><h3>Hive Metastore as an Iceberg catalog</h3><p>Hive Matastore (HMS) is a well-known metadata repository for building a data platform. HMS is capable of abstracting and managing data or files in HDFS, Amazon S3, PostgreSQL, Apache HBase, Apache Kafka, or any other data sources. Iceberg tables are also supported, or rather, we can say they are exceptional in the sense that HMS provides some Iceberg-specific functionalities.</p><h4>Iceberg REST Catalog over HMS</h4><p>Iceberg clients can use various metadata repositories as a catalog. For example, they can choose RDBMS over JDBC or AWS Glue Data Catalog. Of course, HMS is also a typical option. In such a catalog war, people are especially interested in the Iceberg Rest Catalog. The key point is that any vendor or product can offer an Iceberg catalog service if they implement a set of pre-defined REST APIs.</p><p>The standard interface of HMS is implemented on top of the Apache Thrift RPC framework. As HMS is the de facto standard, most tools supporting Iceberg also support Hive Metastore today. However, we may see new tools that are Iceberg-native, or the Iceberg community may add new features only to the REST Catalog. Anyway, we are implementing an embedded Iceberg REST API server in HMS: <a href="https://issues.apache.org/jira/browse/HIVE-28059">HIVE-28059: Iceberg REST Catalog</a>.</p><p>This will enable such tools to operate HMS through the Iceberg REST APIs, as well as existing applications to continue using the Thrift APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rgsIm_Y7nArC58i_.png" /></figure><p>This feature still has some known bugs on the master branch, but it’s promising to me, and I’m supporting it for productionization.</p><h4>Federated Catalog</h4><p>I suppose many Iceberg users expect cloud providers or data warehouse vendors to natively support Apache Iceberg; I’m also one of those people. I recently had a positive experience with the combination of Amazon Athena and <a href="https://aws.amazon.com/s3/features/tables/">Amazon S3 Tables</a>.</p><p>As more vendors offer services similar to S3 Tables, we will likely say, “We store some Iceberg tables in S3 Tables, some ones in Snowflake, additionally, we also manage some Iceberg tables in Amazon S3 on our own!”. <a href="https://issues.apache.org/jira/browse/HIVE-28879">HIVE-28879: Federated Catalog support</a> would help users in such situations, as Hive Metastore can behave as the Single Source of Truth for them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*crBHb47lxbFxm-Pq.png" /></figure><h3>Hive as a Storage Engine</h3><p>Users can complete 99% of Iceberg-related operations on Amazon S3 or Google Cloud Storage, which are super reliable. So, they would expect that Iceberg tables are easy to maintain. However, you actually can’t fully make use of Iceberg unless you effectively resolve a so-called small files problem or delete obsolete snapshots. Hive will offer such maintenance functionalities on top of the foundations that maintain Hive native tables.</p><h4>Compaction</h4><p>You would have experience in compacting small files or splitting large ones if you were familiar with big data solutions. As <a href="https://iceberg.apache.org/docs/1.9.0/partitioning/">Iceberg allows users to flexibly evolve partitioning strategies</a>, you may want to reorganize old data at some point[1].</p><p>Hive has utilities to run major or minor compactions against ACID tables[2]. We have extended them to enable users to optimize Iceberg tables, and <a href="https://issues.apache.org/jira/browse/HIVE-28935?jql=project%20%3D%20HIVE%20AND%20text%20~%20%22iceberg%20compaction%22%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC">we continue to improve them</a>.</p><pre>ALTER TABLE tbl COMPACT &#39;major&#39;;<br>-- Alias of ALTER TABLE ... COMPACT<br>OPTIMIZE TABLE tbl REWRITE DATA;</pre><p>You can also read the excellent article written by Dmitriy: <a href="https://medium.com/@dmitriy.fingerman/hive-iceberg-compaction-an-in-depth-look-at-improving-table-performance-11c717bb6f8b">Hive Iceberg Compaction: An In-Depth Look at Improving Table Performance</a>.</p><h4>Expire old snapshots periodically</h4><p>Branching, time-travel, and rollback capabilities would help data engineers build robust data pipelines. When something goes wrong, they can reproduce the issue or revert any changes in the worst case. However, your CFO would not allow your team to pay a lot of additional money so that they can roll back their tables to those of 10 years ago at any time.</p><p>Therefore, <a href="https://iceberg.apache.org/docs/latest/maintenance/">Iceberg users have to run Spark or other jobs to clean up outdated snapshots</a>. Although you are happy to do so by hand for now, it will be more painful when you manage more Iceberg tables.</p><p>Interestingly, I found <a href="https://issues.apache.org/jira/browse/HIVE-28930">a community member adding this capability to Hive Metastore</a>. I’m positively reviewing the outstanding feature. Hive also has a feature to schedule compactions in a similar way. I suppose Hive will be one of the reasonable options to maintain Iceberg tables.</p><h3>Hive as a Compute Engine</h3><p>The last topic is Hive as a query engine and how to integrate it with the Iceberg ecosystem. Users should select the best engine for each use case, as the Iceberg project is highly vendor-neutral. One example: They can choose Apache Spark for ETL processing and choose Trino for BI workloads. Hive is also a very competitive option backed by Apache Tez or LLAP, and we are improving Iceberg integration.</p><h4>Iceberg REST Catalog Support</h4><p>Hive, as a query engine, is tightly coupled with Hive Metastore. Therefore, we can’t essentially use Hive’s query engine without Hive Metastore[3].</p><p>As mentioned above, various vendors will likely support Iceberg REST API in the future. We created <a href="https://issues.apache.org/jira/browse/HIVE-28658">HIVE-28658: Iceberg REST Catalog client</a> so that HiveServer2 can query data stored in an external Iceberg REST Catalog. Though <a href="https://github.com/apache/hive/pull/5771">we’re struggling to resolve a dependent problem</a>, I’d like to make it happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*JnN4xKnybW0P3eiB.png" /></figure><h3>Summary</h3><p>This post introduces Iceberg-related projects that interest me. Since Hive has been supporting data platforms for many years, it has solid foundations that can quickly adapt to new paradigms. So, I believe a moment of glory for Hive would come in the Data Lakehouse era. You might also like to read <a href="https://docs.google.com/document/d/1tKFmsjYeGlMQjvJ7QQDNcS5wvqrcHRvsDjbJlcHb7Gk/edit?tab=t.0#heading=h.6tzwrfku9liy">Hive: Operating System for Data Lakehouse</a>, which shares my thoughts.</p><p>Of course, we always need your help. Please feel free to reach out to me through <a href="https://x.com/okumin">X</a> or <a href="https://www.linkedin.com/in/okumin/">Linkedin</a>! I would appreciate hearing your opinions, and I can support your contributions.</p><h3>Related Articles</h3><ul><li><a href="https://medium.com/@okumin/hive-bucket-map-join-is-now-available-for-iceberg-users-d3026a60a7bb">Hive: Bucket Map Join is now available for Iceberg users!</a></li><li>[1] <a href="https://issues.apache.org/jira/browse/HIVE-28840">HIVE-28840</a>, <a href="https://issues.apache.org/jira/browse/HIVE-28841">HIVE-28841</a></li><li>[2] Storage Partitioned Join of Apache Spark or Partition-Aware Optimization of Hive requires the partition definition to be simple enough</li><li>[3] Hive ACID is an attempt to add CRUD capabilities in a different way from Iceberg</li><li>[4] Hive on Amazon EMR can use AWS Glue Data Catalog. AWS achieves it by applying <a href="https://issues.apache.org/jira/browse/HIVE-12679">HIVE-12679</a>, which is not merged into the upstream</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ed588992eee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hive: Bucket Map Join is now available for Iceberg users!]]></title>
            <link>https://medium.com/@okumin/hive-bucket-map-join-is-now-available-for-iceberg-users-d3026a60a7bb?source=rss-abdae02be436------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3026a60a7bb</guid>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[apache-hadoop]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Okumin]]></dc:creator>
            <pubDate>Tue, 18 Mar 2025 09:05:29 GMT</pubDate>
            <atom:updated>2025-03-18T09:05:29.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*5DgBYQTELLram4nt.png" /></figure><p>The Apache Hive community is working on <a href="https://issues.apache.org/jira/browse/HIVE-28410">the Partition-Aware Optimization project</a>. The initiative aims to enable Hive’s advanced optimizations by leveraging flexible partitioning strategies or storage layouts, which Open Table Formats provide.</p><p>This article explains <a href="https://issues.apache.org/jira/browse/HIVE-28411">HIVE-28411: Bucket Map Join on Iceberg tables</a>, the initiative&#39;s first deliverable. We plan to roll out this feature with Hive 4.1.0.</p><h3>JOIN algorithms implemented in Hive</h3><p>Let’s review typical JOIN algorithms in Hive and their characteristics, including Bucket Map Join.</p><h4>Distributed Merge Join</h4><p>Merge Join is the most generic and scalable algorithm.</p><p>Let’s say we created two tables with the following DDLs. The <em>web_access_log</em> table retains the access log, and the <em>user_daily_snapshot</em> includes the lists of all users each day.</p><pre>CREATE TABLE web_access_log (<br>  ts TIMESTAMP,<br>  user_id BIGINT,<br>  ip STRING,<br>  method STRING,<br>  path STRING,<br>  status INT,<br>  size BIGINT<br>);<br><br>CREATE TABLE user_daily_snapshot (<br>  dt DATE,<br>  user_id BIGINT,<br>  name STRING,<br>  membership_status STRING<br>);</pre><p>Hive allows users to join the two tables. Given that the number of visits per day is 1 billion, the number of users is 100 million, and the retention period is 365 days, the query joins 365 billion records with 36.5 billion records and generates 365 billion records at maximum.</p><pre>SELECT a.*, b.name, b.membership_status<br>FROM web_access_log a<br>JOIN user_daily_snapshot b<br>ON a.user_id = b.user_id AND date(a.ts) = b.dt</pre><p>Even though any side is too large to fit into RAM, Hive partitions the source data based on the JOIN keys and performs <a href="https://en.wikipedia.org/wiki/Sort-merge_join">Sort Merge Join</a> per partition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*KHDuacwU2pPrm_RO.png" /></figure><p>The scalable Merge Join allows even fact-to-fact JOIN queries to finish successfully as long as the amount of storage is sufficient.</p><h4>Map Join</h4><p>Real-world queries often join a large fact table with small dimension tables; <a href="https://en.wikipedia.org/wiki/Star_schema">the star schema</a> is a typical example. Do you have such a workload? Map Join, also known as Broadcast Join or Broadcast Hash Join, will help you.</p><p>Say you have the <em>users</em> table, which includes the latest snapshot of the list of users, and you join it with your access log. If the number of users was 10 million, Hive could retain all the records stored in <em>users</em> in its memory.</p><pre>CREATE TABLE users (<br>  user_id BIGINT,<br>  name STRING,<br>  membership_status STRING<br>);<br><br>SELECT a.*, b.name, b.membership_status<br>FROM web_access_log a<br>JOIN users b<br>ON a.user_id = b.user_id</pre><p>Once Hive’s optimizer picks up Map Join, Hive broadcasts the smaller side, <em>users</em> in this case, and generates a hash table. Tasks scanning <em>web_access_log</em> directly join the scanned records with <em>users</em> without shuffling <em>web_access_log</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*qrJYwWYt6aMmlCE6.png" /></figure><p>Why can Map Join be more efficient? There are two reasons.</p><ol><li>Hive can skip a massive shuffle</li><li>Hive can skip sorting records before joining them</li></ol><p>By default, Hive automatically applies Map Join based on the estimated size of join sources and the configured threshold via <em>hive.auto.convert.join.noconditionaltask.size</em>. I recommend increasing the threshold because the default value, 10MB, is too small.</p><h4>Dynamic Partitioned Hash Join</h4><p>What if you have 1 billion users? In that case, any source table is unlikely to fit into RAM, meaning Hive would need to shuffle both <em>web_access_log</em> and <em>users</em>. However, if the parallelism was 1,000, each fragment of <em>users</em> after the shuffle includes only 1 million records on average. The number sounds small enough. I expect Hive to shuffle both sides like Merge Join and join them like Map Join. Dynamic Partitioned Hash Join of Hive is such an optimization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*2f-CLsJKsptxUTGg.png" /></figure><p>The feature would be available when you turned on <em>hive.optimize.dynamic.partition.hashjoin</em>.</p><h4>Bucket Map Join</h4><p>“I wanna join a huge fact table with a large dimension table without massively shuffling the fact table!”. Bucket Map Join is for you.</p><p>Hive allows users to create a “bucketed” table. With bucketing enabled, Hive manages each record with its bucket ID derived from <em>hash_function(bucketing columns) % # of buckets</em>. Hive tries to colocate a set of records with the same bucket ID and store them in the same file. The following DDL generates a bucketed table with four buckets based on user_id.</p><pre>CREATE TABLE bucketed_web_access_log (...)<br>CLUSTERED BY(user_id) INTO 4 BUCKETS;<br><br>SELECT a.*, b.name, b.membership_status<br>FROM bucketed_web_access_log a<br>JOIN user_daily_snapshot b<br>ON a.user_id = b.user_id AND date(a.ts) = b.dt</pre><p>Hive can use the metadata and apply a similar optimization to Map Join when joining medium-sized or large-sized dimension tables. Hive shares the same hash function for bucketing and shuffling to skip the massive shuffle of the fact table. It looks like Bucket Map Join applies Map Join per bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*4heZiK-nO2fdXW8I.png" /></figure><p>This optimization is powerful. If you configured the number of buckets to 1,024, you could use Map Join with 1,024 times more oversized dimension tables.</p><p>Hive&#39;s Bucket Map Join is easy to use. Unlike query engines that require both sides to be similarly bucketed, Hive on Tez can trigger Bucket Map Join when only a bigger side is bucketed.</p><h4>Summary: Hive’s JOIN algorithms</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*h-0A6Mrw0ER4JnN09kS1hw.png" /></figure><h3>How to implement Bucket Map Join w/ Iceberg?</h3><p>Apache Iceberg allows users to <a href="https://iceberg.apache.org/docs/latest/partitioning/">manage partitioning strategies flexibly</a> and provides <a href="https://iceberg.apache.org/spec/?h=snapshot#bucket-transform-details">Bucket Transform</a>, which partitions data files similarly to Hive’s bucketed tables. I started working on HIVE-28411, assuming we could map the concept of Iceberg’s bucket into Hive’s bucket.</p><pre>-- An iceberg table partitioned by Bucket Transform<br>CREATE TABLE iceberg_web_access_log (...)<br>PARTITIONED BY SPEC (bucket(4, user_id))<br>STORED BY ICEBERG;</pre><p>The most challenging point was the compatibility of hash functions used in Hive and Open Table Formats. Bucket Map Join assumes the storage system uses the same hash function as Hive’s query engine. The original logic might not work because Iceberg’s bucket function is not guaranteed to always generate the same bucket number as Hive’s. So, in HIVE-28411, we introduced mechanisms for a StorageHandler developer to declare what custom bucket function should be used and for Hive’s query engine to propagate the function to ReduceSinkOperator¹ on the opposite side. Similarly to Bucket Map Join with Hive native tables, the smaller side doesn’t have to be bucketed or doesn’t need to be an Iceberg table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*5DgBYQTELLram4nt.png" /></figure><p>The new APIs allow OTF developers and users to use Bucket Map Join transparently on Iceberg tables and potentially any Open Table Formats. This feature will be available with Hive 4.1.0.</p><h3>Future Work</h3><h4>Optimize Bucket Map Join more using Iceberg-specific metadata</h4><p>We have more chances to improve BMJ, as Iceberg provides more flexible partitioning or time travel than Hive’s native tables.</p><ul><li><a href="https://issues.apache.org/jira/browse/HIVE-28414">HIVE-28414: Flexible join optimization based on partition transform specs</a></li><li><a href="https://issues.apache.org/jira/browse/HIVE-28798">HIVE-28798: Bucket Map Join partially using partition transforms</a></li><li><a href="https://issues.apache.org/jira/browse/HIVE-28818">HIVE-28818: Partition-Aware Optimization with Iceberg’s time travel</a></li></ul><h4>Implement optimizations other than Bucket Map Join</h4><p>Hive’s query engine implements some more optimizations that can leverage physical storage layouts. Partition-Aware Optimization can try to unlock them to Open Table Formats.</p><ul><li><a href="https://issues.apache.org/jira/browse/HIVE-28412">HIVE-28412: Sort Merge Bucket Join for Iceberg tables</a></li><li><a href="https://issues.apache.org/jira/browse/HIVE-28413">HIVE-28413: Group By Optimization for Iceberg tables</a></li></ul><h3>Summary</h3><p>This article introduced Bucket Map Join with Iceberg as the first achievement of Partition-Aware Optimization.</p><p>Iceberg integration is a primary focus of the Hive community. We’re excited that Open Table Formats unlocks Apache Hive&#39;s potential, and we can deliver incredible value to Hive users!</p><p>[1] An Operator that emits intermediate data for shuffle</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3026a60a7bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>