Add session date param; fix checks CLI bug (#4579)

* Fix checks to filter on partitions

* Don't print "missing checks file" on success

Previously, the statement that checks.sql files
were missing was printed on any execution of the for
statement. ("else" clauses after "for"s execute after
completion of the "for" clause).

Instead, we want to print only when there are no files.
This commit is contained in:
Frank Bertsch 2023-11-17 15:33:23 -05:00 коммит произвёл GitHub
Родитель 1fe5f2d095
Коммит 5cf8d30153
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -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
else:
print(f"No checks.sql file found in {sql_path}/{project_id}/{pattern}")

Просмотреть файл

@ -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") }}