-- Strings.
SELECT '""'::json; -- OK.
SELECT $$''$$::json; -- ERROR, single quotes are not allowed
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT $$''$$::json; -- ERROR, single quotes are not allowed
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "'" is invalid.
CONTEXT: JSON data, line 1: '...
SELECT $$''$$::json; -- ERROR, single quotes are not allowed
^
SELECT '"abc"'::json; -- OK
SELECT '"abc'::json; -- ERROR, quotes not closed
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '"abc'::json; -- ERROR, quotes not closed
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token ""abc" is invalid.
CONTEXT: JSON data, line 1: "abc
SELECT '"abc'::json; -- ERROR, quotes not closed
^
SELECT '"abc
def"'::json; -- ERROR, unescaped newline in string constant
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '"abc
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Character with value 0x0a must be escaped.
CONTEXT: JSON data, line 1: "abc
SELECT '"abc
^
SELECT '"\n\"\\"'::json; -- OK, legal escapes
SELECT '"\v"'::json; -- ERROR, not a valid JSON escape
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '"\v"'::json; -- ERROR, not a valid JSON escape
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Escape sequence "\v" is invalid.
CONTEXT: JSON data, line 1: "\v...
SELECT '"\v"'::json; -- ERROR, not a valid JSON escape
^
-- see json_encoding test for input with unicode escapes
-- Numbers.
SELECT '1'::json; -- OK
SELECT '0'::json; -- OK
SELECT '01'::json; -- ERROR, not valid according to JSON spec
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '01'::json; -- ERROR, not valid according to JSON spec
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "01" is invalid.
CONTEXT: JSON data, line 1: 01
SELECT '01'::json; -- ERROR, not valid according to JSON spec
^
SELECT '0.1'::json; -- OK
SELECT '9223372036854775808'::json; -- OK, even though it's too large for int8
SELECT '1e100'::json; -- OK
SELECT '1.3e100'::json; -- OK
SELECT '1f2'::json; -- ERROR
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '1f2'::json; -- ERROR
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "1f2" is invalid.
CONTEXT: JSON data, line 1: 1f2
SELECT '1f2'::json; -- ERROR
^
SELECT '0.x1'::json; -- ERROR
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '0.x1'::json; -- ERROR
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "0.x1" is invalid.
CONTEXT: JSON data, line 1: 0.x1
SELECT '0.x1'::json; -- ERROR
^
SELECT '1.3ex100'::json; -- ERROR
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '1.3ex100'::json; -- ERROR
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "1.3ex100" is invalid.
CONTEXT: JSON data, line 1: 1.3ex100
SELECT '1.3ex100'::json; -- ERROR
^
-- Arrays.
SELECT '[]'::json; -- OK
SELECT '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'::json; -- OK
SELECT '[1,2]'::json; -- OK
SELECT '[1,2,]'::json; -- ERROR, trailing comma
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '[1,2,]'::json; -- ERROR, trailing comma
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected JSON value, but found "]".
CONTEXT: JSON data, line 1: [1,2,]
SELECT '[1,2,]'::json; -- ERROR, trailing comma
^
SELECT '[1,2'::json; -- ERROR, no closing bracket
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '[1,2'::json; -- ERROR, no closing bracket
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: The input string ended unexpectedly.
CONTEXT: JSON data, line 1: [1,2
SELECT '[1,2'::json; -- ERROR, no closing bracket
^
SELECT '[1,[2]'::json; -- ERROR, no closing bracket
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '[1,[2]'::json; -- ERROR, no closing bracket
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: The input string ended unexpectedly.
CONTEXT: JSON data, line 1: [1,[2]
SELECT '[1,[2]'::json; -- ERROR, no closing bracket
^
-- Objects.
SELECT '{}'::json; -- OK
SELECT '{"abc"}'::json; -- ERROR, no value
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc"}'::json; -- ERROR, no value
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected ":", but found "}".
CONTEXT: JSON data, line 1: {"abc"}
SELECT '{"abc"}'::json; -- ERROR, no value
^
SELECT '{"abc":1}'::json; -- OK
SELECT '{1:"abc"}'::json; -- ERROR, keys must be strings
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{1:"abc"}'::json; -- ERROR, keys must be strings
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected string or "}", but found "1".
CONTEXT: JSON data, line 1: {1...
SELECT '{1:"abc"}'::json; -- ERROR, keys must be strings
^
SELECT '{"abc",1}'::json; -- ERROR, wrong separator
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc",1}'::json; -- ERROR, wrong separator
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected ":", but found ",".
CONTEXT: JSON data, line 1: {"abc",...
SELECT '{"abc",1}'::json; -- ERROR, wrong separator
^
SELECT '{"abc"=1}'::json; -- ERROR, totally wrong separator
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc"=1}'::json; -- ERROR, totally wrong separator
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "=" is invalid.
CONTEXT: JSON data, line 1: {"abc"=...
SELECT '{"abc"=1}'::json; -- ERROR, totally wrong separator
^
SELECT '{"abc"::1}'::json; -- ERROR, another wrong separator
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc"::1}'::json; -- ERROR, another wrong separator
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected JSON value, but found ":".
CONTEXT: JSON data, line 1: {"abc"::...
SELECT '{"abc"::1}'::json; -- ERROR, another wrong separator
^
SELECT '{"abc":1,"def":2,"ghi":[3,4],"hij":{"klm":5,"nop":[6]}}'::json; -- OK
SELECT '{"abc":1:2}'::json; -- ERROR, colon in wrong spot
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc":1:2}'::json; -- ERROR, colon in wrong spot
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected "," or "}", but found ":".
CONTEXT: JSON data, line 1: {"abc":1:...
SELECT '{"abc":1:2}'::json; -- ERROR, colon in wrong spot
^
SELECT '{"abc":1,3}'::json; -- ERROR, no value
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{"abc":1,3}'::json; -- ERROR, no value
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected string, but found "3".
CONTEXT: JSON data, line 1: {"abc":1,3...
SELECT '{"abc":1,3}'::json; -- ERROR, no value
^
-- Miscellaneous stuff.
SELECT 'true'::json; -- OK
SELECT 'false'::json; -- OK
SELECT 'null'::json; -- OK
SELECT ' true '::json; -- OK, even with extra whitespace
SELECT 'true false'::json; -- ERROR, too many values
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT 'true false'::json; -- ERROR, too many values
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected end of input, but found "false".
CONTEXT: JSON data, line 1: true false
SELECT 'true false'::json; -- ERROR, too many values
^
SELECT 'true, false'::json; -- ERROR, too many values
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT 'true, false'::json; -- ERROR, too many values
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected end of input, but found ",".
CONTEXT: JSON data, line 1: true,...
SELECT 'true, false'::json; -- ERROR, too many values
^
SELECT 'truf'::json; -- ERROR, not a keyword
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT 'truf'::json; -- ERROR, not a keyword
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "truf" is invalid.
CONTEXT: JSON data, line 1: truf
SELECT 'truf'::json; -- ERROR, not a keyword
^
SELECT 'trues'::json; -- ERROR, not a keyword
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT 'trues'::json; -- ERROR, not a keyword
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Token "trues" is invalid.
CONTEXT: JSON data, line 1: trues
SELECT 'trues'::json; -- ERROR, not a keyword
^
SELECT ''::json; -- ERROR, no value
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT ''::json; -- ERROR, no value
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: The input string ended unexpectedly.
CONTEXT: JSON data, line 1:
SELECT ''::json; -- ERROR, no value
^
SELECT ' '::json; -- ERROR, no value
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT ' '::json; -- ERROR, no value
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: The input string ended unexpectedly.
CONTEXT: JSON data, line 1:
SELECT ' '::json; -- ERROR, no value
^
-- Multi-line JSON input to check ERROR reporting
SELECT '{
"one": 1,
"two":"two",
"three":
true}'::json; -- OK
SELECT '{
"one": 1,
"two":,"two", -- ERROR extraneous comma before field "two"
"three":
true}'::json;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected JSON value, but found ",".
CONTEXT: JSON data, line 3: "two":,...
SELECT '{
^
SELECT '{
"one": 1,
"two":"two",
"averyveryveryveryveryveryveryveryveryverylongfieldname":}'::json;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT '{
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type json
DETAIL: Expected JSON value, but found "}".
CONTEXT: JSON data, line 4: ...yveryveryveryveryveryveryveryverylongfieldname":}
SELECT '{
^
-- ERROR missing value for last field
--constructors
-- array_to_json
SELECT array_to_json(array(select 1 as a));
SELECT array_to_json(array_agg(q),false) from (select x as b, x * 2 as c from generate_series(1,3) x) q;
-stdin-:: Fatal: No such type: 0
SELECT array_to_json(array_agg(q),true) from (select x as b, x * 2 as c from generate_series(1,3) x) q;
-stdin-:: Fatal: No such type: 0
SELECT array_to_json(array_agg(q),false)
FROM ( SELECT $$a$$ || x AS b, y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),
ROW(y.*,ARRAY[4,5,6])] AS z
FROM generate_series(1,2) x,
generate_series(4,5) y) q;
-stdin-:: Error: Parse Sql
-stdin-::3:16: Error: alternative is not implemented yet : 138
ARRAY[ROW(x.*,ARRAY[1,2,3]),
^
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
SELECT array_to_json(array_agg(q),false)
^
-stdin-::1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
SELECT array_to_json(array_agg(q),false)
^
SELECT array_to_json(array_agg(x),false) from generate_series(5,10) x;
SELECT array_to_json('{{1,5},{99,100}}'::int[]);
-- row_to_json
SELECT row_to_json(row(1,'foo'));
-stdin-:: Error: Parse Sql
-stdin-::2:8: Error: alternative is not implemented yet : 138
SELECT row_to_json(row(1,'foo'));
^
SELECT row_to_json(q)
FROM (SELECT $$a$$ || x AS b,
y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),
ROW(y.*,ARRAY[4,5,6])] AS z
FROM generate_series(1,2) x,
generate_series(4,5) y) q;
-stdin-:: Error: Parse Sql
-stdin-::4:10: Error: alternative is not implemented yet : 138
ARRAY[ROW(x.*,ARRAY[1,2,3]),
^
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
SELECT row_to_json(q)
^
-stdin-::1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
SELECT row_to_json(q)
^
SELECT row_to_json(q,true)
FROM (SELECT $$a$$ || x AS b,
y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),
ROW(y.*,ARRAY[4,5,6])] AS z
FROM generate_series(1,2) x,
generate_series(4,5) y) q;
-stdin-:: Error: Parse Sql
-stdin-::4:10: Error: alternative is not implemented yet : 138
ARRAY[ROW(x.*,ARRAY[1,2,3]),
^
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
SELECT row_to_json(q,true)
^
-stdin-::1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
SELECT row_to_json(q,true)
^
CREATE TEMP TABLE rows AS
SELECT x, 'txt' || x as y
FROM generate_series(1,3) AS x;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: RawStmt: alternative is not implemented yet : 277
CREATE TEMP TABLE rows AS
^
SELECT row_to_json(q,true)
FROM rows q;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.rows
SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false);
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: alternative is not implemented yet : 138
SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false);
^
-- anyarray column
analyze rows;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: RawStmt: alternative is not implemented yet : 275
-- anyarray column
^
select attname, to_json(histogram_bounds) histogram_bounds
from pg_stats
where tablename = 'rows' and
schemaname = pg_my_temp_schema()::regnamespace::text
order by 1;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select attname, to_json(histogram_bounds) histogram_bounds
^
-stdin-::1:17: Error: At function: PgCall
select attname, to_json(histogram_bounds) histogram_bounds
^
-stdin-::1:17: Error: Unable to find an overload for proc to_json with given argument types: (anyarray)
select attname, to_json(histogram_bounds) histogram_bounds
^
-- to_json, timestamps
select to_json(timestamp '2014-05-28 12:22:35.614298');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
-- to_json, timestamps
^
-stdin-::2:8: Error: At function: PgCall
select to_json(timestamp '2014-05-28 12:22:35.614298');
^
-stdin-::2:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamp)
select to_json(timestamp '2014-05-28 12:22:35.614298');
^
BEGIN;
SET LOCAL TIME ZONE 10.5;
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamptz)
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
SET LOCAL TIME ZONE -8;
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamptz)
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
^
COMMIT;
select to_json(date '2014-05-28');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(date '2014-05-28');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(date '2014-05-28');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (date)
select to_json(date '2014-05-28');
^
select to_json(date 'Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(date 'Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(date 'Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (date)
select to_json(date 'Infinity');
^
select to_json(date '-Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(date '-Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(date '-Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (date)
select to_json(date '-Infinity');
^
select to_json(timestamp 'Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamp 'Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamp 'Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamp)
select to_json(timestamp 'Infinity');
^
select to_json(timestamp '-Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamp '-Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamp '-Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamp)
select to_json(timestamp '-Infinity');
^
select to_json(timestamptz 'Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamptz 'Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamptz 'Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamptz)
select to_json(timestamptz 'Infinity');
^
select to_json(timestamptz '-Infinity');
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select to_json(timestamptz '-Infinity');
^
-stdin-::1:8: Error: At function: PgCall
select to_json(timestamptz '-Infinity');
^
-stdin-::1:8: Error: Unable to find an overload for proc to_json with given argument types: (timestamptz)
select to_json(timestamptz '-Infinity');
^
--json_agg
SELECT json_agg(q)
FROM ( SELECT $$a$$ || x AS b, y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),
ROW(y.*,ARRAY[4,5,6])] AS z
FROM generate_series(1,2) x,
generate_series(4,5) y) q;
-stdin-:: Error: Parse Sql
-stdin-::4:16: Error: alternative is not implemented yet : 138
ARRAY[ROW(x.*,ARRAY[1,2,3]),
^
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
--json_agg
^
-stdin-::1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
--json_agg
^
SELECT json_agg(q ORDER BY x, y)
FROM rows q;
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: FuncCall: unsupported agg_order
SELECT json_agg(q ORDER BY x, y)
^
UPDATE rows SET x = NULL WHERE x = 1;
-stdin-:: Fatal: Pre type annotation
-stdin-:: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_update' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
SELECT json_agg(q ORDER BY x NULLS FIRST, y)
FROM rows q;
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: FuncCall: unsupported agg_order
SELECT json_agg(q ORDER BY x NULLS FIRST, y)
^
-- non-numeric output
SELECT row_to_json(q)
FROM (SELECT 'NaN'::float8 AS "float8field") q;
SELECT row_to_json(q)
FROM (SELECT 'Infinity'::float8 AS "float8field") q;
SELECT row_to_json(q)
FROM (SELECT '-Infinity'::float8 AS "float8field") q;
-- json input
SELECT row_to_json(q)
FROM (SELECT '{"a":1,"b": [2,3,4,"d","e","f"],"c":{"p":1,"q":2}}'::json AS "jsonfield") q;
-- json extraction functions
CREATE TEMP TABLE test_json (
json_type text,
test_json json
);
INSERT INTO test_json VALUES
('scalar','"a scalar"'),
('array','["zero", "one","two",null,"four","five", [1,2,3],{"f1":9}]'),
('object','{"field1":"val1","field2":"val2","field3":null, "field4": 4, "field5": [1,2,3], "field6": {"f1":9}}');
SELECT test_json -> 'x'
FROM test_json
WHERE json_type = 'scalar';
SELECT test_json -> 'x'
FROM test_json
WHERE json_type = 'array';
SELECT test_json -> 'x'
FROM test_json
WHERE json_type = 'object';
SELECT test_json->'field2'
FROM test_json
WHERE json_type = 'object';
SELECT test_json->>'field2'
FROM test_json
WHERE json_type = 'object';
SELECT test_json -> 2
FROM test_json
WHERE json_type = 'scalar';
SELECT test_json -> 2
FROM test_json
WHERE json_type = 'array';
SELECT test_json -> -1
FROM test_json
WHERE json_type = 'array';
SELECT test_json -> 2
FROM test_json
WHERE json_type = 'object';
SELECT test_json->>2
FROM test_json
WHERE json_type = 'array';
SELECT test_json ->> 6 FROM test_json WHERE json_type = 'array';
SELECT test_json ->> 7 FROM test_json WHERE json_type = 'array';
SELECT test_json ->> 'field4' FROM test_json WHERE json_type = 'object';
SELECT test_json ->> 'field5' FROM test_json WHERE json_type = 'object';
SELECT test_json ->> 'field6' FROM test_json WHERE json_type = 'object';
SELECT json_object_keys(test_json)
FROM test_json
WHERE json_type = 'scalar';
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: Generator functions are not allowed in: SELECT
SELECT json_object_keys(test_json)
^
SELECT json_object_keys(test_json)
FROM test_json
WHERE json_type = 'array';
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: Generator functions are not allowed in: SELECT
SELECT json_object_keys(test_json)
^
SELECT json_object_keys(test_json)
FROM test_json
WHERE json_type = 'object';
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: Generator functions are not allowed in: SELECT
SELECT json_object_keys(test_json)
^
-- test extending object_keys resultset - initial resultset size is 256
select count(*) from
(select json_object_keys(json_object(array_agg(g)))
from (select unnest(array['f'||n,n::text])as g
from generate_series(1,300) as n) x ) y;
-stdin-:: Error: Parse Sql
-stdin-::4:19: Error: Generator functions are not allowed in: SELECT
from (select unnest(array['f'||n,n::text])as g
^
-stdin-::3:13: Error: Generator functions are not allowed in: SELECT
(select json_object_keys(json_object(array_agg(g)))
^
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
-- test extending object_keys resultset - initial resultset size is 256
^
-stdin-::1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
-- test extending object_keys resultset - initial resultset size is 256
^
-- nulls
select (test_json->'field3') is null as expect_false
from test_json
where json_type = 'object';
select (test_json->>'field3') is null as expect_true
from test_json
where json_type = 'object';
select (test_json->3) is null as expect_false
from test_json
where json_type = 'array';
select (test_json->>3) is null as expect_true
from test_json
where json_type = 'array';
-- corner cases
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::text;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::int;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 1;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> -1;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 'z';
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> '';
select '[{"b": "c"}, {"b": "cc"}]'::json -> 1;
select '[{"b": "c"}, {"b": "cc"}]'::json -> 3;
select '[{"b": "c"}, {"b": "cc"}]'::json -> 'z';
select '{"a": "c", "b": null}'::json -> 'b';
select '"foo"'::json -> 1;
select '"foo"'::json -> 'z';
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::text;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::int;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 1;
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 'z';
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> '';
select '[{"b": "c"}, {"b": "cc"}]'::json ->> 1;
select '[{"b": "c"}, {"b": "cc"}]'::json ->> 3;
select '[{"b": "c"}, {"b": "cc"}]'::json ->> 'z';
select '{"a": "c", "b": null}'::json ->> 'b';
select '"foo"'::json ->> 1;
select '"foo"'::json ->> 'z';
-- array length
SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]');
SELECT json_array_length('[]');
SELECT json_array_length('{"f1":1,"f2":[5,6]}');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT json_array_length('{"f1":1,"f2":[5,6]}');
^
-stdin-::1:1: Fatal: ERROR: cannot get array length of a non-array
SELECT json_array_length('{"f1":1,"f2":[5,6]}');
^
SELECT json_array_length('4');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT json_array_length('4');
^
-stdin-::1:1: Fatal: ERROR: cannot get array length of a scalar
SELECT json_array_length('4');
^
-- each
select json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}');
-stdin-:: Error: Parse Sql
-stdin-::2:8: Error: Generator functions are not allowed in: SELECT
select json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}');
^
select * from json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q;
select json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}');
-stdin-:: Error: Parse Sql
-stdin-::1:8: Error: Generator functions are not allowed in: SELECT
select json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}');
^
select * from json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q;
-- extract_path, extract_path_as_text
select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6');
select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2');
select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text);
select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text);
select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6');
select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2');
select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text);
select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text);
-- extract_path nulls
select json_extract_path('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_false;
select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_true;
select json_extract_path('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_false;
select json_extract_path_text('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_true;
-- extract_path operators
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f4','f6'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
-- extract_path operators
^
-stdin-::2:61: Error: At function: PgOp
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f4','f6'];
^
-stdin-::2:61: Error: No such operator: #>
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f4','f6'];
^
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'];
^
-stdin-::1:61: Error: No such operator: #>
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'];
^
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'];
^
-stdin-::1:61: Error: No such operator: #>
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'];
^
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'];
^
-stdin-::1:61: Error: No such operator: #>
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'];
^
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'];
^
-stdin-::1:61: Error: No such operator: #>>
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'];
^
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'];
^
-stdin-::1:61: Error: No such operator: #>>
select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'];
^
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'];
^
-stdin-::1:61: Error: No such operator: #>>
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'];
^
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'];
^
-stdin-::1:61: Error: At function: PgOp
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'];
^
-stdin-::1:61: Error: No such operator: #>>
select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'];
^
-- corner cases for same
select '{"a": {"b":{"c": "foo"}}}'::json #> '{}';
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
-- corner cases for same
^
-stdin-::2:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> '{}';
^
-stdin-::2:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> '{}';
^
select '[1,2,3]'::json #> '{}';
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '[1,2,3]'::json #> '{}';
^
-stdin-::1:24: Error: At function: PgOp
select '[1,2,3]'::json #> '{}';
^
-stdin-::1:24: Error: No such operator: #>
select '[1,2,3]'::json #> '{}';
^
select '"foo"'::json #> '{}';
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '"foo"'::json #> '{}';
^
-stdin-::1:22: Error: At function: PgOp
select '"foo"'::json #> '{}';
^
-stdin-::1:22: Error: No such operator: #>
select '"foo"'::json #> '{}';
^
select '42'::json #> '{}';
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '42'::json #> '{}';
^
-stdin-::1:19: Error: At function: PgOp
select '42'::json #> '{}';
^
-stdin-::1:19: Error: No such operator: #>
select '42'::json #> '{}';
^
select 'null'::json #> '{}';
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select 'null'::json #> '{}';
^
-stdin-::1:21: Error: At function: PgOp
select 'null'::json #> '{}';
^
-stdin-::1:21: Error: No such operator: #>
select 'null'::json #> '{}';
^
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'];
^
-stdin-::1:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'];
^
-stdin-::1:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'];
^
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null];
^
-stdin-::1:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null];
^
-stdin-::1:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null];
^
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''];
^
-stdin-::1:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''];
^
-stdin-::1:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''];
^
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'];
^
-stdin-::1:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'];
^
-stdin-::1:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'];
^
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'];
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'];
^
-stdin-::1:42: Error: At function: PgOp
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'];
^
-stdin-::1:42: Error: No such operator: #>
select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'];
^