-
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
Conversation
a91c309
to
2a7114d
Compare
c96d2bc
to
7a6f71d
Compare
7f1f398
to
4937db9
Compare
…ning and its understanding Co-authored-by: Andres Taylor <andres@planetscale.com> Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
…None Co-authored-by: Florent Poinsard <florent.poinsard@outlook.fr> Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
We should be able to handle calculating dependencies even if the expression is a slice and not valid as a map key. Co-authored-by: Florent Poinsard <florent.poinsard@outlook.fr> Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
395edb6
to
dc15f61
Compare
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
…es done on SelStmt Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
@@ -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 comment
The 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 comment
The 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.
Original Expr // original expression that was replaced by this ExtractedSubquery | ||
ArgName string | ||
HasValuesArg string | ||
OpCode int // this should really be engine.PulloutOpCode, but we cannot depend on engine :( |
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?
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
@@ -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 comment
The 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.
Description
This pull request contains a big refactor of the subqueries system in Gen4. We have introduced a new AST struct
ExtractedSubquery
that replaces entire subquery expression and its parents if it is a comparison or an exists (i.e:(select 1)
,a = (select 1)
,exists (select 1)
,a in (select 1)
, etc). Now, instead of directly rewriting the subquery with its arguments (i.e::__sq1
,:__sq_has_values1
, etc), we rewrite it with anExtractedSubquery
. If in the later planning phase we need to rewrite the subquery to its original form we can directly useExtractedSubquery
'sOriginal
field, and if we wish to keep the subquery as an argument,ExtractedSubquery
's format function will do it.Related Issue(s)
Checklist