Skip to content
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

[1/3][Asset Selection] Remove key_substring + support wildcards in key: #27720

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ functionName: SINKS | ROOTS;

// Attribute expressions for specific attributes
attributeExpr:
KEY COLON value # KeyExpr
| KEY_SUBSTRING COLON value # KeySubstringExpr
KEY COLON keyValue # KeyExpr
| TAG COLON value (EQUAL value)? # TagAttributeExpr
| OWNER COLON value # OwnerAttributeExpr
| GROUP COLON value # GroupAttributeExpr
Expand All @@ -44,6 +43,10 @@ EQUAL: '=';

// Value can be a quoted or unquoted string
value: QUOTED_STRING | UNQUOTED_STRING;
keyValue:
QUOTED_STRING
| UNQUOTED_STRING
| UNQUOTED_REGEX_STRING;

// Operators and keywords
AND: 'and';
Expand All @@ -64,7 +67,6 @@ COMMA: ',';

// Attributes
KEY: 'key';
KEY_SUBSTRING: 'key_substring';
OWNER: 'owner';
GROUP: 'group';
TAG: 'tag';
Expand All @@ -82,6 +84,7 @@ ROOTS: 'roots';
// String tokens
QUOTED_STRING: '"' (~["\\\r\n])* '"';
UNQUOTED_STRING: [a-zA-Z_][a-zA-Z0-9_]*;
UNQUOTED_REGEX_STRING: [a-zA-Z_*][a-zA-Z0-9_*]*;

// Whitespace
WS: [ \t\r\n]+ -> skip;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CodeLocationAssetSelection,
ColumnAssetSelection,
ColumnTagAssetSelection,
KeyWildCardAssetSelection,
TableNameAssetSelection,
)
from dagster._core.storage.tags import KIND_PREFIX
Expand Down Expand Up @@ -113,12 +114,8 @@ def visitFunctionName(self, ctx: AssetSelectionParser.FunctionNameContext):
return "roots"

def visitKeyExpr(self, ctx: AssetSelectionParser.KeyExprContext):
value = self.visit(ctx.value())
return AssetSelection.assets(value)

def visitKeySubstringExpr(self, ctx: AssetSelectionParser.KeySubstringExprContext):
value = self.visit(ctx.value())
return AssetSelection.key_substring(value)
value = self.visit(ctx.keyValue())
return KeyWildCardAssetSelection(selected_key_wildcard=value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question for reviewers, should we attach this to the AssetSelection class (eg. AssetSelection.assetsByWildCardString(value))?


def visitTagAttributeExpr(self, ctx: AssetSelectionParser.TagAttributeExprContext):
key = self.visit(ctx.value(0))
Expand All @@ -145,6 +142,14 @@ def visitCodeLocationAttributeExpr(
code_location = self.visit(ctx.value())
return CodeLocationAssetSelection(selected_code_location=code_location)

def visitKeyValue(self, ctx: AssetSelectionParser.KeyValueContext):
if ctx.QUOTED_STRING():
return ctx.QUOTED_STRING().getText().strip('"')
elif ctx.UNQUOTED_REGEX_STRING():
return ctx.UNQUOTED_REGEX_STRING().getText()
elif ctx.UNQUOTED_STRING():
return ctx.UNQUOTED_STRING().getText()

def visitValue(self, ctx: AssetSelectionParser.ValueContext):
if ctx.QUOTED_STRING():
return ctx.QUOTED_STRING().getText().strip('"')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading