Skip to content

Commit f48654c

Browse files
OwenKephartDagster Devtools
authored andcommitted
[hg] update ui asset selection (#24666)
## Summary & Motivation ## Test Plan ## Changelog > The changelog is generated by an agent that examines merged PRs and > summarizes/categorizes user-facing changes. You can optionally replace > this text with a terse description of any user-facing changes in your PR, > which the agent will prioritize. Otherwise, delete this section. Internal-RevId: 2cc4a63c574afa393f4da495fe564d548dde91e7
1 parent ef028e9 commit f48654c

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

js_modules/ui-core/src/asset-selection/__tests__/AntlrAssetSelection.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,46 @@ describe('parseAssetSelectionQuery', () => {
176176
assertQueryResult('group:my_group', ['C']);
177177
});
178178

179+
it('should parse hierarchical group wildcards', () => {
180+
const HIERARCHICAL_GRAPH: AssetGraphQueryItem[] = [
181+
{
182+
name: 'top',
183+
node: buildAssetNode({groupName: 'marketing'}),
184+
inputs: [{dependsOn: []}],
185+
outputs: [{dependedBy: []}],
186+
},
187+
{
188+
name: 'mid',
189+
node: buildAssetNode({groupName: 'marketing/email'}),
190+
inputs: [{dependsOn: []}],
191+
outputs: [{dependedBy: []}],
192+
},
193+
{
194+
name: 'deep',
195+
node: buildAssetNode({groupName: 'marketing/email/campaign'}),
196+
inputs: [{dependsOn: []}],
197+
outputs: [{dependedBy: []}],
198+
},
199+
{
200+
name: 'sibling',
201+
node: buildAssetNode({groupName: 'sales'}),
202+
inputs: [{dependsOn: []}],
203+
outputs: [{dependedBy: []}],
204+
},
205+
];
206+
const run = (query: string) => {
207+
const result = parseAssetSelectionQuery(HIERARCHICAL_GRAPH, query);
208+
if (result instanceof Error) {
209+
throw result;
210+
}
211+
return new Set(result.all.map((a) => a.name));
212+
};
213+
expect(run('group:marketing')).toEqual(new Set(['top']));
214+
expect(run('group:"marketing/*"')).toEqual(new Set(['mid', 'deep']));
215+
expect(run('group:"marketing*"')).toEqual(new Set(['top', 'mid', 'deep']));
216+
expect(run('group:"*email*"')).toEqual(new Set(['mid', 'deep']));
217+
});
218+
179219
it('should parse kind query', () => {
180220
assertQueryResult('kind:python', ['B']);
181221
assertQueryResult('kind:snowflake', ['B']);

js_modules/ui-core/src/shared/asset-selection/AntlrAssetSelectionVisitor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ export class AntlrAssetSelectionVisitor
231231
const valueCtx = ctx.value();
232232
const value = valueCtx ? getValue(valueCtx) : '';
233233
const isNull = valueCtx ? isNullValue(valueCtx) : false;
234+
const isWildcard = value.includes('*');
235+
const regex = isWildcard
236+
? new RegExp(`^${escapeRegExp(value).replaceAll('\\*', '.*')}$`)
237+
: null;
234238
return new Set(
235239
[...this.all_assets].filter((i) => {
236240
if (i.node.groupName) {
237-
return i.node.groupName === value;
241+
return regex ? regex.test(i.node.groupName) : i.node.groupName === value;
238242
}
239243
return isNull;
240244
}),

0 commit comments

Comments
 (0)