mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Function sumMap decimal fix
This commit is contained in:
parent
0de1535b23
commit
b84112a603
@ -115,7 +115,12 @@ public:
|
||||
"Values for {} are expected to be Numeric, Float or Decimal, passed type {}",
|
||||
getName(), value_type->getName()};
|
||||
|
||||
result_type = value_type_without_nullable->promoteNumericType();
|
||||
WhichDataType value_type_to_check(value_type);
|
||||
|
||||
if (value_type_to_check.isDecimal())
|
||||
result_type = value_type_without_nullable;
|
||||
else
|
||||
result_type = value_type_without_nullable->promoteNumericType();
|
||||
}
|
||||
|
||||
types.emplace_back(std::make_shared<DataTypeArray>(result_type));
|
||||
|
@ -22,3 +22,5 @@
|
||||
([1.01],[1])
|
||||
(['a','b'],[1,2])
|
||||
(['a','ab','abc'],[3,2,1])
|
||||
([1,2,3,4,5,6,7,8],[1.00000,2.00000,6.00000,8.00000,10.00000,12.00000,7.00000,8.00000])
|
||||
([1,2,3,4,5,6,7,8],[1.00000,2.00000,6.00000,8.00000,10.00000,12.00000,7.00000,8.00000])
|
||||
|
@ -38,3 +38,19 @@ select sumMap(val, cnt) from ( SELECT [ CAST(1.01, 'Decimal(10,2)') ] as val, [1
|
||||
|
||||
select sumMap(val, cnt) from ( SELECT [ CAST('a', 'FixedString(1)'), CAST('b', 'FixedString(1)' ) ] as val, [1, 2] as cnt );
|
||||
select sumMap(val, cnt) from ( SELECT [ CAST('abc', 'String'), CAST('ab', 'String'), CAST('a', 'String') ] as val, [1, 2, 3] as cnt );
|
||||
|
||||
DROP TABLE IF EXISTS sum_map_decimal;
|
||||
|
||||
CREATE TABLE sum_map_decimal(
|
||||
statusMap Nested(
|
||||
goal_id UInt16,
|
||||
revenue Decimal32(5)
|
||||
)
|
||||
) ENGINE = Log;
|
||||
|
||||
INSERT INTO sum_map_decimal VALUES ([1, 2, 3], [1.0, 2.0, 3.0]), ([3, 4, 5], [3.0, 4.0, 5.0]), ([4, 5, 6], [4.0, 5.0, 6.0]), ([6, 7, 8], [6.0, 7.0, 8.0]);
|
||||
|
||||
SELECT sumMap(statusMap.goal_id, statusMap.revenue) FROM sum_map_decimal;
|
||||
SELECT sumMapWithOverflow(statusMap.goal_id, statusMap.revenue) FROM sum_map_decimal;
|
||||
|
||||
DROP TABLE sum_map_decimal;
|
||||
|
Loading…
Reference in New Issue
Block a user