diff --git a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java index 3c97310c9f7f..4f78686327a0 100644 --- a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java +++ b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java @@ -91,6 +91,7 @@ import java.io.IOException; import java.sql.Array; import java.sql.Connection; +import java.sql.DatabaseMetaData; import java.sql.JDBCType; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -375,6 +376,20 @@ protected String getTableSchemaName(ResultSet resultSet) return firstNonNull(resultSet.getString("TABLE_SCHEM"), DEFAULT_SCHEMA); } + @Override + protected ResultSet getColumns(JdbcTableHandle handle, DatabaseMetaData metadata) + throws SQLException + { + try { + return super.getColumns(handle, metadata); + } + catch (org.apache.phoenix.schema.TableNotFoundException e) { + // Most JDBC driver return an empty result when DatabaseMetaData.getColumns can't find objects, but Phoenix driver throws an exception + // Rethrow as Trino TableNotFoundException to suppress the exception during listing information_schema + throw new io.trino.spi.connector.TableNotFoundException(new SchemaTableName(handle.getSchemaName(), handle.getTableName())); + } + } + @Override public Optional toColumnMapping(ConnectorSession session, Connection connection, JdbcTypeHandle typeHandle) { diff --git a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java index 5dc2c7184dc0..8a58c68a844c 100644 --- a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java @@ -22,7 +22,6 @@ import io.trino.testing.TestingConnectorBehavior; import io.trino.testing.sql.SqlExecutor; import io.trino.testing.sql.TestTable; -import io.trino.testng.services.Flaky; import org.testng.SkipException; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; @@ -221,30 +220,6 @@ public void testShowCreateTable() ")"); } - // TODO (https://github.com/trinodb/trino/issues/10904): Test is flaky because tests execute in parallel - @Flaky(issue = "https://github.com/trinodb/trino/issues/10904", match = "\\QERROR 1012 (42M03): Table undefined. tableName=") - @Test - @Override - public void testSelectInformationSchemaColumns() - { - super.testSelectInformationSchemaColumns(); - } - - @Override - public void testReadMetadataWithRelationsConcurrentModifications() - { - try { - super.testReadMetadataWithRelationsConcurrentModifications(); - } - catch (Exception expected) { - // The test failure is not guaranteed - // TODO (https://github.com/trinodb/trino/issues/10904): shouldn't fail - assertThat(expected) - .hasMessageContaining("ERROR 1012 (42M03): Table undefined. tableName="); - throw new SkipException("to be fixed"); - } - } - @Override public void testCharVarcharComparison() { diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java index b6ff2f589e29..fdc59d0c8d28 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java @@ -92,6 +92,7 @@ import java.io.IOException; import java.sql.Array; import java.sql.Connection; +import java.sql.DatabaseMetaData; import java.sql.JDBCType; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -367,6 +368,20 @@ protected String getTableSchemaName(ResultSet resultSet) return firstNonNull(resultSet.getString("TABLE_SCHEM"), DEFAULT_SCHEMA); } + @Override + protected ResultSet getColumns(JdbcTableHandle handle, DatabaseMetaData metadata) + throws SQLException + { + try { + return super.getColumns(handle, metadata); + } + catch (org.apache.phoenix.schema.TableNotFoundException e) { + // Most JDBC driver return an empty result when DatabaseMetaData.getColumns can't find objects, but Phoenix driver throws an exception + // Rethrow as Trino TableNotFoundException to suppress the exception during listing information_schema + throw new io.trino.spi.connector.TableNotFoundException(new SchemaTableName(handle.getSchemaName(), handle.getTableName())); + } + } + @Override public Optional toColumnMapping(ConnectorSession session, Connection connection, JdbcTypeHandle typeHandle) { diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java index 1840e546c448..1107244bff7b 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java @@ -24,7 +24,6 @@ import io.trino.testing.TestingConnectorBehavior; import io.trino.testing.sql.SqlExecutor; import io.trino.testing.sql.TestTable; -import io.trino.testng.services.Flaky; import org.testng.SkipException; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; @@ -239,30 +238,6 @@ public void testShowCreateTable() ")"); } - // TODO (https://github.com/trinodb/trino/issues/10904): Test is flaky because tests execute in parallel - @Flaky(issue = "https://github.com/trinodb/trino/issues/10904", match = "\\QERROR 1012 (42M03): Table undefined. tableName=") - @Test - @Override - public void testSelectInformationSchemaColumns() - { - super.testSelectInformationSchemaColumns(); - } - - @Override - public void testReadMetadataWithRelationsConcurrentModifications() - { - try { - super.testReadMetadataWithRelationsConcurrentModifications(); - } - catch (Exception expected) { - // The test failure is not guaranteed - // TODO (https://github.com/trinodb/trino/issues/10904): shouldn't fail - assertThat(expected) - .hasMessageContaining("ERROR 1012 (42M03): Table undefined. tableName="); - throw new SkipException("to be fixed"); - } - } - @Override public void testCharVarcharComparison() {