Skip to content
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 @@ -195,6 +195,18 @@ public List<String> listNamespaces(ConnectorSession session)
}
}

private List<String> listNamespaces(ConnectorSession session, Optional<String> namespace)
{
if (namespace.isPresent()) {
if (isHiveSystemSchema(namespace.get())) {
// TODO https://github.com/trinodb/trino/issues/1559 information_schema should be handled by the engine fully
return ImmutableList.of();
}
return ImmutableList.of(namespace.get());
}
return listNamespaces(session);
}

@Override
public void dropNamespace(ConnectorSession session, String namespace)
{
Expand Down Expand Up @@ -289,7 +301,7 @@ public List<SchemaTableName> listTables(ConnectorSession session, Optional<Strin
{
ImmutableList.Builder<SchemaTableName> tables = ImmutableList.builder();
try {
List<String> namespaces = namespace.map(List::of).orElseGet(() -> listNamespaces(session));
List<String> namespaces = listNamespaces(session, namespace);
for (String glueNamespace : namespaces) {
try {
// Add all tables from a namespace together, in case it is removed while fetching paginated results
Expand Down Expand Up @@ -663,7 +675,7 @@ public List<SchemaTableName> listViews(ConnectorSession session, Optional<String
{
ImmutableList.Builder<SchemaTableName> views = ImmutableList.builder();
try {
List<String> namespaces = namespace.map(List::of).orElseGet(() -> listNamespaces(session));
List<String> namespaces = listNamespaces(session, namespace);
for (String glueNamespace : namespaces) {
try {
views.addAll(getPaginatedResults(
Expand Down Expand Up @@ -775,7 +787,7 @@ public List<SchemaTableName> listMaterializedViews(ConnectorSession session, Opt
{
ImmutableList.Builder<SchemaTableName> materializedViews = ImmutableList.builder();
try {
List<String> namespaces = namespace.map(List::of).orElseGet(() -> listNamespaces(session));
List<String> namespaces = listNamespaces(session, namespace);
for (String glueNamespace : namespaces) {
try {
materializedViews.addAll(getPaginatedResults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ private List<String> listNamespaces(ConnectorSession session, Optional<String> n
{
if (namespace.isPresent()) {
if (isHiveSystemSchema(namespace.get())) {
// TODO https://github.com/trinodb/trino/issues/1559 information_schema should be handled by the engine fully
return ImmutableList.of();
}
return ImmutableList.of(namespace.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ public void testRenameTableAcrossSchemas()
assertUpdate("DROP SCHEMA " + schemaName);
}

/**
* This seemingly duplicate test of {@link BaseConnectorTest#testShowInformationSchemaTables()}
* is used in the context of this class in order to be able to test
* against a wider range of connector configurations.
*/
@Test
public void testShowInformationSchemaTables()
{
assertThat(query("SHOW TABLES FROM information_schema"))
.skippingTypesCheck()
.containsAll("VALUES 'applicable_roles', 'columns', 'enabled_roles', 'roles', 'schemata', 'table_privileges', 'tables', 'views'");
}

@Test
public void testSelectInformationSchemaTables()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,14 @@ public void testDescribeTable()
assertEquals(actualColumns, expectedColumns);
}

@Test
public void testShowInformationSchemaTables()
{
assertThat(query("SHOW TABLES FROM information_schema"))
.skippingTypesCheck()
.containsAll("VALUES 'applicable_roles', 'columns', 'enabled_roles', 'roles', 'schemata', 'table_privileges', 'tables', 'views'");
}

@Test
public void testView()
{
Expand Down