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 @@ -311,8 +311,7 @@ public void testCreateTablePartitionOrdering()
@Override
public void testShowCreateTable()
{
assertThat(computeActual("SHOW CREATE TABLE person").getOnlyValue())
.isInstanceOf(String.class)
assertThat(computeScalar("SHOW CREATE TABLE person"))
.isEqualTo(format(
"CREATE TABLE delta_lake.%s.person (\n" +
" name varchar,\n" +
Expand Down Expand Up @@ -377,7 +376,7 @@ public void testHiveViewsCannotBeAccessed()
{
String viewName = "dummy_view";
hiveMinioDataLake.getHiveHadoop().runOnHive(format("CREATE VIEW %1$s.%2$s AS SELECT * FROM %1$s.customer", SCHEMA, viewName));
assertEquals(computeActual(format("SHOW TABLES LIKE '%s'", viewName)).getOnlyValue(), viewName);
assertEquals(computeScalar(format("SHOW TABLES LIKE '%s'", viewName)), viewName);
assertThatThrownBy(() -> computeActual("DESCRIBE " + viewName)).hasMessageContaining(format("%s.%s is not a Delta Lake table", SCHEMA, viewName));
hiveMinioDataLake.getHiveHadoop().runOnHive("DROP VIEW " + viewName);
}
Expand All @@ -387,7 +386,7 @@ public void testNonDeltaTablesCannotBeAccessed()
{
String tableName = "hive_table";
hiveMinioDataLake.getHiveHadoop().runOnHive(format("CREATE TABLE %s.%s (id BIGINT)", SCHEMA, tableName));
assertEquals(computeActual(format("SHOW TABLES LIKE '%s'", tableName)).getOnlyValue(), tableName);
assertEquals(computeScalar(format("SHOW TABLES LIKE '%s'", tableName)), tableName);
assertThatThrownBy(() -> computeActual("DESCRIBE " + tableName)).hasMessageContaining(tableName + " is not a Delta Lake table");
hiveMinioDataLake.getHiveHadoop().runOnHive(format("DROP TABLE %s.%s", SCHEMA, tableName));
}
Expand Down Expand Up @@ -445,8 +444,7 @@ public void testCreatePartitionedTableAs()
format("CREATE TABLE " + tableName + " WITH (location = '%s', partitioned_by = ARRAY['regionkey']) AS SELECT name, regionkey, comment from nation",
getLocationForTable(bucketName, tableName)),
25);
assertThat(computeActual("SHOW CREATE TABLE " + tableName).getOnlyValue())
.isInstanceOf(String.class)
assertThat(computeScalar("SHOW CREATE TABLE " + tableName))
.isEqualTo(format(
"CREATE TABLE %s.%s.%s (\n" +
" name varchar,\n" +
Expand Down Expand Up @@ -1718,7 +1716,7 @@ private void fillWithInserts(String tableName, String values, int toCreate)
private void invalidateMetadataCache(String tableName)
{
Set<?> activeFiles = computeActual("SELECT \"$path\" FROM " + tableName).getOnlyColumnAsSet();
String location = (String) computeActual(format("SELECT DISTINCT regexp_replace(\"$path\", '/[^/]*$', '') FROM %s", tableName)).getOnlyValue();
String location = (String) computeScalar(format("SELECT DISTINCT regexp_replace(\"$path\", '/[^/]*$', '') FROM %s", tableName));
assertUpdate("DROP TABLE " + tableName);
assertUpdate(format("CREATE TABLE %s(ignore integer) WITH (location = '%s')", tableName, location));
// sanity check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ public void testDescribeTable()
@Override
public void testShowCreateTable()
{
assertThat((String) computeActual("SHOW CREATE TABLE orders").getOnlyValue())
.matches("CREATE TABLE \\w+\\.\\w+\\.orders \\Q(\n" +
assertThat((String) computeScalar("SHOW CREATE TABLE orders"))
.matches("\\QCREATE TABLE " + DELTA_CATALOG + "." + SCHEMA + ".orders (\n" +
" orderkey bigint,\n" +
" custkey bigint,\n" +
" orderstatus varchar,\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
@Override
public void testShowCreateTable()
{
assertThat((String) computeActual("SHOW CREATE TABLE orders").getOnlyValue())
.matches("CREATE TABLE \\w+\\.\\w+\\.orders \\Q(\n" +
String schema = getSession().getSchema().orElseThrow();
assertThat((String) computeScalar("SHOW CREATE TABLE orders"))
.matches("\\QCREATE TABLE hudi." + schema + ".orders (\n" +
" orderkey bigint,\n" +
" custkey bigint,\n" +
" orderstatus varchar(1),\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ public void testShowColumns()
@Override
public void testShowCreateTable()
{
assertThat((String) computeActual("SHOW CREATE TABLE orders").getOnlyValue())
.matches("CREATE TABLE kudu\\.\\w+\\.orders \\Q(\n" +
assertThat(computeScalar("SHOW CREATE TABLE orders"))
.isEqualTo("CREATE TABLE kudu.default.orders (\n" +
" orderkey bigint COMMENT '' WITH ( nullable = true ),\n" +
" custkey bigint COMMENT '' WITH ( nullable = true ),\n" +
" orderstatus varchar COMMENT '' WITH ( nullable = true ),\n" +
Expand Down Expand Up @@ -243,8 +243,7 @@ public void testShowCreateTable()
" number_of_replicas = 1\n" +
")");

MaterializedResult result = computeActual("SHOW CREATE TABLE test_show_create_table");
String sqlStatement = (String) result.getOnlyValue();
String sqlStatement = (String) computeScalar("SHOW CREATE TABLE test_show_create_table");
String tableProperties = sqlStatement.split("\\)\\s*WITH\\s*\\(")[1];
assertTableProperty(tableProperties, "number_of_replicas", "1");
assertTableProperty(tableProperties, "partition_by_hash_columns", Pattern.quote("ARRAY['id']"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,7 @@ public void testView()
assertUpdate("CREATE OR REPLACE VIEW " + testViewWithComment + " COMMENT 'orders' AS " + query);

// verify comment
MaterializedResult materializedRows = computeActual("SHOW CREATE VIEW " + testViewWithComment);
assertThat((String) materializedRows.getOnlyValue()).contains("COMMENT 'orders'");
assertThat((String) computeScalar("SHOW CREATE VIEW " + testViewWithComment)).contains("COMMENT 'orders'");
assertThat(query(
"SELECT table_name, comment FROM system.metadata.table_comments " +
"WHERE catalog_name = '" + catalogName + "' AND " +
Expand Down Expand Up @@ -950,8 +949,7 @@ public void testMaterializedView()
createTestingMaterializedView(viewWithComment, Optional.of("mv_comment"));

// verify comment
MaterializedResult materializedRows = computeActual("SHOW CREATE MATERIALIZED VIEW " + viewWithComment);
assertThat((String) materializedRows.getOnlyValue()).contains("COMMENT 'mv_comment'");
assertThat((String) computeScalar("SHOW CREATE MATERIALIZED VIEW " + viewWithComment)).contains("COMMENT 'mv_comment'");
assertThat(query(
"SELECT table_name, comment FROM system.metadata.table_comments " +
"WHERE catalog_name = '" + view.getCatalogName() + "' AND " +
Expand Down Expand Up @@ -1271,7 +1269,7 @@ public void testShowCreateView()
viewName);
assertUpdate(ddl);

assertEquals(computeActual("SHOW CREATE VIEW " + viewName).getOnlyValue(), ddl);
assertEquals(computeScalar("SHOW CREATE VIEW " + viewName), ddl);

assertUpdate("DROP VIEW " + viewName);
}
Expand Down Expand Up @@ -1688,19 +1686,23 @@ public void testTableSampleWithFiltering()
@Test
public void testShowCreateTable()
{
assertThat((String) computeActual("SHOW CREATE TABLE orders").getOnlyValue())
String catalog = getSession().getCatalog().orElseThrow();
String schema = getSession().getSchema().orElseThrow();
assertThat(computeScalar("SHOW CREATE TABLE orders"))
// If the connector reports additional column properties, the expected value needs to be adjusted in the test subclass
.matches("CREATE TABLE \\w+\\.\\w+\\.orders \\Q(\n" +
" orderkey bigint,\n" +
" custkey bigint,\n" +
" orderstatus varchar(1),\n" +
" totalprice double,\n" +
" orderdate date,\n" +
" orderpriority varchar(15),\n" +
" clerk varchar(15),\n" +
" shippriority integer,\n" +
" comment varchar(79)\n" +
")");
.isEqualTo(format("""
CREATE TABLE %s.%s.orders (
orderkey bigint,
custkey bigint,
orderstatus varchar(1),
totalprice double,
orderdate date,
orderpriority varchar(15),
clerk varchar(15),
shippriority integer,
comment varchar(79)
)""",
catalog, schema));
}

@Test
Expand Down Expand Up @@ -2709,7 +2711,7 @@ public void testCommentTable()
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_comment_", "(a integer)")) {
// comment set
assertUpdate("COMMENT ON TABLE " + table.getName() + " IS 'new comment'");
assertThat((String) computeActual("SHOW CREATE TABLE " + table.getName()).getOnlyValue()).contains("COMMENT 'new comment'");
assertThat((String) computeScalar("SHOW CREATE TABLE " + table.getName())).contains("COMMENT 'new comment'");
assertThat(getTableComment(catalogName, schemaName, table.getName())).isEqualTo("new comment");
assertThat(query(
"SELECT table_name, comment FROM system.metadata.table_comments " +
Expand Down Expand Up @@ -2747,7 +2749,7 @@ public void testCommentTable()
protected String getTableComment(String catalogName, String schemaName, String tableName)
{
String sql = format("SELECT comment FROM system.metadata.table_comments WHERE catalog_name = '%s' AND schema_name = '%s' AND table_name = '%s'", catalogName, schemaName, tableName);
return (String) computeActual(sql).getOnlyValue();
return (String) computeScalar(sql);
}

@Test
Expand All @@ -2768,7 +2770,7 @@ public void testCommentView()
try (TestView view = new TestView(getQueryRunner()::execute, "test_comment_view", "SELECT * FROM region")) {
// comment set
assertUpdate("COMMENT ON VIEW " + view.getName() + " IS 'new comment'");
assertThat((String) computeActual("SHOW CREATE VIEW " + view.getName()).getOnlyValue()).contains("COMMENT 'new comment'");
assertThat((String) computeScalar("SHOW CREATE VIEW " + view.getName())).contains("COMMENT 'new comment'");
assertThat(getTableComment(catalogName, schemaName, view.getName())).isEqualTo("new comment");

// comment updated
Expand Down Expand Up @@ -2808,7 +2810,7 @@ public void testCommentColumn()
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_comment_column_", "(a integer)")) {
// comment set
assertUpdate("COMMENT ON COLUMN " + table.getName() + ".a IS 'new comment'");
assertThat((String) computeActual("SHOW CREATE TABLE " + table.getName()).getOnlyValue()).contains("COMMENT 'new comment'");
assertThat((String) computeScalar("SHOW CREATE TABLE " + table.getName())).contains("COMMENT 'new comment'");
assertThat(getColumnComment(table.getName(), "a")).isEqualTo("new comment");

// comment updated
Expand All @@ -2829,12 +2831,11 @@ public void testCommentColumn()

protected String getColumnComment(String tableName, String columnName)
{
MaterializedResult materializedResult = computeActual(format(
return (String) computeScalar(format(
"SELECT comment FROM information_schema.columns WHERE table_schema = '%s' AND table_name = '%s' AND column_name = '%s'",
getSession().getSchema().orElseThrow(),
tableName,
columnName));
return (String) materializedResult.getOnlyValue();
}

@Test
Expand Down Expand Up @@ -4274,7 +4275,7 @@ public void testMergeLarge()

assertUpdate(
format("INSERT INTO %s SELECT orderkey, custkey, totalprice FROM tpch.sf1.orders", tableName),
(long) computeActual("SELECT count(*) FROM tpch.sf1.orders").getOnlyValue());
(long) computeScalar("SELECT count(*) FROM tpch.sf1.orders"));

@Language("SQL") String mergeSql = "" +
"MERGE INTO " + tableName + " t USING (SELECT * FROM tpch.sf1.orders) s ON (t.orderkey = s.orderkey)\n" +
Expand Down