You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2025/10/16 09:09:34 UTC

(ignite-3) branch ignite-26698 created (now 66e2bcd2615)

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a change to branch ignite-26698
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


      at 66e2bcd2615 wip

This branch includes the following new commits:

     new 66e2bcd2615 wip

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(ignite-3) 01/01: wip

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-26698
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 66e2bcd26159d931dd2153a41a1a4a49a22631eb
Author: amashenkov <am...@apache.org>
AuthorDate: Thu Oct 16 12:09:24 2025 +0300

    wip
---
 .../internal/sql/engine/ItFloatingPointTest.java   |  3 +++
 .../sql/engine/rel/agg/MapReduceAggregates.java    | 23 +++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItFloatingPointTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItFloatingPointTest.java
index d56062242e4..668bc878898 100644
--- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItFloatingPointTest.java
+++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItFloatingPointTest.java
@@ -447,6 +447,9 @@ public class ItFloatingPointTest extends BaseSqlMultiStatementTest {
         assertQuery("SELECT MIN(fn), MIN(dn) FROM test").returns(Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY).check();
         assertQuery("SELECT MAX(fn), MAX(dn) FROM test").returns(Float.NaN, Double.NaN).check();
         assertQuery("SELECT AVG(fn), AVG(dn) FROM test").returns(Double.NaN, Double.NaN).check();
+
+        assertQuery(node(1), "SELECT AVG(f), AVG(d) FROM test").returns(Double.NaN, Double.NaN).check();
+        assertQuery(node(1), "SELECT AVG(fn), AVG(dn) FROM test").returns(Double.NaN, Double.NaN).check();
     }
 
     @Test
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/agg/MapReduceAggregates.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/agg/MapReduceAggregates.java
index a2b430c0b2f..91552eb35b3 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/agg/MapReduceAggregates.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/agg/MapReduceAggregates.java
@@ -658,19 +658,24 @@ public class MapReduceAggregates {
 
             numeratorRef = rexBuilder.ensureType(mapSum0.type, numeratorRef, true);
 
-            RelDataType resultType = typeFactory.decimalOf(call.type);
+            RelDataType resultType = typeSystem.deriveAvgAggType(typeFactory, call.getType());
 
-            // Return correct decimal type with correct scale and precision.
-            int precision = resultType.getPrecision(); // not used.
-            int scale = resultType.getScale();
+            RexNode sumDivCnt;
+            if (SqlTypeUtil.isExactNumeric(resultType)) {
+                // Return correct decimal type with correct scale and precision.
+                int precision = resultType.getPrecision(); // not used.
+                int scale = resultType.getScale();
 
-            RexLiteral p = rexBuilder.makeExactLiteral(BigDecimal.valueOf(precision), tf.createSqlType(SqlTypeName.INTEGER));
-            RexLiteral s = rexBuilder.makeExactLiteral(BigDecimal.valueOf(scale), tf.createSqlType(SqlTypeName.INTEGER));
+                RexLiteral p = rexBuilder.makeExactLiteral(BigDecimal.valueOf(precision), tf.createSqlType(SqlTypeName.INTEGER));
+                RexLiteral s = rexBuilder.makeExactLiteral(BigDecimal.valueOf(scale), tf.createSqlType(SqlTypeName.INTEGER));
 
-            RexNode sumDivCnt = rexBuilder.makeCall(IgniteSqlOperatorTable.DECIMAL_DIVIDE, numeratorRef, denominatorRef, p, s);
+                sumDivCnt = rexBuilder.makeCall(IgniteSqlOperatorTable.DECIMAL_DIVIDE, numeratorRef, denominatorRef, p, s);
 
-            if (call.getType().getSqlTypeName() != SqlTypeName.DECIMAL) {
-                sumDivCnt = rexBuilder.makeCast(call.getType(), sumDivCnt, false, false);
+                if (call.getType().getSqlTypeName() != SqlTypeName.DECIMAL) {
+                    sumDivCnt = rexBuilder.makeCast(call.getType(), sumDivCnt, false, false);
+                }
+            } else {
+                sumDivCnt = rexBuilder.makeCall(IgniteSqlOperatorTable.DIVIDE, numeratorRef, denominatorRef);
             }
 
             if (canBeNull) {