FANNG1 commented on code in PR #8243:
URL: https://github.com/apache/gravitino/pull/8243#discussion_r2296992476
##########
catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java:
##########
@@ -89,17 +93,27 @@ public void initialize(
}
@Override
- public List<String> listTables(String databaseName) throws
NoSuchSchemaException {
- try (Connection connection = getConnection(databaseName)) {
+ public void setDatabaseOperation(DatabaseOperation databaseOperation) {
+ this.schemaOperations = (PostgreSqlSchemaOperations) databaseOperation;
+ }
+
+ @Override
+ public List<String> listTables(String schemaName) throws
NoSuchSchemaException {
+ try (Connection connection = getConnection(schemaName)) {
final List<String> names = Lists.newArrayList();
try (ResultSet tables = getTables(connection)) {
while (tables.next()) {
- if (Objects.equals(tables.getString("TABLE_SCHEM"), databaseName)) {
+ if (Objects.equals(tables.getString("TABLE_SCHEM"), schemaName)) {
names.add(tables.getString("TABLE_NAME"));
}
}
}
- LOG.info("Finished listing tables size {} for database name {} ",
names.size(), databaseName);
+ if (names.isEmpty()) {
Review Comment:
No, if moving `schemaOperations.schemaExists` before,
`schemaOperations.schemaExists` is invoked every time, it will be expensive to
do this because most times the user will not list tables in a empty schema.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]