Skip to content

[636] Load Iceberg source tables in Glue and HMS from metadata_location - #1061

Open
Indian-boult wants to merge 1 commit into
apache:mainfrom
Indian-boult:fix/636-catalog-iceberg-source
Open

Indian-boult wants to merge 1 commit into
apache:mainfrom
Indian-boult:fix/636-catalog-iceberg-source

Conversation

@Indian-boult

Copy link
Copy Markdown
Contributor

Fixes #636
Fixes #759

What is the purpose of the pull request

Catalog sync could not read an Iceberg source table registered in AWS Glue or Hive Metastore by an Iceberg catalog, such as a table created by Athena, Spark or Trino through GlueCatalog or HiveCatalog. Those catalogs keep the current metadata file in the table's metadata_location parameter and write no version-hint.text. GlueCatalogConversionSource and HMSCatalogConversionSource pass that parameter on in the source table's properties, but IcebergConversionSource ignored it and loaded the table from its base path with HadoopTables, which needs a version hint. Every such sync failed with NoSuchTableException: Table does not exist at location, which is the stack trace in #759.

With this change, when a source table has no Iceberg catalog config and carries the catalog's metadata_location, the Iceberg source loads the table read only from that metadata file, the same way Iceberg's own metastore catalogs resolve a table. A table with an Iceberg catalog config is still loaded through that catalog, and a table with neither is still loaded from its base path. Delta and Hudi sources are not affected.

XTable's own Glue and HMS sync clients write the same metadata_location parameter for Iceberg targets, so the source side now reads the pointer the target side writes. The CLI exiting with 0 after this failure is tracked separately in #794 and #889 and is not changed here.

Brief change log

  • IcebergConversionSource loads the table from the catalog's metadata_location through StaticTableOperations when no Iceberg catalog config is set.
  • TestIcebergTable.moveToMetastoreCatalogLayout lays a test table out the way Glue and Hive keep it, with a metadata file named by sequence number and UUID and no version hint.
  • TestIcebergConversionSource#testTableInMetastoreCatalogLoadsFromCatalogMetadataLocation reads such a table through getCurrentSnapshot, getCommitsBacklog and getTableChangeForCommit, and checks that it cannot be found without the parameter.
  • ITRunCatalogSync#testCatalogSyncOfIcebergTableInMetastoreCatalog runs RunCatalogSync with a source catalog that builds the source table the way GlueCatalogConversionSource does, and checks the Delta table it writes. The class now runs its tests in one thread and the existing test counts only its own catalog calls, since both tests share the call counts of TestCatalogSyncImpl.

Verify this pull request

This change added tests and can be verified as follows:

  • Without the change in IcebergConversionSource, the new unit test fails with NoSuchTableException: Table does not exist at location, and the new IT finds 0 records in the Delta target against 30 in the source.
  • With the change, both pass.
  • ./mvnw -pl xtable-core,xtable-utilities -am test passes in every module, with 598 tests and 3 skipped in xtable-core.
  • ITRunCatalogSync, ITIcebergConversionSource and ITConversionController#testVariousOperations pass, 39 tests in all.

A metastore catalog such as AWS Glue or Hive keeps an Iceberg table's
current metadata file in the metadata_location parameter and writes no
version hint, so loading the table from its base path with HadoopTables
failed every catalog sync of such a table. When the source table has no
Iceberg catalog config and carries metadata_location, load the table
read only from that metadata file.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant