mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix std::bad_typeid when JSON functions called with argument of wrong type.
This commit is contained in:
parent
3a0d358694
commit
94c858b2dc
@ -892,7 +892,7 @@ public:
|
|||||||
auto col_type_const = typeid_cast<const ColumnConst *>(col.column.get());
|
auto col_type_const = typeid_cast<const ColumnConst *>(col.column.get());
|
||||||
if (!col_type_const || !isString(col.type))
|
if (!col_type_const || !isString(col.type))
|
||||||
throw Exception{"The last argument of function " + String(function_name)
|
throw Exception{"The last argument of function " + String(function_name)
|
||||||
+ " should be a constant string specifying the return data type, illegal value: " + col.column->getName(),
|
+ " should be a constant string specifying the return data type, illegal value: " + col.name,
|
||||||
ErrorCodes::ILLEGAL_COLUMN};
|
ErrorCodes::ILLEGAL_COLUMN};
|
||||||
|
|
||||||
return DataTypeFactory::instance().get(col_type_const->getValue<String>());
|
return DataTypeFactory::instance().get(col_type_const->getValue<String>());
|
||||||
@ -929,7 +929,7 @@ public:
|
|||||||
auto col_type_const = typeid_cast<const ColumnConst *>(col.column.get());
|
auto col_type_const = typeid_cast<const ColumnConst *>(col.column.get());
|
||||||
if (!col_type_const || !isString(col.type))
|
if (!col_type_const || !isString(col.type))
|
||||||
throw Exception{"The last argument of function " + String(function_name)
|
throw Exception{"The last argument of function " + String(function_name)
|
||||||
+ " should be a constant string specifying the values' data type, illegal value: " + col.column->getName(),
|
+ " should be a constant string specifying the values' data type, illegal value: " + col.name,
|
||||||
ErrorCodes::ILLEGAL_COLUMN};
|
ErrorCodes::ILLEGAL_COLUMN};
|
||||||
|
|
||||||
DataTypePtr key_type = std::make_unique<DataTypeString>();
|
DataTypePtr key_type = std::make_unique<DataTypeString>();
|
||||||
|
@ -99,6 +99,7 @@ d
|
|||||||
e
|
e
|
||||||
u
|
u
|
||||||
v
|
v
|
||||||
|
--show error: type should be const string
|
||||||
--allow_simdjson=0--
|
--allow_simdjson=0--
|
||||||
--JSONLength--
|
--JSONLength--
|
||||||
2
|
2
|
||||||
@ -200,3 +201,4 @@ d
|
|||||||
e
|
e
|
||||||
u
|
u
|
||||||
v
|
v
|
||||||
|
--show error: type should be const string
|
||||||
|
@ -108,6 +108,9 @@ SELECT '--const/non-const mixed--';
|
|||||||
SELECT JSONExtractString('["a", "b", "c", "d", "e"]', idx) FROM (SELECT arrayJoin([1,2,3,4,5]) AS idx);
|
SELECT JSONExtractString('["a", "b", "c", "d", "e"]', idx) FROM (SELECT arrayJoin([1,2,3,4,5]) AS idx);
|
||||||
SELECT JSONExtractString(json, 's') FROM (SELECT arrayJoin(['{"s":"u"}', '{"s":"v"}']) AS json);
|
SELECT JSONExtractString(json, 's') FROM (SELECT arrayJoin(['{"s":"u"}', '{"s":"v"}']) AS json);
|
||||||
|
|
||||||
|
SELECT '--show error: type should be const string';
|
||||||
|
SELECT JSONExtractKeysAndValues([], JSONLength('^?V{LSwp')); -- { serverError 44 }
|
||||||
|
WITH '{"i": 1, "f": 1.2}' AS json SELECT JSONExtract(json, 'i', JSONType(json, 'i')); -- { serverError 44 }
|
||||||
|
|
||||||
|
|
||||||
SELECT '--allow_simdjson=0--';
|
SELECT '--allow_simdjson=0--';
|
||||||
@ -219,3 +222,7 @@ SELECT JSONExtractKeysAndValuesRaw('{"a": "hello", "b": [-100, 200.0, 300], "c":
|
|||||||
SELECT '--const/non-const mixed--';
|
SELECT '--const/non-const mixed--';
|
||||||
SELECT JSONExtractString('["a", "b", "c", "d", "e"]', idx) FROM (SELECT arrayJoin([1,2,3,4,5]) AS idx);
|
SELECT JSONExtractString('["a", "b", "c", "d", "e"]', idx) FROM (SELECT arrayJoin([1,2,3,4,5]) AS idx);
|
||||||
SELECT JSONExtractString(json, 's') FROM (SELECT arrayJoin(['{"s":"u"}', '{"s":"v"}']) AS json);
|
SELECT JSONExtractString(json, 's') FROM (SELECT arrayJoin(['{"s":"u"}', '{"s":"v"}']) AS json);
|
||||||
|
|
||||||
|
SELECT '--show error: type should be const string';
|
||||||
|
SELECT JSONExtractKeysAndValues([], JSONLength('^?V{LSwp')); -- { serverError 44 }
|
||||||
|
WITH '{"i": 1, "f": 1.2}' AS json SELECT JSONExtract(json, 'i', JSONType(json, 'i')); -- { serverError 44 }
|
||||||
|
Loading…
Reference in New Issue
Block a user