-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix support for system tables for Lakehouse #26830
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
base: master
Are you sure you want to change the base?
Conversation
7356018
to
3ad2a43
Compare
3b04a7b
to
07fce46
Compare
} | ||
|
||
@Test | ||
public void testSelectDeltaMetaTables() |
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.
https://trino.io/docs/current/develop/tests.html#conventions-and-recommendations
- Test methods should be defined as package-private.
This test can be renamed to testSelectMetadataTable
.
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.
"Test classes should be defined as package-private and final."
"Test methods should be defined as package-private."
Should I change the class to be package private and final, and the other methods to be package private?
Or just the new methods?
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.
You can change existing visibility, but I recommend handling in a separate PR.
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.
Ok, fixed
{ | ||
computeActual( | ||
""" | ||
CREATE TABLE delta_table |
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.
Please avoid a static table name. Use TestTable
with try-with-resources instead. Or please consider using the existing table.
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.
Used existing table
AS SELECT * FROM tpch.tiny.region | ||
"""); | ||
|
||
assertQuery("SELECT count(*) FROM \"delta_table$history\"", "VALUES 1"); |
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.
assertQuery
method isn't recommend. Please use assertThat(query(...))
instead.
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.
Changed to using assertThat(query(...))
@Test | ||
public void testSelectDeltaMetaTables() | ||
{ | ||
computeActual( |
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.
We usually use assertUpdate
for DDL.
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.
Changed to use existing table
default -> { | ||
// For system tables, the handle will be an instance of io.trino.connector.system.SystemTableHandle | ||
// Some Iceberg system tables ($files and $history) use special splits (FilesTableSplit) | ||
if (split instanceof FilesTableSplit) { |
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.
What's the handle
in this case? it should be the FilesTable
right?
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.
No, it's of io.trino.connector.system.SystemTableHandle type.
And the split is of io.trino.plugin.iceberg.system.files.FilesTableSplit type.
io.trino.connector.system.SystemTableHandle is from trino-main module, which is only a test dependency. That's why I didn't add a new switch case for SystemTableHandle.
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.
Thanks.
In this case we could add a case branch instead of putting it in the default, and raise nice error message to mention which kind of split we are not support yet with the SystemTableHandle
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.
io.trino.connector.system.SystemTableHandle is from trino-main module, which is only a test dependency.
What should be the new scope of the trino-main module?
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.
Make that scope to compile should be fine in this case
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.
Disagree. Please don't include trino-main as a dependency. The module isn't supposed to be depended on by connectors.
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.
It wouldn't work anyway, as the class is in a different class loader.
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.
2aeb63e
to
10fecac
Compare
assertThatThrownBy(() -> computeScalar("SELECT count(*) FROM lakehouse.tpch.\"region$files\"")) | ||
.hasMessageMatching(".* Table .* does not exist"); | ||
assertThatThrownBy(() -> computeScalar("SELECT count(*) FROM lakehouse.tpch.\"region$timeline\"")) | ||
.hasMessageMatching(".* Table .* does not exist"); |
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.
Please use assertThat(query(...)).failure()
so we can ensure that the exception class is TrinoException
.
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.
I'm not able to get the assertion to work. I can't find an example either.
TrinoException is wrapped in a QueryFailedException, which has a cause of FailureException.
The TrinoException is stored as FailureInfo in FailureException.
assertThat(query("SELECT count(*) FROM lakehouse.tpch.\"region$history\""))
.failure().isInstanceOf(TrinoException.class).hasMessage(".* Table .* does not exist");
- fails with ->
java.lang.AssertionError:
Expecting actual throwable to be an instance of:
io.trino.spi.TrinoException
but was:
io.trino.testing.QueryFailedException: line 1:22: Table 'lakehouse.tpch."region$history"' does not exist
assertThat(query("SELECT count(*) FROM lakehouse.tpch.\"region$history\""))
.failure().hasCauseInstanceOf(TrinoException.class).hasMessage(".* Table .* does not exist");
- fails with ->
java.lang.AssertionError:
Expecting a throwable with cause being an instance of:
io.trino.spi.TrinoException
but was an instance of:
io.trino.client.FailureException
Throwable that failed the check:
io.trino.testing.QueryFailedException: line 1:22: Table 'lakehouse.tpch."region$history"' does not exist
assertThatThrownBy(() -> computeScalar("SELECT count(*) FROM lakehouse.tpch.\"region$history\""))
.isInstanceOf(TrinoException.class).hasMessageMatching(".* Table .* does not exist";
assertThatThrownBy(() -> computeScalar("SELECT count(*) FROM lakehouse.tpch.\"region$history\""))
.isInstanceOf(TrinoException.class).hasMessageMatching(".* Table .* does not exist";
- fails like the first example above
8376952
to
7eee45e
Compare
For system tables, the handle will be an instance of io.trino.connector.system.SystemTableHandle. Some Iceberg system tables ($files and $history) use special splits (FilesTableSplit).
7eee45e
to
a83442b
Compare
Fix support for system tables for Lakehouse.
The $files and $history system tables for Iceberg tables are not handled properly.
Fixes #26751
Description
For system tables, the handle will be an instance of io.trino.connector.system.SystemTableHandle.
Some Iceberg system tables ($files and $history) use special splits (FilesTableSplit).
io.trino.connector.system.SystemTableHandle is part of trino-main, which is a test dependency for trino-lakehouse.
The dependency to trino-main is not changed.
Release notes