Repository navigation
feat(cli): add --dry-run to views create-all - #641
Open
leninworld wants to merge 1 commit into
Open
leninworld wants to merge 1 commit into
leninworld wants to merge 1 commit into
Conversation
Part of GoogleCloudPlatform#638. ViewManager.plan_all_views() returns the ordered plan that create_all_views() follows; views create-all --dry-run prints it without creating a BigQuery client.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses part of issue #638 (the
--dry-runprerequisite, acceptance criterion 1).Part of #638
Summary
bq-agent-sdk views create-allsubmitsCREATE OR REPLACE VIEWjobs straight away, so a setup guide (or a person) can't see what it will do before it changes BigQuery. On #638, @caohy1988 agreed to a small--dry-runPR first: "Preview and apply should share one ordered plan, and a test should confirm the preview never creates a BigQuery client."What changed
views.py:ViewManager._view_plan(): runs the registry collision check and returns the ordered(key, denied_columns)list, per-event views first, then cross-event views. It renders no SQL and never touches the client.ViewManager.plan_all_views(): builds one entry per view from_view_plan()withkey,name,target(project.dataset.view), the renderedsqlanddenied_columns(non-empty meanscreate_all_views()skips it).create_all_views()now loops over_view_plan(). The loop body is unchanged: skipped views get the same warning, and each view still goes throughcreate_view()inside the per-viewtry, so one view that fails to render or create is logged and the others still deploy.cli.py:views create-all --dry-runbuilds theViewManagerthe same way (an invalid--denied-columnstill exits 2), prints the plan and creates nothing. JSON and text output givedry_run,created: false,action: "CREATE OR REPLACE VIEW",views(with SQL) andskipped.--format tableprints one row per view (key, name, target, action, denied columns) without the SQL.ViewManagersection and CLI reference) and a CHANGELOG[Unreleased]entry.Tests
tests/test_views.py: the plan lists every registered key in order withget_view_sql()/get_view_name()/ target values;create_all_views()issues its queries in plan order; the denied-column fixture skips exactly the expected set andcreate_view()refuses each skipped key;plan_all_views()never callsmake_bq_client; a view whose SQL fails to render is left out while the rest are still created.tests/test_cli.py:views create-all --dry-runruns end to end with the realViewManagerwhilemake_bq_clientis patched to fail, exits 0, never creates a client and lists every view in plan order withCREATE OR REPLACE VIEWSQL;--dry-run --denied-column=attributesreports the skipped views;--dry-run --denied-column=bogusexits 2;--format tablegives one row per view and no SQL.main; the render-failure test passes on both, since it pins the behaviour this change keeps.pytest -q -n 8 tests: 12,316 passed, 93 skipped (rebased on currentmain).pyink --config pyproject.toml --checkandisort --check-onlypass on the touched Python files.Limits
--dry-runprerequisite. The skill itself, the Streamlit walkthrough and the README links from Feature request: Agent Skill for end-to-end BQAA SDK & dashboard setup #638 are not in this PR.create-allwould submit; it doesn't check whether the views already exist or whether the caller has permission to create them.views create(one view) has no--dry-runyet.