--
-- INT2
--
CREATE TABLE INT2_TBL(f1 int2);
INSERT INTO INT2_TBL(f1) VALUES ('0 ');
INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
INSERT INTO INT2_TBL(f1) VALUES (' -1234');
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: "34.5"
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
^
-- largest and smallest values
INSERT INTO INT2_TBL(f1) VALUES ('32767');
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
-- bad input values -- should give errors
INSERT INTO INT2_TBL(f1) VALUES ('100000');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
-- bad input values -- should give errors
^
-stdin-::1:1: Fatal: ERROR: value "100000" is out of range for type smallint
-- bad input values -- should give errors
^
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: "asdf"
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
^
INSERT INTO INT2_TBL(f1) VALUES (' ');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES (' ');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: " "
INSERT INTO INT2_TBL(f1) VALUES (' ');
^
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: "- 1234"
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
^
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: "4 444"
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
^
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: "123 dt"
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
^
INSERT INTO INT2_TBL(f1) VALUES ('');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtFill!
INSERT INTO INT2_TBL(f1) VALUES ('');
^
-stdin-::1:1: Fatal: ERROR: invalid input syntax for type smallint: ""
INSERT INTO INT2_TBL(f1) VALUES ('');
^
SELECT * FROM INT2_TBL;
SELECT * FROM INT2_TBL AS f(a, b);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT * FROM INT2_TBL AS f(a, b);
^
-stdin-::1:1: Error: Wrong number of columns, expected: 1, got: 2
SELECT * FROM INT2_TBL AS f(a, b);
^
SELECT * FROM (TABLE int2_tbl) AS s (a, b);
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int2_tbl
SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
-- positive odds
SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
-- any evens
SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtMap!
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
^
-stdin-::1:1: Fatal: ERROR: smallint out of range
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
^
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i
WHERE abs(f1) < 16384;
SELECT i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtMap!
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
^
-stdin-::1:1: Fatal: ERROR: smallint out of range
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
^
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i
WHERE f1 < 32766;
SELECT i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: YtMap!
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
^
-stdin-::1:1: Fatal: ERROR: smallint out of range
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
^
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i
WHERE f1 > -32767;
SELECT i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
-- corner cases
SELECT (-1::int2<<15)::text;
SELECT ((-1::int2<<15)+1::int2)::text;
-- check sane handling of INT16_MIN overflow cases
SELECT (-32768)::int2 * (-1)::int2;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
-- check sane handling of INT16_MIN overflow cases
^
-stdin-::1:1: Fatal: ERROR: smallint out of range
-- check sane handling of INT16_MIN overflow cases
^
SELECT (-32768)::int2 / (-1)::int2;
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT (-32768)::int2 / (-1)::int2;
^
-stdin-::1:1: Fatal: ERROR: smallint out of range
SELECT (-32768)::int2 / (-1)::int2;
^
SELECT (-32768)::int2 % (-1)::int2;
-- check rounding when casting from float
SELECT x, x::int2 AS int2_value
FROM (VALUES (-2.5::float8),
(-1.5::float8),
(-0.5::float8),
(0.0::float8),
(0.5::float8),
(1.5::float8),
(2.5::float8)) t(x);
-- check rounding when casting from numeric
SELECT x, x::int2 AS int2_value
FROM (VALUES (-2.5::numeric),
(-1.5::numeric),
(-0.5::numeric),
(0.0::numeric),
(0.5::numeric),
(1.5::numeric),
(2.5::numeric)) t(x);