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 @@ -2535,6 +2535,55 @@ void testDereferencePushdownWithNestedFieldsIncludingArrays()
deleteIndex(tableName);
}

@Test
public void testWildcardTableSameSchema()
throws IOException
{
String suffix = randomNameSuffix();
String firstIndex = format("test_wildcard_%s_1", suffix);
String secondIndex = format("test_wildcard_%s_2", suffix);
String wildcardTable = format("test_wildcard_%s_*", suffix);

String mappings =
"""
{
"properties": {
"long_column": { "type": "long" },
"text_column": { "type": "text" }
}
}
""";

createIndex(firstIndex, mappings);
index(firstIndex, ImmutableMap.<String, Object>builder()
.put("long_column", 1L)
.put("text_column", "Trino")
.buildOrThrow());
createIndex(secondIndex, mappings);
index(secondIndex, ImmutableMap.<String, Object>builder()
.put("long_column", 2L)
.put("text_column", "rocks")
.buildOrThrow());

try {
assertThat(query("DESCRIBE \"" + wildcardTable + "\""))
.skippingTypesCheck()
.matches( "VALUES ('long_column', 'bigint', '', ''), ('text_column', 'varchar', '', '')");
assertThat(query("SELECT * FROM \"" + wildcardTable + "\""))
.matches("VALUES (BIGINT '1', VARCHAR 'Trino'), (BIGINT '2', VARCHAR 'rocks')");

// Unsupported operations
assertQueryFails("DROP TABLE \"" + wildcardTable + "\"", "This connector does not support dropping tables");
assertQueryFails("INSERT INTO \"" + wildcardTable + "\" VALUES (3, 'SQL')", "This connector does not support inserts");
assertQueryFails("ALTER TABLE \"" + wildcardTable + "\" ADD COLUMN new_column INT", "This connector does not support adding columns");
assertQueryFails("ALTER TABLE \"" + wildcardTable + "\" RENAME TO new_wildcard_table", "This connector does not support renaming tables");
Comment thread
ebyhr marked this conversation as resolved.
Outdated
}
finally {
deleteIndex(firstIndex);
deleteIndex(secondIndex);
}
}

protected void assertTableDoesNotExist(String name)
{
String catalogName = getSession().getCatalog().orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,55 @@ public void testDereferencePushdownWithNestedFieldsIncludingArrays()
deleteIndex(tableName);
}

@Test
public void testWildcardTableSameSchema()
throws IOException
{
String suffix = randomNameSuffix();
String firstIndex = format("test_wildcard_%s_1", suffix);
String secondIndex = format("test_wildcard_%s_2", suffix);
String wildcardTable = format("test_wildcard_%s_*", suffix);

String mappings =
"""
{
"properties": {
"long_column": { "type": "long" },
"text_column": { "type": "text" }
}
}
""";

createIndex(firstIndex, mappings);
index(firstIndex, ImmutableMap.<String, Object>builder()
.put("long_column", 1L)
.put("text_column", "Trino")
.buildOrThrow());
createIndex(secondIndex, mappings);
index(secondIndex, ImmutableMap.<String, Object>builder()
.put("long_column", 2L)
.put("text_column", "rocks")
.buildOrThrow());

try {
assertThat(query("DESCRIBE \"" + wildcardTable + "\""))
.skippingTypesCheck()
.matches("VALUES ('long_column', 'bigint', '', ''), ('text_column', 'varchar', '', '')");
assertThat(query("SELECT * FROM \"" + wildcardTable + "\""))
.matches("VALUES (BIGINT '1', VARCHAR 'Trino'), (BIGINT '2', VARCHAR 'rocks')");

// Unsupported operations
assertQueryFails("DROP TABLE \"" + wildcardTable + "\"", "This connector does not support dropping tables");
assertQueryFails("INSERT INTO \"" + wildcardTable + "\" VALUES (3, 'SQL')", "This connector does not support inserts");
assertQueryFails("ALTER TABLE \"" + wildcardTable + "\" ADD COLUMN new_column INT", "This connector does not support adding columns");
assertQueryFails("ALTER TABLE \"" + wildcardTable + "\" RENAME TO new_wildcard_table", "This connector does not support renaming tables");
Comment thread
ebyhr marked this conversation as resolved.
Outdated
}
finally {
deleteIndex(firstIndex);
deleteIndex(secondIndex);
}
}

protected void assertTableDoesNotExist(String name)
{
String catalogName = getSession().getCatalog().orElseThrow();
Expand Down