Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ ScalarFunctionSet JSONFunctions::GetArrayLengthFunction() {
ScalarFunctionSet set("json_array_length");
GetArrayLengthFunctionsInternal(set, LogicalType::VARCHAR);
GetArrayLengthFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments.size() == 1 && func.arguments[0].IsJSONType()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
3 changes: 3 additions & 0 deletions src/duckdb/extension/json/json_functions/json_contains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ ScalarFunctionSet JSONFunctions::GetContainsFunction() {
GetContainsFunctionInternal(set, LogicalType::VARCHAR, LogicalType::VARCHAR);
GetContainsFunctionInternal(set, LogicalType::VARCHAR, LogicalType::JSON());
GetContainsFunctionInternal(set, LogicalType::JSON(), LogicalType::VARCHAR);
for (auto &func : set.functions) {
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
GetContainsFunctionInternal(set, LogicalType::JSON(), LogicalType::JSON());
// TODO: implement json_contains that accepts path argument as well

Expand Down
3 changes: 3 additions & 0 deletions src/duckdb/extension/json/json_functions/json_exists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ScalarFunctionSet JSONFunctions::GetExistsFunction() {
ScalarFunctionSet set("json_exists");
GetExistsFunctionsInternal(set, LogicalType::VARCHAR);
GetExistsFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
12 changes: 12 additions & 0 deletions src/duckdb/extension/json/json_functions/json_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ ScalarFunctionSet JSONFunctions::GetExtractFunction() {
ScalarFunctionSet set("json_extract");
GetExtractFunctionsInternal(set, LogicalType::VARCHAR);
GetExtractFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments[0].IsJSONType() && func.arguments[1].IsNumeric()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand All @@ -68,6 +74,12 @@ ScalarFunctionSet JSONFunctions::GetExtractStringFunction() {
ScalarFunctionSet set("json_extract_string");
GetExtractStringFunctionsInternal(set, LogicalType::VARCHAR);
GetExtractStringFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments[0].IsJSONType() && func.arguments[1].IsNumeric()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
6 changes: 6 additions & 0 deletions src/duckdb/extension/json/json_functions/json_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ ScalarFunctionSet JSONFunctions::GetKeysFunction() {
ScalarFunctionSet set("json_keys");
GetJSONKeysFunctionsInternal(set, LogicalType::VARCHAR);
GetJSONKeysFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments.size() == 1 && func.arguments[0].IsJSONType()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
3 changes: 3 additions & 0 deletions src/duckdb/extension/json/json_functions/json_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ static void GetStructureFunctionInternal(ScalarFunctionSet &set, const LogicalTy
ScalarFunctionSet JSONFunctions::GetStructureFunction() {
ScalarFunctionSet set("json_structure");
GetStructureFunctionInternal(set, LogicalType::VARCHAR);
for (auto &func : set.functions) {
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
GetStructureFunctionInternal(set, LogicalType::JSON());
return set;
}
Expand Down
6 changes: 6 additions & 0 deletions src/duckdb/extension/json/json_functions/json_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ ScalarFunctionSet JSONFunctions::GetTransformFunction() {
ScalarFunctionSet set("json_transform");
GetTransformFunctionInternal(set, LogicalType::VARCHAR);
GetTransformFunctionInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand All @@ -1007,6 +1010,9 @@ ScalarFunctionSet JSONFunctions::GetTransformStrictFunction() {
ScalarFunctionSet set("json_transform_strict");
GetTransformStrictFunctionInternal(set, LogicalType::VARCHAR);
GetTransformStrictFunctionInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
6 changes: 6 additions & 0 deletions src/duckdb/extension/json/json_functions/json_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ ScalarFunctionSet JSONFunctions::GetTypeFunction() {
ScalarFunctionSet set("json_type");
GetTypeFunctionsInternal(set, LogicalType::VARCHAR);
GetTypeFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments.size() == 1 && func.arguments[0].IsJSONType()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
6 changes: 6 additions & 0 deletions src/duckdb/extension/json/json_functions/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ ScalarFunctionSet JSONFunctions::GetValueFunction() {
ScalarFunctionSet set("json_value");
GetValueFunctionsInternal(set, LogicalType::VARCHAR);
GetValueFunctionsInternal(set, LogicalType::JSON());
for (auto &func : set.functions) {
if (func.arguments[0].IsJSONType() && func.arguments[1].IsNumeric()) {
continue;
}
func.errors = FunctionErrors::CAN_THROW_RUNTIME_ERROR;
}
return set;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ class VariantShreddedConversion {
VariantShreddedConversion() = delete;

public:
static vector<VariantValue> Convert(Vector &metadata, Vector &group, idx_t offset, idx_t length, idx_t total_size,
bool is_field);
static vector<VariantValue> Convert(Vector &metadata, Vector &group, idx_t offset, idx_t length, idx_t total_size);
static vector<VariantValue> ConvertShreddedLeaf(Vector &metadata, Vector &value, Vector &typed_value, idx_t offset,
idx_t length, idx_t total_size, const bool is_field);
idx_t length, idx_t total_size);
static vector<VariantValue> ConvertShreddedArray(Vector &metadata, Vector &value, Vector &typed_value, idx_t offset,
idx_t length, idx_t total_size, const bool is_field);
idx_t length, idx_t total_size);
static vector<VariantValue> ConvertShreddedObject(Vector &metadata, Vector &value, Vector &typed_value,
idx_t offset, idx_t length, idx_t total_size,
const bool is_field);
idx_t offset, idx_t length, idx_t total_size);
};

} // namespace duckdb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ VariantValue VariantBinaryDecoder::PrimitiveTypeDecode(const VariantValueMetadat
const_data_ptr_t data) {
switch (value_metadata.primitive_type) {
case VariantPrimitiveType::NULL_TYPE: {
return VariantValue(Value());
return VariantValue::NullValue();
}
case VariantPrimitiveType::BOOLEAN_TRUE: {
return VariantValue(Value::BOOLEAN(true));
Expand Down
Loading
Loading