diff --git a/query/src/pipelines/transforms/group_by/aggregator_polymorphic_keys.rs b/query/src/pipelines/transforms/group_by/aggregator_polymorphic_keys.rs index 651f84ca7901..493fad7f6b28 100644 --- a/query/src/pipelines/transforms/group_by/aggregator_polymorphic_keys.rs +++ b/query/src/pipelines/transforms/group_by/aggregator_polymorphic_keys.rs @@ -97,7 +97,7 @@ pub trait PolymorphicKeysHelper { impl PolymorphicKeysHelper for HashMethodKeysU8 { type State = ShortFixedKeysAggregatorState; fn aggregate_state(&self) -> Self::State { - Self::State::create(u8::MAX as usize) + Self::State::create((u8::MAX as usize) + 1) } type ColumnBuilder = FixedKeysColumnBuilder; @@ -125,7 +125,7 @@ impl PolymorphicKeysHelper for HashMethodKeysU8 { impl PolymorphicKeysHelper for HashMethodKeysU16 { type State = ShortFixedKeysAggregatorState; fn aggregate_state(&self) -> Self::State { - Self::State::create(u16::MAX as usize) + Self::State::create((u16::MAX as usize) + 1) } type ColumnBuilder = FixedKeysColumnBuilder; diff --git a/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.result b/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.result new file mode 100644 index 000000000000..5285996c1756 --- /dev/null +++ b/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.result @@ -0,0 +1,23 @@ +0 +-1 +-127 +-128 +256 +127 +0 +-1 +-32768 +65535 +32766 +0 +-1 +-32768 +-32769 +65535 +0 +0 +-1 +-32768 +-32769 +65535 +0 diff --git a/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.sql b/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.sql new file mode 100644 index 000000000000..6b0bd509cf8f --- /dev/null +++ b/tests/suites/0_stateless/03_dml/03_0020_group_by_negative.sql @@ -0,0 +1,27 @@ +SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c HAVING c = 0; +SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c HAVING c = -1; +SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c HAVING c = -127; +SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c HAVING c = -128; +SELECT COUNT() FROM (SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c); +SELECT COUNT() FROM (SELECT (0 - number) :: Int8 AS c FROM numbers(256) GROUP BY c HAVING c > 0); + +SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c HAVING c = 0; +SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c HAVING c = -1; +SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c HAVING c = -32768; +SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c HAVING c = -32769; +SELECT COUNT() FROM (SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c); +SELECT COUNT() FROM (SELECT (0 - number) :: Int16 AS c FROM numbers(65535) GROUP BY c HAVING c > 0); + +SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c HAVING c = 0; +SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c HAVING c = -1; +SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c HAVING c = -32768; +SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c HAVING c = -32769; +SELECT COUNT() FROM (SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c); +SELECT COUNT() FROM (SELECT (0 - number) :: Int32 AS c FROM numbers(65535) GROUP BY c HAVING c > 0); + +SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c HAVING c = 0; +SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c HAVING c = -1; +SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c HAVING c = -32768; +SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c HAVING c = -32769; +SELECT COUNT() FROM (SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c); +SELECT COUNT() FROM (SELECT (0 - number) :: Int64 AS c FROM numbers(65535) GROUP BY c HAVING c > 0); diff --git a/tests/suites/0_stateless/11_data_type/11_0000_data_type_numeric.result b/tests/suites/0_stateless/11_data_type/11_0000_data_type_numeric.result index 83449c22c418..465fd352cb23 100644 --- a/tests/suites/0_stateless/11_data_type/11_0000_data_type_numeric.result +++ b/tests/suites/0_stateless/11_data_type/11_0000_data_type_numeric.result @@ -1,3 +1,4 @@ -1 255 +-1 127 255 -128 0 diff --git a/tools/fuzz/fuzz_targets/fuzz_parse_sql.rs b/tools/fuzz/fuzz_targets/fuzz_parse_sql.rs index 66046dfead3a..74db41a23b92 100644 --- a/tools/fuzz/fuzz_targets/fuzz_parse_sql.rs +++ b/tools/fuzz/fuzz_targets/fuzz_parse_sql.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use databend_query::sessions::Session; use databend_query::sessions::SessionType; use databend_query::sql::DfParser; use honggfuzz::fuzz;