-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: fix convert number base for hybrid type #21554
Conversation
Signed-off-by: lzmhhh123 <[email protected]>
Signed-off-by: lzmhhh123 <[email protected]>
/cc @ichn-hu |
/cc @XuHuaiyu |
if x.FuncName.L == ast.Cast { | ||
arg0 := x.GetArgs()[0] | ||
if arg0.GetType().Hybrid() || IsBinaryLiteral(arg0) { | ||
str, isNull, err = arg0.EvalString(b.ctx, row) | ||
if isNull || err != nil { | ||
return str, isNull, err | ||
} | ||
d := types.NewStringDatum(str) | ||
str = d.GetBinaryLiteral().ToBitLiteralString(true) | ||
} | ||
} |
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.
what if the func is not Cast but produces string that needs to be converted?
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.
When we build conv
function. If the first argument is NOT string type. The cast
would be wrapped. No other cases. You can refer to this code.
func (c *convFunctionClass) getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
if err := c.verifyArgs(args); err != nil {
return nil, err
}
bf, err := newBaseBuiltinFuncWithTp(ctx, c.funcName, args, types.ETString, types.ETString, types.ETInt, types.ETInt)
if err != nil {
return nil, err
}
bf.tp.Charset, bf.tp.Collate = ctx.GetSessionVars().GetCharsetInfo()
bf.tp.Flen = 64
sig := &builtinConvSig{bf}
sig.setPbCode(tipb.ScalarFuncSig_Conv)
return sig, nil
}
// TODO: change the vecEval match hybrid type fixing. Then open the vectorized evaluation. | ||
return 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.
would you like to create an issue for this?
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 will update #12106, since the PR merged.
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.
Rest LGTM
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
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
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-4.0 in PR #21593 |
Signed-off-by: ti-srebot <[email protected]>
Signed-off-by: lzmhhh123 [email protected]<!-- Thank you for contributing to TiDB!
PR Title Format:
-->
What problem does this PR solve?
Issue Number: close #5817
What is changed and how it works?
How it Works: specified handle hybrid type for conv function.
Related changes
Check List
Tests
Side effects
Release note