Browse Source

YQL-19206 Move contrib/ydb/library/yql/tests/postgresql -> yql/essentials/tests/postgresql
commit_hash:46fdf59714b20cf2b61233a06e58365227d3c8b2

udovichenko-r 3 months ago
parent
commit
72b3cd51dc

+ 10 - 0
yql/essentials/tests/postgresql/README.md

@@ -0,0 +1,10 @@
+Original regression Postgresql tests are in original/cases
+Extracts of original tests used as pre-commit tests are in cases
+
+test.sh runs pre-commit tests. Run ya make in yql/tools/pg-make-test beforehand
+original.sh runs original tests
+
+Run make-tests.sh to build pre-commit tests from original tests. pg_tests.csv file is a report file indicating
+share of SQL statements per testcase, which run successfully.
+
+Run update-status.sh to update status.md from pg_tests.csv

+ 3402 - 0
yql/essentials/tests/postgresql/cases/aggregates.err

@@ -0,0 +1,3402 @@
+Registering pre-existing tables
+	onek
+	int4_tbl
+	INT4_TBL
+	tenk1
+	VARCHAR_TBL
+	aggtest
+	student
+	varchar_tbl
+	int8_tbl
+<sql-statement>
+--
+-- AGGREGATES
+--
+-- avoid bit-exact output here because operations may not be bit-exact.
+SET extra_float_digits = 0;
+</sql-statement>
+<sql-statement>
+SELECT avg(four) AS avg_1 FROM onek;
+</sql-statement>
+<sql-statement>
+SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100;
+</sql-statement>
+<sql-statement>
+-- In 7.1, avg(float4) is computed using float8 arithmetic.
+-- Round the result to 3 digits to avoid platform-specific results.
+SELECT avg(b)::numeric(10,3) AS avg_107_943 FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT avg(gpa) AS avg_3_4 FROM ONLY student;
+</sql-statement>
+<sql-statement>
+SELECT sum(four) AS sum_1500 FROM onek;
+</sql-statement>
+<sql-statement>
+SELECT sum(a) AS sum_198 FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT sum(b) AS avg_431_773 FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT sum(gpa) AS avg_6_8 FROM ONLY student;
+</sql-statement>
+<sql-statement>
+SELECT max(four) AS max_3 FROM onek;
+</sql-statement>
+<sql-statement>
+SELECT max(a) AS max_100 FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT max(aggtest.b) AS max_324_78 FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT max(student.gpa) AS max_3_7 FROM student;
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop(b) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT stddev_samp(b) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT var_pop(b) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT var_samp(b) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop(b::numeric) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT stddev_samp(b::numeric) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT var_pop(b::numeric) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT var_samp(b::numeric) FROM aggtest;
+</sql-statement>
+<sql-statement>
+-- population variance is defined for a single tuple, sample variance
+-- is not
+SELECT var_pop(1.0::float8), var_samp(2.0::float8);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop(3.0::float8), stddev_samp(4.0::float8);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('inf'::float8), var_samp('inf'::float8);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('nan'::float8), var_samp('nan'::float8);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8);
+</sql-statement>
+<sql-statement>
+SELECT var_pop(1.0::float4), var_samp(2.0::float4);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop(3.0::float4), stddev_samp(4.0::float4);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('inf'::float4), var_samp('inf'::float4);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('nan'::float4), var_samp('nan'::float4);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4);
+</sql-statement>
+<sql-statement>
+SELECT var_pop(1.0::numeric), var_samp(2.0::numeric);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop(3.0::numeric), stddev_samp(4.0::numeric);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('inf'::numeric), var_samp('inf'::numeric);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric);
+</sql-statement>
+<sql-statement>
+SELECT var_pop('nan'::numeric), var_samp('nan'::numeric);
+</sql-statement>
+<sql-statement>
+SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric);
+</sql-statement>
+<sql-statement>
+-- verify correct results for null and NaN inputs
+select sum(null::int4) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select sum(null::int8) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select sum(null::numeric) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select sum(null::float8) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select avg(null::int4) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select avg(null::int8) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select avg(null::numeric) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select avg(null::float8) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select sum('NaN'::numeric) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+select avg('NaN'::numeric) from generate_series(1,3);
+</sql-statement>
+<sql-statement>
+-- verify correct results for infinite inputs
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('1'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('1')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('1'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('1')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+</sql-statement>
+<sql-statement>
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+</sql-statement>
+<sql-statement>
+-- test accuracy with a large input offset
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x);
+</sql-statement>
+<sql-statement>
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (7000000000005), (7000000000007)) v(x);
+</sql-statement>
+<sql-statement>
+-- SQL2003 binary aggregates
+SELECT regr_count(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_sxx(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_syy(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_sxy(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_r2(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+SELECT corr(b, a) FROM aggtest;
+</sql-statement>
+<sql-statement>
+-- check single-tuple behavior
+SELECT covar_pop(1::float8,2::float8), covar_samp(3::float8,4::float8);
+</sql-statement>
+<sql-statement>
+SELECT covar_pop(1::float8,'inf'::float8), covar_samp(3::float8,'inf'::float8);
+</sql-statement>
+<sql-statement>
+SELECT covar_pop(1::float8,'nan'::float8), covar_samp(3::float8,'nan'::float8);
+</sql-statement>
+<sql-statement>
+-- test accum and combine functions directly
+CREATE TABLE regr_test (x float8, y float8);
+</sql-statement>
+<sql-statement>
+INSERT INTO regr_test VALUES (10,150),(20,250),(30,350),(80,540),(100,200);
+</sql-statement>
+<sql-statement>
+SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+FROM regr_test WHERE x IN (10,20,30,80);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: sum
+        	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+<sql-statement>
+SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+FROM regr_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: sum
+        	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+<sql-statement>
+SELECT float8_accum('{4,140,2900}'::float8[], 100);
+</sql-statement>
+<sql-statement>
+SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100);
+</sql-statement>
+<sql-statement>
+SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+FROM regr_test WHERE x IN (10,20,30);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: sum
+        	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+<sql-statement>
+SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+FROM regr_test WHERE x IN (80,100);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: sum
+        	SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x)
+	^
+<sql-statement>
+SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[]);
+</sql-statement>
+<sql-statement>
+SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[]);
+</sql-statement>
+<sql-statement>
+SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[]);
+</sql-statement>
+<sql-statement>
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{0,0,0,0,0,0}'::float8[]);
+</sql-statement>
+<sql-statement>
+SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+</sql-statement>
+<sql-statement>
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+</sql-statement>
+<sql-statement>
+DROP TABLE regr_test;
+</sql-statement>
+<sql-statement>
+-- test count, distinct
+SELECT count(four) AS cnt_1000 FROM onek;
+</sql-statement>
+<sql-statement>
+SELECT count(DISTINCT four) AS cnt_4 FROM onek;
+</sql-statement>
+<sql-statement>
+select ten, count(*), sum(four) from onek
+group by ten order by ten;
+</sql-statement>
+<sql-statement>
+select ten, count(four), sum(DISTINCT four) from onek
+group by ten order by ten;
+</sql-statement>
+<sql-statement>
+-- user-defined aggregates
+SELECT newavg(four) AS avg_1 FROM onek;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- user-defined aggregates
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	SELECT newavg(four) AS avg_1 FROM onek;
+	       ^
+            -stdin-:<main>:2:8: Error: No such proc: newavg
+            	SELECT newavg(four) AS avg_1 FROM onek;
+	       ^
+<sql-statement>
+SELECT newsum(four) AS sum_1500 FROM onek;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT newsum(four) AS sum_1500 FROM onek;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT newsum(four) AS sum_1500 FROM onek;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: newsum
+            	SELECT newsum(four) AS sum_1500 FROM onek;
+	       ^
+<sql-statement>
+SELECT newcnt(four) AS cnt_1000 FROM onek;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT newcnt(four) AS cnt_1000 FROM onek;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT newcnt(four) AS cnt_1000 FROM onek;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: newcnt
+            	SELECT newcnt(four) AS cnt_1000 FROM onek;
+	       ^
+<sql-statement>
+SELECT newcnt(*) AS cnt_1000 FROM onek;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: * is expected only in count function
+    	SELECT newcnt(*) AS cnt_1000 FROM onek;
+	       ^
+<sql-statement>
+SELECT oldcnt(*) AS cnt_1000 FROM onek;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: * is expected only in count function
+    	SELECT oldcnt(*) AS cnt_1000 FROM onek;
+	       ^
+<sql-statement>
+SELECT sum2(q1,q2) FROM int8_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT sum2(q1,q2) FROM int8_tbl;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT sum2(q1,q2) FROM int8_tbl;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: sum2
+            	SELECT sum2(q1,q2) FROM int8_tbl;
+	       ^
+<sql-statement>
+-- test for outer-level aggregates
+-- this should work
+select ten, sum(distinct four) from onek a
+group by ten
+having exists (select 1 from onek b where sum(distinct a.four) = b.four);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:5:43: Error: Aggregate functions are not allowed in: WHERE
+    	having exists (select 1 from onek b where sum(distinct a.four) = b.four);
+	                                          ^
+<sql-statement>
+-- this should fail because subquery has an agg of its own in WHERE
+select ten, sum(distinct four) from onek a
+group by ten
+having exists (select 1 from onek b
+               where sum(distinct a.four + b.four) = b.four);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:5:22: Error: Aggregate functions are not allowed in: WHERE
+    	               where sum(distinct a.four + b.four) = b.four);
+	                     ^
+<sql-statement>
+-- Test handling of sublinks within outer-level aggregates.
+-- Per bug report from Daniel Grace.
+select
+  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)))
+from tenk1 o;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- Test handling of sublinks within outer-level aggregates.
+	^
+        -stdin-:<main>:4:3: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+        	  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)))
+	  ^
+            -stdin-:<main>:4:11: Error: At function: PgAgg
+            	  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)))
+	          ^
+                -stdin-:<main>:4:15: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem
+                	  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)))
+	              ^
+                    -stdin-:<main>:4:64: Error: No such column: unique1
+                    	  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)))
+	                                                               ^
+<sql-statement>
+-- Test handling of Params within aggregate arguments in hashed aggregation.
+-- Per bug report from Jeevan Chalke.
+explain (verbose, costs off)
+select s1, s2, sm
+from generate_series(1, 3) s1,
+     lateral (select s2, sum(s1 + s2) sm
+              from generate_series(1, 3) s2 group by s2) ss
+order by 1, 2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Test handling of Params within aggregate arguments in hashed aggregation.
+	^
+<sql-statement>
+select s1, s2, sm
+from generate_series(1, 3) s1,
+     lateral (select s2, sum(s1 + s2) sm
+              from generate_series(1, 3) s2 group by s2) ss
+order by 1, 2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
+    	select s1, s2, sm
+	^
+<sql-statement>
+explain (verbose, costs off)
+select array(select sum(x+y) s
+            from generate_series(1,3) y group by y order by s)
+  from generate_series(1,3) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (verbose, costs off)
+	^
+<sql-statement>
+select array(select sum(x+y) s
+            from generate_series(1,3) y group by y order by s)
+  from generate_series(1,3) x;
+</sql-statement>
+<sql-statement>
+--
+-- test for bitwise integer aggregates
+--
+CREATE TEMPORARY TABLE bitwise_test(
+  i2 INT2,
+  i4 INT4,
+  i8 INT8,
+  i INTEGER,
+  x INT2,
+  y BIT(4)
+);
+</sql-statement>
+<sql-statement>
+-- empty case
+SELECT
+  BIT_AND(i2) AS "?",
+  BIT_OR(i4)  AS "?",
+  BIT_XOR(i8) AS "?"
+FROM bitwise_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- empty case
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: ?
+        	-- empty case
+	^
+<sql-statement>
+COPY bitwise_test FROM STDIN NULL 'null';
+1	1	1	1	1	B0101
+3	3	3	null	2	B0100
+7	7	7	3	4	B1100
+\.
+</sql-statement>
+Metacommand \. is not supported
+<sql-statement>
+SELECT
+  BIT_AND(i2) AS "1",
+  BIT_AND(i4) AS "1",
+  BIT_AND(i8) AS "1",
+  BIT_AND(i)  AS "?",
+  BIT_AND(x)  AS "0",
+  BIT_AND(y)  AS "0100",
+  BIT_OR(i2)  AS "7",
+  BIT_OR(i4)  AS "7",
+  BIT_OR(i8)  AS "7",
+  BIT_OR(i)   AS "?",
+  BIT_OR(x)   AS "7",
+  BIT_OR(y)   AS "1101",
+  BIT_XOR(i2) AS "5",
+  BIT_XOR(i4) AS "5",
+  BIT_XOR(i8) AS "5",
+  BIT_XOR(i)  AS "?",
+  BIT_XOR(x)  AS "7",
+  BIT_XOR(y)  AS "1101"
+FROM bitwise_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: 1
+        	SELECT
+	^
+<sql-statement>
+--
+-- test boolean aggregates
+--
+-- first test all possible transition and final states
+SELECT
+  -- boolean and transitions
+  -- null because strict
+  booland_statefunc(NULL, NULL)  IS NULL AS "t",
+  booland_statefunc(TRUE, NULL)  IS NULL AS "t",
+  booland_statefunc(FALSE, NULL) IS NULL AS "t",
+  booland_statefunc(NULL, TRUE)  IS NULL AS "t",
+  booland_statefunc(NULL, FALSE) IS NULL AS "t",
+  -- and actual computations
+  booland_statefunc(TRUE, TRUE) AS "t",
+  NOT booland_statefunc(TRUE, FALSE) AS "t",
+  NOT booland_statefunc(FALSE, TRUE) AS "t",
+  NOT booland_statefunc(FALSE, FALSE) AS "t";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	--
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: t
+        	--
+	^
+<sql-statement>
+SELECT
+  -- boolean or transitions
+  -- null because strict
+  boolor_statefunc(NULL, NULL)  IS NULL AS "t",
+  boolor_statefunc(TRUE, NULL)  IS NULL AS "t",
+  boolor_statefunc(FALSE, NULL) IS NULL AS "t",
+  boolor_statefunc(NULL, TRUE)  IS NULL AS "t",
+  boolor_statefunc(NULL, FALSE) IS NULL AS "t",
+  -- actual computations
+  boolor_statefunc(TRUE, TRUE) AS "t",
+  boolor_statefunc(TRUE, FALSE) AS "t",
+  boolor_statefunc(FALSE, TRUE) AS "t",
+  NOT boolor_statefunc(FALSE, FALSE) AS "t";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: t
+        	SELECT
+	^
+<sql-statement>
+CREATE TEMPORARY TABLE bool_test(
+  b1 BOOL,
+  b2 BOOL,
+  b3 BOOL,
+  b4 BOOL);
+</sql-statement>
+<sql-statement>
+-- empty case
+SELECT
+  BOOL_AND(b1)   AS "n",
+  BOOL_OR(b3)    AS "n"
+FROM bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- empty case
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: n
+        	-- empty case
+	^
+<sql-statement>
+COPY bool_test FROM STDIN NULL 'null';
+TRUE	null	FALSE	null
+FALSE	TRUE	null	null
+null	TRUE	FALSE	null
+\.
+</sql-statement>
+Metacommand \. is not supported
+<sql-statement>
+SELECT
+  BOOL_AND(b1)     AS "f",
+  BOOL_AND(b2)     AS "t",
+  BOOL_AND(b3)     AS "f",
+  BOOL_AND(b4)     AS "n",
+  BOOL_AND(NOT b2) AS "f",
+  BOOL_AND(NOT b3) AS "t"
+FROM bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: f
+        	SELECT
+	^
+<sql-statement>
+SELECT
+  EVERY(b1)     AS "f",
+  EVERY(b2)     AS "t",
+  EVERY(b3)     AS "f",
+  EVERY(b4)     AS "n",
+  EVERY(NOT b2) AS "f",
+  EVERY(NOT b3) AS "t"
+FROM bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: f
+        	SELECT
+	^
+<sql-statement>
+SELECT
+  BOOL_OR(b1)      AS "t",
+  BOOL_OR(b2)      AS "t",
+  BOOL_OR(b3)      AS "f",
+  BOOL_OR(b4)      AS "n",
+  BOOL_OR(NOT b2)  AS "f",
+  BOOL_OR(NOT b3)  AS "t"
+FROM bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: f
+        	SELECT
+	^
+<sql-statement>
+--
+-- Test cases that should be optimized into indexscans instead of
+-- the generic aggregate implementation.
+--
+-- Basic cases
+explain (costs off)
+  select min(unique1) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	--
+	^
+<sql-statement>
+select min(unique1) from tenk1;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique1) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique1) from tenk1;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique1) from tenk1 where unique1 < 42;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique1) from tenk1 where unique1 < 42;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique1) from tenk1 where unique1 > 42;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique1) from tenk1 where unique1 > 42;
+</sql-statement>
+<sql-statement>
+-- the planner may choose a generic aggregate here if parallel query is
+-- enabled, since that plan will be parallel safe and the "optimized"
+-- plan, which has almost identical cost, will not be.  we want to test
+-- the optimized plan, so temporarily disable parallel query.
+begin;
+</sql-statement>
+<sql-statement>
+set local max_parallel_workers_per_gather = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: max_parallel_workers_per_gather
+    	set local max_parallel_workers_per_gather = 0;
+	^
+<sql-statement>
+explain (costs off)
+  select max(unique1) from tenk1 where unique1 > 42000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique1) from tenk1 where unique1 > 42000;
+</sql-statement>
+<sql-statement>
+rollback;
+</sql-statement>
+<sql-statement>
+-- multi-column index (uses tenk1_thous_tenthous)
+explain (costs off)
+  select max(tenthous) from tenk1 where thousand = 33;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- multi-column index (uses tenk1_thous_tenthous)
+	^
+<sql-statement>
+select max(tenthous) from tenk1 where thousand = 33;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select min(tenthous) from tenk1 where thousand = 33;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select min(tenthous) from tenk1 where thousand = 33;
+</sql-statement>
+<sql-statement>
+-- check parameter propagation into an indexscan subquery
+explain (costs off)
+  select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
+    from int4_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- check parameter propagation into an indexscan subquery
+	^
+<sql-statement>
+select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
+  from int4_tbl;
+</sql-statement>
+<sql-statement>
+-- check some cases that were handled incorrectly in 8.3.0
+explain (costs off)
+  select distinct max(unique2) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- check some cases that were handled incorrectly in 8.3.0
+	^
+<sql-statement>
+select distinct max(unique2) from tenk1;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique2) from tenk1 order by 1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique2) from tenk1 order by 1;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique2) from tenk1 order by max(unique2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique2) from tenk1 order by max(unique2);
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique2) from tenk1 order by max(unique2)+1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique2) from tenk1 order by max(unique2)+1;
+</sql-statement>
+<sql-statement>
+explain (costs off)
+  select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:22: Error: Generator functions are not allowed in: SELECT
+    	select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
+	                     ^
+<sql-statement>
+-- interesting corner case: constant gets optimized into a seqscan
+explain (costs off)
+  select max(100) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- interesting corner case: constant gets optimized into a seqscan
+	^
+<sql-statement>
+select max(100) from tenk1;
+</sql-statement>
+<sql-statement>
+-- try it on an inheritance tree
+create table minmaxtest(f1 int);
+</sql-statement>
+<sql-statement>
+create table minmaxtest1() inherits (minmaxtest);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table minmaxtest1() inherits (minmaxtest);
+	^
+<sql-statement>
+create table minmaxtest2() inherits (minmaxtest);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table minmaxtest2() inherits (minmaxtest);
+	^
+<sql-statement>
+create table minmaxtest3() inherits (minmaxtest);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table minmaxtest3() inherits (minmaxtest);
+	^
+<sql-statement>
+create index minmaxtesti on minmaxtest(f1);
+</sql-statement>
+<sql-statement>
+create index minmaxtest1i on minmaxtest1(f1);
+</sql-statement>
+<sql-statement>
+create index minmaxtest2i on minmaxtest2(f1 desc);
+</sql-statement>
+<sql-statement>
+create index minmaxtest3i on minmaxtest3(f1) where f1 is not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: partial index is not supported yet
+    	create index minmaxtest3i on minmaxtest3(f1) where f1 is not null;
+	^
+<sql-statement>
+insert into minmaxtest values(11), (12);
+</sql-statement>
+<sql-statement>
+insert into minmaxtest1 values(13), (14);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.minmaxtest1
+    
+<sql-statement>
+insert into minmaxtest2 values(15), (16);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.minmaxtest2
+    
+<sql-statement>
+insert into minmaxtest3 values(17), (18);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.minmaxtest3
+    
+<sql-statement>
+explain (costs off)
+  select min(f1), max(f1) from minmaxtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+select min(f1), max(f1) from minmaxtest;
+</sql-statement>
+<sql-statement>
+-- DISTINCT doesn't do anything useful here, but it shouldn't fail
+explain (costs off)
+  select distinct min(f1), max(f1) from minmaxtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- DISTINCT doesn't do anything useful here, but it shouldn't fail
+	^
+<sql-statement>
+select distinct min(f1), max(f1) from minmaxtest;
+</sql-statement>
+<sql-statement>
+drop table minmaxtest cascade;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: CASCADE is not implemented
+    	drop table minmaxtest cascade;
+	^
+<sql-statement>
+-- check for correct detection of nested-aggregate errors
+select max(min(unique1)) from tenk1;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	-- check for correct detection of nested-aggregate errors
+	^
+        -stdin-:<main>:1:1: Fatal: ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp:364  GetCallable(): requirement Callables.cend() != compiler failed, message: Missed callable: PgAgg
+        	-- check for correct detection of nested-aggregate errors
+	^
+<sql-statement>
+select (select max(min(unique1)) from int8_tbl) from tenk1;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:8: Fatal: Execution of node: YtMapReduce!
+    	select (select max(min(unique1)) from int8_tbl) from tenk1;
+	       ^
+        -stdin-:<main>:1:8: Fatal: ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp:364  GetCallable(): requirement Callables.cend() != compiler failed, message: Missed callable: PgAgg
+        	select (select max(min(unique1)) from int8_tbl) from tenk1;
+	       ^
+<sql-statement>
+--
+-- Test removal of redundant GROUP BY columns
+--
+create temp table t1 (a int, b int, c int, d int, primary key (a, b));
+</sql-statement>
+<sql-statement>
+create temp table t2 (x int, y int, z int, primary key (x, y));
+</sql-statement>
+<sql-statement>
+create temp table t3 (a int, b int, c int, primary key(a, b) deferrable);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DEFERRABLE constraints not supported
+    	create temp table t3 (a int, b int, c int, primary key(a, b) deferrable);
+	^
+<sql-statement>
+-- Non-primary-key columns can be removed from GROUP BY
+explain (costs off) select * from t1 group by a,b,c,d;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Non-primary-key columns can be removed from GROUP BY
+	^
+<sql-statement>
+-- No removal can happen if the complete PK is not present in GROUP BY
+explain (costs off) select a,c from t1 group by a,c,d;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- No removal can happen if the complete PK is not present in GROUP BY
+	^
+<sql-statement>
+-- Test removal across multiple relations
+explain (costs off) select *
+from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y
+group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.y,t2.z;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Test removal across multiple relations
+	^
+<sql-statement>
+-- Test case where t1 can be optimized but not t2
+explain (costs off) select t1.*,t2.x,t2.z
+from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y
+group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.z;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Test case where t1 can be optimized but not t2
+	^
+<sql-statement>
+-- Cannot optimize when PK is deferrable
+explain (costs off) select * from t3 group by a,b,c;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Cannot optimize when PK is deferrable
+	^
+<sql-statement>
+create temp table t1c () inherits (t1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create temp table t1c () inherits (t1);
+	^
+<sql-statement>
+-- Ensure we don't remove any columns when t1 has a child table
+explain (costs off) select * from t1 group by a,b,c,d;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Ensure we don't remove any columns when t1 has a child table
+	^
+<sql-statement>
+-- Okay to remove columns if we're only querying the parent.
+explain (costs off) select * from only t1 group by a,b,c,d;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Okay to remove columns if we're only querying the parent.
+	^
+<sql-statement>
+create temp table p_t1 (
+  a int,
+  b int,
+  c int,
+  d int,
+  primary key(a,b)
+) partition by list(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
+    	create temp table p_t1 (
+	^
+<sql-statement>
+create temp table p_t1_1 partition of p_t1 for values in(1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create temp table p_t1_1 partition of p_t1 for values in(1);
+	^
+<sql-statement>
+create temp table p_t1_2 partition of p_t1 for values in(2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create temp table p_t1_2 partition of p_t1 for values in(2);
+	^
+<sql-statement>
+-- Ensure we can remove non-PK columns for partitioned tables.
+explain (costs off) select * from p_t1 group by a,b,c,d;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- Ensure we can remove non-PK columns for partitioned tables.
+	^
+<sql-statement>
+drop table t1 cascade;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: CASCADE is not implemented
+    	drop table t1 cascade;
+	^
+<sql-statement>
+drop table t2;
+</sql-statement>
+<sql-statement>
+drop table t3;
+</sql-statement>
+<sql-statement>
+drop table p_t1;
+</sql-statement>
+<sql-statement>
+--
+-- Test GROUP BY matching of join columns that are type-coerced due to USING
+--
+create temp table t1(f1 int, f2 bigint);
+</sql-statement>
+<sql-statement>
+create temp table t2(f1 bigint, f22 bigint);
+</sql-statement>
+<sql-statement>
+select f1 from t1 left join t2 using (f1) group by f1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	select f1 from t1 left join t2 using (f1) group by f1;
+	^
+        -stdin-:<main>:1:1: Error: Can't find column: f1
+        	select f1 from t1 left join t2 using (f1) group by f1;
+	^
+<sql-statement>
+select f1 from t1 left join t2 using (f1) group by t1.f1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	select f1 from t1 left join t2 using (f1) group by t1.f1;
+	^
+        -stdin-:<main>:1:1: Error: Can't find column: f1
+        	select f1 from t1 left join t2 using (f1) group by t1.f1;
+	^
+<sql-statement>
+select t1.f1 from t1 left join t2 using (f1) group by t1.f1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	select t1.f1 from t1 left join t2 using (f1) group by t1.f1;
+	^
+        -stdin-:<main>:1:1: Error: Can't find column: f1
+        	select t1.f1 from t1 left join t2 using (f1) group by t1.f1;
+	^
+<sql-statement>
+-- only this one should fail:
+select t1.f1 from t1 left join t2 using (f1) group by f1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- only this one should fail:
+	^
+        -stdin-:<main>:1:1: Error: Can't find column: f1
+        	-- only this one should fail:
+	^
+<sql-statement>
+drop table t1, t2;
+</sql-statement>
+<sql-statement>
+--
+-- Test combinations of DISTINCT and/or ORDER BY
+--
+select array_agg(a order by b)
+  from (values (1,4),(2,3),(3,1),(4,2)) v(a,b);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:4:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(a order by b)
+	       ^
+<sql-statement>
+select array_agg(a order by a)
+  from (values (1,4),(2,3),(3,1),(4,2)) v(a,b);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(a order by a)
+	       ^
+<sql-statement>
+select array_agg(a order by a desc)
+  from (values (1,4),(2,3),(3,1),(4,2)) v(a,b);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(a order by a desc)
+	       ^
+<sql-statement>
+select array_agg(b order by a desc)
+  from (values (1,4),(2,3),(3,1),(4,2)) v(a,b);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(b order by a desc)
+	       ^
+<sql-statement>
+select array_agg(distinct a)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+</sql-statement>
+<sql-statement>
+select array_agg(distinct a order by a)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(distinct a order by a)
+	       ^
+<sql-statement>
+select array_agg(distinct a order by a desc)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(distinct a order by a desc)
+	       ^
+<sql-statement>
+select array_agg(distinct a order by a desc nulls last)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(distinct a order by a desc nulls last)
+	       ^
+<sql-statement>
+-- multi-arg aggs, strict/nonstrict, distinct/order by
+select aggfstr(a,b,c)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- multi-arg aggs, strict/nonstrict, distinct/order by
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	select aggfstr(a,b,c)
+	       ^
+            -stdin-:<main>:2:8: Error: No such proc: aggfstr
+            	select aggfstr(a,b,c)
+	       ^
+<sql-statement>
+select aggfns(a,b,c)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select aggfns(a,b,c)
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select aggfns(a,b,c)
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: aggfns
+            	select aggfns(a,b,c)
+	       ^
+<sql-statement>
+select aggfstr(distinct a,b,c)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: agg_distinct must be set only for aggregate functions
+    	select aggfstr(distinct a,b,c)
+	       ^
+<sql-statement>
+select aggfns(distinct a,b,c)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: agg_distinct must be set only for aggregate functions
+    	select aggfns(distinct a,b,c)
+	       ^
+<sql-statement>
+select aggfstr(distinct a,b,c order by b)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfstr(distinct a,b,c order by b)
+	       ^
+<sql-statement>
+select aggfns(distinct a,b,c order by b)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by b)
+	       ^
+<sql-statement>
+-- test specific code paths
+select aggfns(distinct a,a,c order by c using ~<~,a)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,a,c order by c using ~<~,a)
+	       ^
+<sql-statement>
+select aggfns(distinct a,a,c order by c using ~<~)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,a,c order by c using ~<~)
+	       ^
+<sql-statement>
+select aggfns(distinct a,a,c order by a)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,a,c order by a)
+	       ^
+<sql-statement>
+select aggfns(distinct a,b,c order by a,c using ~<~,b)
+  from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+       generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by a,c using ~<~,b)
+	       ^
+<sql-statement>
+-- check node I/O via view creation and usage, also deparsing logic
+create view agg_view1 as
+  select aggfns(a,b,c)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	-- check node I/O via view creation and usage, also deparsing logic
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(distinct a,b,c)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+         generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(distinct a,b,c order by b)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+         generate_series(1,3) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(a,b,c order by b+1)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(a,a,c order by b)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(a,b,c order by c using ~<~)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+create or replace view agg_view1 as
+  select aggfns(distinct a,b,c order by a,c using ~<~,b)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+         generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	create or replace view agg_view1 as
+	^
+<sql-statement>
+select * from agg_view1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_view1
+    
+<sql-statement>
+select pg_get_viewdef('agg_view1'::regclass);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('agg_view1'::regclass);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "agg_view1" does not exist
+
+        	select pg_get_viewdef('agg_view1'::regclass);
+	^
+<sql-statement>
+drop view agg_view1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: View not found: 'agg_view1'
+    	drop view agg_view1;
+	^
+<sql-statement>
+-- incorrect DISTINCT usage errors
+select aggfns(distinct a,b,c order by i)
+  from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by i)
+	       ^
+<sql-statement>
+select aggfns(distinct a,b,c order by a,b+1)
+  from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by a,b+1)
+	       ^
+<sql-statement>
+select aggfns(distinct a,b,c order by a,b,i,c)
+  from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by a,b,i,c)
+	       ^
+<sql-statement>
+select aggfns(distinct a,a,c order by a,b)
+  from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,a,c order by a,b)
+	       ^
+<sql-statement>
+-- string_agg tests
+select string_agg(a,',') from (values('aaaa'),('bbbb'),('cccc')) g(a);
+</sql-statement>
+<sql-statement>
+select string_agg(a,',') from (values('aaaa'),(null),('bbbb'),('cccc')) g(a);
+</sql-statement>
+<sql-statement>
+select string_agg(a,'AB') from (values(null),(null),('bbbb'),('cccc')) g(a);
+</sql-statement>
+<sql-statement>
+select string_agg(a,',') from (values(null),(null)) g(a);
+</sql-statement>
+<sql-statement>
+-- check some implicit casting cases, as per bug #5564
+select string_agg(distinct f1, ',' order by f1) from varchar_tbl;  -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select string_agg(distinct f1, ',' order by f1) from varchar_tbl;  -- ok
+	       ^
+<sql-statement>
+select string_agg(distinct f1::text, ',' order by f1) from varchar_tbl;  -- not ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select string_agg(distinct f1::text, ',' order by f1) from varchar_tbl;  -- not ok
+	       ^
+<sql-statement>
+select string_agg(distinct f1, ',' order by f1::text) from varchar_tbl;  -- not ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select string_agg(distinct f1, ',' order by f1::text) from varchar_tbl;  -- not ok
+	       ^
+<sql-statement>
+select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl;  -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl;  -- ok
+	       ^
+<sql-statement>
+-- string_agg bytea tests
+create table bytea_test_table(v bytea);
+</sql-statement>
+<sql-statement>
+select string_agg(v, '') from bytea_test_table;
+</sql-statement>
+<sql-statement>
+insert into bytea_test_table values(decode('ff','hex'));
+</sql-statement>
+<sql-statement>
+select string_agg(v, '') from bytea_test_table;
+</sql-statement>
+<sql-statement>
+insert into bytea_test_table values(decode('aa','hex'));
+</sql-statement>
+<sql-statement>
+select string_agg(v, '') from bytea_test_table;
+</sql-statement>
+<sql-statement>
+select string_agg(v, NULL) from bytea_test_table;
+</sql-statement>
+<sql-statement>
+select string_agg(v, decode('ee', 'hex')) from bytea_test_table;
+</sql-statement>
+<sql-statement>
+drop table bytea_test_table;
+</sql-statement>
+<sql-statement>
+-- FILTER tests
+select min(unique1) filter (where unique1 > 100) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_filter
+    	select min(unique1) filter (where unique1 > 100) from tenk1;
+	       ^
+<sql-statement>
+select sum(1/ten) filter (where ten > 0) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_filter
+    	select sum(1/ten) filter (where ten > 0) from tenk1;
+	       ^
+<sql-statement>
+select ten, sum(distinct four) filter (where four::text ~ '123') from onek a
+group by ten;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:13: Error: FuncCall: unsupported agg_filter
+    	select ten, sum(distinct four) filter (where four::text ~ '123') from onek a
+	            ^
+<sql-statement>
+select ten, sum(distinct four) filter (where four > 10) from onek a
+group by ten
+having exists (select 1 from onek b where sum(distinct a.four) = b.four);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:3:43: Error: Aggregate functions are not allowed in: WHERE
+    	having exists (select 1 from onek b where sum(distinct a.four) = b.four);
+	                                          ^
+<sql-statement>
+select max(foo COLLATE "C") filter (where (bar collate "POSIX") > '0')
+from (values ('a', 'b')) AS v(foo,bar);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_filter
+    	select max(foo COLLATE "C") filter (where (bar collate "POSIX") > '0')
+	       ^
+<sql-statement>
+-- outer reference in FILTER (PostgreSQL extension)
+select (select count(*)
+        from (values (1)) t0(inner_c))
+from (values (2),(3)) t1(outer_c); -- inner query is aggregation query
+</sql-statement>
+<sql-statement>
+select (select count(*) filter (where outer_c <> 0)
+        from (values (1)) t0(inner_c))
+from (values (2),(3)) t1(outer_c); -- outer query is aggregation query
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:16: Error: FuncCall: unsupported agg_filter
+    	select (select count(*) filter (where outer_c <> 0)
+	               ^
+<sql-statement>
+select (select count(inner_c) filter (where outer_c <> 0)
+        from (values (1)) t0(inner_c))
+from (values (2),(3)) t1(outer_c); -- inner query is aggregation query
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:16: Error: FuncCall: unsupported agg_filter
+    	select (select count(inner_c) filter (where outer_c <> 0)
+	               ^
+<sql-statement>
+select
+  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1))
+     filter (where o.unique1 < 10))
+from tenk1 o;					-- outer query is aggregation query
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:11: Error: FuncCall: unsupported agg_filter
+    	  (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1))
+	          ^
+<sql-statement>
+-- subquery in FILTER clause (PostgreSQL extension)
+select sum(unique1) FILTER (WHERE
+  unique1 IN (SELECT unique1 FROM onek where unique1 < 100)) FROM tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_filter
+    	select sum(unique1) FILTER (WHERE
+	       ^
+<sql-statement>
+-- exercise lots of aggregate parts with FILTER
+select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1)
+    from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c),
+    generate_series(1,2) i;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1)
+	       ^
+<sql-statement>
+-- check handling of bare boolean Var in FILTER
+select max(0) filter (where b1) from bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_filter
+    	select max(0) filter (where b1) from bool_test;
+	       ^
+<sql-statement>
+select (select max(0) filter (where b1)) from bool_test;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:16: Error: FuncCall: unsupported agg_filter
+    	select (select max(0) filter (where b1)) from bool_test;
+	               ^
+<sql-statement>
+-- check for correct detection of nested-aggregate errors in FILTER
+select max(unique1) filter (where sum(ten) > 0) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_filter
+    	select max(unique1) filter (where sum(ten) > 0) from tenk1;
+	       ^
+<sql-statement>
+select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:16: Error: FuncCall: unsupported agg_filter
+    	select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1;
+	               ^
+<sql-statement>
+select max(unique1) filter (where bool_or(ten > 0)) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_filter
+    	select max(unique1) filter (where bool_or(ten > 0)) from tenk1;
+	       ^
+<sql-statement>
+select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:16: Error: FuncCall: unsupported agg_filter
+    	select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1;
+	               ^
+<sql-statement>
+-- ordered-set aggregates
+select p, percentile_cont(p) within group (order by x::float8)
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:11: Error: FuncCall: unsupported agg_order
+    	select p, percentile_cont(p) within group (order by x::float8)
+	          ^
+<sql-statement>
+select p, percentile_cont(p order by p) within group (order by x)  -- error
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:42: Error: ERROR:  cannot use multiple ORDER BY clauses with WITHIN GROUP
+
+    	select p, percentile_cont(p order by p) within group (order by x)  -- error
+	                                         ^
+<sql-statement>
+select p, sum() within group (order by x::float8)  -- error
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:11: Error: FuncCall: unsupported agg_order
+    	select p, sum() within group (order by x::float8)  -- error
+	          ^
+<sql-statement>
+select p, percentile_cont(p,p)  -- error
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select p, percentile_cont(p,p)  -- error
+	^
+        -stdin-:<main>:1:11: Error: At function: PgResolvedCall
+        	select p, percentile_cont(p,p)  -- error
+	          ^
+            -stdin-:<main>:1:11: Error: Aggregate function percentile_cont cannot be called directly
+            	select p, percentile_cont(p,p)  -- error
+	          ^
+<sql-statement>
+select percentile_cont(0.5) within group (order by b) from aggtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_cont(0.5) within group (order by b) from aggtest;
+	       ^
+<sql-statement>
+select percentile_cont(0.5) within group (order by b), sum(b) from aggtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_cont(0.5) within group (order by b), sum(b) from aggtest;
+	       ^
+<sql-statement>
+select percentile_cont(0.5) within group (order by thousand) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_cont(0.5) within group (order by thousand) from tenk1;
+	       ^
+<sql-statement>
+select percentile_disc(0.5) within group (order by thousand) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_disc(0.5) within group (order by thousand) from tenk1;
+	       ^
+<sql-statement>
+select rank(3) within group (order by x)
+from (values (1),(1),(2),(2),(3),(3),(4)) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select rank(3) within group (order by x)
+	       ^
+<sql-statement>
+select cume_dist(3) within group (order by x)
+from (values (1),(1),(2),(2),(3),(3),(4)) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select cume_dist(3) within group (order by x)
+	       ^
+<sql-statement>
+select percent_rank(3) within group (order by x)
+from (values (1),(1),(2),(2),(3),(3),(4),(5)) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percent_rank(3) within group (order by x)
+	       ^
+<sql-statement>
+select dense_rank(3) within group (order by x)
+from (values (1),(1),(2),(2),(3),(3),(4)) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select dense_rank(3) within group (order by x)
+	       ^
+<sql-statement>
+select percentile_disc(array[0,0.1,0.25,0.5,0.75,0.9,1]) within group (order by thousand)
+from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_disc(array[0,0.1,0.25,0.5,0.75,0.9,1]) within group (order by thousand)
+	       ^
+<sql-statement>
+select percentile_cont(array[0,0.25,0.5,0.75,1]) within group (order by thousand)
+from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_cont(array[0,0.25,0.5,0.75,1]) within group (order by thousand)
+	       ^
+<sql-statement>
+select percentile_disc(array[[null,1,0.5],[0.75,0.25,null]]) within group (order by thousand)
+from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_disc(array[[null,1,0.5],[0.75,0.25,null]]) within group (order by thousand)
+	       ^
+<sql-statement>
+select percentile_cont(array[0,1,0.25,0.75,0.5,1,0.3,0.32,0.35,0.38,0.4]) within group (order by x)
+from generate_series(1,6) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_cont(array[0,1,0.25,0.75,0.5,1,0.3,0.32,0.35,0.38,0.4]) within group (order by x)
+	       ^
+<sql-statement>
+select ten, mode() within group (order by string4) from tenk1 group by ten;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:13: Error: FuncCall: unsupported agg_order
+    	select ten, mode() within group (order by string4) from tenk1 group by ten;
+	            ^
+<sql-statement>
+select percentile_disc(array[0.25,0.5,0.75]) within group (order by x)
+from unnest('{fred,jim,fred,jack,jill,fred,jill,jim,jim,sheila,jim,sheila}'::text[]) u(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select percentile_disc(array[0.25,0.5,0.75]) within group (order by x)
+	       ^
+<sql-statement>
+-- check collation propagates up in suitable cases:
+select pg_collation_for(percentile_disc(1) within group (order by x collate "POSIX"))
+  from (values ('fred'),('jim')) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:25: Error: FuncCall: unsupported agg_order
+    	select pg_collation_for(percentile_disc(1) within group (order by x collate "POSIX"))
+	                        ^
+<sql-statement>
+-- ordered-set aggs created with CREATE AGGREGATE
+select test_rank(3) within group (order by x)
+from (values (1),(1),(2),(2),(3),(3),(4)) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select test_rank(3) within group (order by x)
+	       ^
+<sql-statement>
+select test_percentile_disc(0.5) within group (order by thousand) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select test_percentile_disc(0.5) within group (order by thousand) from tenk1;
+	       ^
+<sql-statement>
+-- ordered-set aggs can't use ungrouped vars in direct args:
+select rank(x) within group (order by x) from generate_series(1,5) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select rank(x) within group (order by x) from generate_series(1,5) x;
+	       ^
+<sql-statement>
+-- outer-level agg can't use a grouped arg of a lower level, either:
+select array(select percentile_disc(a) within group (order by x)
+               from (values (0.3),(0.7)) v(a) group by a)
+  from generate_series(1,5) g(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:21: Error: FuncCall: unsupported agg_order
+    	select array(select percentile_disc(a) within group (order by x)
+	                    ^
+<sql-statement>
+-- agg in the direct args is a grouping violation, too:
+select rank(sum(x)) within group (order by x) from generate_series(1,5) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select rank(sum(x)) within group (order by x) from generate_series(1,5) x;
+	       ^
+<sql-statement>
+-- hypothetical-set type unification and argument-count failures:
+select rank(3) within group (order by x) from (values ('fred'),('jim')) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select rank(3) within group (order by x) from (values ('fred'),('jim')) v(x);
+	       ^
+<sql-statement>
+select rank(3) within group (order by stringu1,stringu2) from tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select rank(3) within group (order by stringu1,stringu2) from tenk1;
+	       ^
+<sql-statement>
+select rank('fred') within group (order by x) from generate_series(1,5) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select rank('fred') within group (order by x) from generate_series(1,5) x;
+	       ^
+<sql-statement>
+select rank('adam'::text collate "C") within group (order by x collate "POSIX")
+  from (values ('fred'),('jim')) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select rank('adam'::text collate "C") within group (order by x collate "POSIX")
+	       ^
+<sql-statement>
+-- hypothetical-set type unification successes:
+select rank('adam'::varchar) within group (order by x) from (values ('fred'),('jim')) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select rank('adam'::varchar) within group (order by x) from (values ('fred'),('jim')) v(x);
+	       ^
+<sql-statement>
+select rank('3') within group (order by x) from generate_series(1,5) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select rank('3') within group (order by x) from generate_series(1,5) x;
+	       ^
+<sql-statement>
+-- divide by zero check
+select percent_rank(0) within group (order by x) from generate_series(1,0) x;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	select percent_rank(0) within group (order by x) from generate_series(1,0) x;
+	       ^
+<sql-statement>
+-- deparse and multiple features:
+create view aggordview1 as
+select ten,
+       percentile_disc(0.5) within group (order by thousand) as p50,
+       percentile_disc(0.5) within group (order by thousand) filter (where hundred=1) as px,
+       rank(5,'AZZZZ',50) within group (order by hundred, string4 desc, hundred)
+  from tenk1
+ group by ten order by ten;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	-- deparse and multiple features:
+	^
+<sql-statement>
+select pg_get_viewdef('aggordview1');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select pg_get_viewdef('aggordview1');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  relation "aggordview1" does not exist
+
+        	select pg_get_viewdef('aggordview1');
+	^
+<sql-statement>
+select * from aggordview1 order by ten;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.aggordview1
+    
+<sql-statement>
+drop view aggordview1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: View not found: 'aggordview1'
+    	drop view aggordview1;
+	^
+<sql-statement>
+-- variadic aggregates
+select least_agg(q1,q2) from int8_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- variadic aggregates
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	select least_agg(q1,q2) from int8_tbl;
+	       ^
+            -stdin-:<main>:2:8: Error: No such proc: least_agg
+            	select least_agg(q1,q2) from int8_tbl;
+	       ^
+<sql-statement>
+select least_agg(variadic array[q1,q2]) from int8_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
+    	select least_agg(variadic array[q1,q2]) from int8_tbl;
+	       ^
+<sql-statement>
+select cleast_agg(q1,q2) from int8_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select cleast_agg(q1,q2) from int8_tbl;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select cleast_agg(q1,q2) from int8_tbl;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: cleast_agg
+            	select cleast_agg(q1,q2) from int8_tbl;
+	       ^
+<sql-statement>
+select cleast_agg(4.5,f1) from int4_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select cleast_agg(4.5,f1) from int4_tbl;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select cleast_agg(4.5,f1) from int4_tbl;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: cleast_agg
+            	select cleast_agg(4.5,f1) from int4_tbl;
+	       ^
+<sql-statement>
+select cleast_agg(variadic array[4.5,f1]) from int4_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
+    	select cleast_agg(variadic array[4.5,f1]) from int4_tbl;
+	       ^
+<sql-statement>
+select pg_typeof(cleast_agg(variadic array[4.5,f1])) from int4_tbl;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:18: Error: FuncCall: unsupported func_variadic
+    	select pg_typeof(cleast_agg(variadic array[4.5,f1])) from int4_tbl;
+	                 ^
+<sql-statement>
+-- test aggregates with common transition functions share the same states
+begin work;
+</sql-statement>
+<sql-statement>
+create type avg_state as (total bigint, count bigint);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 314
+    	create type avg_state as (total bigint, count bigint);
+	^
+<sql-statement>
+create or replace function avg_transfn(state avg_state, n int) returns avg_state as
+$$
+declare new_state avg_state;
+begin
+	raise notice 'avg_transfn called with %', n;
+	if state is null then
+		if n is not null then
+			new_state.total := n;
+			new_state.count := 1;
+			return new_state;
+		end if;
+		return null;
+	elsif n is not null then
+		state.total := state.total + n;
+		state.count := state.count + 1;
+		return state;
+	end if;
+	return null;
+end
+$$ language plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create or replace function avg_transfn(state avg_state, n int) returns avg_state as
+	^
+<sql-statement>
+create function avg_finalfn(state avg_state) returns int4 as
+$$
+begin
+	if state is null then
+		return NULL;
+	else
+		return state.total / state.count;
+	end if;
+end
+$$ language plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create function avg_finalfn(state avg_state) returns int4 as
+	^
+<sql-statement>
+create function sum_finalfn(state avg_state) returns int4 as
+$$
+begin
+	if state is null then
+		return NULL;
+	else
+		return state.total;
+	end if;
+end
+$$ language plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create function sum_finalfn(state avg_state) returns int4 as
+	^
+<sql-statement>
+create aggregate my_avg(int4)
+(
+   stype = avg_state,
+   sfunc = avg_transfn,
+   finalfunc = avg_finalfn
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_avg(int4)
+	^
+<sql-statement>
+create aggregate my_sum(int4)
+(
+   stype = avg_state,
+   sfunc = avg_transfn,
+   finalfunc = sum_finalfn
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_sum(int4)
+	^
+<sql-statement>
+-- aggregate state should be shared as aggs are the same.
+select my_avg(one),my_avg(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- aggregate state should be shared as aggs are the same.
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- aggregate state should be shared as aggs are the same.
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_avg(one),my_avg(one) from (values(1),(3)) t(one);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_avg
+                	select my_avg(one),my_avg(one) from (values(1),(3)) t(one);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- aggregate state should be shared as aggs are the same.
+	^
+            -stdin-:<main>:2:20: Error: At function: PgCall
+            	select my_avg(one),my_avg(one) from (values(1),(3)) t(one);
+	                   ^
+                -stdin-:<main>:2:20: Error: No such proc: my_avg
+                	select my_avg(one),my_avg(one) from (values(1),(3)) t(one);
+	                   ^
+<sql-statement>
+-- aggregate state should be shared as transfn is the same for both aggs.
+select my_avg(one),my_sum(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- aggregate state should be shared as transfn is the same for both aggs.
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- aggregate state should be shared as transfn is the same for both aggs.
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_avg(one),my_sum(one) from (values(1),(3)) t(one);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_avg
+                	select my_avg(one),my_sum(one) from (values(1),(3)) t(one);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- aggregate state should be shared as transfn is the same for both aggs.
+	^
+            -stdin-:<main>:2:20: Error: At function: PgCall
+            	select my_avg(one),my_sum(one) from (values(1),(3)) t(one);
+	                   ^
+                -stdin-:<main>:2:20: Error: No such proc: my_sum
+                	select my_avg(one),my_sum(one) from (values(1),(3)) t(one);
+	                   ^
+<sql-statement>
+-- same as previous one, but with DISTINCT, which requires sorting the input.
+select my_avg(distinct one),my_sum(distinct one) from (values(1),(3),(1)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: agg_distinct must be set only for aggregate functions
+    	select my_avg(distinct one),my_sum(distinct one) from (values(1),(3),(1)) t(one);
+	       ^
+<sql-statement>
+-- shouldn't share states due to the distinctness not matching.
+select my_avg(distinct one),my_sum(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: agg_distinct must be set only for aggregate functions
+    	select my_avg(distinct one),my_sum(one) from (values(1),(3)) t(one);
+	       ^
+<sql-statement>
+-- shouldn't share states due to the filter clause not matching.
+select my_avg(one) filter (where one > 1),my_sum(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_filter
+    	select my_avg(one) filter (where one > 1),my_sum(one) from (values(1),(3)) t(one);
+	       ^
+<sql-statement>
+-- this should not share the state due to different input columns.
+select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- this should not share the state due to different input columns.
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- this should not share the state due to different input columns.
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_avg
+                	select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- this should not share the state due to different input columns.
+	^
+            -stdin-:<main>:2:20: Error: At function: PgCall
+            	select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two);
+	                   ^
+                -stdin-:<main>:2:20: Error: No such proc: my_sum
+                	select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two);
+	                   ^
+<sql-statement>
+-- exercise cases where OSAs share state
+select
+  percentile_cont(0.5) within group (order by a),
+  percentile_disc(0.5) within group (order by a)
+from (values(1::float8),(3),(5),(7)) t(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:3:3: Error: FuncCall: unsupported agg_order
+    	  percentile_cont(0.5) within group (order by a),
+	  ^
+<sql-statement>
+select
+  percentile_cont(0.25) within group (order by a),
+  percentile_disc(0.5) within group (order by a)
+from (values(1::float8),(3),(5),(7)) t(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:3: Error: FuncCall: unsupported agg_order
+    	  percentile_cont(0.25) within group (order by a),
+	  ^
+<sql-statement>
+-- these can't share state currently
+select
+  rank(4) within group (order by a),
+  dense_rank(4) within group (order by a)
+from (values(1),(3),(5),(7)) t(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:3:3: Error: FuncCall: unsupported agg_order
+    	  rank(4) within group (order by a),
+	  ^
+<sql-statement>
+-- test that aggs with the same sfunc and initcond share the same agg state
+create aggregate my_sum_init(int4)
+(
+   stype = avg_state,
+   sfunc = avg_transfn,
+   finalfunc = sum_finalfn,
+   initcond = '(10,0)'
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	-- test that aggs with the same sfunc and initcond share the same agg state
+	^
+<sql-statement>
+create aggregate my_avg_init(int4)
+(
+   stype = avg_state,
+   sfunc = avg_transfn,
+   finalfunc = avg_finalfn,
+   initcond = '(10,0)'
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_avg_init(int4)
+	^
+<sql-statement>
+create aggregate my_avg_init2(int4)
+(
+   stype = avg_state,
+   sfunc = avg_transfn,
+   finalfunc = avg_finalfn,
+   initcond = '(4,0)'
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_avg_init2(int4)
+	^
+<sql-statement>
+-- state should be shared if INITCONDs are matching
+select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- state should be shared if INITCONDs are matching
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- state should be shared if INITCONDs are matching
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_sum_init
+                	select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- state should be shared if INITCONDs are matching
+	^
+            -stdin-:<main>:2:25: Error: At function: PgCall
+            	select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one);
+	                        ^
+                -stdin-:<main>:2:25: Error: No such proc: my_avg_init
+                	select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one);
+	                        ^
+<sql-statement>
+-- Varying INITCONDs should cause the states not to be shared.
+select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- Varying INITCONDs should cause the states not to be shared.
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Varying INITCONDs should cause the states not to be shared.
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_sum_init
+                	select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Varying INITCONDs should cause the states not to be shared.
+	^
+            -stdin-:<main>:2:25: Error: At function: PgCall
+            	select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one);
+	                        ^
+                -stdin-:<main>:2:25: Error: No such proc: my_avg_init2
+                	select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one);
+	                        ^
+<sql-statement>
+rollback;
+</sql-statement>
+<sql-statement>
+-- test aggregate state sharing to ensure it works if one aggregate has a
+-- finalfn and the other one has none.
+begin work;
+</sql-statement>
+<sql-statement>
+create or replace function sum_transfn(state int4, n int4) returns int4 as
+$$
+declare new_state int4;
+begin
+	raise notice 'sum_transfn called with %', n;
+	if state is null then
+		if n is not null then
+			new_state := n;
+			return new_state;
+		end if;
+		return null;
+	elsif n is not null then
+		state := state + n;
+		return state;
+	end if;
+	return null;
+end
+$$ language plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create or replace function sum_transfn(state int4, n int4) returns int4 as
+	^
+<sql-statement>
+create function halfsum_finalfn(state int4) returns int4 as
+$$
+begin
+	if state is null then
+		return NULL;
+	else
+		return state / 2;
+	end if;
+end
+$$ language plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create function halfsum_finalfn(state int4) returns int4 as
+	^
+<sql-statement>
+create aggregate my_sum(int4)
+(
+   stype = int4,
+   sfunc = sum_transfn
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_sum(int4)
+	^
+<sql-statement>
+create aggregate my_half_sum(int4)
+(
+   stype = int4,
+   sfunc = sum_transfn,
+   finalfunc = halfsum_finalfn
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	create aggregate my_half_sum(int4)
+	^
+<sql-statement>
+-- Agg state should be shared even though my_sum has no finalfn
+select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- Agg state should be shared even though my_sum has no finalfn
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Agg state should be shared even though my_sum has no finalfn
+	^
+            -stdin-:<main>:2:8: Error: At function: PgCall
+            	select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one);
+	       ^
+                -stdin-:<main>:2:8: Error: No such proc: my_sum
+                	select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one);
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Agg state should be shared even though my_sum has no finalfn
+	^
+            -stdin-:<main>:2:20: Error: At function: PgCall
+            	select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one);
+	                   ^
+                -stdin-:<main>:2:20: Error: No such proc: my_half_sum
+                	select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one);
+	                   ^
+<sql-statement>
+rollback;
+</sql-statement>
+<sql-statement>
+-- test that the aggregate transition logic correctly handles
+-- transition / combine functions returning NULL
+-- First test the case of a normal transition function returning NULL
+BEGIN;
+</sql-statement>
+<sql-statement>
+CREATE FUNCTION balkifnull(int8, int4)
+RETURNS int8
+STRICT
+LANGUAGE plpgsql AS $$
+BEGIN
+    IF $1 IS NULL THEN
+       RAISE 'erroneously called with NULL argument';
+    END IF;
+    RETURN NULL;
+END$$;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	CREATE FUNCTION balkifnull(int8, int4)
+	^
+<sql-statement>
+CREATE AGGREGATE balk(int4)
+(
+    SFUNC = balkifnull(int8, int4),
+    STYPE = int8,
+    PARALLEL = SAFE,
+    INITCOND = '0'
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	CREATE AGGREGATE balk(int4)
+	^
+<sql-statement>
+SELECT balk(hundred) FROM tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT balk(hundred) FROM tenk1;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT balk(hundred) FROM tenk1;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: balk
+            	SELECT balk(hundred) FROM tenk1;
+	       ^
+<sql-statement>
+ROLLBACK;
+</sql-statement>
+<sql-statement>
+-- Secondly test the case of a parallel aggregate combiner function
+-- returning NULL. For that use normal transition function, but a
+-- combiner function returning NULL.
+BEGIN;
+</sql-statement>
+<sql-statement>
+CREATE FUNCTION balkifnull(int8, int8)
+RETURNS int8
+PARALLEL SAFE
+STRICT
+LANGUAGE plpgsql AS $$
+BEGIN
+    IF $1 IS NULL THEN
+       RAISE 'erroneously called with NULL argument';
+    END IF;
+    RETURN NULL;
+END$$;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	CREATE FUNCTION balkifnull(int8, int8)
+	^
+<sql-statement>
+CREATE AGGREGATE balk(int4)
+(
+    SFUNC = int4_sum(int8, int4),
+    STYPE = int8,
+    COMBINEFUNC = balkifnull(int8, int8),
+    PARALLEL = SAFE,
+    INITCOND = '0'
+);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
+    	CREATE AGGREGATE balk(int4)
+	^
+<sql-statement>
+-- force use of parallelism
+ALTER TABLE tenk1 set (parallel_workers = 4);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- force use of parallelism
+	^
+<sql-statement>
+SET LOCAL parallel_setup_cost=0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: parallel_setup_cost
+    	SET LOCAL parallel_setup_cost=0;
+	^
+<sql-statement>
+SET LOCAL max_parallel_workers_per_gather=4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: max_parallel_workers_per_gather
+    	SET LOCAL max_parallel_workers_per_gather=4;
+	^
+<sql-statement>
+EXPLAIN (COSTS OFF) SELECT balk(hundred) FROM tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	EXPLAIN (COSTS OFF) SELECT balk(hundred) FROM tenk1;
+	^
+<sql-statement>
+SELECT balk(hundred) FROM tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT balk(hundred) FROM tenk1;
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT balk(hundred) FROM tenk1;
+	       ^
+            -stdin-:<main>:1:8: Error: No such proc: balk
+            	SELECT balk(hundred) FROM tenk1;
+	       ^
+<sql-statement>
+ROLLBACK;
+</sql-statement>
+<sql-statement>
+-- test coverage for aggregate combine/serial/deserial functions
+BEGIN;
+</sql-statement>
+<sql-statement>
+SET parallel_setup_cost = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: parallel_setup_cost
+    	SET parallel_setup_cost = 0;
+	^
+<sql-statement>
+SET parallel_tuple_cost = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: parallel_tuple_cost
+    	SET parallel_tuple_cost = 0;
+	^
+<sql-statement>
+SET min_parallel_table_scan_size = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: min_parallel_table_scan_size
+    	SET min_parallel_table_scan_size = 0;
+	^
+<sql-statement>
+SET max_parallel_workers_per_gather = 4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: max_parallel_workers_per_gather
+    	SET max_parallel_workers_per_gather = 4;
+	^
+<sql-statement>
+SET parallel_leader_participation = off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: parallel_leader_participation
+    	SET parallel_leader_participation = off;
+	^
+<sql-statement>
+SET enable_indexonlyscan = off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_indexonlyscan
+    	SET enable_indexonlyscan = off;
+	^
+<sql-statement>
+-- variance(int4) covers numeric_poly_combine
+-- sum(int8) covers int8_avg_combine
+-- regr_count(float8, float8) covers int8inc_float8_float8 and aggregates with > 1 arg
+EXPLAIN (COSTS OFF, VERBOSE)
+SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8)
+FROM (SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1) u;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- variance(int4) covers numeric_poly_combine
+	^
+<sql-statement>
+SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8)
+FROM (SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1) u;
+</sql-statement>
+<sql-statement>
+-- variance(int8) covers numeric_combine
+-- avg(numeric) covers numeric_avg_combine
+EXPLAIN (COSTS OFF, VERBOSE)
+SELECT variance(unique1::int8), avg(unique1::numeric)
+FROM (SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1) u;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	-- variance(int8) covers numeric_combine
+	^
+<sql-statement>
+SELECT variance(unique1::int8), avg(unique1::numeric)
+FROM (SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1
+      UNION ALL SELECT * FROM tenk1) u;
+</sql-statement>
+<sql-statement>
+ROLLBACK;
+</sql-statement>
+<sql-statement>
+-- test coverage for dense_rank
+SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:2:8: Error: FuncCall: unsupported agg_order
+    	SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1;
+	       ^
+<sql-statement>
+-- Ensure that the STRICT checks for aggregates does not take NULLness
+-- of ORDER BY columns into account. See bug report around
+-- 2a505161-2727-2473-7c46-591ed108ac52@email.cz
+SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:4:8: Error: FuncCall: unsupported agg_order
+    	SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y);
+	       ^
+<sql-statement>
+SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y);
+	       ^
+<sql-statement>
+-- check collation-sensitive matching between grouping expressions
+select v||'a', case v||'a' when 'aa' then 1 else 0 end, count(*)
+  from unnest(array['a','b']) u(v)
+ group by v||'a' order by 1;
+</sql-statement>
+<sql-statement>
+select v||'a', case when v||'a' = 'aa' then 1 else 0 end, count(*)
+  from unnest(array['a','b']) u(v)
+ group by v||'a' order by 1;
+</sql-statement>
+<sql-statement>
+-- Make sure that generation of HashAggregate for uniqification purposes
+-- does not lead to array overflow due to unexpected duplicate hash keys
+-- see CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com
+set enable_memoize to off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_memoize
+    	-- Make sure that generation of HashAggregate for uniqification purposes
+	^
+<sql-statement>
+explain (costs off)
+  select 1 from tenk1
+   where (hundred, thousand) in (select twothousand, twothousand from onek);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+reset enable_memoize;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	reset enable_memoize;
+	^
+<sql-statement>
+--
+-- Hash Aggregation Spill tests
+--
+set enable_sort=false;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
+    	--
+	^
+<sql-statement>
+set work_mem='64kB';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: work_mem
+    	set work_mem='64kB';
+	^
+<sql-statement>
+select unique1, count(*), sum(twothousand) from tenk1
+group by unique1
+having sum(fivethous) > 4975
+order by sum(twothousand);
+</sql-statement>
+<sql-statement>
+set work_mem to default;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 1
+    	set work_mem to default;
+	^
+<sql-statement>
+set enable_sort to default;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 1
+    	set enable_sort to default;
+	^
+<sql-statement>
+--
+-- Compare results between plans using sorting and plans using hash
+-- aggregation. Force spilling in both cases by setting work_mem low.
+--
+set work_mem='64kB';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: work_mem
+    	--
+	^
+<sql-statement>
+create table agg_data_2k as
+select g from generate_series(0, 1999) g;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_data_2k as
+	^
+<sql-statement>
+analyze agg_data_2k;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
+    	analyze agg_data_2k;
+	^
+<sql-statement>
+create table agg_data_20k as
+select g from generate_series(0, 19999) g;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_data_20k as
+	^
+<sql-statement>
+analyze agg_data_20k;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
+    	analyze agg_data_20k;
+	^
+<sql-statement>
+-- Produce results with sorting.
+set enable_hashagg = false;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
+    	-- Produce results with sorting.
+	^
+<sql-statement>
+set jit_above_cost = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: jit_above_cost
+    	set jit_above_cost = 0;
+	^
+<sql-statement>
+explain (costs off)
+select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3
+  from agg_data_20k group by g%10000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+create table agg_group_1 as
+select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3
+  from agg_data_20k group by g%10000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_group_1 as
+	^
+<sql-statement>
+create table agg_group_2 as
+select * from
+  (values (100), (300), (500)) as r(a),
+  lateral (
+    select (g/2)::numeric as c1,
+           array_agg(g::numeric) as c2,
+	   count(*) as c3
+    from agg_data_2k
+    where g < r.a
+    group by g/2) as s;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_group_2 as
+	^
+<sql-statement>
+set jit_above_cost to default;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 1
+    	set jit_above_cost to default;
+	^
+<sql-statement>
+create table agg_group_3 as
+select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3
+  from agg_data_2k group by g/2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_group_3 as
+	^
+<sql-statement>
+create table agg_group_4 as
+select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3
+  from agg_data_2k group by g/2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_group_4 as
+	^
+<sql-statement>
+-- Produce results with hash aggregation
+set enable_hashagg = true;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
+    	-- Produce results with hash aggregation
+	^
+<sql-statement>
+set enable_sort = false;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
+    	set enable_sort = false;
+	^
+<sql-statement>
+set jit_above_cost = 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: jit_above_cost
+    	set jit_above_cost = 0;
+	^
+<sql-statement>
+explain (costs off)
+select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3
+  from agg_data_20k group by g%10000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off)
+	^
+<sql-statement>
+create table agg_hash_1 as
+select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3
+  from agg_data_20k group by g%10000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_hash_1 as
+	^
+<sql-statement>
+create table agg_hash_2 as
+select * from
+  (values (100), (300), (500)) as r(a),
+  lateral (
+    select (g/2)::numeric as c1,
+           array_agg(g::numeric) as c2,
+	   count(*) as c3
+    from agg_data_2k
+    where g < r.a
+    group by g/2) as s;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_hash_2 as
+	^
+<sql-statement>
+set jit_above_cost to default;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 1
+    	set jit_above_cost to default;
+	^
+<sql-statement>
+create table agg_hash_3 as
+select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3
+  from agg_data_2k group by g/2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_hash_3 as
+	^
+<sql-statement>
+create table agg_hash_4 as
+select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3
+  from agg_data_2k group by g/2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
+    	create table agg_hash_4 as
+	^
+<sql-statement>
+set enable_sort = true;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
+    	set enable_sort = true;
+	^
+<sql-statement>
+set work_mem to default;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 1
+    	set work_mem to default;
+	^
+<sql-statement>
+-- Compare group aggregation results to hash aggregation results
+(select * from agg_hash_1 except select * from agg_group_1)
+  union all
+(select * from agg_group_1 except select * from agg_hash_1);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_group_1
+    
+<sql-statement>
+(select * from agg_hash_2 except select * from agg_group_2)
+  union all
+(select * from agg_group_2 except select * from agg_hash_2);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_group_2
+    
+<sql-statement>
+(select * from agg_hash_3 except select * from agg_group_3)
+  union all
+(select * from agg_group_3 except select * from agg_hash_3);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_hash_3
+    
+<sql-statement>
+(select * from agg_hash_4 except select * from agg_group_4)
+  union all
+(select * from agg_group_4 except select * from agg_hash_4);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.agg_hash_4
+    
+<sql-statement>
+drop table agg_group_1;
+</sql-statement>
+<sql-statement>
+drop table agg_group_2;
+</sql-statement>
+<sql-statement>
+drop table agg_group_3;
+</sql-statement>
+<sql-statement>
+drop table agg_group_4;
+</sql-statement>
+<sql-statement>
+drop table agg_hash_1;
+</sql-statement>
+<sql-statement>
+drop table agg_hash_2;
+</sql-statement>
+<sql-statement>
+drop table agg_hash_3;
+</sql-statement>
+<sql-statement>
+drop table agg_hash_4;
+</sql-statement>

+ 738 - 0
yql/essentials/tests/postgresql/cases/aggregates.out

@@ -0,0 +1,738 @@
+--
+-- AGGREGATES
+--
+-- avoid bit-exact output here because operations may not be bit-exact.
+SET extra_float_digits = 0;
+SELECT avg(four) AS avg_1 FROM onek;
+       avg_1        
+--------------------
+ 1.5000000000000000
+(1 row)
+
+SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100;
+       avg_32        
+---------------------
+ 32.6666666666666667
+(1 row)
+
+-- In 7.1, avg(float4) is computed using float8 arithmetic.
+-- Round the result to 3 digits to avoid platform-specific results.
+SELECT avg(b)::numeric(10,3) AS avg_107_943 FROM aggtest;
+ avg_107_943 
+-------------
+     107.943
+(1 row)
+
+SELECT avg(gpa) AS avg_3_4 FROM ONLY student;
+ avg_3_4 
+---------
+     3.4
+(1 row)
+
+SELECT sum(four) AS sum_1500 FROM onek;
+ sum_1500 
+----------
+     1500
+(1 row)
+
+SELECT sum(a) AS sum_198 FROM aggtest;
+ sum_198 
+---------
+     198
+(1 row)
+
+SELECT sum(gpa) AS avg_6_8 FROM ONLY student;
+ avg_6_8 
+---------
+     6.8
+(1 row)
+
+SELECT max(four) AS max_3 FROM onek;
+ max_3 
+-------
+     3
+(1 row)
+
+SELECT max(a) AS max_100 FROM aggtest;
+ max_100 
+---------
+     100
+(1 row)
+
+SELECT max(aggtest.b) AS max_324_78 FROM aggtest;
+ max_324_78 
+------------
+     324.78
+(1 row)
+
+SELECT max(student.gpa) AS max_3_7 FROM student;
+ max_3_7 
+---------
+     3.7
+(1 row)
+
+SELECT stddev_pop(b) FROM aggtest;
+   stddev_pop    
+-----------------
+ 131.10703231895
+(1 row)
+
+SELECT stddev_samp(b) FROM aggtest;
+   stddev_samp    
+------------------
+ 151.389360803998
+(1 row)
+
+SELECT var_pop(b) FROM aggtest;
+     var_pop      
+------------------
+ 17189.0539234823
+(1 row)
+
+SELECT var_samp(b) FROM aggtest;
+     var_samp     
+------------------
+ 22918.7385646431
+(1 row)
+
+SELECT stddev_pop(b::numeric) FROM aggtest;
+    stddev_pop    
+------------------
+ 131.107032862199
+(1 row)
+
+SELECT stddev_samp(b::numeric) FROM aggtest;
+   stddev_samp    
+------------------
+ 151.389361431288
+(1 row)
+
+SELECT var_pop(b::numeric) FROM aggtest;
+      var_pop       
+--------------------
+ 17189.054065929769
+(1 row)
+
+SELECT var_samp(b::numeric) FROM aggtest;
+      var_samp      
+--------------------
+ 22918.738754573025
+(1 row)
+
+-- population variance is defined for a single tuple, sample variance
+-- is not
+SELECT var_pop(1.0::float8), var_samp(2.0::float8);
+ var_pop | var_samp 
+---------+----------
+       0 |         
+(1 row)
+
+SELECT stddev_pop(3.0::float8), stddev_samp(4.0::float8);
+ stddev_pop | stddev_samp 
+------------+-------------
+          0 |            
+(1 row)
+
+SELECT var_pop('inf'::float8), var_samp('inf'::float8);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+SELECT var_pop('nan'::float8), var_samp('nan'::float8);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+SELECT var_pop(1.0::float4), var_samp(2.0::float4);
+ var_pop | var_samp 
+---------+----------
+       0 |         
+(1 row)
+
+SELECT stddev_pop(3.0::float4), stddev_samp(4.0::float4);
+ stddev_pop | stddev_samp 
+------------+-------------
+          0 |            
+(1 row)
+
+SELECT var_pop('inf'::float4), var_samp('inf'::float4);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+SELECT var_pop('nan'::float4), var_samp('nan'::float4);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+SELECT var_pop('inf'::numeric), var_samp('inf'::numeric);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+SELECT var_pop('nan'::numeric), var_samp('nan'::numeric);
+ var_pop | var_samp 
+---------+----------
+     NaN |         
+(1 row)
+
+SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric);
+ stddev_pop | stddev_samp 
+------------+-------------
+        NaN |            
+(1 row)
+
+-- verify correct results for null and NaN inputs
+select sum(null::int4) from generate_series(1,3);
+ sum 
+-----
+    
+(1 row)
+
+select sum(null::int8) from generate_series(1,3);
+ sum 
+-----
+    
+(1 row)
+
+select sum(null::numeric) from generate_series(1,3);
+ sum 
+-----
+    
+(1 row)
+
+select sum(null::float8) from generate_series(1,3);
+ sum 
+-----
+    
+(1 row)
+
+select avg(null::int4) from generate_series(1,3);
+ avg 
+-----
+    
+(1 row)
+
+select avg(null::int8) from generate_series(1,3);
+ avg 
+-----
+    
+(1 row)
+
+select avg(null::numeric) from generate_series(1,3);
+ avg 
+-----
+    
+(1 row)
+
+select avg(null::float8) from generate_series(1,3);
+ avg 
+-----
+    
+(1 row)
+
+select sum('NaN'::numeric) from generate_series(1,3);
+ sum 
+-----
+ NaN
+(1 row)
+
+select avg('NaN'::numeric) from generate_series(1,3);
+ avg 
+-----
+ NaN
+(1 row)
+
+-- verify correct results for infinite inputs
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('1'), ('infinity')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('1')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+ sum | avg | var_pop 
+-----+-----+---------
+ NaN | NaN |     NaN
+(1 row)
+
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+    sum    |    avg    | var_pop 
+-----------+-----------+---------
+ -Infinity | -Infinity |     NaN
+(1 row)
+
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('1'), ('infinity')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('1')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+   sum    |   avg    | var_pop 
+----------+----------+---------
+ Infinity | Infinity |     NaN
+(1 row)
+
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+ sum | avg | var_pop 
+-----+-----+---------
+ NaN | NaN |     NaN
+(1 row)
+
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+    sum    |    avg    | var_pop 
+-----------+-----------+---------
+ -Infinity | -Infinity |     NaN
+(1 row)
+
+-- test accuracy with a large input offset
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x);
+    avg    | var_pop 
+-----------+---------
+ 100000005 |     2.5
+(1 row)
+
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (7000000000005), (7000000000007)) v(x);
+      avg      | var_pop 
+---------------+---------
+ 7000000000006 |       1
+(1 row)
+
+-- SQL2003 binary aggregates
+SELECT regr_count(b, a) FROM aggtest;
+ regr_count 
+------------
+          4
+(1 row)
+
+SELECT regr_sxx(b, a) FROM aggtest;
+ regr_sxx 
+----------
+     5099
+(1 row)
+
+SELECT regr_syy(b, a) FROM aggtest;
+     regr_syy     
+------------------
+ 68756.2156939293
+(1 row)
+
+SELECT regr_sxy(b, a) FROM aggtest;
+     regr_sxy     
+------------------
+ 2614.51582155004
+(1 row)
+
+SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest;
+ regr_avgx |    regr_avgy     
+-----------+------------------
+      49.5 | 107.943152273074
+(1 row)
+
+SELECT regr_r2(b, a) FROM aggtest;
+      regr_r2       
+--------------------
+ 0.0194977982031803
+(1 row)
+
+SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest;
+    regr_slope     |  regr_intercept  
+-------------------+------------------
+ 0.512750700441271 | 82.5619926012309
+(1 row)
+
+SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest;
+    covar_pop    |    covar_samp    
+-----------------+------------------
+ 653.62895538751 | 871.505273850014
+(1 row)
+
+SELECT corr(b, a) FROM aggtest;
+       corr        
+-------------------
+ 0.139634516517873
+(1 row)
+
+-- check single-tuple behavior
+SELECT covar_pop(1::float8,2::float8), covar_samp(3::float8,4::float8);
+ covar_pop | covar_samp 
+-----------+------------
+         0 |           
+(1 row)
+
+SELECT covar_pop(1::float8,'inf'::float8), covar_samp(3::float8,'inf'::float8);
+ covar_pop | covar_samp 
+-----------+------------
+       NaN |           
+(1 row)
+
+SELECT covar_pop(1::float8,'nan'::float8), covar_samp(3::float8,'nan'::float8);
+ covar_pop | covar_samp 
+-----------+------------
+       NaN |           
+(1 row)
+
+-- test accum and combine functions directly
+CREATE TABLE regr_test (x float8, y float8);
+INSERT INTO regr_test VALUES (10,150),(20,250),(30,350),(80,540),(100,200);
+SELECT float8_accum('{4,140,2900}'::float8[], 100);
+ float8_accum 
+--------------
+ {5,240,6280}
+(1 row)
+
+SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100);
+      float8_regr_accum       
+------------------------------
+ {5,240,6280,1490,95080,8680}
+(1 row)
+
+SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[]);
+ float8_combine 
+----------------
+ {3,60,200}
+(1 row)
+
+SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[]);
+ float8_combine 
+----------------
+ {2,180,200}
+(1 row)
+
+SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[]);
+ float8_combine 
+----------------
+ {5,240,6280}
+(1 row)
+
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{0,0,0,0,0,0}'::float8[]);
+    float8_regr_combine    
+---------------------------
+ {3,60,200,750,20000,2000}
+(1 row)
+
+SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+     float8_regr_combine     
+-----------------------------
+ {2,180,200,740,57800,-3400}
+(1 row)
+
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+     float8_regr_combine      
+------------------------------
+ {5,240,6280,1490,95080,8680}
+(1 row)
+
+DROP TABLE regr_test;
+-- test count, distinct
+SELECT count(four) AS cnt_1000 FROM onek;
+ cnt_1000 
+----------
+     1000
+(1 row)
+
+SELECT count(DISTINCT four) AS cnt_4 FROM onek;
+ cnt_4 
+-------
+     4
+(1 row)
+
+select ten, count(*), sum(four) from onek
+group by ten order by ten;
+ ten | count | sum 
+-----+-------+-----
+   0 |   100 | 100
+   1 |   100 | 200
+   2 |   100 | 100
+   3 |   100 | 200
+   4 |   100 | 100
+   5 |   100 | 200
+   6 |   100 | 100
+   7 |   100 | 200
+   8 |   100 | 100
+   9 |   100 | 200
+(10 rows)
+
+select ten, count(four), sum(DISTINCT four) from onek
+group by ten order by ten;
+ ten | count | sum 
+-----+-------+-----
+   0 |   100 |   2
+   1 |   100 |   4
+   2 |   100 |   2
+   3 |   100 |   4
+   4 |   100 |   2
+   5 |   100 |   4
+   6 |   100 |   2
+   7 |   100 |   4
+   8 |   100 |   2
+   9 |   100 |   4
+(10 rows)
+
+--
+-- test for bitwise integer aggregates
+--
+CREATE TEMPORARY TABLE bitwise_test(
+  i2 INT2,
+  i4 INT4,
+  i8 INT8,
+  i INTEGER,
+  x INT2,
+  y BIT(4)
+);
+CREATE TEMPORARY TABLE bool_test(
+  b1 BOOL,
+  b2 BOOL,
+  b3 BOOL,
+  b4 BOOL);
+select min(unique1) from tenk1;
+ min 
+-----
+   0
+(1 row)
+
+select max(unique1) from tenk1;
+ max  
+------
+ 9999
+(1 row)
+
+select max(unique1) from tenk1 where unique1 < 42;
+ max 
+-----
+  41
+(1 row)
+
+select max(unique1) from tenk1 where unique1 > 42;
+ max  
+------
+ 9999
+(1 row)
+
+-- the planner may choose a generic aggregate here if parallel query is
+-- enabled, since that plan will be parallel safe and the "optimized"
+-- plan, which has almost identical cost, will not be.  we want to test
+-- the optimized plan, so temporarily disable parallel query.
+begin;
+select max(unique1) from tenk1 where unique1 > 42000;
+ max 
+-----
+    
+(1 row)
+
+rollback;
+select max(tenthous) from tenk1 where thousand = 33;
+ max  
+------
+ 9033
+(1 row)
+
+select min(tenthous) from tenk1 where thousand = 33;
+ min 
+-----
+  33
+(1 row)
+
+select distinct max(unique2) from tenk1;
+ max  
+------
+ 9999
+(1 row)
+
+select max(unique2) from tenk1 order by 1;
+ max  
+------
+ 9999
+(1 row)
+
+select max(unique2) from tenk1 order by max(unique2);
+ max  
+------
+ 9999
+(1 row)
+
+select max(unique2) from tenk1 order by max(unique2)+1;
+ max  
+------
+ 9999
+(1 row)
+
+select max(100) from tenk1;
+ max 
+-----
+ 100
+(1 row)
+
+-- try it on an inheritance tree
+create table minmaxtest(f1 int);
+create index minmaxtesti on minmaxtest(f1);
+create index minmaxtest1i on minmaxtest1(f1);
+create index minmaxtest2i on minmaxtest2(f1 desc);
+insert into minmaxtest values(11), (12);
+--
+-- Test removal of redundant GROUP BY columns
+--
+create temp table t1 (a int, b int, c int, d int, primary key (a, b));
+create temp table t2 (x int, y int, z int, primary key (x, y));
+drop table t2;
+--
+-- Test GROUP BY matching of join columns that are type-coerced due to USING
+--
+create temp table t1(f1 int, f2 bigint);
+create temp table t2(f1 bigint, f22 bigint);
+drop table t1, t2;
+select array_agg(distinct a)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+  array_agg   
+--------------
+ {1,2,3,NULL}
+(1 row)
+
+-- string_agg tests
+select string_agg(a,',') from (values('aaaa'),('bbbb'),('cccc')) g(a);
+   string_agg   
+----------------
+ aaaa,bbbb,cccc
+(1 row)
+
+select string_agg(a,',') from (values('aaaa'),(null),('bbbb'),('cccc')) g(a);
+   string_agg   
+----------------
+ aaaa,bbbb,cccc
+(1 row)
+
+select string_agg(a,'AB') from (values(null),(null),('bbbb'),('cccc')) g(a);
+ string_agg 
+------------
+ bbbbABcccc
+(1 row)
+
+select string_agg(a,',') from (values(null),(null)) g(a);
+ string_agg 
+------------
+ 
+(1 row)
+
+-- string_agg bytea tests
+create table bytea_test_table(v bytea);
+select string_agg(v, '') from bytea_test_table;
+ string_agg 
+------------
+ 
+(1 row)
+
+insert into bytea_test_table values(decode('ff','hex'));
+select string_agg(v, '') from bytea_test_table;
+ string_agg 
+------------
+ \xff
+(1 row)
+
+insert into bytea_test_table values(decode('aa','hex'));
+select string_agg(v, '') from bytea_test_table;
+ string_agg 
+------------
+ \xffaa
+(1 row)
+
+select string_agg(v, NULL) from bytea_test_table;
+ string_agg 
+------------
+ \xffaa
+(1 row)
+
+select string_agg(v, decode('ee', 'hex')) from bytea_test_table;
+ string_agg 
+------------
+ \xffeeaa
+(1 row)
+
+drop table bytea_test_table;
+-- outer reference in FILTER (PostgreSQL extension)
+select (select count(*)
+        from (values (1)) t0(inner_c))
+from (values (2),(3)) t1(outer_c); -- inner query is aggregation query
+ count 
+-------
+     1
+     1
+(2 rows)
+
+select p, percentile_cont(p order by p) within group (order by x)  -- error
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+ERROR:  cannot use multiple ORDER BY clauses with WITHIN GROUP
+LINE 1: select p, percentile_cont(p order by p) within group (order ...
+                                                ^
+-- test aggregates with common transition functions share the same states
+begin work;

+ 196 - 0
yql/essentials/tests/postgresql/cases/aggregates.sql

@@ -0,0 +1,196 @@
+--
+-- AGGREGATES
+--
+-- avoid bit-exact output here because operations may not be bit-exact.
+SET extra_float_digits = 0;
+SELECT avg(four) AS avg_1 FROM onek;
+SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100;
+-- In 7.1, avg(float4) is computed using float8 arithmetic.
+-- Round the result to 3 digits to avoid platform-specific results.
+SELECT avg(b)::numeric(10,3) AS avg_107_943 FROM aggtest;
+SELECT avg(gpa) AS avg_3_4 FROM ONLY student;
+SELECT sum(four) AS sum_1500 FROM onek;
+SELECT sum(a) AS sum_198 FROM aggtest;
+SELECT sum(gpa) AS avg_6_8 FROM ONLY student;
+SELECT max(four) AS max_3 FROM onek;
+SELECT max(a) AS max_100 FROM aggtest;
+SELECT max(aggtest.b) AS max_324_78 FROM aggtest;
+SELECT max(student.gpa) AS max_3_7 FROM student;
+SELECT stddev_pop(b) FROM aggtest;
+SELECT stddev_samp(b) FROM aggtest;
+SELECT var_pop(b) FROM aggtest;
+SELECT var_samp(b) FROM aggtest;
+SELECT stddev_pop(b::numeric) FROM aggtest;
+SELECT stddev_samp(b::numeric) FROM aggtest;
+SELECT var_pop(b::numeric) FROM aggtest;
+SELECT var_samp(b::numeric) FROM aggtest;
+-- population variance is defined for a single tuple, sample variance
+-- is not
+SELECT var_pop(1.0::float8), var_samp(2.0::float8);
+SELECT stddev_pop(3.0::float8), stddev_samp(4.0::float8);
+SELECT var_pop('inf'::float8), var_samp('inf'::float8);
+SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8);
+SELECT var_pop('nan'::float8), var_samp('nan'::float8);
+SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8);
+SELECT var_pop(1.0::float4), var_samp(2.0::float4);
+SELECT stddev_pop(3.0::float4), stddev_samp(4.0::float4);
+SELECT var_pop('inf'::float4), var_samp('inf'::float4);
+SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4);
+SELECT var_pop('nan'::float4), var_samp('nan'::float4);
+SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4);
+SELECT var_pop('inf'::numeric), var_samp('inf'::numeric);
+SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric);
+SELECT var_pop('nan'::numeric), var_samp('nan'::numeric);
+SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric);
+-- verify correct results for null and NaN inputs
+select sum(null::int4) from generate_series(1,3);
+select sum(null::int8) from generate_series(1,3);
+select sum(null::numeric) from generate_series(1,3);
+select sum(null::float8) from generate_series(1,3);
+select avg(null::int4) from generate_series(1,3);
+select avg(null::int8) from generate_series(1,3);
+select avg(null::numeric) from generate_series(1,3);
+select avg(null::float8) from generate_series(1,3);
+select sum('NaN'::numeric) from generate_series(1,3);
+select avg('NaN'::numeric) from generate_series(1,3);
+-- verify correct results for infinite inputs
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('1'), ('infinity')) v(x);
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('1')) v(x);
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+SELECT sum(x::float8), avg(x::float8), var_pop(x::float8)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('1'), ('infinity')) v(x);
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('1')) v(x);
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('infinity'), ('infinity')) v(x);
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('infinity')) v(x);
+SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric)
+FROM (VALUES ('-infinity'), ('-infinity')) v(x);
+-- test accuracy with a large input offset
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x);
+SELECT avg(x::float8), var_pop(x::float8)
+FROM (VALUES (7000000000005), (7000000000007)) v(x);
+-- SQL2003 binary aggregates
+SELECT regr_count(b, a) FROM aggtest;
+SELECT regr_sxx(b, a) FROM aggtest;
+SELECT regr_syy(b, a) FROM aggtest;
+SELECT regr_sxy(b, a) FROM aggtest;
+SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest;
+SELECT regr_r2(b, a) FROM aggtest;
+SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest;
+SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest;
+SELECT corr(b, a) FROM aggtest;
+-- check single-tuple behavior
+SELECT covar_pop(1::float8,2::float8), covar_samp(3::float8,4::float8);
+SELECT covar_pop(1::float8,'inf'::float8), covar_samp(3::float8,'inf'::float8);
+SELECT covar_pop(1::float8,'nan'::float8), covar_samp(3::float8,'nan'::float8);
+-- test accum and combine functions directly
+CREATE TABLE regr_test (x float8, y float8);
+INSERT INTO regr_test VALUES (10,150),(20,250),(30,350),(80,540),(100,200);
+SELECT float8_accum('{4,140,2900}'::float8[], 100);
+SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100);
+SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[]);
+SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[]);
+SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[]);
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{0,0,0,0,0,0}'::float8[]);
+SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[],
+                           '{2,180,200,740,57800,-3400}'::float8[]);
+DROP TABLE regr_test;
+-- test count, distinct
+SELECT count(four) AS cnt_1000 FROM onek;
+SELECT count(DISTINCT four) AS cnt_4 FROM onek;
+select ten, count(*), sum(four) from onek
+group by ten order by ten;
+select ten, count(four), sum(DISTINCT four) from onek
+group by ten order by ten;
+--
+-- test for bitwise integer aggregates
+--
+CREATE TEMPORARY TABLE bitwise_test(
+  i2 INT2,
+  i4 INT4,
+  i8 INT8,
+  i INTEGER,
+  x INT2,
+  y BIT(4)
+);
+CREATE TEMPORARY TABLE bool_test(
+  b1 BOOL,
+  b2 BOOL,
+  b3 BOOL,
+  b4 BOOL);
+select min(unique1) from tenk1;
+select max(unique1) from tenk1;
+select max(unique1) from tenk1 where unique1 < 42;
+select max(unique1) from tenk1 where unique1 > 42;
+-- the planner may choose a generic aggregate here if parallel query is
+-- enabled, since that plan will be parallel safe and the "optimized"
+-- plan, which has almost identical cost, will not be.  we want to test
+-- the optimized plan, so temporarily disable parallel query.
+begin;
+select max(unique1) from tenk1 where unique1 > 42000;
+rollback;
+select max(tenthous) from tenk1 where thousand = 33;
+select min(tenthous) from tenk1 where thousand = 33;
+select distinct max(unique2) from tenk1;
+select max(unique2) from tenk1 order by 1;
+select max(unique2) from tenk1 order by max(unique2);
+select max(unique2) from tenk1 order by max(unique2)+1;
+select max(100) from tenk1;
+-- try it on an inheritance tree
+create table minmaxtest(f1 int);
+create index minmaxtesti on minmaxtest(f1);
+create index minmaxtest1i on minmaxtest1(f1);
+create index minmaxtest2i on minmaxtest2(f1 desc);
+insert into minmaxtest values(11), (12);
+--
+-- Test removal of redundant GROUP BY columns
+--
+create temp table t1 (a int, b int, c int, d int, primary key (a, b));
+create temp table t2 (x int, y int, z int, primary key (x, y));
+drop table t2;
+--
+-- Test GROUP BY matching of join columns that are type-coerced due to USING
+--
+create temp table t1(f1 int, f2 bigint);
+create temp table t2(f1 bigint, f22 bigint);
+drop table t1, t2;
+select array_agg(distinct a)
+  from (values (1),(2),(1),(3),(null),(2)) v(a);
+-- string_agg tests
+select string_agg(a,',') from (values('aaaa'),('bbbb'),('cccc')) g(a);
+select string_agg(a,',') from (values('aaaa'),(null),('bbbb'),('cccc')) g(a);
+select string_agg(a,'AB') from (values(null),(null),('bbbb'),('cccc')) g(a);
+select string_agg(a,',') from (values(null),(null)) g(a);
+-- string_agg bytea tests
+create table bytea_test_table(v bytea);
+select string_agg(v, '') from bytea_test_table;
+insert into bytea_test_table values(decode('ff','hex'));
+select string_agg(v, '') from bytea_test_table;
+insert into bytea_test_table values(decode('aa','hex'));
+select string_agg(v, '') from bytea_test_table;
+select string_agg(v, NULL) from bytea_test_table;
+select string_agg(v, decode('ee', 'hex')) from bytea_test_table;
+drop table bytea_test_table;
+-- outer reference in FILTER (PostgreSQL extension)
+select (select count(*)
+        from (values (1)) t0(inner_c))
+from (values (2),(3)) t1(outer_c); -- inner query is aggregation query
+select p, percentile_cont(p order by p) within group (order by x)  -- error
+from generate_series(1,5) x,
+     (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p)
+group by p order by p;
+-- test aggregates with common transition functions share the same states
+begin work;

