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

Test Iceberg operations for information_schema.columns #18300

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
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,26 @@ public void testRemoveOrphanFiles()
assertUpdate("DROP TABLE " + tableName);
}

@Test
public void testInformationSchemaColumns()
{
int tables = 3;
for (int i = 0; i < tables; i++) {
assertUpdate("CREATE TABLE test_select_i_s_columns" + i + "(id VARCHAR, age INT)");
assertUpdate("CREATE TABLE test_other_select_i_s_columns" + i + "(id VARCHAR, age INT)"); // won't match the filter
}

assertFileSystemAccesses("SELECT * FROM information_schema.columns WHERE table_name LIKE 'test_select_i_s_columns%'",
ImmutableMultiset.<FileOperation>builder()
.addCopies(new FileOperation(METADATA_JSON, INPUT_FILE_NEW_STREAM), 3)
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to show that if you have a table that does not match the filter we don't grab the metadata json file. Similarly a predicate on table_schema should filter the same way.

.build());

for (int i = 0; i < tables; i++) {
assertUpdate("DROP TABLE test_select_i_s_columns" + i);
assertUpdate("DROP TABLE test_other_select_i_s_columns" + i);
}
}

private void assertFileSystemAccesses(@Language("SQL") String query, Multiset<FileOperation> expectedAccesses)
{
assertFileSystemAccesses(getSession(), query, expectedAccesses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import static com.google.inject.util.Modules.EMPTY_MODULE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.DROP_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_ALL_DATABASES;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_ALL_TABLES_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.REPLACE_TABLE;
Expand Down Expand Up @@ -319,6 +321,28 @@ public void testUnregisterTable()
.build());
}

@Test
public void testInformationSchemaColumns()
{
int tables = 3;
for (int i = 0; i < tables; i++) {
assertUpdate("CREATE TABLE test_select_i_s_columns" + i + "(id VARCHAR, age INT)");
assertUpdate("CREATE TABLE test_other_select_i_s_columns" + i + "(id VARCHAR, age INT)"); // won't match the filter
}

assertMetastoreInvocations("SELECT * FROM information_schema.columns WHERE table_name LIKE 'test_select_i_s_columns%'",
ImmutableMultiset.builder()
.add(GET_ALL_DATABASES)
.add(GET_ALL_TABLES_FROM_DATABASE)
.addCopies(GET_TABLE, 3)
Copy link
Member

Choose a reason for hiding this comment

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

Small improvement might be to have one table that does not match the LIKE string and show that it does not need a GET_TABLE call.

.build());

for (int i = 0; i < tables; i++) {
assertUpdate("DROP TABLE test_select_i_s_columns" + i);
assertUpdate("DROP TABLE test_other_select_i_s_columns" + i);
}
}

private void assertMetastoreInvocations(@Language("SQL") String query, Multiset<?> expectedInvocations)
{
assertMetastoreInvocations(getSession(), query, expectedInvocations);
Expand Down