From b55c2df393eadbf7b3d9ff48aa985616928ebb63 Mon Sep 17 00:00:00 2001 From: Arthur Passos Date: Wed, 25 Sep 2024 17:06:44 -0300 Subject: [PATCH] naive fix --- .../AggregateFunctionsArithmericOperationsPass.cpp | 4 ++++ .../03236_test_zero_field_decimal.reference | 1 + .../0_stateless/03236_test_zero_field_decimal.sql | 10 ++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/queries/0_stateless/03236_test_zero_field_decimal.reference create mode 100644 tests/queries/0_stateless/03236_test_zero_field_decimal.sql diff --git a/src/Analyzer/Passes/AggregateFunctionsArithmericOperationsPass.cpp b/src/Analyzer/Passes/AggregateFunctionsArithmericOperationsPass.cpp index 1c3b7aef673..b191608cf8a 100644 --- a/src/Analyzer/Passes/AggregateFunctionsArithmericOperationsPass.cpp +++ b/src/Analyzer/Passes/AggregateFunctionsArithmericOperationsPass.cpp @@ -40,6 +40,10 @@ Field zeroField(const Field & value) case Field::Types::Int128: return static_cast(0); case Field::Types::UInt256: return static_cast(0); case Field::Types::Int256: return static_cast(0); + case Field::Types::Decimal32: return static_cast(0); + case Field::Types::Decimal64: return static_cast(0); + case Field::Types::Decimal128: return static_cast(0); + case Field::Types::Decimal256: return static_cast(0); default: break; } diff --git a/tests/queries/0_stateless/03236_test_zero_field_decimal.reference b/tests/queries/0_stateless/03236_test_zero_field_decimal.reference new file mode 100644 index 00000000000..3c54d5e2868 --- /dev/null +++ b/tests/queries/0_stateless/03236_test_zero_field_decimal.reference @@ -0,0 +1 @@ +0.131 diff --git a/tests/queries/0_stateless/03236_test_zero_field_decimal.sql b/tests/queries/0_stateless/03236_test_zero_field_decimal.sql new file mode 100644 index 00000000000..047b255b7ca --- /dev/null +++ b/tests/queries/0_stateless/03236_test_zero_field_decimal.sql @@ -0,0 +1,10 @@ +-- Tags: no-parallel + +DROP TABLE IF EXISTS users_03236_zero; +CREATE TABLE users_03236_zero (uid Int16, name String, num Int16) ENGINE=Memory; + +INSERT INTO users_03236_zero VALUES (1231, 'John', 33); +INSERT INTO users_03236_zero VALUES (6666, 'John', 48); +INSERT INTO users_03236_zero VALUES (8888, 'Alice', 50); + +select sum(num/toDecimal256(1000, 18)) from users_03236_zero;