+ 3455 - 0
yql/essentials/tests/postgresql/cases/alter_table.err

@@ -0,0 +1,3455 @@
+Registering pre-existing tables
+	onek
+	tenk1
+	stud_emp
+<sql-statement>
+--
+-- ALTER_TABLE
+--
+-- Clean up in case a prior regression run failed
+SET client_min_messages TO 'warning';
+</sql-statement>
+<sql-statement>
+DROP ROLE IF EXISTS regress_alter_table_user1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 287
+    	DROP ROLE IF EXISTS regress_alter_table_user1;
+	^
+<sql-statement>
+RESET client_min_messages;
+</sql-statement>
+<sql-statement>
+CREATE USER regress_alter_table_user1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 285
+    	CREATE USER regress_alter_table_user1;
+	^
+<sql-statement>
+--
+-- add attribute
+--
+CREATE TABLE attmp (initial int4);
+</sql-statement>
+<sql-statement>
+COMMENT ON TABLE attmp_wrong IS 'table comment';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 258
+    	COMMENT ON TABLE attmp_wrong IS 'table comment';
+	^
+<sql-statement>
+COMMENT ON TABLE attmp IS 'table comment';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 258
+    	COMMENT ON TABLE attmp IS 'table comment';
+	^
+<sql-statement>
+COMMENT ON TABLE attmp IS NULL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 258
+    	COMMENT ON TABLE attmp IS NULL;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN xmin integer; -- fails
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN xmin integer; -- fails
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN a int4 default 3;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN a int4 default 3;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN b name;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN b name;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN c text;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN c text;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN d float8;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN d float8;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN e float4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN e float4;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN f int2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN f int2;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN g polygon;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN g polygon;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN i char;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN i char;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN k int4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN k int4;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN l tid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN l tid;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN m xid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN m xid;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN n oidvector;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN n oidvector;
+	^
+<sql-statement>
+--ALTER TABLE attmp ADD COLUMN o lock;
+ALTER TABLE attmp ADD COLUMN p boolean;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	--ALTER TABLE attmp ADD COLUMN o lock;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN q point;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN q point;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN r lseg;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN r lseg;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN s path;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN s path;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN t box;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN t box;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN v timestamp;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN v timestamp;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN w interval;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN w interval;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN x float8[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN x float8[];
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN y float4[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN y float4[];
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN z int2[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN z int2[];
+	^
+<sql-statement>
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,    k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+	'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+</sql-statement>
+<sql-statement>
+SELECT * FROM attmp;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp;
+</sql-statement>
+<sql-statement>
+-- the wolf bug - schema mods caused inconsistent row descriptors
+CREATE TABLE attmp (
+	initial 	int4
+);
+</sql-statement>
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN a int4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN a int4;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN b name;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN b name;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN c text;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN c text;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN d float8;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN d float8;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN e float4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN e float4;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN f int2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN f int2;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN g polygon;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN g polygon;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN i char;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN i char;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN k int4;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN k int4;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN l tid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN l tid;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN m xid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN m xid;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN n oidvector;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN n oidvector;
+	^
+<sql-statement>
+--ALTER TABLE attmp ADD COLUMN o lock;
+ALTER TABLE attmp ADD COLUMN p boolean;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	--ALTER TABLE attmp ADD COLUMN o lock;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN q point;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN q point;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN r lseg;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN r lseg;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN s path;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN s path;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN t box;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN t box;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN v timestamp;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN v timestamp;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN w interval;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN w interval;
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN x float8[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN x float8[];
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN y float4[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN y float4[];
+	^
+<sql-statement>
+ALTER TABLE attmp ADD COLUMN z int2[];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp ADD COLUMN z int2[];
+	^
+<sql-statement>
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,   k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+        'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+</sql-statement>
+<sql-statement>
+SELECT * FROM attmp;
+</sql-statement>
+<sql-statement>
+CREATE INDEX attmp_idx ON attmp (a, (d + e), b);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: index expression is not supported yet
+    	CREATE INDEX attmp_idx ON attmp (a, (d + e), b);
+	^
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:37: Error: ERROR:  column number must be in range from 1 to 32767
+
+    	ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000;
+	                                    ^
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 1 SET STATISTICS 1000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER INDEX attmp_idx ALTER COLUMN 1 SET STATISTICS 1000;
+	^
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS 1000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS 1000;
+	^
+<sql-statement>
+\d+ attmp_idx
+</sql-statement>
+Metacommand \d+ attmp_idx is not supported
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 3 SET STATISTICS 1000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER INDEX attmp_idx ALTER COLUMN 3 SET STATISTICS 1000;
+	^
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 4 SET STATISTICS 1000;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER INDEX attmp_idx ALTER COLUMN 4 SET STATISTICS 1000;
+	^
+<sql-statement>
+ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS -1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS -1;
+	^
+<sql-statement>
+DROP TABLE attmp;
+</sql-statement>
+<sql-statement>
+-- fails with incorrect object type
+CREATE VIEW at_v1 AS SELECT 1 as a;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	-- fails with incorrect object type
+	^
+<sql-statement>
+ALTER TABLE at_v1 ALTER COLUMN a SET STATISTICS 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE at_v1 ALTER COLUMN a SET STATISTICS 0;
+	^
+<sql-statement>
+DROP VIEW at_v1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: View not found: 'at_v1'
+    	DROP VIEW at_v1;
+	^
+<sql-statement>
+--
+-- rename - check on both non-temp and temp tables
+--
+CREATE TABLE attmp (regtable int);
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE attmp (attmptable int);
+</sql-statement>
+<sql-statement>
+ALTER TABLE attmp RENAME TO attmp_new;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE attmp RENAME TO attmp_new;
+	^
+<sql-statement>
+SELECT * FROM attmp;
+</sql-statement>
+<sql-statement>
+SELECT * FROM attmp_new;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.attmp_new
+    
+<sql-statement>
+ALTER TABLE attmp RENAME TO attmp_new2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE attmp RENAME TO attmp_new2;
+	^
+<sql-statement>
+SELECT * FROM attmp;		-- should fail
+</sql-statement>
+<sql-statement>
+SELECT * FROM attmp_new;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.attmp_new
+    
+<sql-statement>
+SELECT * FROM attmp_new2;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.attmp_new2
+    
+<sql-statement>
+DROP TABLE attmp_new;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp_new2;
+</sql-statement>
+<sql-statement>
+-- check rename of partitioned tables and indexes also
+CREATE TABLE part_attmp (a int primary key) partition by range (a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
+    	-- check rename of partitioned tables and indexes also
+	^
+<sql-statement>
+CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100);
+	^
+<sql-statement>
+ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index;
+	^
+<sql-statement>
+ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index;
+	^
+<sql-statement>
+ALTER TABLE part_attmp RENAME TO part_at2tmp;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE part_attmp RENAME TO part_at2tmp;
+	^
+<sql-statement>
+ALTER TABLE part_attmp1 RENAME TO part_at2tmp1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE part_attmp1 RENAME TO part_at2tmp1;
+	^
+<sql-statement>
+SET ROLE regress_alter_table_user1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: role
+    	SET ROLE regress_alter_table_user1;
+	^
+<sql-statement>
+ALTER INDEX part_attmp_index RENAME TO fail;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX part_attmp_index RENAME TO fail;
+	^
+<sql-statement>
+ALTER INDEX part_attmp1_index RENAME TO fail;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX part_attmp1_index RENAME TO fail;
+	^
+<sql-statement>
+ALTER TABLE part_at2tmp RENAME TO fail;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE part_at2tmp RENAME TO fail;
+	^
+<sql-statement>
+ALTER TABLE part_at2tmp1 RENAME TO fail;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE part_at2tmp1 RENAME TO fail;
+	^
+<sql-statement>
+RESET ROLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	RESET ROLE;
+	^
+<sql-statement>
+DROP TABLE part_at2tmp;
+</sql-statement>
+<sql-statement>
+--
+-- check renaming to a table's array type's autogenerated name
+-- (the array type's name should get out of the way)
+--
+CREATE TABLE attmp_array (id int);
+</sql-statement>
+<sql-statement>
+CREATE TABLE attmp_array2 (id int);
+</sql-statement>
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "attmp_array[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "attmp_array2[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype;
+	^
+<sql-statement>
+ALTER TABLE attmp_array2 RENAME TO _attmp_array;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE attmp_array2 RENAME TO _attmp_array;
+	^
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "attmp_array[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "_attmp_array[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+	^
+<sql-statement>
+DROP TABLE _attmp_array;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp_array;
+</sql-statement>
+<sql-statement>
+-- renaming to table's own array type's name is an interesting corner case
+CREATE TABLE attmp_array (id int);
+</sql-statement>
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "attmp_array[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype;
+	^
+<sql-statement>
+ALTER TABLE attmp_array RENAME TO _attmp_array;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE attmp_array RENAME TO _attmp_array;
+	^
+<sql-statement>
+SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  type "_attmp_array[]" does not exist
+
+        	SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype;
+	^
+<sql-statement>
+DROP TABLE _attmp_array;
+</sql-statement>
+<sql-statement>
+-- ALTER TABLE ... RENAME on non-table relations
+-- renaming indexes (FIXME: this should probably test the index's functionality)
+ALTER INDEX IF EXISTS __onek_unique1 RENAME TO attmp_onek_unique1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	-- ALTER TABLE ... RENAME on non-table relations
+	^
+<sql-statement>
+ALTER INDEX IF EXISTS __attmp_onek_unique1 RENAME TO onek_unique1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX IF EXISTS __attmp_onek_unique1 RENAME TO onek_unique1;
+	^
+<sql-statement>
+ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1;
+	^
+<sql-statement>
+ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1;
+	^
+<sql-statement>
+SET ROLE regress_alter_table_user1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: role
+    	SET ROLE regress_alter_table_user1;
+	^
+<sql-statement>
+ALTER INDEX onek_unique1 RENAME TO fail;  -- permission denied
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX onek_unique1 RENAME TO fail;  -- permission denied
+	^
+<sql-statement>
+RESET ROLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	RESET ROLE;
+	^
+<sql-statement>
+-- rename statements with mismatching statement and object types
+CREATE TABLE alter_idx_rename_test (a INT);
+</sql-statement>
+<sql-statement>
+CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test (a);
+</sql-statement>
+<sql-statement>
+CREATE TABLE alter_idx_rename_test_parted (a INT) PARTITION BY LIST (a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
+    	CREATE TABLE alter_idx_rename_test_parted (a INT) PARTITION BY LIST (a);
+	^
+<sql-statement>
+CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted (a);
+</sql-statement>
+<sql-statement>
+BEGIN;
+</sql-statement>
+<sql-statement>
+ALTER INDEX alter_idx_rename_test RENAME TO alter_idx_rename_test_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX alter_idx_rename_test RENAME TO alter_idx_rename_test_2;
+	^
+<sql-statement>
+ALTER INDEX alter_idx_rename_test_parted RENAME TO alter_idx_rename_test_parted_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX alter_idx_rename_test_parted RENAME TO alter_idx_rename_test_parted_2;
+	^
+<sql-statement>
+SELECT relation::regclass, mode FROM pg_locks
+WHERE pid = pg_backend_pid() AND locktype = 'relation'
+  AND relation::regclass::text LIKE 'alter\_idx%'
+ORDER BY relation::regclass::text COLLATE "C";
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 365
+    	SELECT relation::regclass, mode FROM pg_locks
+	^
+<sql-statement>
+COMMIT;
+</sql-statement>
+<sql-statement>
+BEGIN;
+</sql-statement>
+<sql-statement>
+ALTER INDEX alter_idx_rename_test_idx RENAME TO alter_idx_rename_test_idx_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX alter_idx_rename_test_idx RENAME TO alter_idx_rename_test_idx_2;
+	^
+<sql-statement>
+ALTER INDEX alter_idx_rename_test_parted_idx RENAME TO alter_idx_rename_test_parted_idx_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX alter_idx_rename_test_parted_idx RENAME TO alter_idx_rename_test_parted_idx_2;
+	^
+<sql-statement>
+SELECT relation::regclass, mode FROM pg_locks
+WHERE pid = pg_backend_pid() AND locktype = 'relation'
+  AND relation::regclass::text LIKE 'alter\_idx%'
+ORDER BY relation::regclass::text COLLATE "C";
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 365
+    	SELECT relation::regclass, mode FROM pg_locks
+	^
+<sql-statement>
+COMMIT;
+</sql-statement>
+<sql-statement>
+BEGIN;
+</sql-statement>
+<sql-statement>
+ALTER TABLE alter_idx_rename_test_idx_2 RENAME TO alter_idx_rename_test_idx_3;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE alter_idx_rename_test_idx_2 RENAME TO alter_idx_rename_test_idx_3;
+	^
+<sql-statement>
+ALTER TABLE alter_idx_rename_test_parted_idx_2 RENAME TO alter_idx_rename_test_parted_idx_3;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE alter_idx_rename_test_parted_idx_2 RENAME TO alter_idx_rename_test_parted_idx_3;
+	^
+<sql-statement>
+SELECT relation::regclass, mode FROM pg_locks
+WHERE pid = pg_backend_pid() AND locktype = 'relation'
+  AND relation::regclass::text LIKE 'alter\_idx%'
+ORDER BY relation::regclass::text COLLATE "C";
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 365
+    	SELECT relation::regclass, mode FROM pg_locks
+	^
+<sql-statement>
+COMMIT;
+</sql-statement>
+<sql-statement>
+DROP TABLE alter_idx_rename_test_2;
+</sql-statement>
+<sql-statement>
+-- renaming views
+CREATE VIEW attmp_view (unique1) AS SELECT unique1 FROM tenk1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>: Error: Not all views have been dropped
+    
+<sql-statement>
+ALTER TABLE attmp_view RENAME TO attmp_view_new;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE attmp_view RENAME TO attmp_view_new;
+	^
+<sql-statement>
+SET ROLE regress_alter_table_user1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: role
+    	SET ROLE regress_alter_table_user1;
+	^
+<sql-statement>
+ALTER VIEW attmp_view_new RENAME TO fail;  -- permission denied
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER VIEW attmp_view_new RENAME TO fail;  -- permission denied
+	^
+<sql-statement>
+RESET ROLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	RESET ROLE;
+	^
+<sql-statement>
+-- hack to ensure we get an indexscan here
+set enable_seqscan to off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_seqscan
+    	-- hack to ensure we get an indexscan here
+	^
+<sql-statement>
+set enable_bitmapscan to off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_bitmapscan
+    	set enable_bitmapscan to off;
+	^
+<sql-statement>
+-- 5 values, sorted
+SELECT unique1 FROM tenk1 WHERE unique1 < 5;
+</sql-statement>
+<sql-statement>
+reset enable_seqscan;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	reset enable_seqscan;
+	^
+<sql-statement>
+reset enable_bitmapscan;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	reset enable_bitmapscan;
+	^
+<sql-statement>
+DROP VIEW attmp_view_new;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: View not found: 'attmp_view_new'
+    	DROP VIEW attmp_view_new;
+	^
+<sql-statement>
+-- toast-like relation name
+alter table stud_emp rename to pg_toast_stud_emp;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	-- toast-like relation name
+	^
+<sql-statement>
+alter table pg_toast_stud_emp rename to stud_emp;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	alter table pg_toast_stud_emp rename to stud_emp;
+	^
+<sql-statement>
+-- renaming index should rename constraint as well
+ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- renaming index should rename constraint as well
+	^
+<sql-statement>
+ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo;
+	^
+<sql-statement>
+ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo;
+	^
+<sql-statement>
+-- renaming constraint
+ALTER TABLE onek ADD CONSTRAINT onek_check_constraint CHECK (unique1 >= 0);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- renaming constraint
+	^
+<sql-statement>
+ALTER TABLE onek RENAME CONSTRAINT onek_check_constraint TO onek_check_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE onek RENAME CONSTRAINT onek_check_constraint TO onek_check_constraint_foo;
+	^
+<sql-statement>
+ALTER TABLE onek DROP CONSTRAINT onek_check_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE onek DROP CONSTRAINT onek_check_constraint_foo;
+	^
+<sql-statement>
+-- renaming constraint should rename index as well
+ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- renaming constraint should rename index as well
+	^
+<sql-statement>
+DROP INDEX onek_unique1_constraint;  -- to see whether it's there
+</sql-statement>
+-stdin-:<main>: Error: Pre type annotation
+
+    -stdin-:<main>:1:1: Error: Unexpected tag: pgObject
+    	DROP INDEX onek_unique1_constraint;  -- to see whether it's there
+	^
+<sql-statement>
+ALTER TABLE onek RENAME CONSTRAINT onek_unique1_constraint TO onek_unique1_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE onek RENAME CONSTRAINT onek_unique1_constraint TO onek_unique1_constraint_foo;
+	^
+<sql-statement>
+DROP INDEX onek_unique1_constraint_foo;  -- to see whether it's there
+</sql-statement>
+-stdin-:<main>: Error: Pre type annotation
+
+    -stdin-:<main>:1:1: Error: Unexpected tag: pgObject
+    	DROP INDEX onek_unique1_constraint_foo;  -- to see whether it's there
+	^
+<sql-statement>
+ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo;
+	^
+<sql-statement>
+-- renaming constraints vs. inheritance
+CREATE TABLE constraint_rename_test (a int CONSTRAINT con1 CHECK (a > 0), b int, c int);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: column constraint not supported
+    	-- renaming constraints vs. inheritance
+	^
+<sql-statement>
+\d constraint_rename_test
+</sql-statement>
+Metacommand \d constraint_rename_test is not supported
+<sql-statement>
+CREATE TABLE constraint_rename_test2 (a int CONSTRAINT con1 CHECK (a > 0), d int) INHERITS (constraint_rename_test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	CREATE TABLE constraint_rename_test2 (a int CONSTRAINT con1 CHECK (a > 0), d int) INHERITS (constraint_rename_test);
+	^
+<sql-statement>
+\d constraint_rename_test2
+</sql-statement>
+Metacommand \d constraint_rename_test2 is not supported
+<sql-statement>
+ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo; -- fail
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo; -- fail
+	^
+<sql-statement>
+ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con1 TO con1foo; -- fail
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con1 TO con1foo; -- fail
+	^
+<sql-statement>
+ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo; -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo; -- ok
+	^
+<sql-statement>
+\d constraint_rename_test
+</sql-statement>
+Metacommand \d constraint_rename_test is not supported
+<sql-statement>
+\d constraint_rename_test2
+</sql-statement>
+Metacommand \d constraint_rename_test2 is not supported
+<sql-statement>
+ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT;
+	^
+<sql-statement>
+ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo; -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo; -- ok
+	^
+<sql-statement>
+ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar; -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar; -- ok
+	^
+<sql-statement>
+\d constraint_rename_test
+</sql-statement>
+Metacommand \d constraint_rename_test is not supported
+<sql-statement>
+\d constraint_rename_test2
+</sql-statement>
+Metacommand \d constraint_rename_test2 is not supported
+<sql-statement>
+ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a);
+	^
+<sql-statement>
+ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo; -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo; -- ok
+	^
+<sql-statement>
+\d constraint_rename_test
+</sql-statement>
+Metacommand \d constraint_rename_test is not supported
+<sql-statement>
+\d constraint_rename_test2
+</sql-statement>
+Metacommand \d constraint_rename_test2 is not supported
+<sql-statement>
+DROP TABLE constraint_rename_test2;
+</sql-statement>
+<sql-statement>
+DROP TABLE constraint_rename_test;
+</sql-statement>
+<sql-statement>
+ALTER TABLE IF EXISTS constraint_not_exist RENAME CONSTRAINT con3 TO con3foo; -- ok
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE IF EXISTS constraint_not_exist RENAME CONSTRAINT con3 TO con3foo; -- ok
+	^
+<sql-statement>
+ALTER TABLE IF EXISTS constraint_rename_test ADD CONSTRAINT con4 UNIQUE (a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE IF EXISTS constraint_rename_test ADD CONSTRAINT con4 UNIQUE (a);
+	^
+<sql-statement>
+-- renaming constraints with cache reset of target relation
+CREATE TABLE constraint_rename_cache (a int,
+  CONSTRAINT chk_a CHECK (a > 0),
+  PRIMARY KEY (a));
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table constraint not supported
+    	-- renaming constraints with cache reset of target relation
+	^
+<sql-statement>
+ALTER TABLE constraint_rename_cache
+  RENAME CONSTRAINT chk_a TO chk_a_new;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_cache
+	^
+<sql-statement>
+ALTER TABLE constraint_rename_cache
+  RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_rename_pkey_new;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	ALTER TABLE constraint_rename_cache
+	^
+<sql-statement>
+CREATE TABLE like_constraint_rename_cache
+  (LIKE constraint_rename_cache INCLUDING ALL);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: CreateStmt: alternative is not implemented yet : 389
+    	CREATE TABLE like_constraint_rename_cache
+	^
+<sql-statement>
+\d like_constraint_rename_cache
+</sql-statement>
+Metacommand \d like_constraint_rename_cache is not supported
+<sql-statement>
+DROP TABLE constraint_rename_cache;
+</sql-statement>
+<sql-statement>
+DROP TABLE like_constraint_rename_cache;
+</sql-statement>
+<sql-statement>
+-- FOREIGN KEY CONSTRAINT adding TEST
+CREATE TABLE attmp2 (a int primary key);
+</sql-statement>
+<sql-statement>
+CREATE TABLE attmp3 (a int, b int);
+</sql-statement>
+<sql-statement>
+CREATE TABLE attmp4 (a int, b int, unique(a,b));
+</sql-statement>
+<sql-statement>
+CREATE TABLE attmp5 (a int, b int);
+</sql-statement>
+<sql-statement>
+-- Insert rows into attmp2 (pktable)
+INSERT INTO attmp2 values (1);
+</sql-statement>
+<sql-statement>
+INSERT INTO attmp2 values (2);
+</sql-statement>
+<sql-statement>
+INSERT INTO attmp2 values (3);
+</sql-statement>
+<sql-statement>
+INSERT INTO attmp2 values (4);
+</sql-statement>
+<sql-statement>
+-- Insert rows into attmp3
+INSERT INTO attmp3 values (1,10);
+</sql-statement>
+<sql-statement>
+INSERT INTO attmp3 values (1,20);
+</sql-statement>
+<sql-statement>
+INSERT INTO attmp3 values (5,50);
+</sql-statement>
+<sql-statement>
+-- Try (and fail) to add constraint due to invalid source columns
+ALTER TABLE attmp3 add constraint attmpconstr foreign key(c) references attmp2 match full;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and fail) to add constraint due to invalid source columns
+	^
+<sql-statement>
+-- Try (and fail) to add constraint due to invalid destination columns explicitly given
+ALTER TABLE attmp3 add constraint attmpconstr foreign key(a) references attmp2(b) match full;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and fail) to add constraint due to invalid destination columns explicitly given
+	^
+<sql-statement>
+-- Try (and fail) to add constraint due to invalid data
+ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and fail) to add constraint due to invalid data
+	^
+<sql-statement>
+-- Delete failing row
+DELETE FROM attmp3 where a=5;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+-- Try (and succeed)
+ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and succeed)
+	^
+<sql-statement>
+ALTER TABLE attmp3 drop constraint attmpconstr;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 drop constraint attmpconstr;
+	^
+<sql-statement>
+INSERT INTO attmp3 values (5,50);
+</sql-statement>
+<sql-statement>
+-- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate
+ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full NOT VALID;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate
+	^
+<sql-statement>
+ALTER TABLE attmp3 validate constraint attmpconstr;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 validate constraint attmpconstr;
+	^
+<sql-statement>
+-- Delete failing row
+DELETE FROM attmp3 where a=5;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+-- Try (and succeed) and repeat to show it works on already valid constraint
+ALTER TABLE attmp3 validate constraint attmpconstr;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and succeed) and repeat to show it works on already valid constraint
+	^
+<sql-statement>
+ALTER TABLE attmp3 validate constraint attmpconstr;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 validate constraint attmpconstr;
+	^
+<sql-statement>
+-- Try a non-verified CHECK constraint
+ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10); -- fail
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try a non-verified CHECK constraint
+	^
+<sql-statement>
+ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) NOT VALID; -- succeeds
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) NOT VALID; -- succeeds
+	^
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- fails
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- fails
+	^
+<sql-statement>
+DELETE FROM attmp3 WHERE NOT b > 10;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- succeeds
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- succeeds
+	^
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- succeeds
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten; -- succeeds
+	^
+<sql-statement>
+-- Test inherited NOT VALID CHECK constraints
+select * from attmp3;
+</sql-statement>
+<sql-statement>
+CREATE TABLE attmp6 () INHERITS (attmp3);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	CREATE TABLE attmp6 () INHERITS (attmp3);
+	^
+<sql-statement>
+CREATE TABLE attmp7 () INHERITS (attmp3);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	CREATE TABLE attmp7 () INHERITS (attmp3);
+	^
+<sql-statement>
+INSERT INTO attmp6 VALUES (6, 30), (7, 16);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.attmp6
+    
+<sql-statement>
+ALTER TABLE attmp3 ADD CONSTRAINT b_le_20 CHECK (b <= 20) NOT VALID;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 ADD CONSTRAINT b_le_20 CHECK (b <= 20) NOT VALID;
+	^
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20;	-- fails
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20;	-- fails
+	^
+<sql-statement>
+DELETE FROM attmp6 WHERE b > 20;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20;	-- succeeds
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20;	-- succeeds
+	^
+<sql-statement>
+-- An already validated constraint must not be revalidated
+CREATE FUNCTION boo(int) RETURNS int IMMUTABLE STRICT LANGUAGE plpgsql AS $$ BEGIN RAISE NOTICE 'boo: %', $1; RETURN $1; END; $$;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	-- An already validated constraint must not be revalidated
+	^
+<sql-statement>
+INSERT INTO attmp7 VALUES (8, 18);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.attmp7
+    
+<sql-statement>
+ALTER TABLE attmp7 ADD CONSTRAINT identity CHECK (b = boo(b));
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp7 ADD CONSTRAINT identity CHECK (b = boo(b));
+	^
+<sql-statement>
+ALTER TABLE attmp3 ADD CONSTRAINT IDENTITY check (b = boo(b)) NOT VALID;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 ADD CONSTRAINT IDENTITY check (b = boo(b)) NOT VALID;
+	^
+<sql-statement>
+ALTER TABLE attmp3 VALIDATE CONSTRAINT identity;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE attmp3 VALIDATE CONSTRAINT identity;
+	^
+<sql-statement>
+-- A NO INHERIT constraint should not be looked for in children during VALIDATE CONSTRAINT
+create table parent_noinh_convalid (a int);
+</sql-statement>
+<sql-statement>
+create table child_noinh_convalid () inherits (parent_noinh_convalid);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table child_noinh_convalid () inherits (parent_noinh_convalid);
+	^
+<sql-statement>
+insert into parent_noinh_convalid values (1);
+</sql-statement>
+<sql-statement>
+insert into child_noinh_convalid values (1);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.child_noinh_convalid
+    
+<sql-statement>
+alter table parent_noinh_convalid add constraint check_a_is_2 check (a = 2) no inherit not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table parent_noinh_convalid add constraint check_a_is_2 check (a = 2) no inherit not valid;
+	^
+<sql-statement>
+-- fail, because of the row in parent
+alter table parent_noinh_convalid validate constraint check_a_is_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail, because of the row in parent
+	^
+<sql-statement>
+delete from only parent_noinh_convalid;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+-- ok (parent itself contains no violating rows)
+alter table parent_noinh_convalid validate constraint check_a_is_2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- ok (parent itself contains no violating rows)
+	^
+<sql-statement>
+select convalidated from pg_constraint where conrelid = 'parent_noinh_convalid'::regclass and conname = 'check_a_is_2';
+</sql-statement>
+<sql-statement>
+-- cleanup
+drop table parent_noinh_convalid, child_noinh_convalid;
+</sql-statement>
+<sql-statement>
+-- Try (and fail) to create constraint from attmp5(a) to attmp4(a) - unique constraint on
+-- attmp4 is a,b
+ALTER TABLE attmp5 add constraint attmpconstr foreign key(a) references attmp4(a) match full;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- Try (and fail) to create constraint from attmp5(a) to attmp4(a) - unique constraint on
+	^
+<sql-statement>
+DROP TABLE attmp7;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp6;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp5;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp4;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp3;
+</sql-statement>
+<sql-statement>
+DROP TABLE attmp2;
+</sql-statement>
+<sql-statement>
+-- NOT VALID with plan invalidation -- ensure we don't use a constraint for
+-- exclusion until validated
+set constraint_exclusion TO 'partition';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: constraint_exclusion
+    	-- NOT VALID with plan invalidation -- ensure we don't use a constraint for
+	^
+<sql-statement>
+create table nv_parent (d date, check (false) no inherit not valid);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table constraint not supported
+    	create table nv_parent (d date, check (false) no inherit not valid);
+	^
+<sql-statement>
+-- not valid constraint added at creation time should automatically become valid
+\d nv_parent
+</sql-statement>
+Metacommand \d nv_parent is not supported
+<sql-statement>
+create table nv_child_2010 () inherits (nv_parent);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table nv_child_2010 () inherits (nv_parent);
+	^
+<sql-statement>
+create table nv_child_2011 () inherits (nv_parent);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table nv_child_2011 () inherits (nv_parent);
+	^
+<sql-statement>
+alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid;
+	^
+<sql-statement>
+alter table nv_child_2011 add check (d between '2011-01-01'::date and '2011-12-31'::date) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table nv_child_2011 add check (d between '2011-01-01'::date and '2011-12-31'::date) not valid;
+	^
+<sql-statement>
+explain (costs off) select * from nv_parent where d between '2011-08-01' and '2011-08-31';
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off) select * from nv_parent where d between '2011-08-01' and '2011-08-31';
+	^
+<sql-statement>
+create table nv_child_2009 (check (d between '2009-01-01'::date and '2009-12-31'::date)) inherits (nv_parent);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table nv_child_2009 (check (d between '2009-01-01'::date and '2009-12-31'::date)) inherits (nv_parent);
+	^
+<sql-statement>
+explain (costs off) select * from nv_parent where d between '2011-08-01'::date and '2011-08-31'::date;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off) select * from nv_parent where d between '2011-08-01'::date and '2011-08-31'::date;
+	^
+<sql-statement>
+explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date;
+	^
+<sql-statement>
+-- after validation, the constraint should be used
+alter table nv_child_2011 VALIDATE CONSTRAINT nv_child_2011_d_check;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- after validation, the constraint should be used
+	^
+<sql-statement>
+explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
+    	explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date;
+	^
+<sql-statement>
+-- add an inherited NOT VALID constraint
+alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31'::date) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add an inherited NOT VALID constraint
+	^
+<sql-statement>
+\d nv_child_2009
+</sql-statement>
+Metacommand \d nv_child_2009 is not supported
+<sql-statement>
+-- we leave nv_parent and children around to help test pg_dump logic
+-- Foreign key adding test with mixed types
+-- Note: these tables are TEMP to avoid name conflicts when this test
+-- is run in parallel with foreign_key.sql.
+CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
+</sql-statement>
+<sql-statement>
+INSERT INTO PKTABLE VALUES(42);
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE FKTABLE (ftest1 inet);
+</sql-statement>
+<sql-statement>
+-- This next should fail, because int=inet does not exist
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- This next should fail, because int=inet does not exist
+	^
+<sql-statement>
+-- This should also fail for the same reason, but here we
+-- give the column name
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- This should also fail for the same reason, but here we
+	^
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+-- This should succeed, even though they are different types,
+-- because int=int8 exists and is a member of the integer opfamily
+CREATE TEMP TABLE FKTABLE (ftest1 int8);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+	^
+<sql-statement>
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+</sql-statement>
+<sql-statement>
+INSERT INTO FKTABLE VALUES(43);		-- should fail
+</sql-statement>
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+-- This should fail, because we'd have to cast numeric to int which is
+-- not an implicit coercion (or use numeric=numeric, but that's not part
+-- of the integer opfamily)
+CREATE TEMP TABLE FKTABLE (ftest1 numeric);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+	^
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+DROP TABLE PKTABLE;
+</sql-statement>
+<sql-statement>
+-- On the other hand, this should work because int implicitly promotes to
+-- numeric, and we allow promotion on the FK side
+CREATE TEMP TABLE PKTABLE (ptest1 numeric PRIMARY KEY);
+</sql-statement>
+<sql-statement>
+INSERT INTO PKTABLE VALUES(42);
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
+	^
+<sql-statement>
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+</sql-statement>
+<sql-statement>
+INSERT INTO FKTABLE VALUES(43);		-- should fail
+</sql-statement>
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+DROP TABLE PKTABLE;
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
+                           PRIMARY KEY(ptest1, ptest2));
+</sql-statement>
+<sql-statement>
+-- This should fail, because we just chose really odd types
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
+	^
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+-- Again, so should this...
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
+     references pktable(ptest1, ptest2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
+	^
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+-- This fails because we mixed up the column ordering
+CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
+     references pktable(ptest2, ptest1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
+	^
+<sql-statement>
+-- As does this...
+ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1)
+     references pktable(ptest1, ptest2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- As does this...
+	^
+<sql-statement>
+DROP TABLE FKTABLE;
+</sql-statement>
+<sql-statement>
+DROP TABLE PKTABLE;
+</sql-statement>
+<sql-statement>
+-- Test that ALTER CONSTRAINT updates trigger deferrability properly
+CREATE TEMP TABLE PKTABLE (ptest1 int primary key);
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+</sql-statement>
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fknd FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fknd FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fkdd FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fkdd FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fkdi FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fkdi FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fknd2 FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fknd2 FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ALTER CONSTRAINT fknd2 NOT DEFERRABLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ALTER CONSTRAINT fknd2 NOT DEFERRABLE;
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fkdd2 FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fkdd2 FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ALTER CONSTRAINT fkdd2 DEFERRABLE INITIALLY DEFERRED;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ALTER CONSTRAINT fkdd2 DEFERRABLE INITIALLY DEFERRED;
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ADD CONSTRAINT fkdi2 FOREIGN KEY(ftest1) REFERENCES pktable
+  ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ADD CONSTRAINT fkdi2 FOREIGN KEY(ftest1) REFERENCES pktable
+	^
+<sql-statement>
+ALTER TABLE FKTABLE ALTER CONSTRAINT fkdi2 DEFERRABLE INITIALLY IMMEDIATE;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	ALTER TABLE FKTABLE ALTER CONSTRAINT fkdi2 DEFERRABLE INITIALLY IMMEDIATE;
+	^
+<sql-statement>
+SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint
+WHERE tgrelid = 'pktable'::regclass
+ORDER BY 1,2,3;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: Sort
+    	SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+	^
+        -stdin-:<main>:1:1: Error: Expected comparable type, but got: Tuple<pgname,pgregproc,pgint2>
+        	SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+	^
+<sql-statement>
+SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint
+WHERE tgrelid = 'fktable'::regclass
+ORDER BY 1,2,3;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: Sort
+    	SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+	^
+        -stdin-:<main>:1:1: Error: Expected comparable type, but got: Tuple<pgname,pgregproc,pgint2>
+        	SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred
+	^
+<sql-statement>
+-- temp tables should go away by themselves, need not drop them.
+-- test check constraint adding
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- add a check constraint
+alter table atacc1 add constraint atacc_test1 check (test>3);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a check constraint
+	^
+<sql-statement>
+-- should fail
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- should succeed
+insert into atacc1 (test) values (4);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the check fails when added
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- insert a soon to be failing row
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- add a check constraint (fails)
+alter table atacc1 add constraint atacc_test1 check (test>3);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a check constraint (fails)
+	^
+<sql-statement>
+insert into atacc1 (test) values (4);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the check fails because the column doesn't exist
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- add a check constraint (fails)
+alter table atacc1 add constraint atacc_test1 check (test1>3);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a check constraint (fails)
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- something a little more complicated
+create table atacc1 ( test int, test2 int, test3 int);
+</sql-statement>
+<sql-statement>
+-- add a check constraint (fails)
+alter table atacc1 add constraint atacc_test1 check (test+test2<test3*4);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a check constraint (fails)
+	^
+<sql-statement>
+-- should fail
+insert into atacc1 (test,test2,test3) values (4,4,2);
+</sql-statement>
+<sql-statement>
+-- should succeed
+insert into atacc1 (test,test2,test3) values (4,4,5);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- lets do some naming tests
+create table atacc1 (test int check (test>3), test2 int);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: column constraint not supported
+    	-- lets do some naming tests
+	^
+<sql-statement>
+alter table atacc1 add check (test2>test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add check (test2>test);
+	^
+<sql-statement>
+-- should fail for $2
+insert into atacc1 (test2, test) values (3, 4);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.atacc1
+    
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- inheritance related tests
+create table atacc1 (test int);
+</sql-statement>
+<sql-statement>
+create table atacc2 (test2 int);
+</sql-statement>
+<sql-statement>
+create table atacc3 (test3 int) inherits (atacc1, atacc2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table atacc3 (test3 int) inherits (atacc1, atacc2);
+	^
+<sql-statement>
+alter table atacc2 add constraint foo check (test2>0);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc2 add constraint foo check (test2>0);
+	^
+<sql-statement>
+-- fail and then succeed on atacc2
+insert into atacc2 (test2) values (-3);
+</sql-statement>
+<sql-statement>
+insert into atacc2 (test2) values (3);
+</sql-statement>
+<sql-statement>
+-- fail and then succeed on atacc3
+insert into atacc3 (test2) values (-3);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.atacc3
+    
+<sql-statement>
+insert into atacc3 (test2) values (3);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.atacc3
+    
+<sql-statement>
+drop table atacc3;
+</sql-statement>
+<sql-statement>
+drop table atacc2;
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- same things with one created with INHERIT
+create table atacc1 (test int);
+</sql-statement>
+<sql-statement>
+create table atacc2 (test2 int);
+</sql-statement>
+<sql-statement>
+create table atacc3 (test3 int) inherits (atacc1, atacc2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table atacc3 (test3 int) inherits (atacc1, atacc2);
+	^
+<sql-statement>
+alter table atacc3 no inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 no inherit atacc2;
+	^
+<sql-statement>
+-- fail
+alter table atacc3 no inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail
+	^
+<sql-statement>
+-- make sure it really isn't a child
+insert into atacc3 (test2) values (3);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.atacc3
+    
+<sql-statement>
+select test2 from atacc2;
+</sql-statement>
+<sql-statement>
+-- fail due to missing constraint
+alter table atacc2 add constraint foo check (test2>0);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail due to missing constraint
+	^
+<sql-statement>
+alter table atacc3 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 inherit atacc2;
+	^
+<sql-statement>
+-- fail due to missing column
+alter table atacc3 rename test2 to testx;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 264
+    	-- fail due to missing column
+	^
+<sql-statement>
+alter table atacc3 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 inherit atacc2;
+	^
+<sql-statement>
+-- fail due to mismatched data type
+alter table atacc3 add test2 bool;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail due to mismatched data type
+	^
+<sql-statement>
+alter table atacc3 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 inherit atacc2;
+	^
+<sql-statement>
+alter table atacc3 drop test2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 drop test2;
+	^
+<sql-statement>
+-- succeed
+alter table atacc3 add test2 int;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- succeed
+	^
+<sql-statement>
+update atacc3 set test2 = 4 where test2 is null;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+alter table atacc3 add constraint foo check (test2>0);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 add constraint foo check (test2>0);
+	^
+<sql-statement>
+alter table atacc3 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc3 inherit atacc2;
+	^
+<sql-statement>
+-- fail due to duplicates and circular inheritance
+alter table atacc3 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail due to duplicates and circular inheritance
+	^
+<sql-statement>
+alter table atacc2 inherit atacc3;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc2 inherit atacc3;
+	^
+<sql-statement>
+alter table atacc2 inherit atacc2;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc2 inherit atacc2;
+	^
+<sql-statement>
+-- test that we really are a child now (should see 4 not 3 and cascade should go through)
+select test2 from atacc2;
+</sql-statement>
+<sql-statement>
+drop table atacc2 cascade;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: CASCADE is not implemented
+    	drop table atacc2 cascade;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- adding only to a parent is allowed as of 9.2
+create table atacc1 (test int);
+</sql-statement>
+<sql-statement>
+create table atacc2 (test2 int) inherits (atacc1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table atacc2 (test2 int) inherits (atacc1);
+	^
+<sql-statement>
+-- ok:
+alter table atacc1 add constraint foo check (test>0) no inherit;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- ok:
+	^
+<sql-statement>
+-- check constraint is not there on child
+insert into atacc2 (test) values (-3);
+</sql-statement>
+<sql-statement>
+-- check constraint is there on parent
+insert into atacc1 (test) values (-3);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test) values (3);
+</sql-statement>
+<sql-statement>
+-- fail, violating row:
+alter table atacc2 add constraint foo check (test>0) no inherit;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- fail, violating row:
+	^
+<sql-statement>
+drop table atacc2;
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- test unique constraint adding
+create table atacc1 ( test int ) ;
+</sql-statement>
+<sql-statement>
+-- add a unique constraint
+alter table atacc1 add constraint atacc_test1 unique (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a unique constraint
+	^
+<sql-statement>
+-- insert first value
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- should fail
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- should succeed
+insert into atacc1 (test) values (4);
+</sql-statement>
+<sql-statement>
+-- try to create duplicates via alter table using - should fail
+alter table atacc1 alter column test type integer using 0;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try to create duplicates via alter table using - should fail
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the unique constraint fails when added
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- add a unique constraint (fails)
+alter table atacc1 add constraint atacc_test1 unique (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a unique constraint (fails)
+	^
+<sql-statement>
+insert into atacc1 (test) values (3);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the unique constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- add a unique constraint (fails)
+alter table atacc1 add constraint atacc_test1 unique (test1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a unique constraint (fails)
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+</sql-statement>
+<sql-statement>
+-- add a unique constraint
+alter table atacc1 add constraint atacc_test1 unique (test, test2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a unique constraint
+	^
+<sql-statement>
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+</sql-statement>
+<sql-statement>
+-- should fail
+insert into atacc1 (test,test2) values (4,4);
+</sql-statement>
+<sql-statement>
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (5,4);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (5,5);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, unique(test));
+</sql-statement>
+<sql-statement>
+alter table atacc1 add unique (test2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add unique (test2);
+	^
+<sql-statement>
+-- should fail for @@ second one @@
+insert into atacc1 (test2, test) values (3, 3);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test2, test) values (2, 3);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- test primary key constraint adding
+create table atacc1 ( id serial, test int) ;
+</sql-statement>
+<sql-statement>
+-- add a primary key constraint
+alter table atacc1 add constraint atacc_test1 primary key (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key constraint
+	^
+<sql-statement>
+-- insert first value
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- should fail
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- should succeed
+insert into atacc1 (test) values (4);
+</sql-statement>
+<sql-statement>
+-- inserting NULL should fail
+insert into atacc1 (test) values(NULL);
+</sql-statement>
+<sql-statement>
+-- try adding a second primary key (should fail)
+alter table atacc1 add constraint atacc_oid1 primary key(id);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try adding a second primary key (should fail)
+	^
+<sql-statement>
+-- drop first primary key constraint
+alter table atacc1 drop constraint atacc_test1 restrict;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- drop first primary key constraint
+	^
+<sql-statement>
+-- try adding a primary key on oid (should succeed)
+alter table atacc1 add constraint atacc_oid1 primary key(id);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try adding a primary key on oid (should succeed)
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the primary key constraint fails when added
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test) values (2);
+</sql-statement>
+<sql-statement>
+-- add a primary key (fails)
+alter table atacc1 add constraint atacc_test1 primary key (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key (fails)
+	^
+<sql-statement>
+insert into atacc1 (test) values (3);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do another one where the primary key constraint fails when added
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- insert soon to be failing row
+insert into atacc1 (test) values (NULL);
+</sql-statement>
+<sql-statement>
+-- add a primary key (fails)
+alter table atacc1 add constraint atacc_test1 primary key (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key (fails)
+	^
+<sql-statement>
+insert into atacc1 (test) values (3);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- let's do one where the primary key constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+-- add a primary key constraint (fails)
+alter table atacc1 add constraint atacc_test1 primary key (test1);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key constraint (fails)
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- adding a new column as primary key to a non-empty table.
+-- should fail unless the column has a non-null default value.
+create table atacc1 ( test int );
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test) values (0);
+</sql-statement>
+<sql-statement>
+-- add a primary key column without a default (fails).
+alter table atacc1 add column test2 int primary key;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key column without a default (fails).
+	^
+<sql-statement>
+-- now add a primary key column with a default (succeeds).
+alter table atacc1 add column test2 int default 0 primary key;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- now add a primary key column with a default (succeeds).
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- this combination used to have order-of-execution problems (bug #15580)
+create table atacc1 (a int);
+</sql-statement>
+<sql-statement>
+insert into atacc1 values(1);
+</sql-statement>
+<sql-statement>
+alter table atacc1
+  add column b float8 not null default random(),
+  add primary key(a);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- additionally, we've seen issues with foreign key validation not being
+-- properly delayed until after a table rewrite.  Check that works ok.
+create table atacc1 (a int primary key);
+</sql-statement>
+<sql-statement>
+alter table atacc1 add constraint atacc1_fkey foreign key (a) references atacc1 (a) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add constraint atacc1_fkey foreign key (a) references atacc1 (a) not valid;
+	^
+<sql-statement>
+alter table atacc1 validate constraint atacc1_fkey, alter a type bigint;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 validate constraint atacc1_fkey, alter a type bigint;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- we've also seen issues with check constraints being validated at the wrong
+-- time when there's a pending table rewrite.
+create table atacc1 (a bigint, b int);
+</sql-statement>
+<sql-statement>
+insert into atacc1 values(1,1);
+</sql-statement>
+<sql-statement>
+alter table atacc1 add constraint atacc1_chk check(b = 1) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add constraint atacc1_chk check(b = 1) not valid;
+	^
+<sql-statement>
+alter table atacc1 validate constraint atacc1_chk, alter a type int;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 validate constraint atacc1_chk, alter a type int;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- same as above, but ensure the constraint violation is detected
+create table atacc1 (a bigint, b int);
+</sql-statement>
+<sql-statement>
+insert into atacc1 values(1,2);
+</sql-statement>
+<sql-statement>
+alter table atacc1 add constraint atacc1_chk check(b = 1) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add constraint atacc1_chk check(b = 1) not valid;
+	^
+<sql-statement>
+alter table atacc1 validate constraint atacc1_chk, alter a type int;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 validate constraint atacc1_chk, alter a type int;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+</sql-statement>
+<sql-statement>
+-- add a primary key constraint
+alter table atacc1 add constraint atacc_test1 primary key (test, test2);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- add a primary key constraint
+	^
+<sql-statement>
+-- try adding a second primary key - should fail
+alter table atacc1 add constraint atacc_test2 primary key (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try adding a second primary key - should fail
+	^
+<sql-statement>
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+</sql-statement>
+<sql-statement>
+-- should fail
+insert into atacc1 (test,test2) values (4,4);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (NULL,3);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (3, NULL);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (NULL,NULL);
+</sql-statement>
+<sql-statement>
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (5,4);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test,test2) values (5,5);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, primary key(test));
+</sql-statement>
+<sql-statement>
+-- only first should succeed
+insert into atacc1 (test2, test) values (3, 3);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test2, test) values (2, 3);
+</sql-statement>
+<sql-statement>
+insert into atacc1 (test2, test) values (1, NULL);
+</sql-statement>
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- alter table / alter column [set/drop] not null tests
+-- try altering system catalogs, should fail
+alter table pg_class alter column relname drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- alter table / alter column [set/drop] not null tests
+	^
+<sql-statement>
+alter table pg_class alter relname set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table pg_class alter relname set not null;
+	^
+<sql-statement>
+-- try altering non-existent table, should fail
+alter table non_existent alter column bar set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try altering non-existent table, should fail
+	^
+<sql-statement>
+alter table non_existent alter column bar drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table non_existent alter column bar drop not null;
+	^
+<sql-statement>
+-- test setting columns to null and not null and vice versa
+-- test checking for null values and primary key
+create table atacc1 (test int not null);
+</sql-statement>
+<sql-statement>
+alter table atacc1 add constraint "atacc1_pkey" primary key (test);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add constraint "atacc1_pkey" primary key (test);
+	^
+<sql-statement>
+alter table atacc1 alter column test drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter column test drop not null;
+	^
+<sql-statement>
+alter table atacc1 drop constraint "atacc1_pkey";
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 drop constraint "atacc1_pkey";
+	^
+<sql-statement>
+alter table atacc1 alter column test drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter column test drop not null;
+	^
+<sql-statement>
+insert into atacc1 values (null);
+</sql-statement>
+<sql-statement>
+alter table atacc1 alter test set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test set not null;
+	^
+<sql-statement>
+delete from atacc1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+alter table atacc1 alter test set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test set not null;
+	^
+<sql-statement>
+-- try altering a non-existent column, should fail
+alter table atacc1 alter bar set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- try altering a non-existent column, should fail
+	^
+<sql-statement>
+alter table atacc1 alter bar drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter bar drop not null;
+	^
+<sql-statement>
+-- try creating a view and altering that, should fail
+create view myview as select * from atacc1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: expected at least one target column
+    	-- try creating a view and altering that, should fail
+	^
+<sql-statement>
+alter table myview alter column test drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table myview alter column test drop not null;
+	^
+<sql-statement>
+alter table myview alter column test set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table myview alter column test set not null;
+	^
+<sql-statement>
+drop view myview;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: View not found: 'myview'
+    	drop view myview;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- set not null verified by constraints
+create table atacc1 (test_a int, test_b int);
+</sql-statement>
+<sql-statement>
+insert into atacc1 values (null, 1);
+</sql-statement>
+<sql-statement>
+-- constraint not cover all values, should fail
+alter table atacc1 add constraint atacc1_constr_or check(test_a is not null or test_b < 10);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- constraint not cover all values, should fail
+	^
+<sql-statement>
+alter table atacc1 alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_a set not null;
+	^
+<sql-statement>
+alter table atacc1 drop constraint atacc1_constr_or;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 drop constraint atacc1_constr_or;
+	^
+<sql-statement>
+-- not valid constraint, should fail
+alter table atacc1 add constraint atacc1_constr_invalid check(test_a is not null) not valid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- not valid constraint, should fail
+	^
+<sql-statement>
+alter table atacc1 alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_a set not null;
+	^
+<sql-statement>
+alter table atacc1 drop constraint atacc1_constr_invalid;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 drop constraint atacc1_constr_invalid;
+	^
+<sql-statement>
+-- with valid constraint
+update atacc1 set test_a = 1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null);
+	^
+<sql-statement>
+alter table atacc1 alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_a set not null;
+	^
+<sql-statement>
+delete from atacc1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+insert into atacc1 values (2, null);
+</sql-statement>
+<sql-statement>
+alter table atacc1 alter test_a drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_a drop not null;
+	^
+<sql-statement>
+-- test multiple set not null at same time
+-- test_a checked by atacc1_constr_a_valid, test_b should fail by table scan
+alter table atacc1 alter test_a set not null, alter test_b set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- test multiple set not null at same time
+	^
+<sql-statement>
+-- commands order has no importance
+alter table atacc1 alter test_b set not null, alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- commands order has no importance
+	^
+<sql-statement>
+-- valid one by table scan, one by check constraints
+update atacc1 set test_b = 1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+alter table atacc1 alter test_b set not null, alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_b set not null, alter test_a set not null;
+	^
+<sql-statement>
+alter table atacc1 alter test_a drop not null, alter test_b drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_a drop not null, alter test_b drop not null;
+	^
+<sql-statement>
+-- both column has check constraints
+alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	-- both column has check constraints
+	^
+<sql-statement>
+alter table atacc1 alter test_b set not null, alter test_a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table atacc1 alter test_b set not null, alter test_a set not null;
+	^
+<sql-statement>
+drop table atacc1;
+</sql-statement>
+<sql-statement>
+-- test inheritance
+create table parent (a int);
+</sql-statement>
+<sql-statement>
+create table child (b varchar(255)) inherits (parent);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: table inheritance not supported
+    	create table child (b varchar(255)) inherits (parent);
+	^
+<sql-statement>
+alter table parent alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table parent alter a set not null;
+	^
+<sql-statement>
+insert into parent values (NULL);
+</sql-statement>
+<sql-statement>
+insert into child (a, b) values (NULL, 'foo');
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.child
+    
+<sql-statement>
+alter table parent alter a drop not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table parent alter a drop not null;
+	^
+<sql-statement>
+insert into parent values (NULL);
+</sql-statement>
+<sql-statement>
+insert into child (a, b) values (NULL, 'foo');
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.child
+    
+<sql-statement>
+alter table only parent alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table only parent alter a set not null;
+	^
+<sql-statement>
+alter table child alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table child alter a set not null;
+	^
+<sql-statement>
+delete from parent;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+alter table only parent alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table only parent alter a set not null;
+	^
+<sql-statement>
+insert into parent values (NULL);
+</sql-statement>
+<sql-statement>
+alter table child alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table child alter a set not null;
+	^
+<sql-statement>
+insert into child (a, b) values (NULL, 'foo');
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.child
+    
+<sql-statement>
+delete from child;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+alter table child alter a set not null;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
+    	alter table child alter a set not null;
+	^
+<sql-statement>
+insert into child (a, b) values (NULL, 'foo');
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.child
+    
+<sql-statement>
+drop table child;
+</sql-statement>
+<sql-statement>
+drop table parent;
+</sql-statement>
+<sql-statement>
+-- test setting and removing default values
+create table def_test (
+	c1	int4 default 5,
+	c2	text default 'initial_default'
+);
+</sql-statement>
+<sql-statement>
+insert into def_test default values;
+</sql-statement>
+-stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'default_values' 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'. 
+
+<sql-statement>
+alter table def_test alter column c1 drop default;
+</sql-statement>
+NSQLTranslationPG::TConverter::ParseAlterTableStmt(AlterTableStmt const*) at /-S/ydb/library/yql/sql/pg/pg_sql.cpp:2904:0
+NSQLTranslationPG::TConverter::ParseRawStmt(RawStmt const*) at /-S/ydb/library/yql/sql/pg/pg_sql.cpp:510:0
+NSQLTranslationPG::TConverter::ParseResult(List const*, TMaybe<unsigned int, NMaybe::TPolicyUndefinedExcept>) at /-S/ydb/library/yql/sql/pg/pg_sql.cpp:393:0
+NSQLTranslationPG::TConverter::OnResult(List const*) at /-S/ydb/library/yql/sql/pg/pg_sql.cpp:351:0
+NYql::PGParse(TBasicString<char, std::__y1::char_traits<char>> const&, NYql::IPGParseEvents&) at /-S/ydb/library/yql/parser/pg_wrapper/parser.cpp:217:0
+NSQLTranslationPG::PGToYql(TBasicString<char, std::__y1::char_traits<char>> const&, NSQLTranslation::TTranslationSettings const&, NYql::TStmtParseInfo*) at /-S/ydb/library/yql/sql/pg/pg_sql.cpp:5109:0
+NSQLTranslation::SqlToYql(TBasicString<char, std::__y1::char_traits<char>> const&, NSQLTranslation::TTranslationSettings const&, TVector<NYql::TWarningRule, std::__y1::allocator<NYql::TWarningRule>>*, NYql::TStmtParseInfo*) at /-S/ydb/library/yql/sql/sql.cpp:38:0
+NYql::TProgram::ParseSql(NSQLTranslation::TTranslationSettings const&) at /-S/ydb/library/yql/core/facade/yql_facade.cpp:658:0
+Main(int, char**) at /-S/ydb/library/yql/tools/pgrun/pgrun.cpp:1239:0
+main at /-S/ydb/library/yql/tools/pgrun/pgrun.cpp:1341:0
+__libc_start_call_main at ../sysdeps/nptl/libc_start_call_main.h:58:0
+__libc_start_main_impl at ../csu/libc-start.c:392:0
+??? at ???:0:0

+ 284 - 0
yql/essentials/tests/postgresql/cases/alter_table.out

@@ -0,0 +1,284 @@
+--
+-- ALTER_TABLE
+--
+-- Clean up in case a prior regression run failed
+SET client_min_messages TO 'warning';
+RESET client_min_messages;
+--
+-- add attribute
+--
+CREATE TABLE attmp (initial int4);
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,    k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+	'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+DROP TABLE attmp;
+-- the wolf bug - schema mods caused inconsistent row descriptors
+CREATE TABLE attmp (
+	initial 	int4
+);
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,   k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+        'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000;
+ERROR:  column number must be in range from 1 to 32767
+LINE 1: ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000;
+                                           ^
+DROP TABLE attmp;
+--
+-- rename - check on both non-temp and temp tables
+--
+CREATE TABLE attmp (regtable int);
+CREATE TEMP TABLE attmp (attmptable int);
+SELECT * FROM attmp;
+ regtable 
+----------
+(0 rows)
+
+--
+-- check renaming to a table's array type's autogenerated name
+-- (the array type's name should get out of the way)
+--
+CREATE TABLE attmp_array (id int);
+CREATE TABLE attmp_array2 (id int);
+DROP TABLE attmp_array;
+-- renaming to table's own array type's name is an interesting corner case
+CREATE TABLE attmp_array (id int);
+-- rename statements with mismatching statement and object types
+CREATE TABLE alter_idx_rename_test (a INT);
+CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test (a);
+CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted (a);
+BEGIN;
+COMMIT;
+BEGIN;
+COMMIT;
+BEGIN;
+COMMIT;
+-- FOREIGN KEY CONSTRAINT adding TEST
+CREATE TABLE attmp2 (a int primary key);
+CREATE TABLE attmp3 (a int, b int);
+CREATE TABLE attmp4 (a int, b int, unique(a,b));
+CREATE TABLE attmp5 (a int, b int);
+-- Insert rows into attmp2 (pktable)
+INSERT INTO attmp2 values (1);
+INSERT INTO attmp2 values (2);
+INSERT INTO attmp2 values (3);
+INSERT INTO attmp2 values (4);
+-- Insert rows into attmp3
+INSERT INTO attmp3 values (1,10);
+INSERT INTO attmp3 values (1,20);
+INSERT INTO attmp3 values (5,50);
+INSERT INTO attmp3 values (5,50);
+-- A NO INHERIT constraint should not be looked for in children during VALIDATE CONSTRAINT
+create table parent_noinh_convalid (a int);
+insert into parent_noinh_convalid values (1);
+DROP TABLE attmp5;
+DROP TABLE attmp4;
+DROP TABLE attmp3;
+DROP TABLE attmp2;
+-- we leave nv_parent and children around to help test pg_dump logic
+-- Foreign key adding test with mixed types
+-- Note: these tables are TEMP to avoid name conflicts when this test
+-- is run in parallel with foreign_key.sql.
+CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
+INSERT INTO PKTABLE VALUES(42);
+CREATE TEMP TABLE FKTABLE (ftest1 inet);
+DROP TABLE FKTABLE;
+-- This should succeed, even though they are different types,
+-- because int=int8 exists and is a member of the integer opfamily
+CREATE TEMP TABLE FKTABLE (ftest1 int8);
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+DROP TABLE FKTABLE;
+-- This should fail, because we'd have to cast numeric to int which is
+-- not an implicit coercion (or use numeric=numeric, but that's not part
+-- of the integer opfamily)
+CREATE TEMP TABLE FKTABLE (ftest1 numeric);
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+-- On the other hand, this should work because int implicitly promotes to
+-- numeric, and we allow promotion on the FK side
+CREATE TEMP TABLE PKTABLE (ptest1 numeric PRIMARY KEY);
+INSERT INTO PKTABLE VALUES(42);
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
+                           PRIMARY KEY(ptest1, ptest2));
+-- This should fail, because we just chose really odd types
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+DROP TABLE FKTABLE;
+-- Again, so should this...
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+DROP TABLE FKTABLE;
+-- This fails because we mixed up the column ordering
+CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+-- Test that ALTER CONSTRAINT updates trigger deferrability properly
+CREATE TEMP TABLE PKTABLE (ptest1 int primary key);
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+-- temp tables should go away by themselves, need not drop them.
+-- test check constraint adding
+create table atacc1 ( test int );
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the check fails when added
+create table atacc1 ( test int );
+-- insert a soon to be failing row
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the check fails because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int, test3 int);
+-- should succeed
+insert into atacc1 (test,test2,test3) values (4,4,5);
+drop table atacc1;
+-- inheritance related tests
+create table atacc1 (test int);
+create table atacc2 (test2 int);
+insert into atacc2 (test2) values (3);
+drop table atacc2;
+drop table atacc1;
+-- same things with one created with INHERIT
+create table atacc1 (test int);
+create table atacc2 (test2 int);
+select test2 from atacc2;
+ test2 
+-------
+(0 rows)
+
+drop table atacc1;
+-- adding only to a parent is allowed as of 9.2
+create table atacc1 (test int);
+-- check constraint is not there on child
+insert into atacc2 (test) values (-3);
+insert into atacc1 (test) values (3);
+drop table atacc2;
+drop table atacc1;
+-- test unique constraint adding
+create table atacc1 ( test int ) ;
+-- insert first value
+insert into atacc1 (test) values (2);
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the unique constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do one where the unique constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+insert into atacc1 (test,test2) values (5,4);
+insert into atacc1 (test,test2) values (5,5);
+drop table atacc1;
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, unique(test));
+-- should fail for @@ second one @@
+insert into atacc1 (test2, test) values (3, 3);
+drop table atacc1;
+-- test primary key constraint adding
+create table atacc1 ( id serial, test int) ;
+-- insert first value
+insert into atacc1 (test) values (2);
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the primary key constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do another one where the primary key constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing row
+insert into atacc1 (test) values (NULL);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do one where the primary key constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- adding a new column as primary key to a non-empty table.
+-- should fail unless the column has a non-null default value.
+create table atacc1 ( test int );
+insert into atacc1 (test) values (0);
+drop table atacc1;
+-- this combination used to have order-of-execution problems (bug #15580)
+create table atacc1 (a int);
+insert into atacc1 values(1);
+drop table atacc1;
+-- additionally, we've seen issues with foreign key validation not being
+-- properly delayed until after a table rewrite.  Check that works ok.
+create table atacc1 (a int primary key);
+drop table atacc1;
+-- we've also seen issues with check constraints being validated at the wrong
+-- time when there's a pending table rewrite.
+create table atacc1 (a bigint, b int);
+insert into atacc1 values(1,1);
+drop table atacc1;
+-- same as above, but ensure the constraint violation is detected
+create table atacc1 (a bigint, b int);
+insert into atacc1 values(1,2);
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+insert into atacc1 (test,test2) values (5,4);
+insert into atacc1 (test,test2) values (5,5);
+drop table atacc1;
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, primary key(test));
+-- only first should succeed
+insert into atacc1 (test2, test) values (3, 3);
+drop table atacc1;
+-- test setting columns to null and not null and vice versa
+-- test checking for null values and primary key
+create table atacc1 (test int not null);
+insert into atacc1 values (null);
+drop table atacc1;
+-- set not null verified by constraints
+create table atacc1 (test_a int, test_b int);
+insert into atacc1 values (null, 1);
+insert into atacc1 values (2, null);
+drop table atacc1;
+-- test inheritance
+create table parent (a int);
+insert into parent values (NULL);
+drop table parent;
+-- test setting and removing default values
+create table def_test (
+	c1	int4 default 5,
+	c2	text default 'initial_default'
+);

+ 273 - 0
yql/essentials/tests/postgresql/cases/alter_table.sql

@@ -0,0 +1,273 @@
+--
+-- ALTER_TABLE
+--
+-- Clean up in case a prior regression run failed
+SET client_min_messages TO 'warning';
+RESET client_min_messages;
+--
+-- add attribute
+--
+CREATE TABLE attmp (initial int4);
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,    k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+	'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+DROP TABLE attmp;
+-- the wolf bug - schema mods caused inconsistent row descriptors
+CREATE TABLE attmp (
+	initial 	int4
+);
+INSERT INTO attmp (a, b, c, d, e, f, g,    i,   k, l, m, n, p, q, r, s, t,
+	v, w, x, y, z)
+   VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
+        'c',
+	314159, '(1,1)', '512',
+	'1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
+	'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
+	'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
+ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000;
+DROP TABLE attmp;
+--
+-- rename - check on both non-temp and temp tables
+--
+CREATE TABLE attmp (regtable int);
+CREATE TEMP TABLE attmp (attmptable int);
+SELECT * FROM attmp;
+--
+-- check renaming to a table's array type's autogenerated name
+-- (the array type's name should get out of the way)
+--
+CREATE TABLE attmp_array (id int);
+CREATE TABLE attmp_array2 (id int);
+DROP TABLE attmp_array;
+-- renaming to table's own array type's name is an interesting corner case
+CREATE TABLE attmp_array (id int);
+-- rename statements with mismatching statement and object types
+CREATE TABLE alter_idx_rename_test (a INT);
+CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test (a);
+CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted (a);
+BEGIN;
+COMMIT;
+BEGIN;
+COMMIT;
+BEGIN;
+COMMIT;
+-- FOREIGN KEY CONSTRAINT adding TEST
+CREATE TABLE attmp2 (a int primary key);
+CREATE TABLE attmp3 (a int, b int);
+CREATE TABLE attmp4 (a int, b int, unique(a,b));
+CREATE TABLE attmp5 (a int, b int);
+-- Insert rows into attmp2 (pktable)
+INSERT INTO attmp2 values (1);
+INSERT INTO attmp2 values (2);
+INSERT INTO attmp2 values (3);
+INSERT INTO attmp2 values (4);
+-- Insert rows into attmp3
+INSERT INTO attmp3 values (1,10);
+INSERT INTO attmp3 values (1,20);
+INSERT INTO attmp3 values (5,50);
+INSERT INTO attmp3 values (5,50);
+-- A NO INHERIT constraint should not be looked for in children during VALIDATE CONSTRAINT
+create table parent_noinh_convalid (a int);
+insert into parent_noinh_convalid values (1);
+DROP TABLE attmp5;
+DROP TABLE attmp4;
+DROP TABLE attmp3;
+DROP TABLE attmp2;
+-- we leave nv_parent and children around to help test pg_dump logic
+-- Foreign key adding test with mixed types
+-- Note: these tables are TEMP to avoid name conflicts when this test
+-- is run in parallel with foreign_key.sql.
+CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
+INSERT INTO PKTABLE VALUES(42);
+CREATE TEMP TABLE FKTABLE (ftest1 inet);
+DROP TABLE FKTABLE;
+-- This should succeed, even though they are different types,
+-- because int=int8 exists and is a member of the integer opfamily
+CREATE TEMP TABLE FKTABLE (ftest1 int8);
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+DROP TABLE FKTABLE;
+-- This should fail, because we'd have to cast numeric to int which is
+-- not an implicit coercion (or use numeric=numeric, but that's not part
+-- of the integer opfamily)
+CREATE TEMP TABLE FKTABLE (ftest1 numeric);
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+-- On the other hand, this should work because int implicitly promotes to
+-- numeric, and we allow promotion on the FK side
+CREATE TEMP TABLE PKTABLE (ptest1 numeric PRIMARY KEY);
+INSERT INTO PKTABLE VALUES(42);
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+-- Check it actually works
+INSERT INTO FKTABLE VALUES(42);		-- should succeed
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
+                           PRIMARY KEY(ptest1, ptest2));
+-- This should fail, because we just chose really odd types
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+DROP TABLE FKTABLE;
+-- Again, so should this...
+CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+DROP TABLE FKTABLE;
+-- This fails because we mixed up the column ordering
+CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE;
+-- Test that ALTER CONSTRAINT updates trigger deferrability properly
+CREATE TEMP TABLE PKTABLE (ptest1 int primary key);
+CREATE TEMP TABLE FKTABLE (ftest1 int);
+-- temp tables should go away by themselves, need not drop them.
+-- test check constraint adding
+create table atacc1 ( test int );
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the check fails when added
+create table atacc1 ( test int );
+-- insert a soon to be failing row
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the check fails because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int, test3 int);
+-- should succeed
+insert into atacc1 (test,test2,test3) values (4,4,5);
+drop table atacc1;
+-- inheritance related tests
+create table atacc1 (test int);
+create table atacc2 (test2 int);
+insert into atacc2 (test2) values (3);
+drop table atacc2;
+drop table atacc1;
+-- same things with one created with INHERIT
+create table atacc1 (test int);
+create table atacc2 (test2 int);
+select test2 from atacc2;
+drop table atacc1;
+-- adding only to a parent is allowed as of 9.2
+create table atacc1 (test int);
+-- check constraint is not there on child
+insert into atacc2 (test) values (-3);
+insert into atacc1 (test) values (3);
+drop table atacc2;
+drop table atacc1;
+-- test unique constraint adding
+create table atacc1 ( test int ) ;
+-- insert first value
+insert into atacc1 (test) values (2);
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the unique constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do one where the unique constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+insert into atacc1 (test,test2) values (5,4);
+insert into atacc1 (test,test2) values (5,5);
+drop table atacc1;
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, unique(test));
+-- should fail for @@ second one @@
+insert into atacc1 (test2, test) values (3, 3);
+drop table atacc1;
+-- test primary key constraint adding
+create table atacc1 ( id serial, test int) ;
+-- insert first value
+insert into atacc1 (test) values (2);
+-- should succeed
+insert into atacc1 (test) values (4);
+drop table atacc1;
+-- let's do one where the primary key constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing rows
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (2);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do another one where the primary key constraint fails when added
+create table atacc1 ( test int );
+-- insert soon to be failing row
+insert into atacc1 (test) values (NULL);
+insert into atacc1 (test) values (3);
+drop table atacc1;
+-- let's do one where the primary key constraint fails
+-- because the column doesn't exist
+create table atacc1 ( test int );
+drop table atacc1;
+-- adding a new column as primary key to a non-empty table.
+-- should fail unless the column has a non-null default value.
+create table atacc1 ( test int );
+insert into atacc1 (test) values (0);
+drop table atacc1;
+-- this combination used to have order-of-execution problems (bug #15580)
+create table atacc1 (a int);
+insert into atacc1 values(1);
+drop table atacc1;
+-- additionally, we've seen issues with foreign key validation not being
+-- properly delayed until after a table rewrite.  Check that works ok.
+create table atacc1 (a int primary key);
+drop table atacc1;
+-- we've also seen issues with check constraints being validated at the wrong
+-- time when there's a pending table rewrite.
+create table atacc1 (a bigint, b int);
+insert into atacc1 values(1,1);
+drop table atacc1;
+-- same as above, but ensure the constraint violation is detected
+create table atacc1 (a bigint, b int);
+insert into atacc1 values(1,2);
+drop table atacc1;
+-- something a little more complicated
+create table atacc1 ( test int, test2 int);
+-- insert initial value
+insert into atacc1 (test,test2) values (4,4);
+-- should all succeed
+insert into atacc1 (test,test2) values (4,5);
+insert into atacc1 (test,test2) values (5,4);
+insert into atacc1 (test,test2) values (5,5);
+drop table atacc1;
+-- lets do some naming tests
+create table atacc1 (test int, test2 int, primary key(test));
+-- only first should succeed
+insert into atacc1 (test2, test) values (3, 3);
+drop table atacc1;
+-- test setting columns to null and not null and vice versa
+-- test checking for null values and primary key
+create table atacc1 (test int not null);
+insert into atacc1 values (null);
+drop table atacc1;
+-- set not null verified by constraints
+create table atacc1 (test_a int, test_b int);
+insert into atacc1 values (null, 1);
+insert into atacc1 values (2, null);
+drop table atacc1;
+-- test inheritance
+create table parent (a int);
+insert into parent values (NULL);
+drop table parent;
+-- test setting and removing default values
+create table def_test (
+	c1	int4 default 5,
+	c2	text default 'initial_default'
+);

+ 3399 - 0
yql/essentials/tests/postgresql/cases/arrays.err

@@ -0,0 +1,3399 @@
+Registering pre-existing tables
+	tenk1
+	int8_tbl
+<sql-statement>
+--
+-- ARRAYS
+--
+CREATE TABLE arrtest (
+	a 			int2[],
+	b 			int4[][][],
+	c 			name[],
+	d			text[][],
+	e 			float8[],
+	f			char(5)[],
+	g			varchar(5)[]
+);
+</sql-statement>
+<sql-statement>
+--
+-- only the 'e' array is 0-based, the others are 1-based.
+--
+INSERT INTO arrtest (a[1:5], b[1:1][1:2][1:2], c, d, f, g)
+   VALUES ('{1,2,3,4,5}', '{{{0,0},{1,2}}}', '{}', '{}', '{}', '{}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	--
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "{1,2,3,4,5}"
+
+        	--
+	^
+<sql-statement>
+UPDATE arrtest SET e[0] = '1.1';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+UPDATE arrtest SET e[1] = '2.2';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+INSERT INTO arrtest (f)
+   VALUES ('{"too long"}');
+</sql-statement>
+<sql-statement>
+INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g)
+   VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
+           '{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
+           '{"abc","abcde"}', '{"abc","abcde"}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g)
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "{11,12,23}"
+
+        	INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g)
+	^
+<sql-statement>
+INSERT INTO arrtest (a, b[1:2], c, d[1:2])
+   VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arrtest (a, b[1:2], c, d[1:2])
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "{}"
+
+        	INSERT INTO arrtest (a, b[1:2], c, d[1:2])
+	^
+<sql-statement>
+INSERT INTO arrtest (b[2]) VALUES(now());  -- error, type mismatch
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: YtWriteTable!
+    	INSERT INTO arrtest (b[2]) VALUES(now());  -- error, type mismatch
+	^
+        -stdin-:<main>:1:1: Error: Failed to convert type: List<Struct<'b':pgtimestamptz>> to List<Struct<'a':pgint2,'b':pgint4,'c':pgname,'d':pgtext,'e':pgfloat8,'f':pgbpchar,'g':pgvarchar>>
+        	INSERT INTO arrtest (b[2]) VALUES(now());  -- error, type mismatch
+	^
+            -stdin-:<main>:1:1: Error: Failed to convert 'b': pgtimestamptz to pgint4
+            	INSERT INTO arrtest (b[2]) VALUES(now());  -- error, type mismatch
+	^
+        -stdin-:<main>:1:1: Error: Table "arrtest" row type differs from the written row type: Struct<-a:pgint2,b:pgint4!=pgtimestamptz,-c:pgname,-d:pgtext,-e:pgfloat8,-f:pgbpchar,-g:pgvarchar>
+        	INSERT INTO arrtest (b[2]) VALUES(now());  -- error, type mismatch
+	^
+<sql-statement>
+INSERT INTO arrtest (b[1:2]) VALUES(now());  -- error, type mismatch
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: YtWriteTable!
+    	INSERT INTO arrtest (b[1:2]) VALUES(now());  -- error, type mismatch
+	^
+        -stdin-:<main>:1:1: Error: Failed to convert type: List<Struct<'b':pgtimestamptz>> to List<Struct<'a':pgint2,'b':pgint4,'c':pgname,'d':pgtext,'e':pgfloat8,'f':pgbpchar,'g':pgvarchar>>
+        	INSERT INTO arrtest (b[1:2]) VALUES(now());  -- error, type mismatch
+	^
+            -stdin-:<main>:1:1: Error: Failed to convert 'b': pgtimestamptz to pgint4
+            	INSERT INTO arrtest (b[1:2]) VALUES(now());  -- error, type mismatch
+	^
+        -stdin-:<main>:1:1: Error: Table "arrtest" row type differs from the written row type: Struct<-a:pgint2,b:pgint4!=pgtimestamptz,-c:pgname,-d:pgtext,-e:pgfloat8,-f:pgbpchar,-g:pgvarchar>
+        	INSERT INTO arrtest (b[1:2]) VALUES(now());  -- error, type mismatch
+	^
+<sql-statement>
+SELECT * FROM arrtest;
+</sql-statement>
+<sql-statement>
+SELECT arrtest.a[1],
+          arrtest.b[1][1][1],
+          arrtest.c[1],
+          arrtest.d[1][1],
+          arrtest.e[0]
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT arrtest.a[1],
+	^
+<sql-statement>
+SELECT a[1], b[1][1][1], c[1], d[1][1], e[0]
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[1], b[1][1][1], c[1], d[1][1], e[0]
+	^
+<sql-statement>
+SELECT a[1:3],
+          b[1:1][1:2][1:2],
+          c[1:2],
+          d[1:1][1:2]
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[1:3],
+	^
+<sql-statement>
+SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	^
+            -stdin-:<main>:1:8: Error: At function: PgCall
+            	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	       ^
+                -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_ndims with given argument types: (int2)
+                	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	^
+            -stdin-:<main>:1:28: Error: At function: PgCall
+            	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	                           ^
+                -stdin-:<main>:1:28: Error: Unable to find an overload for proc array_ndims with given argument types: (int4)
+                	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	                           ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	^
+            -stdin-:<main>:1:48: Error: At function: PgCall
+            	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	                                               ^
+                -stdin-:<main>:1:48: Error: Unable to find an overload for proc array_ndims with given argument types: (name)
+                	SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
+	                                               ^
+<sql-statement>
+SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	^
+            -stdin-:<main>:1:8: Error: At function: PgCall
+            	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	       ^
+                -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_dims with given argument types: (int2)
+                	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	       ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	^
+            -stdin-:<main>:1:27: Error: At function: PgCall
+            	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	                          ^
+                -stdin-:<main>:1:27: Error: Unable to find an overload for proc array_dims with given argument types: (int4)
+                	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	                          ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	^
+            -stdin-:<main>:1:46: Error: At function: PgCall
+            	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	                                             ^
+                -stdin-:<main>:1:46: Error: Unable to find an overload for proc array_dims with given argument types: (name)
+                	SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
+	                                             ^
+<sql-statement>
+-- returns nothing
+SELECT *
+   FROM arrtest
+   WHERE a[1] < 5 and
+         c = '{"foobar"}'::_name;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:4:15: Error: alternative is not implemented yet : 360
+    	   WHERE a[1] < 5 and
+	              ^
+<sql-statement>
+UPDATE arrtest
+  SET a[1:2] = '{16,25}'
+  WHERE NOT a = '{}'::_int2;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+UPDATE arrtest
+  SET b[1:1][1:1][1:2] = '{113, 117}',
+      b[1:1][1:2][2:2] = '{142, 147}'
+  WHERE array_dims(b) = '[1:1][1:2][1:2]';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+UPDATE arrtest
+  SET c[2:2] = '{"new_word"}'
+  WHERE array_dims(c) is not null;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+SELECT a,b,c FROM arrtest;
+</sql-statement>
+<sql-statement>
+SELECT a[1:3],
+          b[1:1][1:2][1:2],
+          c[1:2],
+          d[1:1][2:2]
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[1:3],
+	^
+<sql-statement>
+SELECT b[1:1][2][2],
+       d[1:1][2]
+   FROM arrtest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT b[1:1][2][2],
+	^
+<sql-statement>
+INSERT INTO arrtest(a) VALUES('{1,null,3}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arrtest(a) VALUES('{1,null,3}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "{1,null,3}"
+
+        	INSERT INTO arrtest(a) VALUES('{1,null,3}');
+	^
+<sql-statement>
+SELECT a FROM arrtest;
+</sql-statement>
+<sql-statement>
+UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:43: Error: alternative is not implemented yet : 360
+    	UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL;
+	                                          ^
+<sql-statement>
+SELECT a FROM arrtest WHERE a[2] IS NULL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:34: Error: alternative is not implemented yet : 360
+    	SELECT a FROM arrtest WHERE a[2] IS NULL;
+	                                 ^
+<sql-statement>
+DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:32: Error: alternative is not implemented yet : 360
+    	DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL;
+	                               ^
+<sql-statement>
+SELECT a,b,c FROM arrtest;
+</sql-statement>
+<sql-statement>
+-- test mixed slice/scalar subscripting
+select '{{1,2,3},{4,5,6},{7,8,9}}'::int[];
+</sql-statement>
+<sql-statement>
+select ('{{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	select ('{{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2];
+	^
+<sql-statement>
+select '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[];
+</sql-statement>
+<sql-statement>
+select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2];
+	^
+<sql-statement>
+--
+-- check subscription corner cases
+--
+-- More subscripts than MAXDIM (6)
+SELECT ('{}'::int[])[1][2][3][4][5][6][7];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	--
+	^
+<sql-statement>
+-- NULL index yields NULL when selecting
+SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL][1];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	-- NULL index yields NULL when selecting
+	^
+<sql-statement>
+SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL:1][1];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL:1][1];
+	^
+<sql-statement>
+SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][1:NULL][1];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][1:NULL][1];
+	^
+<sql-statement>
+-- NULL index in assignment is an error
+UPDATE arrtest
+  SET c[NULL] = '{"can''t assign"}'
+  WHERE array_dims(c) is not null;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+UPDATE arrtest
+  SET c[NULL:1] = '{"can''t assign"}'
+  WHERE array_dims(c) is not null;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+UPDATE arrtest
+  SET c[1:NULL] = '{"can''t assign"}'
+  WHERE array_dims(c) is not null;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+-- Un-subscriptable type
+SELECT (now())[1];
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	-- Un-subscriptable type
+	^
+<sql-statement>
+-- test slices with empty lower and/or upper index
+CREATE TEMP TABLE arrtest_s (
+  a       int2[],
+  b       int2[][]
+);
+</sql-statement>
+<sql-statement>
+INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "{1,2,3,4,5}"
+
+        	INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}');
+	^
+<sql-statement>
+INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type smallint: "[0:4]={1,2,3,4,5}"
+
+        	INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}');
+	^
+<sql-statement>
+SELECT * FROM arrtest_s;
+</sql-statement>
+<sql-statement>
+SELECT a[:3], b[:2][:2] FROM arrtest_s;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[:3], b[:2][:2] FROM arrtest_s;
+	^
+<sql-statement>
+SELECT a[2:], b[2:][2:] FROM arrtest_s;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[2:], b[2:][2:] FROM arrtest_s;
+	^
+<sql-statement>
+SELECT a[:], b[:] FROM arrtest_s;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT a[:], b[:] FROM arrtest_s;
+	^
+<sql-statement>
+-- updates
+UPDATE arrtest_s SET a[:3] = '{11, 12, 13}', b[:2][:2] = '{{11,12}, {14,15}}'
+  WHERE array_lower(a,1) = 1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+SELECT * FROM arrtest_s;
+</sql-statement>
+<sql-statement>
+UPDATE arrtest_s SET a[3:] = '{23, 24, 25}', b[2:][2:] = '{{25,26}, {28,29}}';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+SELECT * FROM arrtest_s;
+</sql-statement>
+<sql-statement>
+UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+SELECT * FROM arrtest_s;
+</sql-statement>
+<sql-statement>
+UPDATE arrtest_s SET a[:] = '{23, 24, 25}';  -- fail, too small
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+INSERT INTO arrtest_s VALUES(NULL, NULL);
+</sql-statement>
+<sql-statement>
+UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}';  -- fail, no good with null
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+-- check with fixed-length-array type, such as point
+SELECT f1[0:1] FROM POINT_TBL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	-- check with fixed-length-array type, such as point
+	^
+<sql-statement>
+SELECT f1[0:] FROM POINT_TBL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT f1[0:] FROM POINT_TBL;
+	^
+<sql-statement>
+SELECT f1[:1] FROM POINT_TBL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT f1[:1] FROM POINT_TBL;
+	^
+<sql-statement>
+SELECT f1[:] FROM POINT_TBL;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	SELECT f1[:] FROM POINT_TBL;
+	^
+<sql-statement>
+-- subscript assignments to fixed-width result in NULL if previous value is NULL
+UPDATE point_tbl SET f1[0] = 10 WHERE f1 IS NULL RETURNING *;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+INSERT INTO point_tbl(f1[0]) VALUES(0) RETURNING *;
+</sql-statement>
+-stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'returning' 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'. 
+
+<sql-statement>
+-- NULL assignments get ignored
+UPDATE point_tbl SET f1[0] = NULL WHERE f1::text = '(10,10)'::point::text RETURNING *;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+-- but non-NULL subscript assignments work
+UPDATE point_tbl SET f1[0] = -10, f1[1] = -10 WHERE f1::text = '(10,10)'::point::text RETURNING *;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+-- but not to expand the range
+UPDATE point_tbl SET f1[3] = 10 WHERE f1::text = '(-10,-10)'::point::text RETURNING *;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+--
+-- test array extension
+--
+CREATE TEMP TABLE arrtest1 (i int[], t text[]);
+</sql-statement>
+<sql-statement>
+insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: YtWriteTable!
+    	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+        -stdin-:<main>:1:1: Error: Failed to convert type: List<Struct<'i':_pgint4,'t':_pgtext>> to List<Struct<'i':pgint4,'t':pgtext>>
+        	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+            -stdin-:<main>:1:1: Error: Failed to convert 'i': _pgint4 to pgint4
+            	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+        -stdin-:<main>:1:1: Error: Table "arrtest1" row type differs from the written row type: Struct<i:pgint4!=_pgint4,t:pgtext!=_pgtext>
+        	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[2] = 22, t[2] = 'twenty-two';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[5] = 5, t[5] = 'five';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[8] = 8, t[8] = 'eight';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[0] = 0, t[0] = 'zero';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[-3] = -3, t[-3] = 'minus-three';
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[0:2] = array[10,11,12], t[0:2] = array['ten','eleven','twelve'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[8:10] = array[18,null,20], t[8:10] = array['p18',null,'p20'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[11:12] = array[null,22], t[11:12] = array[null,'p22'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[15:16] = array[null,26], t[15:16] = array[null,'p26'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[-5:-3] = array[-15,-14,-13], t[-5:-3] = array['m15','m14','m13'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[-7:-6] = array[-17,null], t[-7:-6] = array['m17',null];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[-12:-10] = array[-22,null,-20], t[-12:-10] = array['m22',null,'m20'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+delete from arrtest1;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: YtWriteTable!
+    	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+        -stdin-:<main>:1:1: Error: Failed to convert type: List<Struct<'i':_pgint4,'t':_pgtext>> to List<Struct<'i':pgint4,'t':pgtext>>
+        	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+            -stdin-:<main>:1:1: Error: Failed to convert 'i': _pgint4 to pgint4
+            	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+        -stdin-:<main>:1:1: Error: Table "arrtest1" row type differs from the written row type: Struct<i:pgint4!=_pgint4,t:pgtext!=_pgtext>
+        	insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
+	^
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+update arrtest1 set i[0:5] = array[0,1,2,null,4,5], t[0:5] = array['z','p1','p2',null,'p4','p5'];
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from arrtest1;
+</sql-statement>
+<sql-statement>
+--
+-- array expressions and operators
+--
+-- table creation and INSERTs
+CREATE TEMP TABLE arrtest2 (i integer ARRAY[4], f float8[], n numeric[], t text[], d timestamp[]);
+</sql-statement>
+<sql-statement>
+INSERT INTO arrtest2 VALUES(
+  ARRAY[[[113,142],[1,147]]],
+  ARRAY[1.1,1.2,1.3]::float8[],
+  ARRAY[1.1,1.2,1.3],
+  ARRAY[[['aaa','aab'],['aba','abb'],['aca','acb']],[['baa','bab'],['bba','bbb'],['bca','bcb']]],
+  ARRAY['19620326','19931223','19970117']::timestamp[]
+);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: YtWriteTable!
+    	INSERT INTO arrtest2 VALUES(
+	^
+        -stdin-:<main>:1:1: Error: Failed to convert type: List<Struct<'d':_pgtimestamp,'f':_pgfloat8,'i':_pgint4,'n':_pgnumeric,'t':_pgtext>> to List<Struct<'d':pgtimestamp,'f':pgfloat8,'i':pgint4,'n':pgnumeric,'t':pgtext>>
+        	INSERT INTO arrtest2 VALUES(
+	^
+            -stdin-:<main>:1:1: Error: Failed to convert 'd': _pgtimestamp to pgtimestamp
+            	INSERT INTO arrtest2 VALUES(
+	^
+        -stdin-:<main>:1:1: Error: Table "arrtest2" row type differs from the written row type: Struct<d:pgtimestamp!=_pgtimestamp,f:pgfloat8!=_pgfloat8,i:pgint4!=_pgint4,n:pgnumeric!=_pgnumeric,t:pgtext!=_pgtext>
+        	INSERT INTO arrtest2 VALUES(
+	^
+<sql-statement>
+-- some more test data
+CREATE TEMP TABLE arrtest_f (f0 int, f1 text, f2 float8);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(1,'cat1',1.21);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(2,'cat1',1.24);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(3,'cat1',1.18);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(4,'cat1',1.26);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(5,'cat1',1.15);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(6,'cat2',1.15);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(7,'cat2',1.26);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(8,'cat2',1.32);
+</sql-statement>
+<sql-statement>
+insert into arrtest_f values(9,'cat2',1.30);
+</sql-statement>
+<sql-statement>
+CREATE TEMP TABLE arrtest_i (f0 int, f1 text, f2 int);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(1,'cat1',21);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(2,'cat1',24);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(3,'cat1',18);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(4,'cat1',26);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(5,'cat1',15);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(6,'cat2',15);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(7,'cat2',26);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(8,'cat2',32);
+</sql-statement>
+<sql-statement>
+insert into arrtest_i values(9,'cat2',30);
+</sql-statement>
+<sql-statement>
+-- expressions
+SELECT t.f[1][3][1] AS "131", t.f[2][2][1] AS "221" FROM (
+  SELECT ARRAY[[[111,112],[121,122],[131,132]],[[211,212],[221,122],[231,232]]] AS f
+) AS t;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	-- expressions
+	^
+<sql-statement>
+SELECT ARRAY[[[[[['hello'],['world']]]]]];
+</sql-statement>
+<sql-statement>
+SELECT ARRAY[ARRAY['hello'],ARRAY['world']];
+</sql-statement>
+<sql-statement>
+SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY";
+</sql-statement>
+<sql-statement>
+-- with nulls
+SELECT '{1,null,3}'::int[];
+</sql-statement>
+<sql-statement>
+SELECT ARRAY[1,NULL,3];
+</sql-statement>
+<sql-statement>
+-- functions
+SELECT array_append(array[42], 6) AS "{42,6}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- functions
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	SELECT array_append(array[42], 6) AS "{42,6}";
+	       ^
+            -stdin-:<main>:2:8: Error: Unable to find an overload for proc array_append with given argument types: (_int4,int4)
+            	SELECT array_append(array[42], 6) AS "{42,6}";
+	       ^
+<sql-statement>
+SELECT array_prepend(6, array[42]) AS "{6,42}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_prepend(6, array[42]) AS "{6,42}";
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_prepend(6, array[42]) AS "{6,42}";
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_prepend with given argument types: (int4,_int4)
+            	SELECT array_prepend(6, array[42]) AS "{6,42}";
+	       ^
+<sql-statement>
+SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}";
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}";
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_cat with given argument types: (_int4,_int4)
+            	SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}";
+	       ^
+<sql-statement>
+SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}";
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}";
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_cat with given argument types: (_int4,_int4)
+            	SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}";
+	       ^
+<sql-statement>
+SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_cat with given argument types: (_int4,_int4)
+            	SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY[1,2,3,4,5], 4);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY[1,2,3,4,5], 4);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY[1,2,3,4,5], 4);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_int4,int4)
+            	SELECT array_position(ARRAY[1,2,3,4,5], 4);
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY[5,3,4,2,1], 4);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY[5,3,4,2,1], 4);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY[5,3,4,2,1], 4);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_int4,int4)
+            	SELECT array_position(ARRAY[5,3,4,2,1], 4);
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY[[1,2],[3,4]], 3);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY[[1,2],[3,4]], 3);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY[[1,2],[3,4]], 3);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_int4,int4)
+            	SELECT array_position(ARRAY[[1,2],[3,4]], 3);
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_text,unknown)
+            	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon');
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_text,unknown)
+            	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat');
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_text,unknown)
+            	SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL);
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_text,unknown)
+            	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL);
+	       ^
+<sql-statement>
+SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_text,unknown)
+            	SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat');
+	       ^
+<sql-statement>
+SELECT array_positions(NULL, 10);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(NULL, 10);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(NULL, 10);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (unknown,int4)
+            	SELECT array_positions(NULL, 10);
+	       ^
+<sql-statement>
+SELECT array_positions(NULL, NULL::int);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(NULL, NULL::int);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(NULL, NULL::int);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (unknown,int4)
+            	SELECT array_positions(NULL, NULL::int);
+	       ^
+<sql-statement>
+SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (_int4,int4)
+            	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4);
+	       ^
+<sql-statement>
+SELECT array_positions(ARRAY[[1,2],[3,4]], 4);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(ARRAY[[1,2],[3,4]], 4);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(ARRAY[[1,2],[3,4]], 4);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (_int4,int4)
+            	SELECT array_positions(ARRAY[[1,2],[3,4]], 4);
+	       ^
+<sql-statement>
+SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (_int4,unknown)
+            	SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL);
+	       ^
+<sql-statement>
+SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (_int4,unknown)
+            	SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL);
+	       ^
+<sql-statement>
+SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+                                          FROM generate_series(1,100) g(i)),
+                                  'AAAAAAAAAAAAAAAAAAAAAAAAA5'), 1);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	       ^
+            -stdin-:<main>:1:21: Error: At function: PgCall
+            	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	                    ^
+                -stdin-:<main>:1:37: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+                	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	                                    ^
+                    -stdin-:<main>:1:84: Error: At function: PgOp
+                    	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	                                                                                   ^
+                        -stdin-:<main>:1:84: Error: Unable to find an overload for operator || with given argument type(s): (text,int4)
+                        	SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10
+	                                                                                   ^
+<sql-statement>
+DO $$
+DECLARE
+  o int;
+  a int[] := ARRAY[1,2,3,2,3,1,2];
+BEGIN
+  o := array_position(a, 2);
+  WHILE o IS NOT NULL
+  LOOP
+    RAISE NOTICE '%', o;
+    o := array_position(a, 2, o + 1);
+  END LOOP;
+END
+$$ LANGUAGE plpgsql;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 263
+    	DO $$
+	^
+<sql-statement>
+SELECT array_position('[2:4]={1,2,3}'::int[], 1);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_position('[2:4]={1,2,3}'::int[], 1);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_position('[2:4]={1,2,3}'::int[], 1);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_position with given argument types: (_int4,int4)
+            	SELECT array_position('[2:4]={1,2,3}'::int[], 1);
+	       ^
+<sql-statement>
+SELECT array_positions('[2:4]={1,2,3}'::int[], 1);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT array_positions('[2:4]={1,2,3}'::int[], 1);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT array_positions('[2:4]={1,2,3}'::int[], 1);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_positions with given argument types: (_int4,int4)
+            	SELECT array_positions('[2:4]={1,2,3}'::int[], 1);
+	       ^
+<sql-statement>
+SELECT
+    array_position(ids, (1, 1)),
+    array_positions(ids, (1, 1))
+        FROM
+(VALUES
+    (ARRAY[(0, 0), (1, 1)]),
+    (ARRAY[(1, 1)])
+) AS f (ids);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:6:6: Error: alternative is not implemented yet : 138
+    	    (ARRAY[(0, 0), (1, 1)]),
+	     ^
+    -stdin-:<main>:2:5: Error: alternative is not implemented yet : 138
+    	    array_position(ids, (1, 1)),
+	    ^
+<sql-statement>
+-- operators
+SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]];
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
+    	-- operators
+	^
+        -stdin-:<main>: Error: At function: PgSetItem
+        
+            -stdin-:<main>:1:1: Error: At function: PgWhere
+            	-- operators
+	^
+                -stdin-:<main>:2:31: Error: At function: PgOp
+                	SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]];
+	                              ^
+                    -stdin-:<main>:2:31: Error: Unable to find an overload for operator = with given argument type(s): (int4,_int4)
+                    	SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]];
+	                              ^
+<sql-statement>
+SELECT NOT ARRAY[1.1,1.2,1.3] = ARRAY[1.1,1.2,1.3] AS "FALSE";
+</sql-statement>
+<sql-statement>
+SELECT ARRAY[1,2] || 3 AS "{1,2,3}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[1,2] || 3 AS "{1,2,3}";
+	^
+        -stdin-:<main>:1:19: Error: At function: PgOp
+        	SELECT ARRAY[1,2] || 3 AS "{1,2,3}";
+	                  ^
+            -stdin-:<main>:1:19: Error: Unable to find an overload for operator || with given argument type(s): (_int4,int4)
+            	SELECT ARRAY[1,2] || 3 AS "{1,2,3}";
+	                  ^
+<sql-statement>
+SELECT 0 || ARRAY[1,2] AS "{0,1,2}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT 0 || ARRAY[1,2] AS "{0,1,2}";
+	^
+        -stdin-:<main>:1:10: Error: At function: PgOp
+        	SELECT 0 || ARRAY[1,2] AS "{0,1,2}";
+	         ^
+            -stdin-:<main>:1:10: Error: Unable to find an overload for operator || with given argument type(s): (int4,_int4)
+            	SELECT 0 || ARRAY[1,2] AS "{0,1,2}";
+	         ^
+<sql-statement>
+SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}";
+	^
+        -stdin-:<main>:1:19: Error: At function: PgOp
+        	SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}";
+	                  ^
+            -stdin-:<main>:1:19: Error: Unable to find an overload for operator || with given argument type(s): (_int4,_int4)
+            	SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}";
+	                  ^
+<sql-statement>
+SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY";
+	^
+        -stdin-:<main>:1:35: Error: At function: PgOp
+        	SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY";
+	                                  ^
+            -stdin-:<main>:1:35: Error: Unable to find an overload for operator || with given argument type(s): (_text,_text)
+            	SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY";
+	                                  ^
+<sql-statement>
+SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}";
+	^
+        -stdin-:<main>:1:27: Error: At function: PgOp
+        	SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}";
+	                          ^
+            -stdin-:<main>:1:27: Error: Unable to find an overload for operator || with given argument type(s): (_int4,_int4)
+            	SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}";
+	                          ^
+<sql-statement>
+SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}";
+	^
+        -stdin-:<main>:1:33: Error: At function: PgOp
+        	SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}";
+	                                ^
+            -stdin-:<main>:1:19: Error: At function: PgOp
+            	SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}";
+	                  ^
+                -stdin-:<main>:1:19: Error: Unable to find an overload for operator || with given argument type(s): (_int4,_int4)
+                	SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}";
+	                  ^
+<sql-statement>
+SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}";
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}";
+	^
+        -stdin-:<main>:1:24: Error: At function: PgOp
+        	SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}";
+	                       ^
+            -stdin-:<main>:1:10: Error: At function: PgOp
+            	SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}";
+	         ^
+                -stdin-:<main>:1:10: Error: Unable to find an overload for operator || with given argument type(s): (int4,_int4)
+                	SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}";
+	         ^
+<sql-statement>
+SELECT ARRAY[1.1] || ARRAY[2,3,4];
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT ARRAY[1.1] || ARRAY[2,3,4];
+	^
+        -stdin-:<main>:1:19: Error: At function: PgOp
+        	SELECT ARRAY[1.1] || ARRAY[2,3,4];
+	                  ^
+            -stdin-:<main>:1:19: Error: Unable to find an overload for operator || with given argument type(s): (_numeric,_int4)
+            	SELECT ARRAY[1.1] || ARRAY[2,3,4];
+	                  ^
+<sql-statement>
+SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
+    	SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x);
+	^
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
+    	SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x);
+	^
+        -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
+        	SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x);
+	^
+<sql-statement>
+SELECT ROW(1,2) || array_agg(x) FROM (VALUES (ROW(3,4)), (ROW(5,6))) v(x);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
+    	SELECT ROW(1,2) || array_agg(x) FROM (VALUES (ROW(3,4)), (ROW(5,6))) v(x);
+	^
+    -stdin-:<main>:1:17: Error: alternative is not implemented yet : 138
+    	SELECT ROW(1,2) || array_agg(x) FROM (VALUES (ROW(3,4)), (ROW(5,6))) v(x);
+	                ^
+<sql-statement>
+SELECT * FROM array_op_test WHERE i @> '{32}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i && '{32}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i @> '{17}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i && '{17}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i @> '{32,17}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i && '{32,17}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i = '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i @> '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i && '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i <@ '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i = '{NULL}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i @> '{NULL}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i && '{NULL}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE i <@ '{NULL}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t <@ '{AAAAAAAA72908,AAAAAAAAAAAAAAAAAAA17075,AA88409,AAAAAAAAAAAAAAAAAA36842,AAAAAAA48038,AAAAAAAAAAAAAA10611}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t = '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t @> '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t && '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+SELECT * FROM array_op_test WHERE t <@ '{}' ORDER BY seqno;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.array_op_test
+    
+<sql-statement>
+-- array casts
+SELECT ARRAY[1,2,3]::text[]::int[]::float8[] AS "{1,2,3}";
+</sql-statement>
+<sql-statement>
+SELECT pg_typeof(ARRAY[1,2,3]::text[]::int[]::float8[]) AS "double precision[]";
+</sql-statement>
+<sql-statement>
+SELECT ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[] AS "{{a,bc},{def,hijk}}";
+</sql-statement>
+<sql-statement>
+SELECT pg_typeof(ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[]) AS "character varying[]";
+</sql-statement>
+<sql-statement>
+SELECT CAST(ARRAY[[[[[['a','bb','ccc']]]]]] as text[]) as "{{{{{{a,bb,ccc}}}}}}";
+</sql-statement>
+<sql-statement>
+SELECT NULL::text[]::int[] AS "NULL";
+</sql-statement>
+<sql-statement>
+-- scalar op any/all (array)
+select 33 = any ('{1,2,3}');
+</sql-statement>
+<sql-statement>
+select 33 = any ('{1,2,33}');
+</sql-statement>
+<sql-statement>
+select 33 = all ('{1,2,33}');
+</sql-statement>
+<sql-statement>
+select 33 >= all ('{1,2,33}');
+</sql-statement>
+<sql-statement>
+-- boundary cases
+select null::int >= all ('{1,2,33}');
+</sql-statement>
+<sql-statement>
+select null::int >= all ('{}');
+</sql-statement>
+<sql-statement>
+select null::int >= any ('{}');
+</sql-statement>
+<sql-statement>
+-- cross-datatype
+select 33.4 = any (array[1,2,3]);
+</sql-statement>
+<sql-statement>
+select 33.4 > all (array[1,2,3]);
+</sql-statement>
+<sql-statement>
+-- errors
+select 33 * any ('{1,2,3}');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- errors
+	^
+        -stdin-:<main>:2:11: Error: At function: PgAnyResolvedOp
+        	select 33 * any ('{1,2,3}');
+	          ^
+            -stdin-:<main>:2:11: Error: Expected boolean operator result, but got: int4
+            	select 33 * any ('{1,2,3}');
+	          ^
+<sql-statement>
+select 33 * any (44);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select 33 * any (44);
+	^
+        -stdin-:<main>:1:11: Error: At function: PgAnyOp
+        	select 33 * any (44);
+	          ^
+            -stdin-:<main>:1:11: Error: ydb/library/yql/parser/pg_catalog/catalog.cpp:2143: Condition violated: `fromTypePtr'
+            	select 33 * any (44);
+	          ^
+<sql-statement>
+-- nulls
+select 33 = any (null::int[]);
+</sql-statement>
+<sql-statement>
+select null::int = any ('{1,2,3}');
+</sql-statement>
+<sql-statement>
+select 33 = any ('{1,null,3}');
+</sql-statement>
+<sql-statement>
+select 33 = any ('{1,null,33}');
+</sql-statement>
+<sql-statement>
+select 33 = all (null::int[]);
+</sql-statement>
+<sql-statement>
+select null::int = all ('{1,2,3}');
+</sql-statement>
+<sql-statement>
+select 33 = all ('{1,null,3}');
+</sql-statement>
+<sql-statement>
+select 33 = all ('{33,null,33}');
+</sql-statement>
+<sql-statement>
+-- nulls later in the bitmap
+SELECT -1 != ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1,1000) g(i)));
+</sql-statement>
+<sql-statement>
+-- test indexes on arrays
+create temp table arr_tbl (f1 int[] unique);
+</sql-statement>
+<sql-statement>
+insert into arr_tbl values ('{1,2,3}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_tbl values ('{1,2,3}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,3}"
+
+        	insert into arr_tbl values ('{1,2,3}');
+	^
+<sql-statement>
+insert into arr_tbl values ('{1,2}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_tbl values ('{1,2}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2}"
+
+        	insert into arr_tbl values ('{1,2}');
+	^
+<sql-statement>
+-- failure expected:
+insert into arr_tbl values ('{1,2,3}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	-- failure expected:
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,3}"
+
+        	-- failure expected:
+	^
+<sql-statement>
+insert into arr_tbl values ('{2,3,4}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_tbl values ('{2,3,4}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{2,3,4}"
+
+        	insert into arr_tbl values ('{2,3,4}');
+	^
+<sql-statement>
+insert into arr_tbl values ('{1,5,3}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_tbl values ('{1,5,3}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,5,3}"
+
+        	insert into arr_tbl values ('{1,5,3}');
+	^
+<sql-statement>
+insert into arr_tbl values ('{1,2,10}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_tbl values ('{1,2,10}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,10}"
+
+        	insert into arr_tbl values ('{1,2,10}');
+	^
+<sql-statement>
+set enable_seqscan to off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_seqscan
+    	set enable_seqscan to off;
+	^
+<sql-statement>
+set enable_bitmapscan to off;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_bitmapscan
+    	set enable_bitmapscan to off;
+	^
+<sql-statement>
+select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
+</sql-statement>
+<sql-statement>
+select * from arr_tbl where f1 >= '{1,2,3}' and f1 < '{1,5,3}';
+</sql-statement>
+<sql-statement>
+-- test ON CONFLICT DO UPDATE with arrays
+create temp table arr_pk_tbl (pk int4 primary key, f1 int[]);
+</sql-statement>
+<sql-statement>
+insert into arr_pk_tbl values (1, '{1,2,3}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	insert into arr_pk_tbl values (1, '{1,2,3}');
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,3}"
+
+        	insert into arr_pk_tbl values (1, '{1,2,3}');
+	^
+<sql-statement>
+insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk)
+  do update set f1[1] = excluded.f1[1], f1[3] = excluded.f1[3]
+  returning pk, f1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: InsertStmt: not supported onConflictClause
+    	insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk)
+	^
+<sql-statement>
+insert into arr_pk_tbl(pk, f1[1:2]) values (1, '{6,7,8}') on conflict (pk)
+  do update set f1[1] = excluded.f1[1],
+    f1[2] = excluded.f1[2],
+    f1[3] = excluded.f1[3]
+  returning pk, f1;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: InsertStmt: not supported onConflictClause
+    	insert into arr_pk_tbl(pk, f1[1:2]) values (1, '{6,7,8}') on conflict (pk)
+	^
+<sql-statement>
+-- note: if above selects don't produce the expected tuple order,
+-- then you didn't get an indexscan plan, and something is busted.
+reset enable_seqscan;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	-- note: if above selects don't produce the expected tuple order,
+	^
+<sql-statement>
+reset enable_bitmapscan;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
+    	reset enable_bitmapscan;
+	^
+<sql-statement>
+-- test [not] (like|ilike) (any|all) (...)
+select 'foo' like any (array['%a', '%o']); -- t
+</sql-statement>
+<sql-statement>
+select 'foo' like any (array['%a', '%b']); -- f
+</sql-statement>
+<sql-statement>
+select 'foo' like all (array['f%', '%o']); -- t
+</sql-statement>
+<sql-statement>
+select 'foo' like all (array['f%', '%b']); -- f
+</sql-statement>
+<sql-statement>
+select 'foo' not like any (array['%a', '%b']); -- t
+</sql-statement>
+<sql-statement>
+select 'foo' not like all (array['%a', '%o']); -- f
+</sql-statement>
+<sql-statement>
+select 'foo' ilike any (array['%A', '%O']); -- t
+</sql-statement>
+<sql-statement>
+select 'foo' ilike all (array['F%', '%O']); -- t
+</sql-statement>
+<sql-statement>
+--
+-- General array parser tests
+--
+-- none of the following should be accepted
+select '{{1,{2}},{2,3}}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	--
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{{1,{2}},{2,3}}"
+DETAIL:  Unexpected "{" character.
+
+        	--
+	^
+<sql-statement>
+select '{{},{}}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select '{{},{}}'::text[];
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{{},{}}"
+DETAIL:  Unexpected "}" character.
+
+        	select '{{},{}}'::text[];
+	^
+<sql-statement>
+select E'{{1,2},\\{2,3}}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select E'{{1,2},\\{2,3}}'::text[];
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{{1,2},\{2,3}}"
+DETAIL:  Unexpected "\" character.
+
+        	select E'{{1,2},\\{2,3}}'::text[];
+	^
+<sql-statement>
+select '{{"1 2" x},{3}}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select '{{"1 2" x},{3}}'::text[];
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{{"1 2" x},{3}}"
+DETAIL:  Unexpected array element.
+
+        	select '{{"1 2" x},{3}}'::text[];
+	^
+<sql-statement>
+select '{}}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select '{}}'::text[];
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{}}"
+DETAIL:  Junk after closing right brace.
+
+        	select '{}}'::text[];
+	^
+<sql-statement>
+select '{ }}'::text[];
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select '{ }}'::text[];
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  malformed array literal: "{ }}"
+DETAIL:  Junk after closing right brace.
+
+        	select '{ }}'::text[];
+	^
+<sql-statement>
+select array[];
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array[];
+	^
+        -stdin-:<main>:1:8: Error: At function: PgArray
+        	select array[];
+	       ^
+            -stdin-:<main>:1:8: Error: Expected at least 1 argument(s), but got 0
+            	select array[];
+	       ^
+<sql-statement>
+-- none of the above should be accepted
+-- all of the following should be accepted
+select '{}'::text[];
+</sql-statement>
+<sql-statement>
+select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[];
+</sql-statement>
+<sql-statement>
+select '{0 second  ,0 second}'::interval[];
+</sql-statement>
+<sql-statement>
+select '{ { "," } , { 3 } }'::text[];
+</sql-statement>
+<sql-statement>
+select '  {   {  "  0 second  "   ,  0 second  }   }'::text[];
+</sql-statement>
+<sql-statement>
+select '{
+           0 second,
+           @ 1 hour @ 42 minutes @ 20 seconds
+         }'::interval[];
+</sql-statement>
+<sql-statement>
+select array[]::text[];
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array[]::text[];
+	^
+        -stdin-:<main>:1:17: Error: At function: PgCast
+        	select array[]::text[];
+	                ^
+            -stdin-:<main>:1:8: Error: At function: PgArray
+            	select array[]::text[];
+	       ^
+                -stdin-:<main>:1:8: Error: Expected at least 1 argument(s), but got 0
+                	select array[]::text[];
+	       ^
+<sql-statement>
+select '[0:1]={1.1,2.2}'::float8[];
+</sql-statement>
+<sql-statement>
+-- all of the above should be accepted
+-- tests for array aggregates
+CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]);
+</sql-statement>
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{1,2,3,4}','{{grey,red},{blue,blue}}','{1.6, 0.0}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,3,4}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{1,2,3}','{{grey,red},{grey,blue}}','{1.6}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{1,2,3}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: max
+        	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{3,3,2,4,5,6}','{{white,yellow},{pink,orange}}','{2.1,3.3,1.8,1.7,1.6}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{3,3,2,4,5,6}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: max
+        	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{2}','{{black,red},{green,orange}}','{1.6,2.2,2.6,0.4}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{2}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: max
+        	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{4,2,6,7,8,1}','{{red},{black},{purple},{blue},{blue}}',NULL);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{4,2,6,7,8,1}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: max
+        	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+<sql-statement>
+INSERT INTO arraggtest (f1, f2, f3) VALUES
+('{}','{{pink,white,blue,red,grey,orange}}','{2.1,1.87,1.4,2.2}');
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
+    	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  invalid input syntax for type integer: "{}"
+
+        	INSERT INTO arraggtest (f1, f2, f3) VALUES
+	^
+<sql-statement>
+SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+        -stdin-:<main>:1:1: Error: Duplicated member: max
+        	SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest;
+	^
+<sql-statement>
+-- A few simple tests for arrays of composite types
+create type comptype as (f1 int, f2 text);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 314
+    	-- A few simple tests for arrays of composite types
+	^
+<sql-statement>
+create table comptable (c1 comptype, c2 comptype[]);
+</sql-statement>
+<sql-statement>
+-- XXX would like to not have to specify row() construct types here ...
+insert into comptable
+  values (row(1,'foo'), array[row(2,'bar')::comptype, row(3,'baz')::comptype]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
+    	-- XXX would like to not have to specify row() construct types here ...
+	^
+<sql-statement>
+-- check that implicitly named array type _comptype isn't a problem
+create type _comptype as enum('fooey');
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 315
+    	-- check that implicitly named array type _comptype isn't a problem
+	^
+<sql-statement>
+select * from comptable;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.comptable
+    
+<sql-statement>
+select c2[2].f2 from comptable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
+    	select c2[2].f2 from comptable;
+	^
+<sql-statement>
+drop type _comptype;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 373
+    	drop type _comptype;
+	^
+<sql-statement>
+drop table comptable;
+</sql-statement>
+<sql-statement>
+drop type comptype;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 373
+    	drop type comptype;
+	^
+<sql-statement>
+create or replace function unnest1(anyarray)
+returns setof anyelement as $$
+select $1[s] from generate_subscripts($1,1) g(s);
+$$ language sql immutable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create or replace function unnest1(anyarray)
+	^
+<sql-statement>
+create or replace function unnest2(anyarray)
+returns setof anyelement as $$
+select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
+                   generate_subscripts($1,2) g2(s2);
+$$ language sql immutable;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
+    	create or replace function unnest2(anyarray)
+	^
+<sql-statement>
+select * from unnest1(array[1,2,3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	select * from unnest1(array[1,2,3]);
+	^
+        -stdin-:<main>:1:15: Error: At function: PgCall
+        	select * from unnest1(array[1,2,3]);
+	              ^
+            -stdin-:<main>:1:15: Error: No such proc: unnest1
+            	select * from unnest1(array[1,2,3]);
+	              ^
+<sql-statement>
+select * from unnest2(array[[1,2,3],[4,5,6]]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	select * from unnest2(array[[1,2,3],[4,5,6]]);
+	^
+        -stdin-:<main>:1:15: Error: At function: PgCall
+        	select * from unnest2(array[[1,2,3],[4,5,6]]);
+	              ^
+            -stdin-:<main>:1:15: Error: No such proc: unnest2
+            	select * from unnest2(array[[1,2,3],[4,5,6]]);
+	              ^
+<sql-statement>
+drop function unnest1(anyarray);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
+    	drop function unnest1(anyarray);
+	^
+<sql-statement>
+drop function unnest2(anyarray);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
+    	drop function unnest2(anyarray);
+	^
+<sql-statement>
+select array_fill(null::integer, array[3,3],array[2,2]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(null::integer, array[3,3],array[2,2]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(null::integer, array[3,3],array[2,2]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4,_int4)
+            	select array_fill(null::integer, array[3,3],array[2,2]);
+	       ^
+<sql-statement>
+select array_fill(null::integer, array[3,3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(null::integer, array[3,3]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(null::integer, array[3,3]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4)
+            	select array_fill(null::integer, array[3,3]);
+	       ^
+<sql-statement>
+select array_fill(null::text, array[3,3],array[2,2]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(null::text, array[3,3],array[2,2]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(null::text, array[3,3],array[2,2]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (text,_int4,_int4)
+            	select array_fill(null::text, array[3,3],array[2,2]);
+	       ^
+<sql-statement>
+select array_fill(null::text, array[3,3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(null::text, array[3,3]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(null::text, array[3,3]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (text,_int4)
+            	select array_fill(null::text, array[3,3]);
+	       ^
+<sql-statement>
+select array_fill(7, array[3,3],array[2,2]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(7, array[3,3],array[2,2]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(7, array[3,3],array[2,2]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4,_int4)
+            	select array_fill(7, array[3,3],array[2,2]);
+	       ^
+<sql-statement>
+select array_fill(7, array[3,3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(7, array[3,3]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(7, array[3,3]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4)
+            	select array_fill(7, array[3,3]);
+	       ^
+<sql-statement>
+select array_fill('juhu'::text, array[3,3],array[2,2]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill('juhu'::text, array[3,3],array[2,2]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill('juhu'::text, array[3,3],array[2,2]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (text,_int4,_int4)
+            	select array_fill('juhu'::text, array[3,3],array[2,2]);
+	       ^
+<sql-statement>
+select array_fill('juhu'::text, array[3,3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill('juhu'::text, array[3,3]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill('juhu'::text, array[3,3]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (text,_int4)
+            	select array_fill('juhu'::text, array[3,3]);
+	       ^
+<sql-statement>
+select a, a = '{}' as is_eq, array_dims(a)
+  from (select array_fill(42, array[0]) as a) ss;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select a, a = '{}' as is_eq, array_dims(a)
+	^
+        -stdin-:<main>:2:16: Error: At function: PgCall
+        	  from (select array_fill(42, array[0]) as a) ss;
+	               ^
+            -stdin-:<main>:2:16: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4)
+            	  from (select array_fill(42, array[0]) as a) ss;
+	               ^
+<sql-statement>
+select a, a = '{}' as is_eq, array_dims(a)
+  from (select array_fill(42, '{}') as a) ss;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select a, a = '{}' as is_eq, array_dims(a)
+	^
+        -stdin-:<main>:2:16: Error: At function: PgCall
+        	  from (select array_fill(42, '{}') as a) ss;
+	               ^
+            -stdin-:<main>:2:16: Error: Unable to find an overload for proc array_fill with given argument types: (int4,unknown)
+            	  from (select array_fill(42, '{}') as a) ss;
+	               ^
+<sql-statement>
+select a, a = '{}' as is_eq, array_dims(a)
+  from (select array_fill(42, '{}', '{}') as a) ss;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select a, a = '{}' as is_eq, array_dims(a)
+	^
+        -stdin-:<main>:2:16: Error: At function: PgCall
+        	  from (select array_fill(42, '{}', '{}') as a) ss;
+	               ^
+            -stdin-:<main>:2:16: Error: Unable to find an overload for proc array_fill with given argument types: (int4,unknown,unknown)
+            	  from (select array_fill(42, '{}', '{}') as a) ss;
+	               ^
+<sql-statement>
+-- raise exception
+select array_fill(1, null, array[2,2]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- raise exception
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	select array_fill(1, null, array[2,2]);
+	       ^
+            -stdin-:<main>:2:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,unknown,_int4)
+            	select array_fill(1, null, array[2,2]);
+	       ^
+<sql-statement>
+select array_fill(1, array[2,2], null);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(1, array[2,2], null);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(1, array[2,2], null);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4,unknown)
+            	select array_fill(1, array[2,2], null);
+	       ^
+<sql-statement>
+select array_fill(1, array[2,2], '{}');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(1, array[2,2], '{}');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(1, array[2,2], '{}');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4,unknown)
+            	select array_fill(1, array[2,2], '{}');
+	       ^
+<sql-statement>
+select array_fill(1, array[3,3], array[1,1,1]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(1, array[3,3], array[1,1,1]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(1, array[3,3], array[1,1,1]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4,_int4)
+            	select array_fill(1, array[3,3], array[1,1,1]);
+	       ^
+<sql-statement>
+select array_fill(1, array[1,2,null]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(1, array[1,2,null]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(1, array[1,2,null]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4)
+            	select array_fill(1, array[1,2,null]);
+	       ^
+<sql-statement>
+select array_fill(1, array[[1,2],[3,4]]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_fill(1, array[[1,2],[3,4]]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_fill(1, array[[1,2],[3,4]]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_fill with given argument types: (int4,_int4)
+            	select array_fill(1, array[[1,2],[3,4]]);
+	       ^
+<sql-statement>
+select string_to_array('1|2|3', '|');
+</sql-statement>
+<sql-statement>
+select string_to_array('1|2|3|', '|');
+</sql-statement>
+<sql-statement>
+select string_to_array('1||2|3||', '||');
+</sql-statement>
+<sql-statement>
+select string_to_array('1|2|3', '');
+</sql-statement>
+<sql-statement>
+select string_to_array('', '|');
+</sql-statement>
+<sql-statement>
+select string_to_array('1|2|3', NULL);
+</sql-statement>
+<sql-statement>
+select string_to_array(NULL, '|') IS NULL;
+</sql-statement>
+<sql-statement>
+select string_to_array('abc', '');
+</sql-statement>
+<sql-statement>
+select string_to_array('abc', '', 'abc');
+</sql-statement>
+<sql-statement>
+select string_to_array('abc', ',');
+</sql-statement>
+<sql-statement>
+select string_to_array('abc', ',', 'abc');
+</sql-statement>
+<sql-statement>
+select string_to_array('1,2,3,4,,6', ',');
+</sql-statement>
+<sql-statement>
+select string_to_array('1,2,3,4,,6', ',', '');
+</sql-statement>
+<sql-statement>
+select string_to_array('1,2,3,4,*,6', ',', '*');
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1|2|3', '') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('', '|') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table(NULL, '|') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('abc', '') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('abc', ',') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v);
+</sql-statement>
+<sql-statement>
+select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v);
+</sql-statement>
+<sql-statement>
+select array_to_string(NULL::int4[], ',') IS NULL;
+</sql-statement>
+<sql-statement>
+select array_to_string('{}'::int4[], ',');
+</sql-statement>
+<sql-statement>
+select array_to_string(array[1,2,3,4,NULL,6], ',');
+</sql-statement>
+<sql-statement>
+select array_to_string(array[1,2,3,4,NULL,6], ',', '*');
+</sql-statement>
+<sql-statement>
+select array_to_string(array[1,2,3,4,NULL,6], NULL);
+</sql-statement>
+<sql-statement>
+select array_to_string(array[1,2,3,4,NULL,6], ',', NULL);
+</sql-statement>
+<sql-statement>
+select array_to_string(string_to_array('1|2|3', '|'), '|');
+</sql-statement>
+<sql-statement>
+select array_length(array[1,2,3], 1);
+</sql-statement>
+<sql-statement>
+select array_length(array[[1,2,3], [4,5,6]], 0);
+</sql-statement>
+<sql-statement>
+select array_length(array[[1,2,3], [4,5,6]], 1);
+</sql-statement>
+<sql-statement>
+select array_length(array[[1,2,3], [4,5,6]], 2);
+</sql-statement>
+<sql-statement>
+select array_length(array[[1,2,3], [4,5,6]], 3);
+</sql-statement>
+<sql-statement>
+select cardinality(NULL::int[]);
+</sql-statement>
+<sql-statement>
+select cardinality('{}'::int[]);
+</sql-statement>
+<sql-statement>
+select cardinality(array[1,2,3]);
+</sql-statement>
+<sql-statement>
+select cardinality('[2:4]={5,6,7}'::int[]);
+</sql-statement>
+<sql-statement>
+select cardinality('{{1,2}}'::int[]);
+</sql-statement>
+<sql-statement>
+select cardinality('{{1,2},{3,4},{5,6}}'::int[]);
+</sql-statement>
+<sql-statement>
+select cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[]);
+</sql-statement>
+<sql-statement>
+-- array_agg(anynonarray)
+select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss;
+</sql-statement>
+<sql-statement>
+select array_agg(ten) from (select ten from tenk1 where unique1 < 15 order by unique1) ss;
+</sql-statement>
+<sql-statement>
+select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15 order by unique1) ss;
+</sql-statement>
+<sql-statement>
+select array_agg(unique1) from tenk1 where unique1 < -15;
+</sql-statement>
+<sql-statement>
+-- array_agg(anyarray)
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar);
+</sql-statement>
+<sql-statement>
+select array_agg(distinct ar order by ar desc)
+  from (select array[i / 2] from generate_series(1,10) a(i)) b(ar);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: FuncCall: unsupported agg_order
+    	select array_agg(distinct ar order by ar desc)
+	       ^
+<sql-statement>
+select array_agg(ar)
+  from (select array_agg(array[i, i+1, i-1])
+        from generate_series(1,2) a(i)) b(ar);
+</sql-statement>
+<sql-statement>
+select array_agg(array[i+1.2, i+1.3, i+1.4]) from generate_series(1,3) g(i);
+</sql-statement>
+<sql-statement>
+select array_agg(array['Hello', i::text]) from generate_series(9,11) g(i);
+</sql-statement>
+<sql-statement>
+select array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i);
+</sql-statement>
+<sql-statement>
+-- errors
+select array_agg('{}'::int[]) from generate_series(1,2);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	-- errors
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  cannot accumulate empty arrays
+
+        	-- errors
+	^
+<sql-statement>
+select array_agg(null::int[]) from generate_series(1,2);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select array_agg(null::int[]) from generate_series(1,2);
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  cannot accumulate null arrays
+
+        	select array_agg(null::int[]) from generate_series(1,2);
+	^
+<sql-statement>
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3}'::int[])) v(ar);
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	select array_agg(ar)
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  cannot accumulate arrays of different dimensionality
+
+        	select array_agg(ar)
+	^
+<sql-statement>
+select unnest(array[1,2,3]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: Generator functions are not allowed in: SELECT
+    	select unnest(array[1,2,3]);
+	       ^
+<sql-statement>
+select * from unnest(array[1,2,3]);
+</sql-statement>
+<sql-statement>
+select unnest(array[1,2,3,4.5]::float8[]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: Generator functions are not allowed in: SELECT
+    	select unnest(array[1,2,3,4.5]::float8[]);
+	       ^
+<sql-statement>
+select unnest(array[1,2,3,4.5]::numeric[]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: Generator functions are not allowed in: SELECT
+    	select unnest(array[1,2,3,4.5]::numeric[]);
+	       ^
+<sql-statement>
+select unnest(array[1,2,3,null,4,null,null,5,6]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: Generator functions are not allowed in: SELECT
+    	select unnest(array[1,2,3,null,4,null,null,5,6]);
+	       ^
+<sql-statement>
+select unnest(array[1,2,3,null,4,null,null,5,6]::text[]);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:8: Error: Generator functions are not allowed in: SELECT
+    	select unnest(array[1,2,3,null,4,null,null,5,6]::text[]);
+	       ^
+<sql-statement>
+select abs(unnest(array[1,2,null,-3]));
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:12: Error: Generator functions are not allowed in: SELECT
+    	select abs(unnest(array[1,2,null,-3]));
+	           ^
+<sql-statement>
+select array_remove(array[1,2,2,3], 2);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array[1,2,2,3], 2);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove(array[1,2,2,3], 2);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_int4,int4)
+            	select array_remove(array[1,2,2,3], 2);
+	       ^
+<sql-statement>
+select array_remove(array[1,2,2,3], 5);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array[1,2,2,3], 5);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove(array[1,2,2,3], 5);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_int4,int4)
+            	select array_remove(array[1,2,2,3], 5);
+	       ^
+<sql-statement>
+select array_remove(array[1,NULL,NULL,3], NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array[1,NULL,NULL,3], NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove(array[1,NULL,NULL,3], NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_int4,unknown)
+            	select array_remove(array[1,NULL,NULL,3], NULL);
+	       ^
+<sql-statement>
+select array_remove(array['A','CC','D','C','RR'], 'RR');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array['A','CC','D','C','RR'], 'RR');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove(array['A','CC','D','C','RR'], 'RR');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_text,unknown)
+            	select array_remove(array['A','CC','D','C','RR'], 'RR');
+	       ^
+<sql-statement>
+select array_remove(array[1.0, 2.1, 3.3], 1);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array[1.0, 2.1, 3.3], 1);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove(array[1.0, 2.1, 3.3], 1);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_numeric,int4)
+            	select array_remove(array[1.0, 2.1, 3.3], 1);
+	       ^
+<sql-statement>
+select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (unknown,int4)
+            	select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
+	       ^
+<sql-statement>
+select array_remove(array['X','X','X'], 'X') = '{}';
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_remove(array['X','X','X'], 'X') = '{}';
+	^
+        -stdin-:<main>:1:46: Error: At function: PgOp
+        	select array_remove(array['X','X','X'], 'X') = '{}';
+	                                             ^
+            -stdin-:<main>:1:8: Error: At function: PgCall
+            	select array_remove(array['X','X','X'], 'X') = '{}';
+	       ^
+                -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_remove with given argument types: (_text,unknown)
+                	select array_remove(array['X','X','X'], 'X') = '{}';
+	       ^
+<sql-statement>
+select array_replace(array[1,2,5,4],5,3);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array[1,2,5,4],5,3);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array[1,2,5,4],5,3);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_int4,int4,int4)
+            	select array_replace(array[1,2,5,4],5,3);
+	       ^
+<sql-statement>
+select array_replace(array[1,2,5,4],5,NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array[1,2,5,4],5,NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array[1,2,5,4],5,NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_int4,int4,unknown)
+            	select array_replace(array[1,2,5,4],5,NULL);
+	       ^
+<sql-statement>
+select array_replace(array[1,2,NULL,4,NULL],NULL,5);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array[1,2,NULL,4,NULL],NULL,5);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array[1,2,NULL,4,NULL],NULL,5);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_int4,unknown,int4)
+            	select array_replace(array[1,2,NULL,4,NULL],NULL,5);
+	       ^
+<sql-statement>
+select array_replace(array['A','B','DD','B'],'B','CC');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array['A','B','DD','B'],'B','CC');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array['A','B','DD','B'],'B','CC');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_text,unknown,unknown)
+            	select array_replace(array['A','B','DD','B'],'B','CC');
+	       ^
+<sql-statement>
+select array_replace(array[1,NULL,3],NULL,NULL);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array[1,NULL,3],NULL,NULL);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array[1,NULL,3],NULL,NULL);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_int4,unknown,unknown)
+            	select array_replace(array[1,NULL,3],NULL,NULL);
+	       ^
+<sql-statement>
+select array_replace(array['AB',NULL,'CDE'],NULL,'12');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	select array_replace(array['AB',NULL,'CDE'],NULL,'12');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	select array_replace(array['AB',NULL,'CDE'],NULL,'12');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc array_replace with given argument types: (_text,unknown,unknown)
+            	select array_replace(array['AB',NULL,'CDE'],NULL,'12');
+	       ^
+<sql-statement>
+-- array(select array-value ...)
+select array(select array[i,i/2] from generate_series(1,5) i);
+</sql-statement>
+<sql-statement>
+select array(select array['Hello', i::text] from generate_series(9,11) i);
+</sql-statement>
+<sql-statement>
+-- Insert/update on a column that is array of composite
+create temp table t1 (f1 int8_tbl[]);
+</sql-statement>
+<sql-statement>
+insert into t1 (f1[5].q1) values(42);
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t1
+    
+<sql-statement>
+select * from t1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t1
+    
+<sql-statement>
+update t1 set f1[5].q2 = 43;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: 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'. 
+    
+<sql-statement>
+select * from t1;
+</sql-statement>
+-stdin-:<main>: Fatal: Table metadata loading
+
+    -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t1
+    
+<sql-statement>
+-- Check that arrays of composites are safely detoasted when needed
+create temp table src (f1 text);
+</sql-statement>
+<sql-statement>
+insert into src
+  select string_agg(random()::text,'') from generate_series(1,10000);
+</sql-statement>
+<sql-statement>
+create type textandtext as (c1 text, c2 text);
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 314
+    	create type textandtext as (c1 text, c2 text);
+	^
+<sql-statement>
+create temp table dest (f1 textandtext[]);
+</sql-statement>
+<sql-statement>
+insert into dest select array[row(f1,f1)::textandtext] from src;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:43: Error: alternative is not implemented yet : 138
+    	insert into dest select array[row(f1,f1)::textandtext] from src;
+	                                          ^
+<sql-statement>
+select length(md5((f1[1]).c2)) from dest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:15: Error: alternative is not implemented yet : 360
+    	select length(md5((f1[1]).c2)) from dest;
+	              ^
+<sql-statement>
+delete from src;
+</sql-statement>
+-stdin-:<main>: Fatal: Pre type annotation
+
+    -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' 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'. 
+    
+<sql-statement>
+select length(md5((f1[1]).c2)) from dest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:15: Error: alternative is not implemented yet : 360
+    	select length(md5((f1[1]).c2)) from dest;
+	              ^
+<sql-statement>
+truncate table src;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 257
+    	truncate table src;
+	^
+<sql-statement>
+drop table src;
+</sql-statement>
+<sql-statement>
+select length(md5((f1[1]).c2)) from dest;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:15: Error: alternative is not implemented yet : 360
+    	select length(md5((f1[1]).c2)) from dest;
+	              ^
+<sql-statement>
+drop table dest;
+</sql-statement>
+<sql-statement>
+drop type textandtext;
+</sql-statement>
+-stdin-:<main>: Error: Parse Sql
+
+    -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 373
+    	drop type textandtext;
+	^
+<sql-statement>
+-- Tests for polymorphic-array form of width_bucket()
+-- this exercises the varwidth and float8 code paths
+SELECT
+    op,
+    width_bucket(op::numeric, ARRAY[1, 3, 5, 10.0]::numeric[]) AS wb_n1,
+    width_bucket(op::numeric, ARRAY[0, 5.5, 9.99]::numeric[]) AS wb_n2,
+    width_bucket(op::numeric, ARRAY[-6, -5, 2.0]::numeric[]) AS wb_n3,
+    width_bucket(op::float8, ARRAY[1, 3, 5, 10.0]::float8[]) AS wb_f1,
+    width_bucket(op::float8, ARRAY[0, 5.5, 9.99]::float8[]) AS wb_f2,
+    width_bucket(op::float8, ARRAY[-6, -5, 2.0]::float8[]) AS wb_f3
+FROM (VALUES
+  (-5.2),
+  (-0.0000000001),
+  (0.000000000001),
+  (1),
+  (1.99999999999999),
+  (2),
+  (2.00000000000001),
+  (3),
+  (4),
+  (4.5),
+  (5),
+  (5.5),
+  (6),
+  (7),
+  (8),
+  (9),
+  (9.99999999999999),
+  (10),
+  (10.0000000000001)
+) v(op);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
+    	-- Tests for polymorphic-array form of width_bucket()
+	^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:5:5: Error: At function: PgCall
+            	    width_bucket(op::numeric, ARRAY[1, 3, 5, 10.0]::numeric[]) AS wb_n1,
+	    ^
+                -stdin-:<main>:5:5: Error: Unable to find an overload for proc width_bucket with given argument types: (numeric,_numeric)
+                	    width_bucket(op::numeric, ARRAY[1, 3, 5, 10.0]::numeric[]) AS wb_n1,
+	    ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:6:5: Error: At function: PgCall
+            	    width_bucket(op::numeric, ARRAY[0, 5.5, 9.99]::numeric[]) AS wb_n2,
+	    ^
+                -stdin-:<main>:6:5: Error: Unable to find an overload for proc width_bucket with given argument types: (numeric,_numeric)
+                	    width_bucket(op::numeric, ARRAY[0, 5.5, 9.99]::numeric[]) AS wb_n2,
+	    ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:7:5: Error: At function: PgCall
+            	    width_bucket(op::numeric, ARRAY[-6, -5, 2.0]::numeric[]) AS wb_n3,
+	    ^
+                -stdin-:<main>:7:5: Error: Unable to find an overload for proc width_bucket with given argument types: (numeric,_numeric)
+                	    width_bucket(op::numeric, ARRAY[-6, -5, 2.0]::numeric[]) AS wb_n3,
+	    ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:8:5: Error: At function: PgCall
+            	    width_bucket(op::float8, ARRAY[1, 3, 5, 10.0]::float8[]) AS wb_f1,
+	    ^
+                -stdin-:<main>:8:5: Error: Unable to find an overload for proc width_bucket with given argument types: (float8,_float8)
+                	    width_bucket(op::float8, ARRAY[1, 3, 5, 10.0]::float8[]) AS wb_f1,
+	    ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:9:5: Error: At function: PgCall
+            	    width_bucket(op::float8, ARRAY[0, 5.5, 9.99]::float8[]) AS wb_f2,
+	    ^
+                -stdin-:<main>:9:5: Error: Unable to find an overload for proc width_bucket with given argument types: (float8,_float8)
+                	    width_bucket(op::float8, ARRAY[0, 5.5, 9.99]::float8[]) AS wb_f2,
+	    ^
+        -stdin-:<main>:1:1: Error: At function: PgResultItem
+        	-- Tests for polymorphic-array form of width_bucket()
+	^
+            -stdin-:<main>:10:5: Error: At function: PgCall
+            	    width_bucket(op::float8, ARRAY[-6, -5, 2.0]::float8[]) AS wb_f3
+	    ^
+                -stdin-:<main>:10:5: Error: Unable to find an overload for proc width_bucket with given argument types: (float8,_float8)
+                	    width_bucket(op::float8, ARRAY[-6, -5, 2.0]::float8[]) AS wb_f3
+	    ^
+<sql-statement>
+-- ensure float8 path handles NaN properly
+SELECT
+    op,
+    width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb
+FROM (VALUES
+  (-5.2::float8),
+  (4::float8),
+  (77::float8),
+  ('NaN'::float8)
+) v(op);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- ensure float8 path handles NaN properly
+	^
+        -stdin-:<main>:4:5: Error: At function: PgCall
+        	    width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb
+	    ^
+            -stdin-:<main>:4:5: Error: Unable to find an overload for proc width_bucket with given argument types: (float8,_float8)
+            	    width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb
+	    ^
+<sql-statement>
+-- these exercise the generic fixed-width code path
+SELECT
+    op,
+    width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1
+FROM generate_series(0,11) as op;
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- these exercise the generic fixed-width code path
+	^
+        -stdin-:<main>:4:5: Error: At function: PgCall
+        	    width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1
+	    ^
+            -stdin-:<main>:4:5: Error: Unable to find an overload for proc width_bucket with given argument types: (int4,_int4)
+            	    width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1
+	    ^
+<sql-statement>
+SELECT width_bucket(now(),
+                    array['yesterday', 'today', 'tomorrow']::timestamptz[]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT width_bucket(now(),
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT width_bucket(now(),
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc width_bucket with given argument types: (timestamptz,_timestamptz)
+            	SELECT width_bucket(now(),
+	       ^
+<sql-statement>
+-- corner cases
+SELECT width_bucket(5, ARRAY[3]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- corner cases
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	SELECT width_bucket(5, ARRAY[3]);
+	       ^
+            -stdin-:<main>:2:8: Error: Unable to find an overload for proc width_bucket with given argument types: (int4,_int4)
+            	SELECT width_bucket(5, ARRAY[3]);
+	       ^
+<sql-statement>
+SELECT width_bucket(5, '{}');
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT width_bucket(5, '{}');
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT width_bucket(5, '{}');
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc width_bucket with given argument types: (int4,unknown)
+            	SELECT width_bucket(5, '{}');
+	       ^
+<sql-statement>
+-- error cases
+SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	-- error cases
+	^
+        -stdin-:<main>:2:8: Error: At function: PgCall
+        	SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
+	       ^
+            -stdin-:<main>:2:8: Error: Unable to find an overload for proc width_bucket with given argument types: (text,_int4)
+            	SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
+	       ^
+<sql-statement>
+SELECT width_bucket(5, ARRAY[3, 4, NULL]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT width_bucket(5, ARRAY[3, 4, NULL]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT width_bucket(5, ARRAY[3, 4, NULL]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc width_bucket with given argument types: (int4,_int4)
+            	SELECT width_bucket(5, ARRAY[3, 4, NULL]);
+	       ^
+<sql-statement>
+SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
+	       ^
+            -stdin-:<main>:1:8: Error: Unable to find an overload for proc width_bucket with given argument types: (int4,_int4)
+            	SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
+	       ^
+<sql-statement>
+-- trim_array
+SELECT arr, trim_array(arr, 2)
+FROM
+(VALUES ('{1,2,3,4,5,6}'::bigint[]),
+        ('{1,2}'),
+        ('[10:16]={1,2,3,4,5,6,7}'),
+        ('[-15:-10]={1,2,3,4,5,6}'),
+        ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr);
+</sql-statement>
+<sql-statement>
+SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  number of elements to trim must be between 0 and 3
+
+        	SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
+	^
+<sql-statement>
+SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail
+</sql-statement>
+-stdin-:<main>: Fatal: Execution
+
+    -stdin-:<main>:1:1: Fatal: Execution of node: Result
+    	SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail
+	^
+        -stdin-:<main>:1:1: Fatal: ERROR:  number of elements to trim must be between 0 and 3
+
+        	SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail
+	^
+<sql-statement>
+SELECT trim_array(ARRAY[]::int[], 1); -- fail
+</sql-statement>
+-stdin-:<main>: Error: Type annotation
+
+    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
+    	SELECT trim_array(ARRAY[]::int[], 1); -- fail
+	^
+        -stdin-:<main>:1:8: Error: At function: PgCall
+        	SELECT trim_array(ARRAY[]::int[], 1); -- fail
+	       ^
+            -stdin-:<main>:1:28: Error: At function: PgCast
+            	SELECT trim_array(ARRAY[]::int[], 1); -- fail
+	                           ^
+                -stdin-:<main>:1:19: Error: At function: PgArray
+                	SELECT trim_array(ARRAY[]::int[], 1); -- fail
+	                  ^
+                    -stdin-:<main>:1:19: Error: Expected at least 1 argument(s), but got 0
+                    	SELECT trim_array(ARRAY[]::int[], 1); -- fail
+	                  ^

+ 771 - 0
yql/essentials/tests/postgresql/cases/arrays.out

@@ -0,0 +1,771 @@
+--
+-- ARRAYS
+--
+CREATE TABLE arrtest (
+	a 			int2[],
+	b 			int4[][][],
+	c 			name[],
+	d			text[][],
+	e 			float8[],
+	f			char(5)[],
+	g			varchar(5)[]
+);
+-- test mixed slice/scalar subscripting
+select '{{1,2,3},{4,5,6},{7,8,9}}'::int[];
+           int4            
+---------------------------
+ {{1,2,3},{4,5,6},{7,8,9}}
+(1 row)
+
+select '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[];
+                 int4                 
+--------------------------------------
+ [0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}
+(1 row)
+
+-- test slices with empty lower and/or upper index
+CREATE TEMP TABLE arrtest_s (
+  a       int2[],
+  b       int2[][]
+);
+INSERT INTO arrtest_s VALUES(NULL, NULL);
+--
+-- test array extension
+--
+CREATE TEMP TABLE arrtest1 (i int[], t text[]);
+--
+-- array expressions and operators
+--
+-- table creation and INSERTs
+CREATE TEMP TABLE arrtest2 (i integer ARRAY[4], f float8[], n numeric[], t text[], d timestamp[]);
+-- some more test data
+CREATE TEMP TABLE arrtest_f (f0 int, f1 text, f2 float8);
+insert into arrtest_f values(1,'cat1',1.21);
+insert into arrtest_f values(2,'cat1',1.24);
+insert into arrtest_f values(3,'cat1',1.18);
+insert into arrtest_f values(4,'cat1',1.26);
+insert into arrtest_f values(5,'cat1',1.15);
+insert into arrtest_f values(6,'cat2',1.15);
+insert into arrtest_f values(7,'cat2',1.26);
+insert into arrtest_f values(8,'cat2',1.32);
+insert into arrtest_f values(9,'cat2',1.30);
+CREATE TEMP TABLE arrtest_i (f0 int, f1 text, f2 int);
+insert into arrtest_i values(1,'cat1',21);
+insert into arrtest_i values(2,'cat1',24);
+insert into arrtest_i values(3,'cat1',18);
+insert into arrtest_i values(4,'cat1',26);
+insert into arrtest_i values(5,'cat1',15);
+insert into arrtest_i values(6,'cat2',15);
+insert into arrtest_i values(7,'cat2',26);
+insert into arrtest_i values(8,'cat2',32);
+insert into arrtest_i values(9,'cat2',30);
+SELECT ARRAY[[[[[['hello'],['world']]]]]];
+           array           
+---------------------------
+ {{{{{{hello},{world}}}}}}
+(1 row)
+
+SELECT ARRAY[ARRAY['hello'],ARRAY['world']];
+       array       
+-------------------
+ {{hello},{world}}
+(1 row)
+
+-- with nulls
+SELECT '{1,null,3}'::int[];
+    int4    
+------------
+ {1,NULL,3}
+(1 row)
+
+SELECT ARRAY[1,NULL,3];
+   array    
+------------
+ {1,NULL,3}
+(1 row)
+
+SELECT NOT ARRAY[1.1,1.2,1.3] = ARRAY[1.1,1.2,1.3] AS "FALSE";
+ FALSE 
+-------
+ f
+(1 row)
+
+-- array casts
+SELECT ARRAY[1,2,3]::text[]::int[]::float8[] AS "{1,2,3}";
+ {1,2,3} 
+---------
+ {1,2,3}
+(1 row)
+
+SELECT pg_typeof(ARRAY[1,2,3]::text[]::int[]::float8[]) AS "double precision[]";
+ double precision[] 
+--------------------
+ double precision[]
+(1 row)
+
+SELECT ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[] AS "{{a,bc},{def,hijk}}";
+ {{a,bc},{def,hijk}} 
+---------------------
+ {{a,bc},{def,hijk}}
+(1 row)
+
+SELECT pg_typeof(ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[]) AS "character varying[]";
+ character varying[] 
+---------------------
+ character varying[]
+(1 row)
+
+SELECT CAST(ARRAY[[[[[['a','bb','ccc']]]]]] as text[]) as "{{{{{{a,bb,ccc}}}}}}";
+ {{{{{{a,bb,ccc}}}}}} 
+----------------------
+ {{{{{{a,bb,ccc}}}}}}
+(1 row)
+
+SELECT NULL::text[]::int[] AS "NULL";
+ NULL 
+------
+ 
+(1 row)
+
+-- scalar op any/all (array)
+select 33 = any ('{1,2,3}');
+ ?column? 
+----------
+ f
+(1 row)
+
+select 33 = any ('{1,2,33}');
+ ?column? 
+----------
+ t
+(1 row)
+
+select 33 = all ('{1,2,33}');
+ ?column? 
+----------
+ f
+(1 row)
+
+select 33 >= all ('{1,2,33}');
+ ?column? 
+----------
+ t
+(1 row)
+
+-- boundary cases
+select null::int >= all ('{1,2,33}');
+ ?column? 
+----------
+ 
+(1 row)
+
+select null::int >= all ('{}');
+ ?column? 
+----------
+ t
+(1 row)
+
+select null::int >= any ('{}');
+ ?column? 
+----------
+ f
+(1 row)
+
+-- cross-datatype
+select 33.4 = any (array[1,2,3]);
+ ?column? 
+----------
+ f
+(1 row)
+
+select 33.4 > all (array[1,2,3]);
+ ?column? 
+----------
+ t
+(1 row)
+
+-- nulls
+select 33 = any (null::int[]);
+ ?column? 
+----------
+ 
+(1 row)
+
+select null::int = any ('{1,2,3}');
+ ?column? 
+----------
+ 
+(1 row)
+
+select 33 = any ('{1,null,3}');
+ ?column? 
+----------
+ 
+(1 row)
+
+select 33 = any ('{1,null,33}');
+ ?column? 
+----------
+ t
+(1 row)
+
+select 33 = all (null::int[]);
+ ?column? 
+----------
+ 
+(1 row)
+
+select null::int = all ('{1,2,3}');
+ ?column? 
+----------
+ 
+(1 row)
+
+select 33 = all ('{1,null,3}');
+ ?column? 
+----------
+ f
+(1 row)
+
+select 33 = all ('{33,null,33}');
+ ?column? 
+----------
+ 
+(1 row)
+
+-- nulls later in the bitmap
+SELECT -1 != ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1,1000) g(i)));
+ ?column? 
+----------
+ 
+(1 row)
+
+-- test indexes on arrays
+create temp table arr_tbl (f1 int[] unique);
+-- test ON CONFLICT DO UPDATE with arrays
+create temp table arr_pk_tbl (pk int4 primary key, f1 int[]);
+-- test [not] (like|ilike) (any|all) (...)
+select 'foo' like any (array['%a', '%o']); -- t
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'foo' like any (array['%a', '%b']); -- f
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'foo' like all (array['f%', '%o']); -- t
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'foo' like all (array['f%', '%b']); -- f
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'foo' not like any (array['%a', '%b']); -- t
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'foo' not like all (array['%a', '%o']); -- f
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'foo' ilike any (array['%A', '%O']); -- t
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'foo' ilike all (array['F%', '%O']); -- t
+ ?column? 
+----------
+ t
+(1 row)
+
+--
+-- General array parser tests
+--
+-- none of the following should be accepted
+select '{{1,{2}},{2,3}}'::text[];
+ERROR:  malformed array literal: "{{1,{2}},{2,3}}"
+LINE 1: select '{{1,{2}},{2,3}}'::text[];
+               ^
+DETAIL:  Unexpected "{" character.
+select '{{},{}}'::text[];
+ERROR:  malformed array literal: "{{},{}}"
+LINE 1: select '{{},{}}'::text[];
+               ^
+DETAIL:  Unexpected "}" character.
+select E'{{1,2},\\{2,3}}'::text[];
+ERROR:  malformed array literal: "{{1,2},\{2,3}}"
+LINE 1: select E'{{1,2},\\{2,3}}'::text[];
+               ^
+DETAIL:  Unexpected "\" character.
+select '{{"1 2" x},{3}}'::text[];
+ERROR:  malformed array literal: "{{"1 2" x},{3}}"
+LINE 1: select '{{"1 2" x},{3}}'::text[];
+               ^
+DETAIL:  Unexpected array element.
+select '{}}'::text[];
+ERROR:  malformed array literal: "{}}"
+LINE 1: select '{}}'::text[];
+               ^
+DETAIL:  Junk after closing right brace.
+select '{ }}'::text[];
+ERROR:  malformed array literal: "{ }}"
+LINE 1: select '{ }}'::text[];
+               ^
+DETAIL:  Junk after closing right brace.
+-- none of the above should be accepted
+-- all of the following should be accepted
+select '{}'::text[];
+ text 
+------
+ {}
+(1 row)
+
+select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[];
+                     text                      
+-----------------------------------------------
+ {{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}
+(1 row)
+
+select '{ { "," } , { 3 } }'::text[];
+    text     
+-------------
+ {{","},{3}}
+(1 row)
+
+select '  {   {  "  0 second  "   ,  0 second  }   }'::text[];
+             text              
+-------------------------------
+ {{"  0 second  ","0 second"}}
+(1 row)
+
+select '[0:1]={1.1,2.2}'::float8[];
+     float8      
+-----------------
+ [0:1]={1.1,2.2}
+(1 row)
+
+-- all of the above should be accepted
+-- tests for array aggregates
+CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]);
+create table comptable (c1 comptype, c2 comptype[]);
+drop table comptable;
+select string_to_array('1|2|3', '|');
+ string_to_array 
+-----------------
+ {1,2,3}
+(1 row)
+
+select string_to_array('1|2|3|', '|');
+ string_to_array 
+-----------------
+ {1,2,3,""}
+(1 row)
+
+select string_to_array('1||2|3||', '||');
+ string_to_array 
+-----------------
+ {1,2|3,""}
+(1 row)
+
+select string_to_array('1|2|3', '');
+ string_to_array 
+-----------------
+ {1|2|3}
+(1 row)
+
+select string_to_array('', '|');
+ string_to_array 
+-----------------
+ {}
+(1 row)
+
+select string_to_array('1|2|3', NULL);
+ string_to_array 
+-----------------
+ {1,|,2,|,3}
+(1 row)
+
+select string_to_array(NULL, '|') IS NULL;
+ ?column? 
+----------
+ t
+(1 row)
+
+select string_to_array('abc', '');
+ string_to_array 
+-----------------
+ {abc}
+(1 row)
+
+select string_to_array('abc', '', 'abc');
+ string_to_array 
+-----------------
+ {NULL}
+(1 row)
+
+select string_to_array('abc', ',');
+ string_to_array 
+-----------------
+ {abc}
+(1 row)
+
+select string_to_array('abc', ',', 'abc');
+ string_to_array 
+-----------------
+ {NULL}
+(1 row)
+
+select string_to_array('1,2,3,4,,6', ',');
+ string_to_array 
+-----------------
+ {1,2,3,4,"",6}
+(1 row)
+
+select string_to_array('1,2,3,4,,6', ',', '');
+ string_to_array  
+------------------
+ {1,2,3,4,NULL,6}
+(1 row)
+
+select string_to_array('1,2,3,4,*,6', ',', '*');
+ string_to_array  
+------------------
+ {1,2,3,4,NULL,6}
+(1 row)
+
+select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v);
+ v | is null 
+---+---------
+ 1 | f
+ 2 | f
+ 3 | f
+(3 rows)
+
+select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v);
+ v | is null 
+---+---------
+ 1 | f
+ 2 | f
+ 3 | f
+   | f
+(4 rows)
+
+select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v);
+  v  | is null 
+-----+---------
+ 1   | f
+ 2|3 | f
+     | f
+(3 rows)
+
+select v, v is null as "is null" from string_to_table('1|2|3', '') g(v);
+   v   | is null 
+-------+---------
+ 1|2|3 | f
+(1 row)
+
+select v, v is null as "is null" from string_to_table('', '|') g(v);
+ v | is null 
+---+---------
+(0 rows)
+
+select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v);
+ v | is null 
+---+---------
+ 1 | f
+ | | f
+ 2 | f
+ | | f
+ 3 | f
+(5 rows)
+
+select v, v is null as "is null" from string_to_table(NULL, '|') g(v);
+ v | is null 
+---+---------
+(0 rows)
+
+select v, v is null as "is null" from string_to_table('abc', '') g(v);
+  v  | is null 
+-----+---------
+ abc | f
+(1 row)
+
+select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v);
+ v | is null 
+---+---------
+   | t
+(1 row)
+
+select v, v is null as "is null" from string_to_table('abc', ',') g(v);
+  v  | is null 
+-----+---------
+ abc | f
+(1 row)
+
+select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v);
+ v | is null 
+---+---------
+   | t
+(1 row)
+
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v);
+ v | is null 
+---+---------
+ 1 | f
+ 2 | f
+ 3 | f
+ 4 | f
+   | f
+ 6 | f
+(6 rows)
+
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v);
+ v | is null 
+---+---------
+ 1 | f
+ 2 | f
+ 3 | f
+ 4 | f
+   | t
+ 6 | f
+(6 rows)
+
+select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v);
+ v | is null 
+---+---------
+ 1 | f
+ 2 | f
+ 3 | f
+ 4 | f
+   | t
+ 6 | f
+(6 rows)
+
+select array_to_string(NULL::int4[], ',') IS NULL;
+ ?column? 
+----------
+ t
+(1 row)
+
+select array_to_string('{}'::int4[], ',');
+ array_to_string 
+-----------------
+ 
+(1 row)
+
+select array_to_string(array[1,2,3,4,NULL,6], ',');
+ array_to_string 
+-----------------
+ 1,2,3,4,6
+(1 row)
+
+select array_to_string(array[1,2,3,4,NULL,6], ',', '*');
+ array_to_string 
+-----------------
+ 1,2,3,4,*,6
+(1 row)
+
+select array_to_string(array[1,2,3,4,NULL,6], NULL);
+ array_to_string 
+-----------------
+ 
+(1 row)
+
+select array_to_string(array[1,2,3,4,NULL,6], ',', NULL);
+ array_to_string 
+-----------------
+ 1,2,3,4,6
+(1 row)
+
+select array_to_string(string_to_array('1|2|3', '|'), '|');
+ array_to_string 
+-----------------
+ 1|2|3
+(1 row)
+
+select array_length(array[1,2,3], 1);
+ array_length 
+--------------
+            3
+(1 row)
+
+select array_length(array[[1,2,3], [4,5,6]], 0);
+ array_length 
+--------------
+             
+(1 row)
+
+select array_length(array[[1,2,3], [4,5,6]], 1);
+ array_length 
+--------------
+            2
+(1 row)
+
+select array_length(array[[1,2,3], [4,5,6]], 2);
+ array_length 
+--------------
+            3
+(1 row)
+
+select array_length(array[[1,2,3], [4,5,6]], 3);
+ array_length 
+--------------
+             
+(1 row)
+
+select cardinality(NULL::int[]);
+ cardinality 
+-------------
+            
+(1 row)
+
+select cardinality('{}'::int[]);
+ cardinality 
+-------------
+           0
+(1 row)
+
+select cardinality(array[1,2,3]);
+ cardinality 
+-------------
+           3
+(1 row)
+
+select cardinality('[2:4]={5,6,7}'::int[]);
+ cardinality 
+-------------
+           3
+(1 row)
+
+select cardinality('{{1,2}}'::int[]);
+ cardinality 
+-------------
+           2
+(1 row)
+
+select cardinality('{{1,2},{3,4},{5,6}}'::int[]);
+ cardinality 
+-------------
+           6
+(1 row)
+
+select cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[]);
+ cardinality 
+-------------
+           8
+(1 row)
+
+select array_agg(unique1) from tenk1 where unique1 < -15;
+ array_agg 
+-----------
+ 
+(1 row)
+
+-- array_agg(anyarray)
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar);
+   array_agg   
+---------------
+ {{1,2},{3,4}}
+(1 row)
+
+select array_agg(ar)
+  from (select array_agg(array[i, i+1, i-1])
+        from generate_series(1,2) a(i)) b(ar);
+      array_agg      
+---------------------
+ {{{1,2,0},{2,3,1}}}
+(1 row)
+
+select array_agg(array[i+1.2, i+1.3, i+1.4]) from generate_series(1,3) g(i);
+                  array_agg                  
+---------------------------------------------
+ {{2.2,2.3,2.4},{3.2,3.3,3.4},{4.2,4.3,4.4}}
+(1 row)
+
+select array_agg(array['Hello', i::text]) from generate_series(9,11) g(i);
+             array_agg             
+-----------------------------------
+ {{Hello,9},{Hello,10},{Hello,11}}
+(1 row)
+
+select array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i);
+              array_agg               
+--------------------------------------
+ {{1,1,2},{2,2,3},{3,NULL,4},{4,4,5}}
+(1 row)
+
+-- errors
+select array_agg('{}'::int[]) from generate_series(1,2);
+ERROR:  cannot accumulate empty arrays
+select array_agg(null::int[]) from generate_series(1,2);
+ERROR:  cannot accumulate null arrays
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3}'::int[])) v(ar);
+ERROR:  cannot accumulate arrays of different dimensionality
+select * from unnest(array[1,2,3]);
+ unnest 
+--------
+      1
+      2
+      3
+(3 rows)
+
+-- array(select array-value ...)
+select array(select array[i,i/2] from generate_series(1,5) i);
+              array              
+---------------------------------
+ {{1,0},{2,1},{3,1},{4,2},{5,2}}
+(1 row)
+
+select array(select array['Hello', i::text] from generate_series(9,11) i);
+               array               
+-----------------------------------
+ {{Hello,9},{Hello,10},{Hello,11}}
+(1 row)
+
+-- Insert/update on a column that is array of composite
+create temp table t1 (f1 int8_tbl[]);
+-- Check that arrays of composites are safely detoasted when needed
+create temp table src (f1 text);
+insert into src
+  select string_agg(random()::text,'') from generate_series(1,10000);
+create temp table dest (f1 textandtext[]);
+drop table src;
+drop table dest;
+-- trim_array
+SELECT arr, trim_array(arr, 2)
+FROM
+(VALUES ('{1,2,3,4,5,6}'::bigint[]),
+        ('{1,2}'),
+        ('[10:16]={1,2,3,4,5,6,7}'),
+        ('[-15:-10]={1,2,3,4,5,6}'),
+        ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr);
+              arr              |   trim_array    
+-------------------------------+-----------------
+ {1,2,3,4,5,6}                 | {1,2,3,4}
+ {1,2}                         | {}
+ [10:16]={1,2,3,4,5,6,7}       | {1,2,3,4,5}
+ [-15:-10]={1,2,3,4,5,6}       | {1,2,3,4}
+ {{1,10},{2,20},{3,30},{4,40}} | {{1,10},{2,20}}
+(5 rows)
+
+SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
+ERROR:  number of elements to trim must be between 0 and 3
+SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail
+ERROR:  number of elements to trim must be between 0 and 3

+ 207 - 0
yql/essentials/tests/postgresql/cases/arrays.sql

@@ -0,0 +1,207 @@
+--
+-- ARRAYS
+--
+CREATE TABLE arrtest (
+	a 			int2[],
+	b 			int4[][][],
+	c 			name[],
+	d			text[][],
+	e 			float8[],
+	f			char(5)[],
+	g			varchar(5)[]
+);
+-- test mixed slice/scalar subscripting
+select '{{1,2,3},{4,5,6},{7,8,9}}'::int[];
+select '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[];
+-- test slices with empty lower and/or upper index
+CREATE TEMP TABLE arrtest_s (
+  a       int2[],
+  b       int2[][]
+);
+INSERT INTO arrtest_s VALUES(NULL, NULL);
+--
+-- test array extension
+--
+CREATE TEMP TABLE arrtest1 (i int[], t text[]);
+--
+-- array expressions and operators
+--
+-- table creation and INSERTs
+CREATE TEMP TABLE arrtest2 (i integer ARRAY[4], f float8[], n numeric[], t text[], d timestamp[]);
+-- some more test data
+CREATE TEMP TABLE arrtest_f (f0 int, f1 text, f2 float8);
+insert into arrtest_f values(1,'cat1',1.21);
+insert into arrtest_f values(2,'cat1',1.24);
+insert into arrtest_f values(3,'cat1',1.18);
+insert into arrtest_f values(4,'cat1',1.26);
+insert into arrtest_f values(5,'cat1',1.15);
+insert into arrtest_f values(6,'cat2',1.15);
+insert into arrtest_f values(7,'cat2',1.26);
+insert into arrtest_f values(8,'cat2',1.32);
+insert into arrtest_f values(9,'cat2',1.30);
+CREATE TEMP TABLE arrtest_i (f0 int, f1 text, f2 int);
+insert into arrtest_i values(1,'cat1',21);
+insert into arrtest_i values(2,'cat1',24);
+insert into arrtest_i values(3,'cat1',18);
+insert into arrtest_i values(4,'cat1',26);
+insert into arrtest_i values(5,'cat1',15);
+insert into arrtest_i values(6,'cat2',15);
+insert into arrtest_i values(7,'cat2',26);
+insert into arrtest_i values(8,'cat2',32);
+insert into arrtest_i values(9,'cat2',30);
+SELECT ARRAY[[[[[['hello'],['world']]]]]];
+SELECT ARRAY[ARRAY['hello'],ARRAY['world']];
+-- with nulls
+SELECT '{1,null,3}'::int[];
+SELECT ARRAY[1,NULL,3];
+SELECT NOT ARRAY[1.1,1.2,1.3] = ARRAY[1.1,1.2,1.3] AS "FALSE";
+-- array casts
+SELECT ARRAY[1,2,3]::text[]::int[]::float8[] AS "{1,2,3}";
+SELECT pg_typeof(ARRAY[1,2,3]::text[]::int[]::float8[]) AS "double precision[]";
+SELECT ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[] AS "{{a,bc},{def,hijk}}";
+SELECT pg_typeof(ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[]) AS "character varying[]";
+SELECT CAST(ARRAY[[[[[['a','bb','ccc']]]]]] as text[]) as "{{{{{{a,bb,ccc}}}}}}";
+SELECT NULL::text[]::int[] AS "NULL";
+-- scalar op any/all (array)
+select 33 = any ('{1,2,3}');
+select 33 = any ('{1,2,33}');
+select 33 = all ('{1,2,33}');
+select 33 >= all ('{1,2,33}');
+-- boundary cases
+select null::int >= all ('{1,2,33}');
+select null::int >= all ('{}');
+select null::int >= any ('{}');
+-- cross-datatype
+select 33.4 = any (array[1,2,3]);
+select 33.4 > all (array[1,2,3]);
+-- nulls
+select 33 = any (null::int[]);
+select null::int = any ('{1,2,3}');
+select 33 = any ('{1,null,3}');
+select 33 = any ('{1,null,33}');
+select 33 = all (null::int[]);
+select null::int = all ('{1,2,3}');
+select 33 = all ('{1,null,3}');
+select 33 = all ('{33,null,33}');
+-- nulls later in the bitmap
+SELECT -1 != ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1,1000) g(i)));
+-- test indexes on arrays
+create temp table arr_tbl (f1 int[] unique);
+-- test ON CONFLICT DO UPDATE with arrays
+create temp table arr_pk_tbl (pk int4 primary key, f1 int[]);
+-- test [not] (like|ilike) (any|all) (...)
+select 'foo' like any (array['%a', '%o']); -- t
+select 'foo' like any (array['%a', '%b']); -- f
+select 'foo' like all (array['f%', '%o']); -- t
+select 'foo' like all (array['f%', '%b']); -- f
+select 'foo' not like any (array['%a', '%b']); -- t
+select 'foo' not like all (array['%a', '%o']); -- f
+select 'foo' ilike any (array['%A', '%O']); -- t
+select 'foo' ilike all (array['F%', '%O']); -- t
+--
+-- General array parser tests
+--
+-- none of the following should be accepted
+select '{{1,{2}},{2,3}}'::text[];
+select '{{},{}}'::text[];
+select E'{{1,2},\\{2,3}}'::text[];
+select '{{"1 2" x},{3}}'::text[];
+select '{}}'::text[];
+select '{ }}'::text[];
+-- none of the above should be accepted
+-- all of the following should be accepted
+select '{}'::text[];
+select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[];
+select '{ { "," } , { 3 } }'::text[];
+select '  {   {  "  0 second  "   ,  0 second  }   }'::text[];
+select '[0:1]={1.1,2.2}'::float8[];
+-- all of the above should be accepted
+-- tests for array aggregates
+CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]);
+create table comptable (c1 comptype, c2 comptype[]);
+drop table comptable;
+select string_to_array('1|2|3', '|');
+select string_to_array('1|2|3|', '|');
+select string_to_array('1||2|3||', '||');
+select string_to_array('1|2|3', '');
+select string_to_array('', '|');
+select string_to_array('1|2|3', NULL);
+select string_to_array(NULL, '|') IS NULL;
+select string_to_array('abc', '');
+select string_to_array('abc', '', 'abc');
+select string_to_array('abc', ',');
+select string_to_array('abc', ',', 'abc');
+select string_to_array('1,2,3,4,,6', ',');
+select string_to_array('1,2,3,4,,6', ',', '');
+select string_to_array('1,2,3,4,*,6', ',', '*');
+select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v);
+select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v);
+select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v);
+select v, v is null as "is null" from string_to_table('1|2|3', '') g(v);
+select v, v is null as "is null" from string_to_table('', '|') g(v);
+select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v);
+select v, v is null as "is null" from string_to_table(NULL, '|') g(v);
+select v, v is null as "is null" from string_to_table('abc', '') g(v);
+select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v);
+select v, v is null as "is null" from string_to_table('abc', ',') g(v);
+select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v);
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v);
+select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v);
+select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v);
+select array_to_string(NULL::int4[], ',') IS NULL;
+select array_to_string('{}'::int4[], ',');
+select array_to_string(array[1,2,3,4,NULL,6], ',');
+select array_to_string(array[1,2,3,4,NULL,6], ',', '*');
+select array_to_string(array[1,2,3,4,NULL,6], NULL);
+select array_to_string(array[1,2,3,4,NULL,6], ',', NULL);
+select array_to_string(string_to_array('1|2|3', '|'), '|');
+select array_length(array[1,2,3], 1);
+select array_length(array[[1,2,3], [4,5,6]], 0);
+select array_length(array[[1,2,3], [4,5,6]], 1);
+select array_length(array[[1,2,3], [4,5,6]], 2);
+select array_length(array[[1,2,3], [4,5,6]], 3);
+select cardinality(NULL::int[]);
+select cardinality('{}'::int[]);
+select cardinality(array[1,2,3]);
+select cardinality('[2:4]={5,6,7}'::int[]);
+select cardinality('{{1,2}}'::int[]);
+select cardinality('{{1,2},{3,4},{5,6}}'::int[]);
+select cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[]);
+select array_agg(unique1) from tenk1 where unique1 < -15;
+-- array_agg(anyarray)
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar);
+select array_agg(ar)
+  from (select array_agg(array[i, i+1, i-1])
+        from generate_series(1,2) a(i)) b(ar);
+select array_agg(array[i+1.2, i+1.3, i+1.4]) from generate_series(1,3) g(i);
+select array_agg(array['Hello', i::text]) from generate_series(9,11) g(i);
+select array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i);
+-- errors
+select array_agg('{}'::int[]) from generate_series(1,2);
+select array_agg(null::int[]) from generate_series(1,2);
+select array_agg(ar)
+  from (values ('{1,2}'::int[]), ('{3}'::int[])) v(ar);
+select * from unnest(array[1,2,3]);
+-- array(select array-value ...)
+select array(select array[i,i/2] from generate_series(1,5) i);
+select array(select array['Hello', i::text] from generate_series(9,11) i);
+-- Insert/update on a column that is array of composite
+create temp table t1 (f1 int8_tbl[]);
+-- Check that arrays of composites are safely detoasted when needed
+create temp table src (f1 text);
+insert into src
+  select string_agg(random()::text,'') from generate_series(1,10000);
+create temp table dest (f1 textandtext[]);
+drop table src;
+drop table dest;
+-- trim_array
+SELECT arr, trim_array(arr, 2)
+FROM
+(VALUES ('{1,2,3,4,5,6}'::bigint[]),
+        ('{1,2}'),
+        ('[10:16]={1,2,3,4,5,6,7}'),
+        ('[-15:-10]={1,2,3,4,5,6}'),
+        ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr);
+SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
+SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail

Some files were not shown because too many files changed in this diff