-
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
Improve typing during query planning #16310
Conversation
Signed-off-by: Andres Taylor <andres@planetscale.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16310 +/- ##
==========================================
- Coverage 68.71% 68.71% -0.01%
==========================================
Files 1547 1547
Lines 198286 198338 +52
==========================================
+ Hits 136257 136281 +24
- Misses 62029 62057 +28 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
// replaceAggrWithArg replaces aggregate functions with Arguments in the given expression. | ||
// this is to prepare for sending the expression to the evalengine compiler to figure out the type | ||
func (ctx *PlanningContext) replaceAggrWithArg(e sqlparser.Expr, cfg *evalengine.Config, env *evalengine.ExpressionEnv) (expr sqlparser.Expr, unknown bool) { | ||
expr = sqlparser.CopyOnRewrite(e, nil, func(cursor *sqlparser.CopyOnWriteCursor) { | ||
agg, ok := cursor.Node().(sqlparser.AggrFunc) | ||
if !ok { |
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.
I see the TODO, do you want to keep this unused method before removing the TODO?
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.
yeah, that was my thought, but it's not important. if you think it should go, I can delete it
Signed-off-by: Andres Taylor <andres@planetscale.com>
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.
LGTM!
Description
We've long had pretty bad typing in the semantic analysis, and pretty great typing in the evalengine. This PR tries to connect the two.
The only typing during semantic analysis that we'll do is to copy information over from the VSchema, and fill the types of column names known to the vschema.
Actual typing will happen when the planner asks for type info, and not before that. The typing will be more expensive, but will only be done when it's really needed.
The PR contains TODOs about enabling the type logic for aggregate functions as well. At the moment we don't calculate these types correctly, so let's revisit once that is done.
Related Issue(s)
Checklist
Deployment Notes