diff --git a/plugin/trino-singlestore/pom.xml b/plugin/trino-singlestore/pom.xml index 4335ded26fb7..d9dbb8db1df2 100644 --- a/plugin/trino-singlestore/pom.xml +++ b/plugin/trino-singlestore/pom.xml @@ -27,7 +27,7 @@ com.singlestore singlestore-jdbc-client - 1.2.3 + 1.2.8 diff --git a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java index e0784159039c..a9d1f6f06fe7 100644 --- a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java +++ b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java @@ -59,6 +59,7 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; @@ -216,11 +217,13 @@ public boolean supportsAggregationPushdown(ConnectorSession session, JdbcTableHa @Override public Collection listSchemas(Connection connection) { - // for SingleStore, we need to list catalogs instead of schemas - try (ResultSet resultSet = connection.getMetaData().getCatalogs()) { + // Avoid using DatabaseMetaData.getCatalogs method because + // https://github.com/memsql/S2-JDBC-Connector/pull/9 causes the driver to return only the databases in the current workspace + try (PreparedStatement statement = connection.prepareStatement("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA"); + ResultSet resultSet = statement.executeQuery()) { ImmutableSet.Builder schemaNames = ImmutableSet.builder(); while (resultSet.next()) { - String schemaName = resultSet.getString("TABLE_CAT"); + String schemaName = resultSet.getString("SCHEMA_NAME"); // skip internal schemas if (filterSchema(schemaName)) { schemaNames.add(schemaName);