Add register_table procedure support for iceberg table#14375
Add register_table procedure support for iceberg table#14375findepi merged 2 commits intotrinodb:masterfrom
register_table procedure support for iceberg table#14375Conversation
6e09f17 to
e464f17
Compare
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
|
The approach generally looks good to me. Thanks for putting this together |
f9fca42 to
01679f5
Compare
01679f5 to
1203740
Compare
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergErrorCode.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
...no-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractIcebergTableOperations.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
57a7092 to
9ddb33d
Compare
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
...no-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractIcebergTableOperations.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
...n/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergRegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Should we maybe integrate the tests from this class into BaseIcebergConnectorTest ?
...n/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergRegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
...n/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergRegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/TrinoCatalog.java
Outdated
Show resolved
Hide resolved
...o-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/GlueIcebergTableOperations.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
0308ec8 to
034538f
Compare
...test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergGlueCatalogConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergGlueCatalogConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
@Inject
private HdfsClient hdfsClient;
and
There was a problem hiding this comment.
A bit of context behind hdfsClient
|
@anusudarsan @dain can you please review this with respect to locations & security? |
There was a problem hiding this comment.
- Do we have a test for this? (against Glue catalog)
- If we take out these lines, would it still pass?
- if we do one call to Glue with proper err handling, we won't have any concurrency issues
There was a problem hiding this comment.
Yes, We have test against Glue catalog as well.
There was a problem hiding this comment.
In #14375 (comment) i meant to use the existing IcebergFileFormat class (io.trino.plugin.iceberg.IcebergFileFormat). Why do you want to have a copy?
There was a problem hiding this comment.
enum variable returns the value in the uppercase like (ORC, AVRO, and PARQUET) which was causing failure in some test cases where we access table comment and column comment. My intention was to make the format name lowercase while constructing the tableName.
Now, I have removed the local copy of IcebergFileFormat and used io.trino.plugin.iceberg.IcebergFileFormat and then converted to lowercase wherever required.
There was a problem hiding this comment.
I could not understand, In Locally tableName seems to be "not case-sensitive" whereas in CI tableName is "case-sensitive". Test cases are failing in CI build.
There was a problem hiding this comment.
On Mac, the local filesystem is case-insensitive (by default).
On the CI it's case sensitive.
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Same as for Glue case -- if we remove this and have proper err handling, there is no question that the code is concurrently correct.
For HMS this is already test-covered io.trino.plugin.iceberg.TestIcebergRegisterTableProcedure#testRegisterTableWithExistingTable, you would just need to update the expected message, as it will be slightly different:
java.lang.AssertionError:
Expecting message:
<"Table already exists: 'tpch.test_register_table_with_existing_table_rwlb2koaqo'">
to match regex:
<".*Table '(.*)' already exists.*">
but did not.
There was a problem hiding this comment.
Removed the check and modified the test case of Glue and HMS.
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
.../trino-product-tests/src/main/java/io/trino/tests/product/iceberg/util/IcebergTestUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
by looking at the methoid signature, I don't understand what "withURI" means.
Why do we want a change here?
There was a problem hiding this comment.
Some test cases were already using getTableLocation where the caller gets the tableLocation withouthdfs://hadoop-master:9000 (hdfsURI). For me, I wanted to have a fully qualified tableLocation to call registerTable.
Here withURI means, return the table location which includes hdfs://hadoop-master:9000
That is why I have overloaded the method to not disturb the existing caller.
There was a problem hiding this comment.
For now, I have reverted my change and returned the table location with hdfs://hadoop-master:9000 always. My mac has issue with product tests, so relying on CI build to see the error if any.
`
There was a problem hiding this comment.
The test cases are failing.
It is found that hdfsClient requires table location without hdfs://hadoop-master:9000 to perform file operation and register_table procedure call requires table location with hdfs://hadoop-master:9000
There was a problem hiding this comment.
is withNamenodeURI make sense?
|
.../trino-product-tests/src/main/java/io/trino/tests/product/iceberg/util/IcebergTestUtils.java
Outdated
Show resolved
Hide resolved
|
Moved smoke tests into |
Bumping up the comment. |
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java
Outdated
Show resolved
Hide resolved
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
...in/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/RegisterTableProcedure.java
Outdated
Show resolved
Hide resolved
testing/trino-testing-containers/src/main/java/io/trino/testing/minio/MinioClient.java
Outdated
Show resolved
Hide resolved
...roduct-tests/src/main/java/io/trino/tests/product/iceberg/TestIcebergSparkCompatibility.java
Outdated
Show resolved
Hide resolved
.../trino-product-tests/src/main/java/io/trino/tests/product/iceberg/util/IcebergTestUtils.java
Outdated
Show resolved
Hide resolved
alexjo2144
left a comment
There was a problem hiding this comment.
Just some documentation wording nit picks 👍
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Outdated
Show resolved
Hide resolved
|
Congratulations @krvikash .. well done on persisting through and working with all the reviewers towards a successful merge. Great collaboration everyone! |
Description
Fixes #13552
Adding
register_tableprocedure for iceberg connector to register table using existing metadata..metadata.jsoninside themetadatafolder and use it for creating the tableschema_name,table_name, andtable_locationshould be not-null and valid, Otherwise, the exception will be thrownmetadata_file_location(See the usage below)Valid usages:
register_table(schema_name => ..., table_name => ..., table_location => ...)register_table(schema_name => ..., table_name => ..., table_location => ..., metadata_file_location => ...)Sample Queries:
CALL iceberg.system.register_table('default', 'src_22', 'hdfs://hadoop-master:9000/user/hive/warehouse/orders_5-581fad8517934af6be1857a903559d44');CALL iceberg.system.register_table('default', 'src_22', 'hdfs://hadoop-master:9000/user/hive/warehouse/orders_5-581fad8517934af6be1857a903559d44', null);CALL iceberg.system.register_table('default', 'src_22', 'hdfs://hadoop-master:9000/user/hive/warehouse/orders_5-581fad8517934af6be1857a903559d44', '00003-409702ba-4735-4645-8f14-09537cc0b2c8.metadata.json');Test cases are added for success and failure scenarios in the following classes.
TestIcebergRegisterTableProcedureBaseIcebergConnectorSmokeTestTestIcebergSparkCompatibilityConfiguration:
By default
register_tableprocedure is disabled. Enable procedure by settingiceberg.register-table-procedure.enabledtotruein config.Non-technical explanation
NA
Release notes
( ) This is not user-visible or docs only and no release notes are required.
(X) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: