You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-785 Implement DISTRIBUTED JSON functions
The following functions are created: Create function JSON_VALID and test cases Create function JSON_DEPTH and test cases Create function JSON_LENGTH and test cases Create function JSON_EQUALS and test cases Create function JSON_NORMALIZE and test cases Create function JSON_TYPE and test cases Create function JSON_OBJECT and test cases Create function JSON_ARRAY and test cases Create function JSON_KEYS and test cases Create function JSON_EXISTS and test cases Create function JSON_QUOTE/JSON_UNQUOTE and test cases Create function JSON_COMPACT/DETAILED/LOOSE and test cases Create function JSON_MERGE and test cases Create function JSON_MERGE_PATCH and test cases Create function JSON_VALUE and test cases Create function JSON_QUERY and test cases Create function JSON_CONTAINS and test cases Create function JSON_ARRAY_APPEND and test cases Create function JSON_ARRAY_INSERT and test cases Create function JSON_INSERT/REPLACE/SET and test cases Create function JSON_REMOVE and test cases Create function JSON_CONTAINS_PATH and test cases Create function JSON_OVERLAPS and test cases Create function JSON_EXTRACT and test cases Create function JSON_SEARCH and test cases Note: Some functions output differs from MDB because session variables that affects functions output,e.g JSON_QUOTE/JSON_UNQUOTE This depends on MCOL-5212
This commit is contained in:
@ -3550,6 +3550,35 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp
|
||||
return rc;
|
||||
}
|
||||
|
||||
// parse the boolean fields to string "true" or "false"
|
||||
ReturnedColumn* buildBooleanConstantColumn(Item* item, gp_walk_info& gwi, bool& nonSupport)
|
||||
{
|
||||
ConstantColumn* cc = NULL;
|
||||
|
||||
if (gwi.thd)
|
||||
{
|
||||
{
|
||||
if (!item->fixed())
|
||||
{
|
||||
item->fix_fields(gwi.thd, (Item**)&item);
|
||||
}
|
||||
}
|
||||
}
|
||||
int64_t val = static_cast<int64_t>(item->val_int());
|
||||
cc = new ConstantColumnSInt(colType_MysqlToIDB(item), val ? "true" : "false", val);
|
||||
|
||||
if (cc)
|
||||
cc->timeZone(gwi.timeZone);
|
||||
|
||||
if (cc && item->name.length)
|
||||
cc->alias(item->name.str);
|
||||
|
||||
if (cc)
|
||||
cc->charsetNumber(item->collation.collation->number);
|
||||
|
||||
return cc;
|
||||
}
|
||||
|
||||
ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport)
|
||||
{
|
||||
if (get_fe_conn_info_ptr() == NULL)
|
||||
@ -4013,7 +4042,24 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ReturnedColumn* rc = buildReturnedColumn(ifp->arguments()[i], gwi, nonSupport);
|
||||
ReturnedColumn* rc = NULL;
|
||||
|
||||
|
||||
// Special treatment for json functions
|
||||
// All boolean arguments will be parsed as boolean string true(false)
|
||||
// E.g. the result of `SELECT JSON_ARRAY(true, false)` should be [true, false] instead of [1, 0]
|
||||
bool mayHasBoolArg = ((funcName == "json_insert" || funcName == "json_replace" ||
|
||||
funcName == "json_set" || funcName == "json_array_append" ||
|
||||
funcName == "json_array_insert") && i != 0 && i % 2 == 0) ||
|
||||
(funcName == "json_array") ||
|
||||
(funcName == "json_object" && i % 2 == 1);
|
||||
bool isBoolType =
|
||||
(ifp->arguments()[i]->const_item() && ifp->arguments()[i]->type_handler()->is_bool_type());
|
||||
|
||||
if (mayHasBoolArg && isBoolType)
|
||||
rc = buildBooleanConstantColumn(ifp->arguments()[i], gwi, nonSupport);
|
||||
else
|
||||
rc = buildReturnedColumn(ifp->arguments()[i], gwi, nonSupport);
|
||||
|
||||
// MCOL-1510 It must be a temp table field, so find the corresponding column.
|
||||
if (!rc && ifp->arguments()[i]->type() == Item::REF_ITEM)
|
||||
|
Reference in New Issue
Block a user