Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[opt](fucntion) improve json_extract function handle const column (#3…
…6927) ## Proposed changes VARCHAR json_extract(VARCHAR json_str, VARCHAR path[, VARCHAR path] ...) ``` for (int i = 0; i < arguments.size(); i++) { column_ptrs.push_back( block.get_by_position(arguments[i]).column->convert_to_full_column_if_const()); data_columns.push_back(assert_cast<const ColumnString*>(column_ptrs.back().get())); } before not handle const column, as the input arguments are variadic, and most user case is like: json_extract(column, '$.fparam.nested_2') so could special deal with two arguments could reuse json document. ``` ``` mysql [test]>select count(json_extract(a, '$.fparam.nested_2')) from json_table_2; +---------------------------------------------+ | count(json_extract(a, '$.fparam.nested_2')) | +---------------------------------------------+ | 10000001 | +---------------------------------------------+ 1 row in set (1.06 sec) mysql [test]>select count(json_extract(a, '$.fparam.nested_2')) from json_table_2; +---------------------------------------------+ | count(json_extract(a, '$.fparam.nested_2')) | +---------------------------------------------+ | 10000001 | +---------------------------------------------+ 1 row in set (1.02 sec) mysql [test]> mysql [test]> mysql [test]>select count(json_extract(a, '$.fparam.nested_2')) from json_table_2; +---------------------------------------------+ | count(json_extract(a, '$.fparam.nested_2')) | +---------------------------------------------+ | 10000001 | +---------------------------------------------+ 1 row in set (44.22 sec) mysql [test]>select count(json_extract(a, '$.fparam.nested_2')) from json_table_2; +---------------------------------------------+ | count(json_extract(a, '$.fparam.nested_2')) | +---------------------------------------------+ | 10000001 | +---------------------------------------------+ 1 row in set (42.80 sec) ``` <!--Describe your changes.-->
- Loading branch information