Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test translation of view with namesake column aliases which are differing in case #11240

Merged
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 @@ -664,6 +664,32 @@ public void testViewReferencingHiveAndIcebergTables()
onHive().executeQuery("DROP TABLE default.view_iceberg_table");
}

@Test(groups = HIVE_VIEWS)
public void testViewWithColumnAliasesDifferingInCase()
{
onHive().executeQuery("DROP TABLE IF EXISTS test_hive_namesake_column_name_a");
onHive().executeQuery("DROP TABLE IF EXISTS test_hive_namesake_column_name_b");
findinpath marked this conversation as resolved.
Show resolved Hide resolved
onHive().executeQuery("CREATE TABLE test_hive_namesake_column_name_a(some_id string)");
onHive().executeQuery("CREATE TABLE test_hive_namesake_column_name_b(SOME_ID string)");
onHive().executeQuery("INSERT INTO TABLE test_hive_namesake_column_name_a VALUES ('hive')");
onHive().executeQuery("INSERT INTO TABLE test_hive_namesake_column_name_b VALUES (' hive ')");

onHive().executeQuery("DROP VIEW IF EXISTS test_namesake_column_names_view");
onHive().executeQuery("" +
"CREATE VIEW test_namesake_column_names_view AS \n" +
" SELECT a.some_id FROM test_hive_namesake_column_name_a a \n" +
" LEFT JOIN (SELECT trim(SOME_ID) AS SOME_ID FROM test_hive_namesake_column_name_b) b \n" +
" ON a.some_id = b.some_id \n" +
" WHERE a.some_id != ''");
assertViewQuery(
"SELECT * FROM test_namesake_column_names_view",
queryAssert -> queryAssert.containsOnly(row("hive")));

onHive().executeQuery("DROP TABLE test_hive_namesake_column_name_a");
onHive().executeQuery("DROP TABLE test_hive_namesake_column_name_b");
onHive().executeQuery("DROP VIEW test_namesake_column_names_view");
}

protected static void assertViewQuery(String query, Consumer<QueryAssert> assertion)
{
// Ensure Hive and Presto view compatibility by comparing the results
Expand Down