ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [50/50] [abbrv] incubator-ignite git commit: ignite-gg9499 - avg fixes
Date Mon, 26 Jan 2015 08:18:55 GMT
ignite-gg9499 - avg fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/eda4dd0e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/eda4dd0e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/eda4dd0e

Branch: refs/heads/ignite-gg9499
Commit: eda4dd0e04f4825bb9ae6f556edc74c38dcb2d04
Parents: bdf988e
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Mon Jan 26 00:22:08 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Mon Jan 26 00:22:08 2015 +0300

----------------------------------------------------------------------
 .../processors/query/h2/sql/GridSqlQuerySplitter.java       | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eda4dd0e/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
b/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
index 4251451..b6e6f33 100644
--- a/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -11,7 +11,6 @@ package org.gridgain.grid.kernal.processors.query.h2.sql;
 
 import org.apache.ignite.*;
 import org.gridgain.grid.kernal.processors.cache.query.*;
-import org.gridgain.grid.util.typedef.*;
 
 import java.sql.*;
 import java.util.*;
@@ -51,6 +50,7 @@ public class GridSqlQuerySplitter {
      * @return Two step query.
      */
     public static GridCacheTwoStepQuery split(Connection conn, String query, Object[] params)
{
+        // TODO possibly get column types from query.
         GridSqlSelect srcQry = GridSqlQueryParser.parse(conn, query);
 
         if (srcQry.groups().isEmpty()) { // Simple case.
@@ -127,7 +127,7 @@ public class GridSqlQuerySplitter {
             String mapAggAlias = columnName(idx);
 
             switch (agg.type()) {
-                case AVG: // SUM( AVG(x)*COUNT(x) )/SUM( COUNT(x) ).
+                case AVG: // SUM( AVG(CAST(x AS DECIMAL))*COUNT(x) )/SUM( COUNT(x) ).
                     //-- COUNT(x) map
                     GridSqlElement cntMapAgg = aggregate(agg.distinct(), COUNT).addChild(agg.child());
 
@@ -139,8 +139,9 @@ public class GridSqlQuerySplitter {
 
                     mapSelect.add(cntMapAgg);
 
-                    //-- AVG(x) map
-                    mapAgg = aggregate(agg.distinct(), AVG).addChild(agg.child()); // Add
function argument.
+                    //-- AVG(CAST(x AS DECIMAL)) map
+                    mapAgg = aggregate(agg.distinct(), AVG).addChild( // Add function argument.
+                        function(CAST).setCastType("DECIMAL").addChild(agg.child()));
 
                     //-- SUM( AVG(x)*COUNT(x) )/SUM( COUNT(x) ) reduce
                     GridSqlElement sumUpRdc = aggregate(false, SUM).addChild(


Mime
View raw message