-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Support internal function to_binary()
for new charset
#29863
Comments
@zimulala @xiongjiwei @ou-bing @Defined2014 @unconsolable @jackwener @chacha923 @hawkingrei @jayl-zxl FYI, please feel free to leave your suggestions here, if any. |
Looks good since it can reduce code repetition, but I have a small question. for i := 0; i < n; i++ {
var str string
if buf.IsNull(i) {
result.AppendNull()
continue
}
str = buf.GetString(i)
str, err = enc.EncodeString(str) I wonder whether an encode buffer should be introduced here to reduce memory allocation. |
@unconsolable Good catch! If you are interested in it you can file a PR to fix it. By the way, we are trying to collect all the functions that can be wrapped by |
The code changes about built-in functions in TiKV can be minimized.
After the investigation about several built-in functions, I found some common patterns:
We can extract these patterns into another
Sig
namedbuiltinToBinarySig
(to_binary()
) and wrap the cast function as follows:The rewrite process before this proposal:
select some_builtin(arg1, arg2...)
is rewritten to
select some_builtin(cast_as_string(arg1), cast_as_string(arg2)...)
The rewrite process after this proposal:
select some_builtin(arg1, arg2...)
is rewritten to
select some_builtin(to_binary(cast_as_string(arg1)), to_binary(cast_as_string(arg2))...)
Then we can maintain a built-in function list to determine which function needs to be wrapped, instead of putting the boilerplates everywhere.
The text was updated successfully, but these errors were encountered: