Skip to content

Commit

Permalink
Allow relative hashes in table references (#7565)
Browse files Browse the repository at this point in the history
  • Loading branch information
adutra authored Sep 28, 2023
1 parent 7df5c39 commit b9bdda8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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

0 comments on commit b9bdda8

Please sign in to comment.