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 @@ -92,19 +92,7 @@ private static boolean isSchemaEmpty(Session session, CatalogSchemaName schema,
{
QualifiedTablePrefix tablePrefix = new QualifiedTablePrefix(schema.getCatalogName(), schema.getSchemaName());

// These are best efforts checks that don't provide any guarantees against concurrent DDL operations
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be beneficial to add views & materialized views in the io.trino.testing.BaseConnectorTest#testDropNonEmptySchema depending on:

  • SUPPORTS_CREATE_VIEW
  • SUPPORTS_CREATE_MATERIALIZED_VIEW

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good idea, but we would have to test all these 3 cases separately. I don't plan to do this though. Do you want to want to follow up?

Copy link
Copy Markdown
Contributor

@findinpath findinpath Mar 22, 2022

Choose a reason for hiding this comment

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

Yes, I'll create a PR based on your changes.

See #11614

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I'll create a PR based on your changes.

many thanks!

if (!metadata.listTables(session, tablePrefix).isEmpty()) {
return false;
}

if (!metadata.listViews(session, tablePrefix).isEmpty()) {
return false;
}

if (!metadata.listMaterializedViews(session, tablePrefix).isEmpty()) {
return false;
}

return true;
// This is a best effort check that doesn't provide any guarantees against concurrent DDL operations
return metadata.listTables(session, tablePrefix).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ Optional<TableExecuteHandle> getTableHandleForExecute(
TableStatistics getTableStatistics(Session session, TableHandle tableHandle, Constraint constraint);

/**
* Get the names that match the specified table prefix (never null).
* Get the relation names that match the specified table prefix (never null).
* This includes all relations (e.g. tables, views, materialized views).
Comment on lines +145 to +146
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I did not check. Is this accurate for all the connector now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I went through all the implementations of io.trino.spi.connector.ConnectorMetadata#listViews and io.trino.spi.connector.ConnectorMetadata#listMaterializedViews and the corresponding listTables implementation does indeed return the views / materialized views as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did not check. Is this accurate for all the connector now?

even if it wasn't the case yet, we already have this

/**
* List table, view and materialized view names, possibly filtered by schema. An empty list is returned if none match.
*/
default List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaName)

and Metadata just calls that method.

*/
List<QualifiedObjectName> listTables(Session session, QualifiedTablePrefix prefix);

Expand Down