Skip to content

Commit 64caca2

Browse files
authored
[DENG-10379] Add --skip-existing option to updating schemas (#8648)
1 parent 51c89cd commit 64caca2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

bigquery_etl/cli/query.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,13 @@ def schema():
19431943
is_flag=True,
19441944
default=False,
19451945
)
1946+
@click.option(
1947+
"--skip_existing",
1948+
"--skip-existing",
1949+
help="Skip updating schemas for existing schema files.",
1950+
is_flag=True,
1951+
default=False,
1952+
)
19461953
def update(
19471954
name,
19481955
sql_dir,
@@ -1955,6 +1962,7 @@ def update(
19551962
is_init,
19561963
use_dataset_schema,
19571964
use_global_schema,
1965+
skip_existing,
19581966
):
19591967
"""CLI command for generating the query schema."""
19601968
if not is_authenticated():
@@ -1975,7 +1983,12 @@ def update(
19751983
for query_file in query_files
19761984
if str(query_file)
19771985
not in ConfigLoader.get("schema", "deploy", "skip", fallback=[])
1986+
and (not skip_existing or (query_file.parent / SCHEMA_FILE).exists() is False)
19781987
]
1988+
1989+
if len(query_files) == 0:
1990+
return
1991+
19791992
dependency_graph = get_dependency_graph([sql_dir], without_views=True)
19801993
manager = multiprocessing.Manager()
19811994
tmp_tables = manager.dict({})

0 commit comments

Comments
 (0)