diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java index a0af7270eec7..fae763fb471d 100644 --- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java +++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java @@ -303,6 +303,33 @@ public void testInsertNegativeDate() .hasStackTraceContaining("TrinoException: Driver returned null LocalDate for a non-null value"); } + @Override + public void testNativeQueryCreateStatement() + { + // SingleStore returns a ResultSet metadata with no columns for CREATE TABLE statement. + // This is unusual, because other connectors don't produce a ResultSet metadata for CREATE TABLE at all. + // The query fails because there are no columns, but even if columns were not required, the query would fail + // to execute in SingleStore because the connector wraps it in additional syntax, which causes syntax error. + assertFalse(getQueryRunner().tableExists(getSession(), "numbers")); + assertThatThrownBy(() -> query("SELECT * FROM TABLE(system.query(query => 'CREATE TABLE numbers(n INTEGER)'))")) + .hasMessageContaining("descriptor has no fields"); + assertFalse(getQueryRunner().tableExists(getSession(), "numbers")); + } + + @Override + public void testNativeQueryInsertStatementTableExists() + { + // SingleStore returns a ResultSet metadata with no columns for INSERT statement. + // This is unusual, because other connectors don't produce a ResultSet metadata for INSERT at all. + // The query fails because there are no columns, but even if columns were not required, the query would fail + // to execute in SingleStore because the connector wraps it in additional syntax, which causes syntax error. + try (TestTable testTable = simpleTable()) { + assertThatThrownBy(() -> query(format("SELECT * FROM TABLE(system.query(query => 'INSERT INTO %s VALUES (3)'))", testTable.getName()))) + .hasMessageContaining("descriptor has no fields"); + assertQuery("SELECT * FROM " + testTable.getName(), "VALUES 1, 2"); + } + } + /** * This test helps to tune TupleDomain simplification threshold. */