tledkov-gridgain commented on a change in pull request #9148:
URL: https://github.com/apache/ignite/pull/9148#discussion_r702955872



##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/BaseAggregateTest.java
##########
@@ -512,6 +513,98 @@ public void sumOnDifferentRowsCount() throws 
IgniteCheckedException {
         }
     }
 
+    /** */
+    @Test
+    public void sumIntegerOverflow() {
+        ExecutionContext<Object[]> ctx = executionContext(F.first(nodes()), 
UUID.randomUUID(), 0);
+        IgniteTypeFactory tf = ctx.getTypeFactory();
+        RelDataType rowType = TypeUtils.createRowType(tf, int.class, 
int.class);
+        ScanNode<Object[]> scan = new ScanNode<>(ctx, rowType, Arrays.asList(
+            row(0, Integer.MAX_VALUE / 2),
+            row(0, Integer.MAX_VALUE / 2 + 11)
+        ));
+
+        AggregateCall call = AggregateCall.create(
+            SqlStdOperatorTable.SUM,
+            false,
+            false,
+            false,
+            ImmutableIntList.of(1),
+            -1,
+            RelCollations.EMPTY,
+            tf.createJavaType(BigDecimal.class),
+            null);
+
+        ImmutableList<ImmutableBitSet> grpSets = 
ImmutableList.of(ImmutableBitSet.of(0));
+
+        RelDataType aggRowType = TypeUtils.createRowType(tf, int.class);
+
+        SingleNode<Object[]> aggChain = createAggregateNodesChain(
+            ctx,
+            grpSets,
+            call,
+            rowType,
+            aggRowType,
+            rowFactory(),
+            scan
+        );
+
+        RootNode<Object[]> root = new RootNode<>(ctx, aggRowType);
+        root.register(aggChain);
+
+        assertTrue(root.hasNext());
+
+        Assert.assertArrayEquals(row(0, new 
BigDecimal(Integer.MAX_VALUE).add(new BigDecimal(10))), root.next());

Review comment:
       Fixed with plain sum of long. Also changed the type of the sum of 
INTEGER from DECIMAL to BIGINT (Long)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to