Skip to content
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

Support Iceberg version travel by reference name #19111

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

amogh-jahagirdar
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar commented Sep 20, 2023

Description

Support Iceberg version travel by reference name.

Note: This is a rebased version of #15646. I addressed some conflicts, added an additional test, and cleaned up a nit. @jackye1995 was the original author of this PR, I just marked myself as a co-author (let me know what is the practice followed in the Trino community).

Additional context and related issues

SELECT * FROM table AS OF VERSION 'tag-name'

Release notes

( ) This is not user-visible or is 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:

Copy link
Member

@mosabua mosabua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original PR was reviewed and approved by @alexjo2144 , @findinpath , and @ebyhr . I reviewed for differences, wording on user facing messages and beyond. All looks good to me.

Copy link
Member

@alexjo2144 alexjo2144 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good to me.

if (versionType == BIGINT) {
snapshotId = (long) version.getVersion();
}
else if (versionType instanceof VarcharType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a plan to support CharType in follow-up?

Copy link
Contributor Author

@amogh-jahagirdar amogh-jahagirdar Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not originally, but I don't see why we wouldn't want to support it. Happy to address in a follow on though if possible. Should I create a tracking issue for follow up or do you recommend I just address it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file an issue + add TODO comment here linking to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -784,6 +784,31 @@ public void testSnapshotReferenceSystemTable()
"('main', 'BRANCH', " + snapshotId3 + ", null, null, null)");
}

@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestIcebergReadVersionedTable seems a better class for testing time travel. (No need to change this PR because it requires more work)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sounds good, when I follow up with CharType support #19111 (comment) I can move all the test in a separate commit.

@@ -1319,6 +1319,18 @@ SELECT *
FROM example.testdb.customer_orders FOR VERSION AS OF 8954597067493422955
```

Iceberg supports named references of snapshots via branches and tags.
Time travel can be performed to branches and tags in the table.
Note that when time traveling to a branch, the snapshot which is resolved is the head of the branch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused by this last sentence. Could you elaborate on that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apache/iceberg#5364 (comment)

@amogh-jahagirdar, let's try to do a slightly condensed version of this comment to explain how our behavior is driven by a retention policy and is not a direct parallel to git branching behavior.

Later, I want to take this comment and elaborate with some visuals to explain this behavior in more detail, and we can shorten the explanation and link to the Iceberg docs at that time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amogh-jahagirdar, I spoke with @ebyhr on the side and he's just gonna remove that line for now and you and I should follow up and make an easy reference point in the Iceberg docs to point to about this.

apache/iceberg#8638

@ebyhr ebyhr merged commit fe83979 into trinodb:master Sep 25, 2023
4 of 14 checks passed
@github-actions github-actions bot added this to the 427 milestone Sep 25, 2023
if (ref == null) {
throw new TrinoException(INVALID_ARGUMENTS, "Cannot find snapshot with reference name: " + refName);
}
snapshotId = ref.snapshotId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this implementation, it seems that there is no distinction between branch and tag queries in trino, and both are used to query a fixed snapshot ?

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

Successfully merging this pull request may close these issues.

9 participants