Have `bqetl query` commands fail if they don't find a matching query (#4662)
* Have `bqetl query` commands fail if they don't find a matching query. * Update `test_run_query_no_query_file` test.
This commit is contained in:
Родитель
25c18112b5
Коммит
308822d7cf
|
@ -426,6 +426,8 @@ def info(ctx, name, sql_dir, project_id, cost, last_updated):
|
|||
ignore=["derived_view_schemas", "stable_views"],
|
||||
)
|
||||
query_files = paths_matching_name_pattern(name, ctx.obj["TMP_DIR"], project_id)
|
||||
if query_files == []:
|
||||
raise click.ClickException(f"No queries matching `{name}` were found.")
|
||||
|
||||
for query_file in query_files:
|
||||
query_file_path = Path(query_file)
|
||||
|
@ -719,6 +721,8 @@ def backfill(
|
|||
ignore=["derived_view_schemas", "stable_views", "country_code_lookup"],
|
||||
)
|
||||
query_files = paths_matching_name_pattern(name, ctx.obj["TMP_DIR"], project_id)
|
||||
if query_files == []:
|
||||
raise click.ClickException(f"No queries matching `{name}` were found.")
|
||||
|
||||
for query_file in query_files:
|
||||
query_file_path = Path(query_file)
|
||||
|
@ -895,6 +899,8 @@ def run(
|
|||
ignore=["derived_view_schemas", "stable_views", "country_code_lookup"],
|
||||
)
|
||||
query_files = paths_matching_name_pattern(name, ctx.obj["TMP_DIR"], project_id)
|
||||
if query_files == []:
|
||||
raise click.ClickException(f"No queries matching `{name}` were found.")
|
||||
|
||||
_run_query(
|
||||
query_files,
|
||||
|
@ -1992,6 +1998,8 @@ def deploy(
|
|||
query_files = paths_matching_name_pattern(
|
||||
name, ctx.obj["TMP_DIR"], project_id, ["query.*"]
|
||||
)
|
||||
if not query_files:
|
||||
raise click.ClickException(f"No queries matching `{name}` were found.")
|
||||
|
||||
def _deploy(query_file):
|
||||
if respect_dryrun_skip and str(query_file) in DryRun.skipped_files():
|
||||
|
@ -2253,6 +2261,8 @@ def validate_schema(
|
|||
ignore=["derived_view_schemas", "stable_views"],
|
||||
)
|
||||
query_files = paths_matching_name_pattern(name, ctx.obj["TMP_DIR"], project_id)
|
||||
if query_files == []:
|
||||
raise click.ClickException(f"No queries matching `{name}` were found.")
|
||||
|
||||
_validate_schema = partial(
|
||||
_validate_schema_from_path,
|
||||
|
|
|
@ -131,5 +131,10 @@ class TestEntrypoint:
|
|||
|
||||
@pytest.mark.integration
|
||||
def test_run_query_no_query_file(self):
|
||||
result = subprocess.check_output([ENTRYPOINT_SCRIPT, "query"])
|
||||
assert b"No files matching:" in result
|
||||
with pytest.raises(subprocess.CalledProcessError) as e:
|
||||
subprocess.run(
|
||||
[ENTRYPOINT_SCRIPT, "query"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
assert b"No queries matching" in e.value.stderr
|
||||
|
|
Загрузка…
Ссылка в новой задаче