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

Add session date param; fix checks CLI bug #4579

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions bigquery_etl/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ def paths_matching_checks_pattern(
pattern, sql_path, project_id, ["checks.sql"], CHECKS_FILE_RE
)

for checks_file in checks_files:
match = CHECKS_FILE_RE.match(str(checks_file))
if match:
project = match.group(1)
dataset = match.group(2)
table = match.group(3)
yield checks_file, project, dataset, table
if checks_files:
for checks_file in checks_files:
match = CHECKS_FILE_RE.match(str(checks_file))
if match:
project = match.group(1)
dataset = match.group(2)
table = match.group(3)
yield checks_file, project, dataset, table
Comment on lines +90 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
if checks_files:
for checks_file in checks_files:
match = CHECKS_FILE_RE.match(str(checks_file))
if match:
project = match.group(1)
dataset = match.group(2)
table = match.group(3)
yield checks_file, project, dataset, table
if not checks_files:
print(f"No checks.sql file found in {sql_path}/{project_id}/{pattern}")
return
for checks_file in checks_files:
match = CHECKS_FILE_RE.match(str(checks_file))
if match:
project = match.group(1)
dataset = match.group(2)
table = match.group(3)
yield checks_file, project, dataset, table

(and remove lines 98-99)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early returns hurt my functional programming core 😩

else:
print(f"No checks.sql file found in {sql_path}/{project_id}/{pattern}")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#fail
-- ga_session_id should be unique across all partitions
{{ is_unique(["ga_session_id"]) }}
{{ is_unique(["ga_session_id"], "session_date = @session_date") }}

#fail
{{ min_row_count(10000) }}
{{ min_row_count(100, "session_date = @session_date") }}