-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iceberg: use native implementation to obtain snapshot schema #13614
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiacongling would you be able to add a regression product test for this case?
see TestIcebergSparkCompatibility
for existing tests
@findepi sure |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Spend some time with the testing framework and finally get it work. A case is added in SuiteCompatibility for the reason that Iceberg metafile is changing over times, we must make sure tables created by an early version of Trino can be queried normally in newer versions. Early versions (<= 364) of Trino use iceberg v0.11 which did not support time traveling. The snapshot did not have a field named
|
@findepi Could you review this PR? |
...-launcher/src/main/java/io/trino/tests/product/launcher/suite/suites/SuiteCompatibility.java
Outdated
Show resolved
Hide resolved
...ests/src/main/java/io/trino/tests/product/iceberg/TestIcebergFormatVersionCompatibility.java
Outdated
Show resolved
Hide resolved
...ests/src/main/java/io/trino/tests/product/iceberg/TestIcebergFormatVersionCompatibility.java
Outdated
Show resolved
Hide resolved
...ests/src/main/java/io/trino/tests/product/iceberg/TestIcebergFormatVersionCompatibility.java
Outdated
Show resolved
Hide resolved
55e9583
to
0c85b4d
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@xiacongling please squash the commits and follow the |
@@ -326,7 +327,7 @@ public IcebergTableHandle getTableHandle( | |||
long snapshotId = endVersion.map(connectorTableVersion -> getSnapshotIdFromVersion(table, connectorTableVersion)) | |||
.orElseGet(() -> resolveSnapshotId(table, name.getSnapshotId().get(), isAllowLegacySnapshotSyntax(session))); | |||
tableSnapshotId = Optional.of(snapshotId); | |||
tableSchema = table.schemas().get(table.snapshot(snapshotId).schemaId()); | |||
tableSchema = schemaFor(table, snapshotId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, here's what that method does:
public static Schema schemaFor(Table table, long snapshotId) {
Snapshot snapshot = table.snapshot(snapshotId);
Preconditions.checkArgument(snapshot != null, "Cannot find snapshot with ID %s", snapshotId);
Integer schemaId = snapshot.schemaId();
// schemaId could be null, if snapshot was created before Iceberg added schema id to snapshot
if (schemaId != null) {
Schema schema = table.schemas().get(schemaId);
Preconditions.checkState(schema != null,
"Cannot find schema with schema id %s", schemaId);
return schema;
}
// TODO: recover the schema by reading previous metadata files
return table.schema();
}
0c85b4d
to
7ba88af
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@findinpath done |
...ests/src/main/java/io/trino/tests/product/iceberg/TestIcebergFormatVersionCompatibility.java
Outdated
Show resolved
Hide resolved
7ba88af
to
66ae1dc
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
66ae1dc
to
45387dc
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Iceberg snapshot definition in table metadata file does not have a schema-id until Iceberg version 0.12. Time travel queries on a table created by early versions of Trino (<=364) will fail without this fix.
45387dc
to
f67c2f1
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
I confirmed @xiacongling already submit CLA last week. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
Merged, thanks! |
Description
a fix
Iceberg Connector
Uss native implementation to obtain snapshot schema when executing Iceberg time travel queries. Time travel queries on a table created with Iceberg<0.12 will fail without this fix.
Related issues, pull requests, and links
related to #12743 #12786
fixes #13613
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
() No release notes entries required.
(x) Release notes entries required with the following suggested text