[feature](jsonb) jsonb functions (#13366)

Issue Number: Step3 of DSIP-016: Support JSON type
This commit is contained in:
Kang
2022-10-19 08:44:08 +08:00
committed by GitHub
parent ac037e57f5
commit 755a946516
7 changed files with 1286 additions and 70 deletions

View File

@ -17,6 +17,7 @@
#include "vec/function/function_test_util.h"
#include "runtime/jsonb_value.h"
#include "vec/data_types/data_type_array.h"
#include "vec/data_types/data_type_bitmap.h"
#include "vec/data_types/data_type_decimal.h"
@ -66,6 +67,10 @@ size_t type_index_to_data_type(const std::vector<std::any>& input_types, size_t
desc.type = doris_udf::FunctionContext::TYPE_STRING;
type = std::make_shared<DataTypeString>();
return 1;
case TypeIndex::JSONB:
desc.type = doris_udf::FunctionContext::TYPE_JSONB;
type = std::make_shared<DataTypeJsonb>();
return 1;
case TypeIndex::BitMap:
desc.type = doris_udf::FunctionContext::TYPE_OBJECT;
type = std::make_shared<DataTypeBitMap>();
@ -177,6 +182,10 @@ bool insert_cell(MutableColumnPtr& column, DataTypePtr type_ptr, const std::any&
if (type.is_string()) {
auto str = std::any_cast<ut_type::STRING>(cell);
column->insert_data(str.c_str(), str.size());
} else if (type.is_json()) {
auto str = std::any_cast<ut_type::STRING>(cell);
JsonBinaryValue jsonb_val(str.c_str(), str.size());
column->insert_data(jsonb_val.value(), jsonb_val.size());
} else if (type.idx == TypeIndex::BitMap) {
BitmapValue* bitmap = std::any_cast<BitmapValue*>(cell);
column->insert_data((char*)bitmap, sizeof(BitmapValue));