JSON_TYPEOF (Lakehouse v1)
Zwraca typ najwyższego poziomu struktury JSON.
Składnia Analyze
Dział zatytułowany „Składnia Analyze”func.json_typeof(<json_string>)Przykłady Analyze
Dział zatytułowany „Przykłady Analyze”func.json_typeof(func.parse_json('null'))|-----------------------------------------+null |
--func.json_typeof(func.parse_json('true'))|-----------------------------------------+boolean |
--func.json_typeof(func.parse_json('"plaidcloud"'))|-----------------------------------------------+string |
--func.json_typeof(func.parse_json('-1.23'))|------------------------------------------+number |
--func.json_typeof(func.parse_json('[1,2,3]'))|--------------------------------------------+array |
--func.json_typeof(func.parse_json('{"name": "alice", "age": 30}'))|-----------------------------------------------------------------+object |Składnia SQL
Dział zatytułowany „Składnia SQL”JSON_TYPEOF(<json_string>)Typ zwracany
Dział zatytułowany „Typ zwracany”Typem zwracanym przez funkcję json_typeof (lub podobną) jest ciąg znaków wskazujący typ danych sparsowanej wartości JSON. Możliwe zwracane wartości to: ‘null’, ‘boolean’, ‘string’, ‘number’, ‘array’ i ‘object’.
Przykłady SQL
Dział zatytułowany „Przykłady SQL”-- Parsing a JSON value that is NULLSELECT JSON_TYPEOF(PARSE_JSON(NULL));
--func.json_typeof(func.parse_json(null))|-----------------------------+ |
-- Parsing a JSON value that is the string 'null'SELECT JSON_TYPEOF(PARSE_JSON('null'));
--func.json_typeof(func.parse_json('null'))|-------------------------------+null |
SELECT JSON_TYPEOF(PARSE_JSON('true'));
--func.json_typeof(func.parse_json('true'))|-------------------------------+boolean |
SELECT JSON_TYPEOF(PARSE_JSON('"PlaidCloud Lakehouse"'));
--func.json_typeof(func.parse_json('"databend"'))|-------------------------------------+string |
SELECT JSON_TYPEOF(PARSE_JSON('-1.23'));
--func.json_typeof(func.parse_json('-1.23'))|--------------------------------+number |
SELECT JSON_TYPEOF(PARSE_JSON('[1,2,3]'));
--func.json_typeof(func.parse_json('[1,2,3]'))|----------------------------------+array |
SELECT JSON_TYPEOF(PARSE_JSON('{"name": "Alice", "age": 30}'));
--func.json_typeof(func.parse_json('{"name": "alice", "age": 30}'))|-------------------------------------------------------+object |