Skip to content

Commit 084db72

Browse files
committed
[run-tests] Dryrun get query and table schema
1 parent f44c150 commit 084db72

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

bigquery_etl/dryrun.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ def validate_schema(self):
570570
return True
571571

572572
query_file_path = Path(self.sqlfile)
573+
table_name = query_file_path.parent.name
574+
dataset_name = query_file_path.parent.parent.name
575+
project_name = query_file_path.parent.parent.parent.name
576+
self.project = project_name
577+
self.dataset = dataset_name
578+
self.table = table_name
579+
573580
query_schema = Schema.from_json(self.get_schema())
574581
if self.errors():
575582
# ignore file when there are errors that self.get_schema() did not raise
@@ -581,27 +588,7 @@ def validate_schema(self):
581588
click.echo(f"No schema file defined for {query_file_path}", err=True)
582589
return True
583590

584-
table_name = query_file_path.parent.name
585-
dataset_name = query_file_path.parent.parent.name
586-
project_name = query_file_path.parent.parent.parent.name
587-
588-
partitioned_by = None
589-
if (
590-
self.metadata
591-
and self.metadata.bigquery
592-
and self.metadata.bigquery.time_partitioning
593-
):
594-
partitioned_by = self.metadata.bigquery.time_partitioning.field
595-
596-
table_schema = Schema.for_table(
597-
project_name,
598-
dataset_name,
599-
table_name,
600-
client=self.client,
601-
id_token=self.id_token,
602-
partitioned_by=partitioned_by,
603-
filename=basename(self.sqlfile),
604-
)
591+
table_schema = Schema.from_json(self.get_table_schema())
605592

606593
# This check relies on the new schema being deployed to prod
607594
if not query_schema.compatible(table_schema):

0 commit comments

Comments
 (0)