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

Allow relative hashes in table references #7565

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ as necessary. Empty sections will not end in the release notes.
- Introduces sizing of the Nessie object cache using a relative value of the max Java heap size.
The defaults have been changed to 70% of the Java max heap size (from the previous default of 64MB).
If a fixed cache size setting has been explicitly configured, consider to change it to the fraction based one.
- Relative hashes are now supported in table references, thus allowing SQL queries to specify a relative hash
in the `FROM` clause, e.g. `FROM table1@main#1234^1`.

### Deprecations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static TableReference parse(String tableReference) {
b.reference(refName);
}
if (hashOrTimestamp != null) {
if (Validation.isValidHash(hashOrTimestamp)) {
if (Validation.isValidHashOrRelativeSpec(hashOrTimestamp)) {
b.hash(hashOrTimestamp);
} else {
b.timestamp(hashOrTimestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,37 @@ static List<Object[]> fromContentKeyTestCases() {
"12345678abcdef12345678abcdef",
null
},
// relative hashes - unambiguous
new Object[] {
"`simple_name@ref#12345678abcdef12345678abcdef~1^2*2023-09-28T12:34:56.789Z`",
"simple_name",
"ref",
"12345678abcdef12345678abcdef~1^2*2023-09-28T12:34:56.789Z",
null
},
new Object[] {
"`simple_name#12345678abcdef12345678abcdef~1^2*2023-09-28T12:34:56.789Z`",
"simple_name",
null,
"12345678abcdef12345678abcdef~1^2*2023-09-28T12:34:56.789Z",
null
},
// relative hashes - ambiguous
new Object[] {
"`simple_name@ref#~1^2*2023-09-28T12:34:56.789Z`",
"simple_name",
"ref",
"~1^2*2023-09-28T12:34:56.789Z",
null
},
new Object[] {
"`simple_name#~1^2*2023-09-28T12:34:56.789Z`",
"simple_name",
null,
"~1^2*2023-09-28T12:34:56.789Z",
null
},
// timestamps
new Object[] {"`simple_name#2020-12-24`", "simple_name", null, null, "2020-12-24"},
new Object[] {"`simple_name@ref#2020-12-24`", "simple_name", "ref", null, "2020-12-24"});
}
Expand Down