-
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
Copy expression types to avoid weight_strings and derived tables #15069
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,11 @@ limitations under the License. | |
package operators | ||
|
||
import ( | ||
"vitess.io/vitess/go/mysql/collations" | ||
"vitess.io/vitess/go/sqltypes" | ||
"vitess.io/vitess/go/vt/sqlparser" | ||
"vitess.io/vitess/go/vt/vtgate/engine" | ||
"vitess.io/vitess/go/vt/vtgate/evalengine" | ||
"vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" | ||
) | ||
|
||
|
@@ -199,8 +202,16 @@ func createMergedUnion( | |
continue | ||
} | ||
deps = deps.Merge(ctx.SemTable.RecursiveDeps(rae.Expr)) | ||
ctx.SemTable.CopySemanticInfo(rae.Expr, col) | ||
ctx.SemTable.CopySemanticInfo(lae.Expr, col) | ||
rt, foundR := ctx.SemTable.TypeForExpr(rae.Expr) | ||
lt, foundL := ctx.SemTable.TypeForExpr(lae.Expr) | ||
if foundR && foundL { | ||
types := []sqltypes.Type{rt.Type(), lt.Type()} | ||
t := evalengine.AggregateTypes(types) | ||
ctx.SemTable.ExprTypes[col] = evalengine.NewType(t, collations.Unknown) | ||
} else { | ||
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. I don't think we should have the else clause here. It's not correct to use either of the two types as the common type. Like my example showed, you can have a situation where one side is an int, the other side is a datetime, but the common type is varchar. If we don't have both types available, I think we need to use the 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. I understand now. There shouldn't be an "else" processing logic. If it is a syntax tree node for the now() function, we can save its corresponding 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. Yeah, we could/should update |
||
ctx.SemTable.CopySemanticInfo(rae.Expr, col) | ||
ctx.SemTable.CopySemanticInfo(lae.Expr, col) | ||
} | ||
ctx.SemTable.Recursive[col] = deps | ||
} | ||
|
||
|
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.
@systay Shouldn't this have used
AggregateEvalTypes
so that the collation is also known and notcollations.Unknown
?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.
Ah, #15122 answers my question here.