Skip to content

Commit 285bc11

Browse files
committed
Chore: clean up bigquery info. schema integration test
1 parent 6921468 commit 285bc11

1 file changed

Lines changed: 9 additions & 49 deletions

File tree

tests/core/engine_adapter/integration/test_integration_bigquery.py

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ def test_information_schema_view_external_model(ctx: TestContext, tmp_path: Path
204204
# This representation is produced by BigQuery's parser, so that the mapping schema
205205
# nesting depth is consistent with other table references in a project, which will
206206
# usually look like `project.dataset.table`.
207-
information_schema_tables_view = ctx.table("INFORMATION_SCHEMA.TABLES")
208-
assert len(information_schema_tables_view.parts) == 3
207+
information_schema_tables = ctx.table("INFORMATION_SCHEMA.TABLES")
208+
assert len(information_schema_tables.parts) == 3
209209

210210
model_name = ctx.table("test")
211-
dependency = f"`{'.'.join(part.name for part in information_schema_tables_view.parts)}`"
211+
dependency = f"`{'.'.join(part.name for part in information_schema_tables.parts)}`"
212212

213213
init_example_project(tmp_path, dialect="bigquery", template=ProjectTemplate.EMPTY)
214214
with open(tmp_path / "models" / "test.sql", "w", encoding="utf-8") as f:
@@ -231,60 +231,20 @@ def _mutate_config(_: str, config: Config) -> None:
231231
sqlmesh.create_external_models()
232232
sqlmesh.load()
233233

234-
assert sqlmesh.get_model(information_schema_tables_view.sql()).columns_to_types == {
234+
actual_columns_to_types = sqlmesh.get_model(information_schema_tables.sql()).columns_to_types
235+
expected_columns_to_types = {
235236
"table_catalog": exp.DataType.build("TEXT"),
236237
"table_schema": exp.DataType.build("TEXT"),
237238
"table_name": exp.DataType.build("TEXT"),
238239
"table_type": exp.DataType.build("TEXT"),
239-
"is_insertable_into": exp.DataType.build("TEXT"),
240-
"is_typed": exp.DataType.build("TEXT"),
241-
"creation_time": exp.DataType.build("TIMESTAMPTZ"),
242-
"base_table_catalog": exp.DataType.build("TEXT"),
243-
"base_table_schema": exp.DataType.build("TEXT"),
244-
"base_table_name": exp.DataType.build("TEXT"),
245-
"snapshot_time_ms": exp.DataType.build("TIMESTAMPTZ"),
246-
"ddl": exp.DataType.build("TEXT"),
247-
"default_collation_name": exp.DataType.build("TEXT"),
248-
"upsert_stream_apply_watermark": exp.DataType.build("TIMESTAMPTZ"),
249-
"replica_source_catalog": exp.DataType.build("TEXT"),
250-
"replica_source_schema": exp.DataType.build("TEXT"),
251-
"replica_source_name": exp.DataType.build("TEXT"),
252-
"replication_status": exp.DataType.build("TEXT"),
253-
"replication_error": exp.DataType.build("TEXT"),
254-
"is_change_history_enabled": exp.DataType.build("TEXT"),
255-
"sync_status": exp.DataType.build(
256-
"STRUCT<last_completion_time TIMESTAMPTZ, error_time TIMESTAMPTZ, error STRUCT<reason TEXT, location TEXT, message TEXT>>"
257-
),
258240
}
259241

242+
assert actual_columns_to_types is not None
243+
assert actual_columns_to_types.items() >= expected_columns_to_types.items()
244+
260245
rendered_query = sqlmesh.get_model(model_name.sql()).render_query()
261246
assert isinstance(rendered_query, exp.Query)
262-
263-
assert rendered_query.sql("bigquery", pretty=True) == (
264-
"SELECT\n"
265-
" `tables`.`table_catalog` AS `table_catalog`,\n"
266-
" `tables`.`table_schema` AS `table_schema`,\n"
267-
" `tables`.`table_name` AS `table_name`,\n"
268-
" `tables`.`table_type` AS `table_type`,\n"
269-
" `tables`.`is_insertable_into` AS `is_insertable_into`,\n"
270-
" `tables`.`is_typed` AS `is_typed`,\n"
271-
" `tables`.`creation_time` AS `creation_time`,\n"
272-
" `tables`.`base_table_catalog` AS `base_table_catalog`,\n"
273-
" `tables`.`base_table_schema` AS `base_table_schema`,\n"
274-
" `tables`.`base_table_name` AS `base_table_name`,\n"
275-
" `tables`.`snapshot_time_ms` AS `snapshot_time_ms`,\n"
276-
" `tables`.`ddl` AS `ddl`,\n"
277-
" `tables`.`default_collation_name` AS `default_collation_name`,\n"
278-
" `tables`.`upsert_stream_apply_watermark` AS `upsert_stream_apply_watermark`,\n"
279-
" `tables`.`replica_source_catalog` AS `replica_source_catalog`,\n"
280-
" `tables`.`replica_source_schema` AS `replica_source_schema`,\n"
281-
" `tables`.`replica_source_name` AS `replica_source_name`,\n"
282-
" `tables`.`replication_status` AS `replication_status`,\n"
283-
" `tables`.`replication_error` AS `replication_error`,\n"
284-
" `tables`.`is_change_history_enabled` AS `is_change_history_enabled`,\n"
285-
" `tables`.`sync_status` AS `sync_status`\n"
286-
f"FROM {dependency} AS `tables`"
287-
)
247+
assert not rendered_query.selects[0].is_star
288248

289249

290250
def test_compare_nested_values_in_table_diff(ctx: TestContext):

0 commit comments

Comments
 (0)