mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Move ExtraArg to the end of arguments of JSONExtract().
This commit is contained in:
parent
d003682626
commit
76bda0342b
@ -117,10 +117,10 @@ public:
|
|||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw Exception{"Function " + getName() + " requires at least two arguments", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
|
throw Exception{"Function " + getName() + " requires at least two arguments", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
|
||||||
|
|
||||||
auto col_type_const = typeid_cast<const ColumnConst *>(arguments[1].column.get());
|
auto col_type_const = typeid_cast<const ColumnConst *>(arguments[arguments.size() - 1].column.get());
|
||||||
|
|
||||||
if (!col_type_const)
|
if (!col_type_const)
|
||||||
throw Exception{"Illegal non-const column " + arguments[1].column->getName() + " of argument of function " + getName(),
|
throw Exception{"Illegal non-const column " + arguments[arguments.size() - 1].column->getName() + " of argument of function " + getName(),
|
||||||
ErrorCodes::ILLEGAL_COLUMN};
|
ErrorCodes::ILLEGAL_COLUMN};
|
||||||
|
|
||||||
virtual_type = DataTypeFactory::instance().get(col_type_const->getValue<String>());
|
virtual_type = DataTypeFactory::instance().get(col_type_const->getValue<String>());
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
|
|
||||||
actions.reserve(arguments.size() - 1 - ExtraArg);
|
actions.reserve(arguments.size() - 1 - ExtraArg);
|
||||||
|
|
||||||
for (const auto i : ext::range(1 + ExtraArg, arguments.size()))
|
for (const auto i : ext::range(1, arguments.size() - ExtraArg))
|
||||||
{
|
{
|
||||||
if (isString(arguments[i].type))
|
if (isString(arguments[i].type))
|
||||||
actions.push_back(Action::key);
|
actions.push_back(Action::key);
|
||||||
@ -194,7 +194,7 @@ public:
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ok = tryMove(pjh, actions[j], (*block.getByPosition(arguments[j + 1 + ExtraArg]).column)[i]);
|
ok = tryMove(pjh, actions[j], (*block.getByPosition(arguments[j + 1]).column)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
|
@ -14,7 +14,7 @@ SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1);
|
|||||||
SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2);
|
SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2);
|
||||||
SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1);
|
SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1);
|
||||||
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, String, String, Array(Float64))');
|
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, String, String, Array(Float64))');
|
||||||
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Array(Int32)', 'b');
|
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Int32)');
|
||||||
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Array(String)');
|
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Array(String)');
|
||||||
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Array(Tuple(Int16, Float32, UInt8))');
|
SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Array(Tuple(Int16, Float32, UInt8))');
|
||||||
SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300], "c":{"d":[121,144]}}');
|
SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300], "c":{"d":[121,144]}}');
|
||||||
|
@ -143,7 +143,7 @@ select JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300
|
|||||||
|
|
||||||
The usage of accessors is the same as above.
|
The usage of accessors is the same as above.
|
||||||
|
|
||||||
## JSONExtract(params, type[, accessors]...)
|
## JSONExtract(params[, accessors...], type)
|
||||||
|
|
||||||
Parse data from JSON values with a given ClickHouse data type.
|
Parse data from JSON values with a given ClickHouse data type.
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ If the value does not exist or has a wrong type, `null` will be returned.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
select JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Int8', 'b', 1) = -100
|
select JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1, 'Int8') = -100
|
||||||
select JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, String, String, Array(Float64))') = ('a', 'hello', 'b', [-100.0, 200.0, 300.0])
|
select JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, String, String, Array(Float64))') = ('a', 'hello', 'b', [-100.0, 200.0, 300.0])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user