Skip to content

Commit cc1c4ff

Browse files
committed
[run-tests] undo schema changes
1 parent dec49ec commit cc1c4ff

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

bigquery_etl/dryrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def _get_cached_table_metadata(self, table_identifier, ttl_seconds=None):
318318
with open(cache_file, "rb") as f:
319319
cached_data = pickle.load(f)
320320
return cached_data
321-
except (pickle.PickleError, EOFError, OSError) as e:
321+
except (pickle.PickleError, EOFError, OSError):
322322
return None
323323
return None
324324

bigquery_etl/schema/__init__.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from google.cloud.bigquery import SchemaField
1414

1515
from .. import dryrun
16-
from ..config import ConfigLoader
1716

1817
SCHEMA_FILE = "schema.yaml"
1918

@@ -59,28 +58,24 @@ def from_json(cls, json_schema):
5958
return cls(json_schema)
6059

6160
@classmethod
62-
def for_table(
63-
cls,
64-
project,
65-
dataset,
66-
table,
67-
partitioned_by=None,
68-
filename="query.sql",
69-
*args,
70-
**kwargs,
71-
):
61+
def for_table(cls, project, dataset, table, partitioned_by=None, *args, **kwargs):
7262
"""Get the schema for a BigQuery table."""
63+
query = f"SELECT * FROM `{project}.{dataset}.{table}`"
64+
65+
if partitioned_by:
66+
query += f" WHERE DATE(`{partitioned_by}`) = DATE('2020-01-01')"
67+
7368
try:
74-
sql_dir = ConfigLoader.get("default", "sql_dir")
7569
return cls(
7670
dryrun.DryRun(
77-
os.path.join(sql_dir, project, dataset, table, filename),
71+
os.path.join(project, dataset, table, "query.sql"),
72+
query,
7873
project=project,
7974
dataset=dataset,
8075
table=table,
8176
*args,
8277
**kwargs,
83-
).get_table_schema()
78+
).get_schema()
8479
)
8580
except Exception as e:
8681
print(f"Cannot get schema for {project}.{dataset}.{table}: {e}")

bigquery_etl/schema/stable_table_schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def prod_schemas_uri():
7171
with the most recent production schemas deploy.
7272
"""
7373
dryrun = DryRun(
74-
"moz-fx-data-shared-prod/telemetry_derived/foo/query.sql", content="SELECT 1", use_cache=False
74+
"moz-fx-data-shared-prod/telemetry_derived/foo/query.sql",
75+
content="SELECT 1",
76+
use_cache=False,
7577
)
7678
build_id = dryrun.get_dataset_labels()["schemas_build_id"]
7779
commit_hash = build_id.split("_")[-1]

tests/test_dryrun.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import os
2-
import tempfile
3-
import time
4-
from unittest import mock
52

63
import pytest
74

0 commit comments

Comments
 (0)