-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Gen4: subquery refactor #8974
Gen4: subquery refactor #8974
Changes from all commits
a901e28
0560feb
36141d2
efd95b2
5497971
0573e46
148513e
41541b0
2483b11
f31d4c3
e12a286
dc15f61
1f2bb8d
96a780d
90d924c
ee3a800
986cb67
cfa5705
24ad27c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1720,3 +1720,33 @@ func (node *RenameTable) Format(buf *TrackedBuffer) { | |
prefix = ", " | ||
} | ||
} | ||
|
||
func (node *ExtractedSubquery) Format(buf *TrackedBuffer) { | ||
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. missing comment, and we should not create the new expressions here, we should create them when we create this struct, I think 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. as the new struct is also an SQLNode, we can keep the Format function here. |
||
switch original := node.Original.(type) { | ||
case *ExistsExpr: | ||
buf.astPrintf(node, "%v", NewArgument(node.ArgName)) | ||
case *ComparisonExpr: | ||
// other_side = :__sq | ||
cmp := &ComparisonExpr{ | ||
Left: node.OtherSide, | ||
Right: NewArgument(node.ArgName), | ||
Operator: original.Operator, | ||
} | ||
var expr Expr = cmp | ||
switch original.Operator { | ||
case InOp: | ||
// :__sq_has_values = 1 and other_side in ::__sq | ||
cmp.Right = NewListArg(node.ArgName) | ||
hasValue := &ComparisonExpr{Left: NewArgument(node.HasValuesArg), Right: NewIntLiteral("1"), Operator: EqualOp} | ||
expr = AndExpressions(hasValue, cmp) | ||
case NotInOp: | ||
// :__sq_has_values = 0 or other_side not in ::__sq | ||
cmp.Right = NewListArg(node.ArgName) | ||
hasValue := &ComparisonExpr{Left: NewArgument(node.HasValuesArg), Right: NewIntLiteral("0"), Operator: EqualOp} | ||
expr = OrExpressions(hasValue, cmp) | ||
} | ||
buf.astPrintf(node, "%v", expr) | ||
case *Subquery: | ||
buf.astPrintf(node, "%v", NewArgument(node.ArgName)) | ||
} | ||
} |
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.
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.
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.
Should we move the opcode here then? or some other common package?