Apache Iceberg is an open table format for huge analytic datasets. Iceberg adds tables to compute engines including Spark, Trino, PrestoDB, Flink, Hive and Impala using a high-performance table format that works just like a SQL table.
This article assumes that you have mastered the basic knowledge and operation of Iceberg. For the knowledge about Iceberg not mentioned in this article, you can obtain it from its Official Documentation.
By using kyuubi, we can run SQL queries towards Iceberg which is more convenient, easy to understand, and easy to expand than directly using hive to manipulate Iceberg.
To enable the integration of kyuubi hive sql engine and Iceberg, you need to:
The classpath of kyuubi hive sql engine with Iceberg supported consists of
kyuubi-hive-sql-engine-1.9.0-SNAPSHOT_2.12.jar, the engine jar deployed with Kyuubi distributions
a copy of hive distribution
iceberg-hive-runtime-<hive.version>_<scala.version>-<iceberg.version>.jar (example: iceberg-hive-runtime-3.2_2.12-0.14.0.jar), which can be found in the Maven Central
In order to make the Iceberg packages visible for the runtime classpath of engines, we can use the method:
Execute ADD JAR statement in the Kyuubi to add dependencies to Hive’s auxiliary classpath. For example:
ADD JAR /path/to/iceberg-hive-runtime.jar;
Please mind the compatibility of different Iceberg and Hive versions, which can be confirmed on the page of Iceberg multi engine support.
To activate functionality of Iceberg, we can set the following configurations:
iceberg.engine.hive.enabled=true in the Hadoop configuration. For example, setting this in the hive-site.xml
CREATE TABLE as a example,
CREATE TABLE x (i int) STORED BY 'org.apache.iceberg.mr.hive.HiveIcebergStorageHandler'; CREATE EXTERNAL TABLE x (i int) STORED BY 'org.apache.iceberg.mr.hive.HiveIcebergStorageHandler';
SELECT as a example,
SELECT * FROM foo;
INSERT as a example,
INSERT INTO foo VALUES (1, 'a'), (2, 'b'), (3, 'c'); INSERT OVERWRITE TABLE target SELECT * FROM source;
ALTER as a example,
ALTER TABLE t SET TBLPROPERTIES('...'='...');