DROP TABLE IF EXISTS cs1;
DROP TABLE IF EXISTS cs2;
DROP TABLE IF EXISTS cs3;
CREATE TABLE cs1 (d1 DECIMAL(38))engine=columnstore;
INSERT INTO cs1 VALUES (-12345678901234567890123456789012345678), (12345678901234567890123456789012345678),
(-99999999999999999999999999999999999998);
SELECT d1 FROM cs1;
SELECT CALSHOWPARTITIONS('cs1', 'd1');
SELECT CALSETTRACE(1);
SELECT d1 FROM cs1 WHERE d1 < -99999999999999999999999999999999999998;
SHOW WARNINGS;
SELECT d1 FROM cs1 WHERE d1 > -99999999999999999999999999999999999998;
SHOW WARNINGS;
SELECT d1 FROM cs1 WHERE d1 < -99999999999999999999999999999999999998 OR
d1 > 12345678901234567890123456789012345678;
SHOW WARNINGS;

CREATE TABLE cs2 (d1 DECIMAL(38,10))engine=columnstore;
INSERT INTO cs2 VALUES (-1234567890123456789012345678.9012345678), (1234567890123456789012345678.9012345678),
(-9999999999999999999999999999.9999999998);
SELECT d1 FROM cs2;
SELECT CALSHOWPARTITIONS('cs2', 'd1');
SELECT CALSETTRACE(1);
SELECT d1 FROM cs2 WHERE d1 < -9999999999999999999999999999.9999999998;
SHOW WARNINGS;
SELECT d1 FROM cs2 WHERE d1 > -9999999999999999999999999999.9999999998;
SHOW WARNINGS;
SELECT d1 FROM cs2 WHERE d1 < -9999999999999999999999999999.9999999998 OR
d1 > 1234567890123456789012345678.9012345678;
SHOW WARNINGS;

CREATE TABLE cs3 (d1 DECIMAL(38,38))engine=columnstore;
INSERT INTO cs3 VALUES (-0.12345678901234567890123456789012345678), (0.12345678901234567890123456789012345678),
(-0.99999999999999999999999999999999999998);
SELECT d1 FROM cs3;
SELECT CALSHOWPARTITIONS('cs3', 'd1');
SELECT CALSETTRACE(1);
SELECT d1 FROM cs3 WHERE d1 < -0.99999999999999999999999999999999999998;
SHOW WARNINGS;
SELECT d1 FROM cs3 WHERE d1 > -0.99999999999999999999999999999999999998;
SHOW WARNINGS;
SELECT d1 FROM cs3 WHERE d1 < -0.99999999999999999999999999999999999998 OR
d1 > 0.12345678901234567890123456789012345678;
SHOW WARNINGS;
