From 102f6f66a72450234ba953f9c5a759353ea89221 Mon Sep 17 00:00:00 2001 From: RogerYK Date: Fri, 28 Jan 2022 11:20:34 +0800 Subject: [PATCH] Add test --- .../01060_substring_negative_size.reference | 33 ------ .../01060_substring_negative_size.sql | 110 +++--------------- ..._arraySlice_negative_offset_size.reference | 15 +++ .../02185_arraySlice_negative_offset_size.sql | 25 ++++ ...5_substring_negative_offset_size.reference | 31 +++++ .../02185_substring_negative_offset_size.sql | 48 ++++++++ 6 files changed, 134 insertions(+), 128 deletions(-) create mode 100644 tests/queries/0_stateless/02185_arraySlice_negative_offset_size.reference create mode 100644 tests/queries/0_stateless/02185_arraySlice_negative_offset_size.sql create mode 100644 tests/queries/0_stateless/02185_substring_negative_offset_size.reference create mode 100644 tests/queries/0_stateless/02185_substring_negative_offset_size.sql diff --git a/tests/queries/0_stateless/01060_substring_negative_size.reference b/tests/queries/0_stateless/01060_substring_negative_size.reference index 3e219d20f02..b25696dc7d6 100644 --- a/tests/queries/0_stateless/01060_substring_negative_size.reference +++ b/tests/queries/0_stateless/01060_substring_negative_size.reference @@ -2,26 +2,11 @@ bcdef bcdef bcdef bcdef -bcdef -bcdef - - - -g -g -g - bcdef bcdef bcdef bcdef -bcdef - - - -g -g -g - bcdef 23456 @@ -31,15 +16,6 @@ bcdef 2345 bcdef 345 -- - - - -6 - - - - - bcdef 23456 @@ -49,12 +25,3 @@ bcdef 2345 bcdef 345 -- - - - -6 - - - - diff --git a/tests/queries/0_stateless/01060_substring_negative_size.sql b/tests/queries/0_stateless/01060_substring_negative_size.sql index 321644db2fa..23cab14a6e0 100644 --- a/tests/queries/0_stateless/01060_substring_negative_size.sql +++ b/tests/queries/0_stateless/01060_substring_negative_size.sql @@ -2,115 +2,35 @@ select substring('abcdefgh', 2, -2); select substring('abcdefgh', materialize(2), -2); select substring('abcdefgh', 2, materialize(-2)); select substring('abcdefgh', materialize(2), materialize(-2)); -select substring(materialize('abcdefgh'), 2, -2); -select substring(materialize('abcdefgh'), materialize(2), materialize(-2)); - -select substring('abcdefgh', -2, -2); -select substring(materialize('abcdefgh'), -2, -2); -select substring(materialize('abcdefgh'), materialize(-2), materialize(-2)); - -select substring('abcdefgh', -2, -1); -select substring(materialize('abcdefgh'), -2, -1); -select substring(materialize('abcdefgh'), materialize(-2), materialize(-1)); select '-'; select substring(cast('abcdefgh' as FixedString(8)), 2, -2); select substring(cast('abcdefgh' as FixedString(8)), materialize(2), -2); select substring(cast('abcdefgh' as FixedString(8)), 2, materialize(-2)); -select substring(materialize(cast('abcdefgh' as FixedString(8))), 2, -2); select substring(cast('abcdefgh' as FixedString(8)), materialize(2), materialize(-2)); -select substring(cast('abcdefgh' as FixedString(8)), -2, -2); -select substring(materialize(cast('abcdefgh' as FixedString(8))), -2, -2); -select substring(materialize(cast('abcdefgh' as FixedString(8))), materialize(-2), materialize(-2)); +select '-'; -select substring(cast('abcdefgh' as FixedString(8)), -2, -1); -select substring(materialize(cast('abcdefgh' as FixedString(8))), -2, -1); -select substring(materialize(cast('abcdefgh' as FixedString(8))), materialize(-2), materialize(-1)); +drop table if exists t; +create table t (s String, l Int8, r Int8) engine = Memory; +insert into t values ('abcdefgh', 2, -2), ('12345678', 3, -3); + +select substring(s, 2, -2) from t; +select substring(s, l, -2) from t; +select substring(s, 2, r) from t; +select substring(s, l, r) from t; select '-'; drop table if exists t; -create table t -( - s String, - l Int8, - r Int8 -) engine = Memory; -insert into t(s, l, r) -values ('abcdefgh', 2, -2),('12345678', 3, -3); +create table t (s FixedString(8), l Int8, r Int8) engine = Memory; +insert into t values ('abcdefgh', 2, -2), ('12345678', 3, -3); -select substring(s, 2, -2) -from t; -select substring(s, l, -2) -from t; -select substring(s, 2, r) -from t; -select substring(s, l, r) -from t; - -select '-'; +select substring(s, 2, -2) from t; +select substring(s, l, -2) from t; +select substring(s, 2, r) from t; +select substring(s, l, r) from t; drop table if exists t; -create table t -( - s String, - l Int8, - r Int8 -) engine = Memory; -insert into t -values ('abcdefgh', -2, -2),('12345678', -3, -3); -select substring(s, -2, -2) -from t; -select substring(s, l, -2) -from t; -select substring(s, -2, r) -from t; -select substring(s, l, r) -from t; - -select '-'; - -drop table if exists t; -create table t -( - s FixedString(8), - l Int8, - r Int8 -) engine = Memory; -insert into t -values ('abcdefgh', 2, -2),('12345678', 3, -3); - -select substring(s, 2, -2) -from t; -select substring(s, l, -2) -from t; -select substring(s, 2, r) -from t; -select substring(s, l, r) -from t; - -select '-'; - -drop table if exists t; -create table t -( - s FixedString(8), - l Int8, - r Int8 -) engine = Memory; -insert into t -values ('abcdefgh', -2, -2),('12345678', -3, -3); - -select substring(s, -2, -2) -from t; -select substring(s, l, -2) -from t; -select substring(s, -2, r) -from t; -select substring(s, l, r) -from t; - -drop table if exists t; diff --git a/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.reference b/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.reference new file mode 100644 index 00000000000..4e3701e4f86 --- /dev/null +++ b/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.reference @@ -0,0 +1,15 @@ +[] +[] +[] +[7] +[7] +[7] +- +[] +[] +[] +[6] +[] +[] +[] +[] diff --git a/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.sql b/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.sql new file mode 100644 index 00000000000..e7f9f3948d9 --- /dev/null +++ b/tests/queries/0_stateless/02185_arraySlice_negative_offset_size.sql @@ -0,0 +1,25 @@ +select arraySlice([1, 2, 3, 4, 5, 6, 7, 8], -2, -2); +select arraySlice(materialize([1, 2, 3, 4, 5, 6, 7, 8]), -2, -2); +select arraySlice(materialize([1, 2, 3, 4, 5, 6, 7, 8]), materialize(-2), materialize(-2)); + +select arraySlice([1, 2, 3, 4, 5, 6, 7, 8], -2, -1); +select arraySlice(materialize([1, 2, 3, 4, 5, 6, 7, 8]), -2, -1); +select arraySlice(materialize([1, 2, 3, 4, 5, 6, 7, 8]), materialize(-2), materialize(-1)); + +select '-'; +drop table if exists t; +create table t +( + s Array(Int), + l Int8, + r Int8 +) engine = Memory; + +insert into t values ([1, 2, 3, 4, 5, 6, 7, 8], -2, -2),([1, 2, 3, 4, 5, 6, 7, 8], -3, -3); + +select arraySlice(s, -2, -2) from t; +select arraySlice(s, l, -2) from t; +select arraySlice(s, -2, r) from t; +select arraySlice(s, l, r) from t; + +drop table if exists t; \ No newline at end of file diff --git a/tests/queries/0_stateless/02185_substring_negative_offset_size.reference b/tests/queries/0_stateless/02185_substring_negative_offset_size.reference new file mode 100644 index 00000000000..107f083a4d8 --- /dev/null +++ b/tests/queries/0_stateless/02185_substring_negative_offset_size.reference @@ -0,0 +1,31 @@ + + + +g +g +g +- + + + +g +g +g +- + + + +6 + + + + +- + + + +6 + + + + diff --git a/tests/queries/0_stateless/02185_substring_negative_offset_size.sql b/tests/queries/0_stateless/02185_substring_negative_offset_size.sql new file mode 100644 index 00000000000..715dff30369 --- /dev/null +++ b/tests/queries/0_stateless/02185_substring_negative_offset_size.sql @@ -0,0 +1,48 @@ +select substring('abcdefgh', -2, -2); +select substring(materialize('abcdefgh'), -2, -2); +select substring(materialize('abcdefgh'), materialize(-2), materialize(-2)); + +select substring('abcdefgh', -2, -1); +select substring(materialize('abcdefgh'), -2, -1); +select substring(materialize('abcdefgh'), materialize(-2), materialize(-1)); + +select '-'; +select substring(cast('abcdefgh' as FixedString(8)), -2, -2); +select substring(materialize(cast('abcdefgh' as FixedString(8))), -2, -2); +select substring(materialize(cast('abcdefgh' as FixedString(8))), materialize(-2), materialize(-2)); + +select substring(cast('abcdefgh' as FixedString(8)), -2, -1); +select substring(materialize(cast('abcdefgh' as FixedString(8))), -2, -1); +select substring(materialize(cast('abcdefgh' as FixedString(8))), materialize(-2), materialize(-1)); + +select '-'; +drop table if exists t; +create table t +( + s String, + l Int8, + r Int8 +) engine = Memory; + +insert into t values ('abcdefgh', -2, -2),('12345678', -3, -3); + +select substring(s, -2, -2) from t; +select substring(s, l, -2) from t; +select substring(s, -2, r) from t; +select substring(s, l, r) from t; + +select '-'; +drop table if exists t; +create table t( + s FixedString(8), + l Int8, + r Int8 +) engine = Memory; +insert into t values ('abcdefgh', -2, -2),('12345678', -3, -3); + +select substring(s, -2, -2) from t; +select substring(s, l, -2) from t; +select substring(s, -2, r) from t; +select substring(s, l, r) from t; + +drop table if exists t;