vinishjail97 commented on code in PR #995: URL: https://github.com/apache/incubator-xtable/pull/995#discussion_r4672054626
########## website/docs/features-and-limitations.md: ########## @@ -27,15 +27,33 @@ In addition to synchronizing table format metadata, Apache XTable™ (Incubating This reduces friction by eliminating the manual step of registering tables in multiple catalogs and enhances flexibility by avoiding catalog lock-in. HMS and AWS Glue are the two catalogs supported right now, support for other catalogs (Unity, Apache Polaris, Apache Gravitino, DataHub) coming soon. +### Secondary index for Iceberg tables +A sync to a Hudi target can build a secondary index on a column of an Iceberg source table and keep it current on each later sync. +The index is stored as a Hudi metadata table in the data folder of the table, and Spark sessions with the XTable Spark SQL extensions use it to read only the files that hold the values of a point lookup. Review Comment: `data folder` there's no folder concept in object storage? ########## website/docs/features-and-limitations.md: ########## @@ -27,15 +27,33 @@ In addition to synchronizing table format metadata, Apache XTable™ (Incubating This reduces friction by eliminating the manual step of registering tables in multiple catalogs and enhances flexibility by avoiding catalog lock-in. HMS and AWS Glue are the two catalogs supported right now, support for other catalogs (Unity, Apache Polaris, Apache Gravitino, DataHub) coming soon. +### Secondary index for Iceberg tables +A sync to a Hudi target can build a secondary index on a column of an Iceberg source table and keep it current on each later sync. +The index is stored as a Hudi metadata table in the data folder of the table, and Spark sessions with the XTable Spark SQL extensions use it to read only the files that hold the values of a point lookup. Review Comment: `use it to read only the files that hold the values of a point lookup` re-write this to say it gives the exact files holding the matches something like this...the current one is not communicating the capability of the feature? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not Review Comment: Iceberg is the source of truth...communicate this as well? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you Review Comment: `four XTable jars` is too specific...you need the pluggable tf jar and it's dependencies? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses Review Comment: `Your writer` What is your writer here? Avoid you, your etc. in official docs :) ########## website/docs/how-to-index.md: ########## @@ -36,6 +36,28 @@ datasets: xtable.hudi.target.secondary.index.column: c_email_address ``` +Run the sync with either jar, for example: Review Comment: either jar is too vauge specify the use-case when to use each? utilities for a standalone service and spark-runtime for existing spark clusters etc.? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. Review Comment: This is not required in the docs? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. + +:::caution Every writer needs the jars +When the module is not on the classpath, Hudi writes the table in its native format without an Review Comment: `When the module is not on the classpath, Hudi writes the table in its native format without an error` Are you sure about this? Wouldn't it thrown an exception if `hoodie.table.format` as passed as ICEBERG? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. + +:::caution Every writer needs the jars +When the module is not on the classpath, Hudi writes the table in its native format without an +error. Iceberg then does not see the commits of that writer, and the next writer that has the jars +rolls them back. Put the jars on every job that writes the table, including table services such as +clean and clustering that run in separate jobs. +::: + +## Creating a table + +Set `hoodie.table.format=ICEBERG` on the first write. Hudi stores the format in +`hoodie.properties`, so later writes do not repeat it. The Hudi metadata table must stay off on +every write (see [Limitations](#limitations)). + +```scala md title="scala" +val basePath = "s3://example-warehouse/db/trips" + +df.write.format("hudi") + .option("hoodie.table.name", "trips") + .option("hoodie.datasource.write.recordkey.field", "id") + .option("hoodie.datasource.write.precombine.field", "ts") + .option("hoodie.datasource.write.partitionpath.field", "city") + .option("hoodie.table.format", "ICEBERG") + .option("hoodie.metadata.enable", "false") + .mode("append") + .save(basePath) +``` + +Upserts, deletes, insert overwrite, clean, clustering, rollbacks and savepoints work as on any Hudi +table. Pass `hoodie.metadata.enable=false` on every write, and in SQL sessions set it before you +run `UPDATE`, `DELETE`, `MERGE INTO` or a procedure. + +## Reading the table + +The same folder reads as both formats: + +```scala md title="scala" +spark.read.format("hudi").load(basePath) +spark.read.format("iceberg").load(basePath) +``` + +The Iceberg metadata is in the `metadata/` folder under the base path, so any engine that reads +Iceberg tables by path, or a catalog that registers the latest `metadata.json` file, reads the +table without Hudi. + +## Limitations + +- Copy-on-write tables only. Hudi refuses to load a merge-on-read table with this format. +- The Hudi metadata table must stay off (`hoodie.metadata.enable=false`). A commit on a table that + has a metadata table fails, and the next write rolls it back. +- Identity partitioning only. Timestamp-based and custom key generators with typed partition + fields are refused. +- Restore is refused before it changes the table. +- One writer at a time. +- The Iceberg table uses format version 2. +- Write the table only through Hudi. Other engines read it as an Iceberg table, but Hudi does not Review Comment: This needs to explained properly and confusing. ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. + +:::caution Every writer needs the jars +When the module is not on the classpath, Hudi writes the table in its native format without an +error. Iceberg then does not see the commits of that writer, and the next writer that has the jars +rolls them back. Put the jars on every job that writes the table, including table services such as +clean and clustering that run in separate jobs. +::: + +## Creating a table + +Set `hoodie.table.format=ICEBERG` on the first write. Hudi stores the format in +`hoodie.properties`, so later writes do not repeat it. The Hudi metadata table must stay off on +every write (see [Limitations](#limitations)). + +```scala md title="scala" +val basePath = "s3://example-warehouse/db/trips" + +df.write.format("hudi") + .option("hoodie.table.name", "trips") + .option("hoodie.datasource.write.recordkey.field", "id") + .option("hoodie.datasource.write.precombine.field", "ts") + .option("hoodie.datasource.write.partitionpath.field", "city") + .option("hoodie.table.format", "ICEBERG") + .option("hoodie.metadata.enable", "false") + .mode("append") + .save(basePath) +``` + +Upserts, deletes, insert overwrite, clean, clustering, rollbacks and savepoints work as on any Hudi +table. Pass `hoodie.metadata.enable=false` on every write, and in SQL sessions set it before you Review Comment: ``` Pass `hoodie.metadata.enable=false` on every write, and in SQL sessions set it before you run `UPDATE`, `DELETE`, `MERGE INTO` or a procedure ``` This is confusing why? ########## website/docs/features-and-limitations.md: ########## @@ -27,15 +27,33 @@ In addition to synchronizing table format metadata, Apache XTable™ (Incubating This reduces friction by eliminating the manual step of registering tables in multiple catalogs and enhances flexibility by avoiding catalog lock-in. HMS and AWS Glue are the two catalogs supported right now, support for other catalogs (Unity, Apache Polaris, Apache Gravitino, DataHub) coming soon. +### Secondary index for Iceberg tables +A sync to a Hudi target can build a secondary index on a column of an Iceberg source table and keep it current on each later sync. Review Comment: `keep it current on each later sync` simplify this? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four Review Comment: `You need Hudi 1.2.x for this` This is very naive and not ASF docs language...please re-write. ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. + +:::caution Every writer needs the jars +When the module is not on the classpath, Hudi writes the table in its native format without an +error. Iceberg then does not see the commits of that writer, and the next writer that has the jars +rolls them back. Put the jars on every job that writes the table, including table services such as +clean and clustering that run in separate jobs. +::: + +## Creating a table + +Set `hoodie.table.format=ICEBERG` on the first write. Hudi stores the format in +`hoodie.properties`, so later writes do not repeat it. The Hudi metadata table must stay off on +every write (see [Limitations](#limitations)). + +```scala md title="scala" +val basePath = "s3://example-warehouse/db/trips" + +df.write.format("hudi") + .option("hoodie.table.name", "trips") + .option("hoodie.datasource.write.recordkey.field", "id") + .option("hoodie.datasource.write.precombine.field", "ts") + .option("hoodie.datasource.write.partitionpath.field", "city") + .option("hoodie.table.format", "ICEBERG") + .option("hoodie.metadata.enable", "false") + .mode("append") + .save(basePath) +``` + +Upserts, deletes, insert overwrite, clean, clustering, rollbacks and savepoints work as on any Hudi +table. Pass `hoodie.metadata.enable=false` on every write, and in SQL sessions set it before you +run `UPDATE`, `DELETE`, `MERGE INTO` or a procedure. + +## Reading the table + +The same folder reads as both formats: + +```scala md title="scala" +spark.read.format("hudi").load(basePath) +spark.read.format("iceberg").load(basePath) +``` + +The Iceberg metadata is in the `metadata/` folder under the base path, so any engine that reads +Iceberg tables by path, or a catalog that registers the latest `metadata.json` file, reads the +table without Hudi. + +## Limitations + +- Copy-on-write tables only. Hudi refuses to load a merge-on-read table with this format. +- The Hudi metadata table must stay off (`hoodie.metadata.enable=false`). A commit on a table that Review Comment: Re-confirm this? ########## website/docs/how-to-iceberg-table-format.md: ########## @@ -0,0 +1,112 @@ +--- +sidebar_position: 5 +title: "Write Hudi tables as Iceberg tables" +--- + +# Write Hudi tables as Iceberg tables + +Apache Hudi 1.1 added pluggable table formats ([RFC-93](https://github.com/apache/hudi/blob/master/rfc/rfc-93/rfc-93.md)): +a Hudi writer can keep the metadata of another table format next to its own, in the same commit. +Apache XTable™ (Incubating) provides the Apache Iceberg implementation in the +`xtable-iceberg-pluggable-tf` module. With it, every Hudi write, clean, rollback, savepoint and +archive also commits an Iceberg snapshot in the table folder, so the table reads as a standard +Iceberg table right after the write, without a separate sync job. + +Iceberg decides which Hudi commits are visible: a Hudi commit whose Iceberg snapshot was not +committed is treated as pending and is rolled back by the next write, and a failed Iceberg commit +fails the Hudi operation. + +## Setting up Spark + +You need Hudi 1.2.x for this. Alongside the Hudi Spark bundle your job already uses, add four +XTable jars and the Iceberg Spark runtime. The XTable jars are on Maven Central from 0.5.0, so you +can download them directly: + +```shell md title="shell" +REPO=https://repo1.maven.org/maven2/org/apache/xtable +VERSION=0.5.0-incubating +curl -O $REPO/xtable-iceberg-pluggable-tf_2.12/$VERSION/xtable-iceberg-pluggable-tf_2.12-$VERSION.jar +curl -O $REPO/xtable-core_2.12/$VERSION/xtable-core_2.12-$VERSION.jar +curl -O $REPO/xtable-api/$VERSION/xtable-api-$VERSION.jar +curl -O $REPO/xtable-hudi-support-utils/$VERSION/xtable-hudi-support-utils-$VERSION.jar +``` + +The Iceberg Spark runtime is there because the XTable jars don't bundle Iceberg. Your writer uses +it to commit each snapshot, and you can read the table back as Iceberg in the same session. The +example below is for Spark 3.5, so pick the bundles that match your Spark version. + +```shell md title="shell" +XTABLE_JARS=xtable-iceberg-pluggable-tf_2.12-$VERSION.jar,\ +xtable-core_2.12-$VERSION.jar,\ +xtable-api-$VERSION.jar,\ +xtable-hudi-support-utils-$VERSION.jar + +spark-shell \ + --jars $XTABLE_JARS,hudi-spark3.5-bundle_2.12-1.2.1.jar,iceberg-spark-runtime-3.5_2.12-1.9.2.jar \ + --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \ + --conf spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension \ + --conf spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar +``` + +`spark-submit` takes the same `--jars` and `--conf` options. + +Each commit can log a warning, `Skipping a ConversionTarget whose engine library is not on the +classpath`, for the Delta targets of `xtable-core`. The Iceberg format does not use them, so you +can ignore it. + +:::caution Every writer needs the jars +When the module is not on the classpath, Hudi writes the table in its native format without an +error. Iceberg then does not see the commits of that writer, and the next writer that has the jars +rolls them back. Put the jars on every job that writes the table, including table services such as +clean and clustering that run in separate jobs. +::: + +## Creating a table + +Set `hoodie.table.format=ICEBERG` on the first write. Hudi stores the format in +`hoodie.properties`, so later writes do not repeat it. The Hudi metadata table must stay off on +every write (see [Limitations](#limitations)). + +```scala md title="scala" +val basePath = "s3://example-warehouse/db/trips" + +df.write.format("hudi") + .option("hoodie.table.name", "trips") + .option("hoodie.datasource.write.recordkey.field", "id") + .option("hoodie.datasource.write.precombine.field", "ts") + .option("hoodie.datasource.write.partitionpath.field", "city") + .option("hoodie.table.format", "ICEBERG") + .option("hoodie.metadata.enable", "false") + .mode("append") + .save(basePath) +``` + +Upserts, deletes, insert overwrite, clean, clustering, rollbacks and savepoints work as on any Hudi +table. Pass `hoodie.metadata.enable=false` on every write, and in SQL sessions set it before you +run `UPDATE`, `DELETE`, `MERGE INTO` or a procedure. + +## Reading the table + +The same folder reads as both formats: + +```scala md title="scala" +spark.read.format("hudi").load(basePath) +spark.read.format("iceberg").load(basePath) +``` + +The Iceberg metadata is in the `metadata/` folder under the base path, so any engine that reads +Iceberg tables by path, or a catalog that registers the latest `metadata.json` file, reads the +table without Hudi. + +## Limitations + +- Copy-on-write tables only. Hudi refuses to load a merge-on-read table with this format. +- The Hudi metadata table must stay off (`hoodie.metadata.enable=false`). A commit on a table that + has a metadata table fails, and the next write rolls it back. +- Identity partitioning only. Timestamp-based and custom key generators with typed partition + fields are refused. +- Restore is refused before it changes the table. +- One writer at a time. Review Comment: `One writer at a time` Say multi-writer not supported? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
