Skip to content

feat(cli): add intersection matching for tag selectors - #2492

Open
dmargol1 wants to merge 1 commit into
dataform-co:mainfrom
dmargol1:feat/tags-intersection
Open

dmargol1 wants to merge 1 commit into
dataform-co:mainfrom
dmargol1:feat/tags-intersection

Conversation

@dmargol1

Copy link
Copy Markdown
Contributor

Closes #1466.

dataform run --tags A,B selects actions tagged A or B. This adds --tags-intersection, which selects only actions that carry every listed tag. Union matching stays the default. compile gets the matching --output-tags-intersection option, so a selection can be checked before running it.

dataform run <project-dir> --tags A,B --tags-intersection
dataform compile <project-dir> --output-tags A,B --output-tags-intersection --json

This continues #1467 and #1968. Thanks to @AnOtterGithubUser and @zsomborkincses. The flag name follows the suggestion in the review of #1968.

Only tag matching changes. The rest of selection works as before:

  • Actions given with --actions (or --output-actions) are still added to the tag matches.
  • --include-deps and --include-dependents expand that combined selection. Expanded actions don't need the tags.
  • Using the flag without any tags, or with an empty tag (for example from a trailing comma in --tags A,), is an error. Union mode is unchanged: it still accepts empty entries.
  • If nothing matches, nothing is selected, and the command still succeeds, as an unmatched --tags does today.

RunConfig gets a new field, tags_intersection = 12. The managed service's InvocationConfig has no equivalent option, and this PR doesn't change that.

Testing

  • tests/api/prune.spec.ts covers:

    • intersection vs the unchanged union default
    • a single tag
    • a tag no action has
    • literal matching (including "")
    • --actions combined with the intersection
    • --include-deps and --include-dependents expanding from the intersection

    With only the prune.ts change reverted, 6 of the 8 tests fail. The other 2 guard the unchanged union default and single-tag behavior.

  • cli/index_compile_test.ts and cli/index_project_test.ts cover the flags for compile and run, including rejecting missing or empty tags. These checks happen while parsing arguments, so they don't need BigQuery.

  • cli/index_run_e2e_test.ts adds a run --build-only --json integration test (no tables created). I ran it, along with the existing golden-path test, against my own project.

./scripts/run_tests and ./scripts/lint pass. cli/README.md was regenerated with bazel run //cli:update_readme.

🤖 Generated with Claude Code

@dmargol1
dmargol1 requested a review from a team as a code owner November 25, 2026 06:07
@dmargol1
dmargol1 requested review from kolina and removed request for a team November 25, 2026 06:07
@apilaskowski
apilaskowski requested review from rafal-hawrylak and removed request for kolina November 25, 2026 15:17
Add --tags-intersection to run and --output-tags-intersection to compile, so
--tags selects only actions that carry every listed tag. Union matching stays the
default. Actions given with --actions are still added, and dependency expansion
applies to the combined selection. The flags reject missing or empty tags.

Closes dataform-co#1466.
@dmargol1
dmargol1 force-pushed the feat/tags-intersection branch from c768b56 to 634b0f7 Compare November 28, 2026 02:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dataform cli filtering union of tags and not intersection

2 participants