-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1466] Filter intersection of tags #1467
base: main
Are you sure you want to change the base?
Changes from all commits
93406f8
676f151
b3cfb1b
a05c4f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -47,6 +47,7 @@ function computeIncludedActionNames( | |||||
|
||||||
const hasActionSelector = runConfig.actions?.length > 0; | ||||||
const hasTagSelector = runConfig.tags?.length > 0; | ||||||
const hasIncludeAllTagsSelector = runConfig.includeAllTags?.valueOf(); | ||||||
|
||||||
// If no selectors, return all actions. | ||||||
if (!hasActionSelector && !hasTagSelector) { | ||||||
|
@@ -64,9 +65,18 @@ function computeIncludedActionNames( | |||||
|
||||||
// Determine actions selected with --tag option and update applicable actions | ||||||
if (hasTagSelector) { | ||||||
allActions | ||||||
.filter(action => action.tags.some(tag => runConfig.tags.includes(tag))) | ||||||
.forEach(action => includedActionNames.add(targetAsReadableString(action.target))); | ||||||
// Keep actions wich include every tags in --tag option | ||||||
if (hasIncludeAllTagsSelector) { | ||||||
allActions | ||||||
.filter(action => runConfig.tags.every(tag => action.tags.includes(tag))) | ||||||
.forEach(action => includedActionNames.add(targetAsReadableString(action.target))); | ||||||
} | ||||||
// Keep actions with include at least one tag in --tag option | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
else { | ||||||
allActions | ||||||
.filter(action => action.tags.some(tag => runConfig.tags.includes(tag))) | ||||||
.forEach(action => includedActionNames.add(targetAsReadableString(action.target))); | ||||||
} | ||||||
} | ||||||
|
||||||
// Compute all transitive dependencies. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ option go_package = "github.com/dataform-co/dataform/protos/dataform"; | |
message RunConfig { | ||
repeated string actions = 1; | ||
repeated string tags = 5; | ||
bool include_all_tags = 10; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "include all" is ambiguous in semantic meaning - IMO something like |
||
bool include_dependencies = 3; | ||
bool include_dependents = 11; | ||
bool full_refresh = 2; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,6 +291,11 @@ suite("@dataform/api", () => { | |
target: { schema: "schema", name: "op_d" }, | ||
tags: ["tag3"], | ||
queries: ["create or replace view schema.someview as select 1 as test"] | ||
}, | ||
{ | ||
target: { schema: "schema", name: "op_e" }, | ||
tags: ["tag1", "tag2"], | ||
queries: ["create or replace view schema.someview as select 1 as test"] | ||
} | ||
], | ||
tables: [ | ||
|
@@ -395,6 +400,23 @@ suite("@dataform/api", () => { | |
expect(actionNames).includes("schema.tab_a"); | ||
}); | ||
|
||
test("prune actions with --tags (with include all tags)", () => { | ||
const prunedGraph = prune(TEST_GRAPH_WITH_TAGS, { | ||
tags: ["tag1", "tag2"], | ||
includeAllTags: true | ||
}); | ||
const actionNames = [ | ||
...prunedGraph.tables.map(action => targetAsReadableString(action.target)), | ||
...prunedGraph.operations.map(action => targetAsReadableString(action.target)) | ||
]; | ||
expect(actionNames).includes("schema.op_e"); | ||
expect(actionNames).includes("schema.tab_a"); | ||
expect(actionNames).not.includes("schema.op_a"); | ||
expect(actionNames).not.includes("schema.op_b"); | ||
expect(actionNames).not.includes("schema.op_c"); | ||
expect(actionNames).not.includes("schema.op_d"); | ||
Comment on lines
+412
to
+417
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be better as |
||
}); | ||
|
||
test("prune actions with --actions with dependencies", () => { | ||
const prunedGraph = prune(TEST_GRAPH, { actions: ["schema.a"], includeDependencies: true }); | ||
const actionNames = [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.