Skip to content

Commit 2fe741a

Browse files
committed
fix(test-validation): detect missing columns in Dupe_Rows test
1 parent 1f6ad69 commit 2fe741a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

testgen/commands/queries/test_parameter_validation_query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def _get_query(self, template_file_name: str, sub_directory: str | None = "valid
3535
"CAT_TEST_IDS": tuple(self.test_ids or []),
3636
"START_TIME": self.today,
3737
"NOW_TIMESTAMP": date_service.get_now_as_string(),
38-
"COLUMNS_TABLE": f"{self.tg_schema}.INFORMATION_SCHEMA.COLUMNS" if self.flavor == "bigquery" else "information_schema.columns"
38+
"COLUMNS_TABLE": f"{self.tg_schema}.INFORMATION_SCHEMA.COLUMNS" if self.flavor == "bigquery" else "information_schema.columns",
39+
"ID_SEPARATOR": "`" if self.flavor in ("databricks", "bigquery") else '"',
3940
}
4041
query = replace_params(query, params)
4142
return query, params

testgen/template/validate_tests/ex_get_test_column_list_tg.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
SELECT cat_test_id,
1818
schema_name AS schema_name,
1919
table_name AS table_name,
20-
TRIM(UNNEST(STRING_TO_ARRAY(column_name, ','))) as column_name
20+
TRIM(TRIM(UNNEST(STRING_TO_ARRAY(column_name, ','))), '{ID_SEPARATOR}') as column_name
2121
FROM test_definitions d
2222
INNER JOIN test_types t
2323
ON d.test_type = t.test_type
@@ -26,23 +26,23 @@
2626
AND t.test_scope = 'referential'
2727
AND t.test_type NOT LIKE 'Aggregate_%'
2828
UNION
29-
-- FROM: groupby_names (should be referential)
29+
-- FROM: groupby_names
3030
SELECT cat_test_id,
3131
schema_name AS schema_name,
3232
table_name AS table_name,
33-
TRIM(UNNEST(STRING_TO_ARRAY(groupby_names, ','))) as column_name
33+
TRIM(TRIM(UNNEST(STRING_TO_ARRAY(groupby_names, ','))), '{ID_SEPARATOR}') as column_name
3434
FROM test_definitions d
3535
INNER JOIN test_types t
3636
ON d.test_type = t.test_type
3737
WHERE test_suite_id = :TEST_SUITE_ID
3838
AND COALESCE(test_active, 'Y') = 'Y'
39-
AND t.test_scope IN ('column', 'referential')
39+
AND t.test_scope IN ('column', 'referential', 'table')
4040
UNION
4141
-- FROM: window_date_column (referential)
4242
SELECT cat_test_id,
4343
schema_name AS schema_name,
4444
table_name AS table_name,
45-
TRIM(UNNEST(STRING_TO_ARRAY(window_date_column, ','))) as column_name
45+
TRIM(TRIM(UNNEST(STRING_TO_ARRAY(window_date_column, ','))), '{ID_SEPARATOR}') as column_name
4646
FROM test_definitions d
4747
INNER JOIN test_types t
4848
ON d.test_type = t.test_type
@@ -54,7 +54,7 @@
5454
SELECT cat_test_id,
5555
match_schema_name AS schema_name,
5656
match_table_name AS table_name,
57-
TRIM(UNNEST(STRING_TO_ARRAY(match_column_names, ','))) as column_name
57+
TRIM(TRIM(UNNEST(STRING_TO_ARRAY(match_column_names, ','))), '{ID_SEPARATOR}') as column_name
5858
FROM test_definitions d
5959
INNER JOIN test_types t
6060
ON d.test_type = t.test_type
@@ -67,7 +67,7 @@
6767
SELECT cat_test_id,
6868
match_schema_name AS schema_name,
6969
match_table_name AS table_name,
70-
TRIM(UNNEST(STRING_TO_ARRAY(match_groupby_names, ','))) as column_name
70+
TRIM(TRIM(UNNEST(STRING_TO_ARRAY(match_groupby_names, ','))), '{ID_SEPARATOR}') as column_name
7171
FROM test_definitions d
7272
INNER JOIN test_types t
7373
ON d.test_type = t.test_type

0 commit comments

Comments
 (0)