mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Use capital letters in the names of json functions: jsonHas => JSONHas
This commit is contained in:
parent
0d26ac8583
commit
8be2e728c0
@ -24,7 +24,7 @@ public:
|
|||||||
class JSONHasImpl : public JSONNullableImplBase<DataTypeUInt8>
|
class JSONHasImpl : public JSONNullableImplBase<DataTypeUInt8>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonHas"};
|
static constexpr auto name{"JSONHas"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator &) { return {1}; }
|
static Field getValue(ParsedJson::iterator &) { return {1}; }
|
||||||
};
|
};
|
||||||
@ -32,7 +32,7 @@ public:
|
|||||||
class JSONLengthImpl : public JSONNullableImplBase<DataTypeUInt64>
|
class JSONLengthImpl : public JSONNullableImplBase<DataTypeUInt64>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonLength"};
|
static constexpr auto name{"JSONLength"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
class JSONTypeImpl : public JSONNullableImplBase<DataTypeString>
|
class JSONTypeImpl : public JSONNullableImplBase<DataTypeString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonType"};
|
static constexpr auto name{"JSONType"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
class JSONExtractImpl
|
class JSONExtractImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtract"};
|
static constexpr auto name{"JSONExtract"};
|
||||||
|
|
||||||
static DataTypePtr getType(const DataTypePtr & type)
|
static DataTypePtr getType(const DataTypePtr & type)
|
||||||
{
|
{
|
||||||
@ -243,7 +243,7 @@ public:
|
|||||||
class JSONExtractUIntImpl : public JSONNullableImplBase<DataTypeUInt64>
|
class JSONExtractUIntImpl : public JSONNullableImplBase<DataTypeUInt64>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractUInt"};
|
static constexpr auto name{"JSONExtractUInt"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -257,7 +257,7 @@ public:
|
|||||||
class JSONExtractIntImpl : public JSONNullableImplBase<DataTypeInt64>
|
class JSONExtractIntImpl : public JSONNullableImplBase<DataTypeInt64>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractInt"};
|
static constexpr auto name{"JSONExtractInt"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -271,7 +271,7 @@ public:
|
|||||||
class JSONExtractFloatImpl : public JSONNullableImplBase<DataTypeFloat64>
|
class JSONExtractFloatImpl : public JSONNullableImplBase<DataTypeFloat64>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractFloat"};
|
static constexpr auto name{"JSONExtractFloat"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -285,7 +285,7 @@ public:
|
|||||||
class JSONExtractBoolImpl : public JSONNullableImplBase<DataTypeUInt8>
|
class JSONExtractBoolImpl : public JSONNullableImplBase<DataTypeUInt8>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractBool"};
|
static constexpr auto name{"JSONExtractBool"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -301,7 +301,7 @@ public:
|
|||||||
// class JSONExtractRawImpl: public JSONNullableImplBase<DataTypeString>
|
// class JSONExtractRawImpl: public JSONNullableImplBase<DataTypeString>
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
// static constexpr auto name {"jsonExtractRaw"};
|
// static constexpr auto name {"JSONExtractRaw"};
|
||||||
|
|
||||||
// static Field getValue(ParsedJson::iterator & pjh)
|
// static Field getValue(ParsedJson::iterator & pjh)
|
||||||
// {
|
// {
|
||||||
@ -312,7 +312,7 @@ public:
|
|||||||
class JSONExtractStringImpl : public JSONNullableImplBase<DataTypeString>
|
class JSONExtractStringImpl : public JSONNullableImplBase<DataTypeString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractString"};
|
static constexpr auto name{"JSONExtractString"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -326,7 +326,7 @@ public:
|
|||||||
class JSONExtractKeyImpl : public JSONNullableImplBase<DataTypeString>
|
class JSONExtractKeyImpl : public JSONNullableImplBase<DataTypeString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto name{"jsonExtractKey"};
|
static constexpr auto name{"JSONExtractKey"};
|
||||||
|
|
||||||
static Field getValue(ParsedJson::iterator & pjh)
|
static Field getValue(ParsedJson::iterator & pjh)
|
||||||
{
|
{
|
||||||
@ -341,17 +341,17 @@ public:
|
|||||||
#else
|
#else
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
struct JSONHasImpl { static constexpr auto name{"jsonHas"}; };
|
struct JSONHasImpl { static constexpr auto name{"JSONHas"}; };
|
||||||
struct JSONLengthImpl { static constexpr auto name{"jsonLength"}; };
|
struct JSONLengthImpl { static constexpr auto name{"JSONLength"}; };
|
||||||
struct JSONTypeImpl { static constexpr auto name{"jsonType"}; };
|
struct JSONTypeImpl { static constexpr auto name{"JSONType"}; };
|
||||||
struct JSONExtractImpl { static constexpr auto name{"jsonExtract"}; };
|
struct JSONExtractImpl { static constexpr auto name{"JSONExtract"}; };
|
||||||
struct JSONExtractUIntImpl { static constexpr auto name{"jsonExtractUInt"}; };
|
struct JSONExtractUIntImpl { static constexpr auto name{"JSONExtractUInt"}; };
|
||||||
struct JSONExtractIntImpl { static constexpr auto name{"jsonExtractInt"}; };
|
struct JSONExtractIntImpl { static constexpr auto name{"JSONExtractInt"}; };
|
||||||
struct JSONExtractFloatImpl { static constexpr auto name{"jsonExtractFloat"}; };
|
struct JSONExtractFloatImpl { static constexpr auto name{"JSONExtractFloat"}; };
|
||||||
struct JSONExtractBoolImpl { static constexpr auto name{"jsonExtractBool"}; };
|
struct JSONExtractBoolImpl { static constexpr auto name{"JSONExtractBool"}; };
|
||||||
//struct JSONExtractRawImpl { static constexpr auto name {"jsonExtractRaw"}; };
|
//struct JSONExtractRawImpl { static constexpr auto name {"JSONExtractRaw"}; };
|
||||||
struct JSONExtractStringImpl { static constexpr auto name{"jsonExtractString"}; };
|
struct JSONExtractStringImpl { static constexpr auto name{"JSONExtractString"}; };
|
||||||
struct JSONExtractKeyImpl { static constexpr auto name{"jsonExtractKey"}; };
|
struct JSONExtractKeyImpl { static constexpr auto name{"JSONExtractKey"}; };
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
select jsonLength('{"a": "hello", "b": [-100, 200.0, 300]}');
|
SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}');
|
||||||
select jsonType('{"a": "hello", "b": [-100, 200.0, 300]}');
|
SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}');
|
||||||
select jsonHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'a');
|
SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'a');
|
||||||
select jsonHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1);
|
SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1);
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2);
|
SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2);
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1);
|
SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1);
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2);
|
SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2);
|
||||||
select jsonExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1);
|
SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1);
|
||||||
select jsonExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a');
|
SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a');
|
||||||
select jsonLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
||||||
select jsonType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b');
|
||||||
select jsonExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1);
|
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]}', 'Array(Int32)', 'b');
|
||||||
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))');
|
||||||
|
@ -60,7 +60,7 @@ There is currently no support for code points in the format `\uXXXX\uYYYY` that
|
|||||||
|
|
||||||
The following functions are based on [simdjson](https://github.com/lemire/simdjson) designed for more complex JSON parsing requirements. The assumption 2 mentioned above still applies.
|
The following functions are based on [simdjson](https://github.com/lemire/simdjson) designed for more complex JSON parsing requirements. The assumption 2 mentioned above still applies.
|
||||||
|
|
||||||
## jsonHas(params[, accessors]...)
|
## JSONHas(params[, accessors]...)
|
||||||
|
|
||||||
If the value exists in the JSON document, `1` will be returned.
|
If the value exists in the JSON document, `1` will be returned.
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ If the value does not exist, `null` will be returned.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
select jsonHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1
|
select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1
|
||||||
select jsonHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = null
|
select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = null
|
||||||
```
|
```
|
||||||
|
|
||||||
An accessor can be either a string, a positive integer or a negative integer.
|
An accessor can be either a string, a positive integer or a negative integer.
|
||||||
@ -84,14 +84,14 @@ You may use integers to access both JSON arrays and JSON objects.
|
|||||||
So, for example:
|
So, for example:
|
||||||
|
|
||||||
```
|
```
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a'
|
select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a'
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b'
|
select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b'
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b'
|
select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b'
|
||||||
select jsonExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a'
|
select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a'
|
||||||
select jsonExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello'
|
select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello'
|
||||||
```
|
```
|
||||||
|
|
||||||
## jsonLength(params[, accessors]...)
|
## JSONLength(params[, accessors]...)
|
||||||
|
|
||||||
Return the length of a JSON array or a JSON object.
|
Return the length of a JSON array or a JSON object.
|
||||||
|
|
||||||
@ -100,13 +100,13 @@ If the value does not exist or has a wrong type, `null` will be returned.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
select jsonLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3
|
select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3
|
||||||
select jsonLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2
|
select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2
|
||||||
```
|
```
|
||||||
|
|
||||||
The usage of accessors is the same as above.
|
The usage of accessors is the same as above.
|
||||||
|
|
||||||
## jsonType(params[, accessors]...)
|
## JSONType(params[, accessors]...)
|
||||||
|
|
||||||
Return the type of a JSON value.
|
Return the type of a JSON value.
|
||||||
|
|
||||||
@ -115,18 +115,18 @@ If the value does not exist, `null` will be returned.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
select jsonType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object'
|
select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object'
|
||||||
select jsonType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String'
|
select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String'
|
||||||
select jsonType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array'
|
select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array'
|
||||||
```
|
```
|
||||||
|
|
||||||
The usage of accessors is the same as above.
|
The usage of accessors is the same as above.
|
||||||
|
|
||||||
## jsonExtractUInt(params[, accessors]...)
|
## JSONExtractUInt(params[, accessors]...)
|
||||||
## jsonExtractInt(params[, accessors]...)
|
## JSONExtractInt(params[, accessors]...)
|
||||||
## jsonExtractFloat(params[, accessors]...)
|
## JSONExtractFloat(params[, accessors]...)
|
||||||
## jsonExtractBool(params[, accessors]...)
|
## JSONExtractBool(params[, accessors]...)
|
||||||
## jsonExtractString(params[, accessors]...)
|
## JSONExtractString(params[, accessors]...)
|
||||||
|
|
||||||
Parse data from JSON values which is similar to `visitParam` functions.
|
Parse data from JSON values which is similar to `visitParam` functions.
|
||||||
|
|
||||||
@ -135,15 +135,15 @@ If the value does not exist or has a wrong type, `null` will be returned.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
select jsonExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello'
|
select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello'
|
||||||
select jsonExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100
|
select JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100
|
||||||
select jsonExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0
|
select JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0
|
||||||
select jsonExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300
|
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, type[, accessors]...)
|
||||||
|
|
||||||
Parse data from JSON values with a given ClickHouse data type.
|
Parse data from JSON values with a given ClickHouse data type.
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ 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]}', 'Int8', 'b', 1) = -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])
|
||||||
```
|
```
|
||||||
|
|
||||||
The usage of accessors is the same as above.
|
The usage of accessors is the same as above.
|
||||||
|
Loading…
Reference in New Issue
Block a user