-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add string function split_part #1445
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
Conversation
|
|
||
| StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content, | ||
| const StringVal& delimiter,const IntVal& field) { | ||
| if (field.val <= 0) return StringVal::null(); |
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 content、delimiter or field is null?
| } | ||
|
|
||
|
|
||
| StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content, |
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.
| StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content, | |
| StringVal StringFunctions::split_part(FunctionContext* context, const StringVal& content, |
|
|
||
|
|
||
| StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content, | ||
| const StringVal& delimiter,const IntVal& field) { |
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.
| const StringVal& delimiter,const IntVal& field) { | |
| const StringVal& delimiter, const IntVal& field) { |
| const StringVal& delimiter,const IntVal& field) { | ||
| if (field.val <= 0) return StringVal::null(); | ||
| int find[field.val]; //store substring position | ||
| for(int i=0;i<=field.val;i++) find[i] = -1; // init |
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.
| for(int i=0;i<=field.val;i++) find[i] = -1; // init | |
| for (int i=0;i<=field.val;i++) find[i] = -1; // init |
| int find[field.val]; //store substring position | ||
| for(int i=0;i<=field.val;i++) find[i] = -1; // init | ||
| int from = 0; | ||
| for(int i=1;i<=field.val;i++){ // find |
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.
| for(int i=1;i<=field.val;i++){ // find | |
| for (int i=1; i<=field.val; i++) { // find |
| for(int i=0;i<=field.val;i++) find[i] = -1; // init | ||
| int from = 0; | ||
| for(int i=1;i<=field.val;i++){ // find | ||
| find[i-1] = indexOf(content.ptr,0,content.len, delimiter.ptr,0,delimiter.len,from); |
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.
| find[i-1] = indexOf(content.ptr,0,content.len, delimiter.ptr,0,delimiter.len,from); | |
| find[i-1] = indexOf(content.ptr,0, content.len, delimiter.ptr, 0, delimiter.len, from); |
You should add one space after punctuation
| break; | ||
| } | ||
| } | ||
| if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find |
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.
| if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find | |
| if ((field.val > 1 && find[field.val-2] == -1) || (field.val == 1 && find[field.val-1] == -1)){ // not find |
| if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find | ||
| return StringVal::null(); | ||
| } | ||
| int start_pos,len; |
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.
define len when it is needed
| return do_money_format(context, ss.str()); | ||
| } | ||
|
|
||
| static int indexOf(const uint8_t* source, int sourceOffset, int sourceCount, |
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.
| static int indexOf(const uint8_t* source, int sourceOffset, int sourceCount, | |
| static int index_of(const uint8_t* source, int sourceOffset, int sourceCount, |
|
感谢指出问题, 我仔细修改下再提交。 |
… (apache#1445) * (Enhancement)[load-json] support simdjson in new json reader (apache#16903) be config: enable_simdjson_reader=true related PR apache#11665 * [Optimize](simd json reader) Cached search results for previous row (keyed as index in JSON object) - used as a hint. (apache#17124) * [Optimize](simd json reader) Cached search results for previous row (keyed as index in JSON object) - used as a hint. `_simdjson_set_column_value` could become a hot spot while parsing json in simdjson mode, introduce `_prev_positions` to cache results for previous row (keyed as index in JSON object) due to the json name field order, should be quite the same between each lines * fix case
Add string function split_part. Just like postgresql