[feature](jsonb function)change jsonb_extract_string behavior and doc (#14619)
1. change jsonb_extract_string behavior: convert to string instead of NULL if the type of json path is not string 2. move jsonb tutorial doc to JSONB data type
This commit is contained in:
@ -368,6 +368,8 @@ struct JsonbExtractStringImpl {
|
||||
writer.reset(new JsonbWriter());
|
||||
}
|
||||
|
||||
std::unique_ptr<JsonbToJson> formater;
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; ++i) {
|
||||
int l_size = loffsets[i] - loffsets[i - 1];
|
||||
const auto l_raw = reinterpret_cast<const char*>(&ldata[loffsets[i - 1]]);
|
||||
@ -413,9 +415,33 @@ struct JsonbExtractStringImpl {
|
||||
StringOP::push_value_string(
|
||||
std::string_view(str_value->getBlob(), str_value->length()), i,
|
||||
res_data, res_offsets);
|
||||
} else if (value->isNull()) {
|
||||
StringOP::push_value_string("null", i, res_data, res_offsets);
|
||||
} else if (value->isTrue()) {
|
||||
StringOP::push_value_string("true", i, res_data, res_offsets);
|
||||
} else if (value->isFalse()) {
|
||||
StringOP::push_value_string("false", i, res_data, res_offsets);
|
||||
} else if (value->isInt8()) {
|
||||
StringOP::push_value_string(std::to_string(((const JsonbInt8Val*)value)->val()),
|
||||
i, res_data, res_offsets);
|
||||
} else if (value->isInt16()) {
|
||||
StringOP::push_value_string(
|
||||
std::to_string(((const JsonbInt16Val*)value)->val()), i, res_data,
|
||||
res_offsets);
|
||||
} else if (value->isInt32()) {
|
||||
StringOP::push_value_string(
|
||||
std::to_string(((const JsonbInt32Val*)value)->val()), i, res_data,
|
||||
res_offsets);
|
||||
} else if (value->isInt64()) {
|
||||
StringOP::push_value_string(
|
||||
std::to_string(((const JsonbInt64Val*)value)->val()), i, res_data,
|
||||
res_offsets);
|
||||
} else {
|
||||
StringOP::push_null_string(i, res_data, res_offsets, null_map);
|
||||
continue;
|
||||
if (!formater) {
|
||||
formater.reset(new JsonbToJson());
|
||||
}
|
||||
StringOP::push_value_string(formater->to_json_string(value), i, res_data,
|
||||
res_offsets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user