-
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
Update AST helper generation #7558
Conversation
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: GuptaManan100 <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
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.
Looks good to me! We spent quite a bit of time reviewing this together. ✨
return nil | ||
} | ||
|
||
func (gen *astHelperGen) GenerateCode() (map[string]*jen.File, error) { |
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.
Do we need a comment for an exported function?
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
This reverts commit cd7c4b3. Turns out this change significantly degrades performance, and we don't want that... Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
@systay I now see where the performance regression in cd7c4b3 comes from -- you're actually allocating closures now! By removing the extra argument to every replacement function, all the visitor callbacks that were previously pure functions are becoming closures, which require an allocation even if they're not being called. Definitely a performance regression. |
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.
Really nice work.
const ( | ||
// these consts are here to try to trick the generator | ||
thisIsNotAType BasicType = 1 | ||
thisIsNotAType2 BasicType = 2 | ||
) |
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.
looks like they are not used in the code.
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.
the comment is not lying. these consts produce code that we had to do extra checks in the generator code to avoid. They are here to mimic sqlparser types such as ReadOnly
(https://github.com/vitessio/vitess/blob/master/go/vt/sqlparser/constants.go#L254)
func (tv *testVisitor) assertEquals(t *testing.T, expected []step) { | ||
t.Helper() | ||
var lines []string | ||
error := false |
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.
nit: error is reserved word, better to name as err
Description
This PR removes the
visitorgen
component that used to create the VitessRewriter
, and addsasthelpergen
that generates both the rewriter, but also deep-clone methods for all AST types.The Gen4 planner tries join in both directions. Given the following query:
The new planner will try to first plan the A side on the left, and the send data from A to B as params, and then will try the other variation. The two versions would be:
As can be seen in these examples, we need to be able to clone the original predicate and then change it in two different ways to test both alternatives.
Related Issue(s)
#7280
Checklist
Impacted Areas in Vitess
Components that this PR will affect: