ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [5/5] incubator-ignite git commit: ignite-1142 - removed extra parsing for merge table columns with types
Date Wed, 29 Jul 2015 22:46:22 GMT
ignite-1142 - removed extra parsing for merge table columns with types


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

Branch: refs/heads/ignite-1142
Commit: d82df227f598989ca9a0dadbf0dbc7078b468bea
Parents: 5f96b5b
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Jul 30 01:45:45 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Jul 30 01:45:45 2015 +0300

----------------------------------------------------------------------
 .../cache/query/GridCacheSqlQuery.java          | 23 +++++
 .../processors/query/h2/sql/GridSqlElement.java |  5 ++
 .../query/h2/sql/GridSqlQueryParser.java        | 95 ++++++++++----------
 .../query/h2/sql/GridSqlQuerySplitter.java      | 54 +++++++++--
 .../processors/query/h2/sql/GridSqlType.java    |  8 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 23 +++--
 6 files changed, 142 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index 7a0e140..256fd7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -26,6 +26,7 @@ import org.apache.ignite.marshaller.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 
 import java.nio.*;
+import java.util.*;
 
 /**
  * Query.
@@ -52,6 +53,11 @@ public class GridCacheSqlQuery implements Message {
     /** */
     private byte[] paramsBytes;
 
+    /** */
+    @GridToStringInclude
+    @GridDirectTransient
+    private LinkedHashMap<String, ?> columns;
+
     /**
      * For {@link Message}.
      */
@@ -74,6 +80,23 @@ public class GridCacheSqlQuery implements Message {
     }
 
     /**
+     * @return Columns.
+     */
+    public LinkedHashMap<String, ?> columns() {
+        return columns;
+    }
+
+    /**
+     * @param columns Columns.
+     * @return {@code this}.
+     */
+    public GridCacheSqlQuery columns(LinkedHashMap<String, ?> columns) {
+        this.columns = columns;
+
+        return this;
+    }
+
+    /**
      * @return Alias.
      */
     public String alias() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
index e3c8c4b..0f98a33 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
@@ -113,4 +113,9 @@ public abstract class GridSqlElement implements Iterable<GridSqlElement>
{
     @Override public Iterator<GridSqlElement> iterator() {
         return children.iterator();
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return getSQL();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index 195fb28..a52f3b0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -204,12 +204,12 @@ public class GridSqlQueryParser {
                 res = new GridSqlSubquery(parse(qry));
             }
             else if (tbl instanceof FunctionTable)
-                res = parseExpression(FUNC_EXPR.get((FunctionTable)tbl));
+                res = parseExpression(FUNC_EXPR.get((FunctionTable)tbl), false);
             else if (tbl instanceof RangeTable) {
                 res = new GridSqlFunction(GridSqlFunctionType.SYSTEM_RANGE);
 
-                res.addChild(parseExpression(RANGE_MIN.get((RangeTable)tbl)));
-                res.addChild(parseExpression(RANGE_MAX.get((RangeTable)tbl)));
+                res.addChild(parseExpression(RANGE_MIN.get((RangeTable)tbl), false));
+                res.addChild(parseExpression(RANGE_MAX.get((RangeTable)tbl), false));
             }
             else
                 assert0(false, filter.getSelect().getSQL());
@@ -241,7 +241,7 @@ public class GridSqlQueryParser {
         res.distinct(select.isDistinct());
 
         Expression where = CONDITION.get(select);
-        res.where(parseExpression(where));
+        res.where(parseExpression(where, false));
 
         Set<TableFilter> allFilters = new HashSet<>(select.getTopFilters());
 
@@ -256,7 +256,7 @@ public class GridSqlQueryParser {
             GridSqlElement gridFilter = parseTable(filter);
 
             from = from == null ? gridFilter : new GridSqlJoin(from, gridFilter, filter.isJoinOuter(),
-                parseExpression(filter.getJoinCondition()));
+                parseExpression(filter.getJoinCondition(), false));
 
             allFilters.remove(filter);
 
@@ -271,7 +271,7 @@ public class GridSqlQueryParser {
         ArrayList<Expression> expressions = select.getExpressions();
 
         for (int i = 0; i < expressions.size(); i++)
-            res.addColumn(parseExpressionWithType(expressions.get(i)), i < select.getColumnCount());
+            res.addColumn(parseExpression(expressions.get(i), true), i < select.getColumnCount());
 
         int[] grpIdx = GROUP_INDEXES.get(select);
 
@@ -285,8 +285,8 @@ public class GridSqlQueryParser {
 
         processSortOrder(select.getSortOrder(), res);
 
-        res.limit(parseExpression(select.getLimit()));
-        res.offset(parseExpression(select.getOffset()));
+        res.limit(parseExpression(select.getLimit(), false));
+        res.offset(parseExpression(select.getOffset(), false));
 
         return res;
     }
@@ -345,8 +345,8 @@ public class GridSqlQueryParser {
 
         res.unionType(union.getUnionType());
 
-        res.limit(parseExpression(union.getLimit()));
-        res.offset(parseExpression(union.getOffset()));
+        res.limit(parseExpression(union.getLimit(), false));
+        res.offset(parseExpression(union.getOffset(), false));
 
         processSortOrder(UNION_SORT.get(union), res);
 
@@ -357,41 +357,32 @@ public class GridSqlQueryParser {
 
     /**
      * @param expression Expression.
+     * @param calcTypes Calculate types for all the expressions.
      * @return Parsed expression.
      */
-    private GridSqlElement parseExpression(@Nullable Expression expression) {
+    private GridSqlElement parseExpression(@Nullable Expression expression, boolean calcTypes)
{
         if (expression == null)
             return null;
 
         GridSqlElement res = (GridSqlElement)h2ObjToGridObj.get(expression);
 
         if (res == null) {
-            res = parseExpression0(expression);
+            res = parseExpression0(expression, calcTypes);
 
-            h2ObjToGridObj.put(expression, res);
-        }
+            if (calcTypes) {
+                GridSqlType type = GridSqlType.UNKNOWN;
 
-        return res;
-    }
+                if (expression.getType() != Value.UNKNOWN) {
+                    Column c = new Column(null, expression.getType(), expression.getPrecision(),
expression.getScale(),
+                        expression.getDisplaySize());
 
-    /**
-     * @param expression H2 Expression.
-     * @return Parsed expression.
-     */
-    private GridSqlElement parseExpressionWithType(Expression expression) {
-        GridSqlElement res = parseExpression(expression);
-
-        if (res != null && res.resultType() == null) {
-            GridSqlType type = GridSqlType.UNKNOWN;
-
-            if (expression.getType() != Value.UNKNOWN) {
-                Column c = new Column(null, expression.getType(), expression.getPrecision(),
expression.getScale(),
-                    expression.getDisplaySize());
+                    type = new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(),
c.getCreateSQL());
+                }
 
-                type = new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(),
c.getCreateSQL());
+                res.resultType(type);
             }
 
-            res.resultType(type);
+            h2ObjToGridObj.put(expression, res);
         }
 
         return res;
@@ -399,9 +390,10 @@ public class GridSqlQueryParser {
 
     /**
      * @param expression Expression.
+     * @param calcTypes Calculate types for all the expressions.
      * @return Parsed expression.
      */
-    private GridSqlElement parseExpression0(Expression expression) {
+    private GridSqlElement parseExpression0(Expression expression, boolean calcTypes) {
         if (expression instanceof ExpressionColumn) {
             TableFilter tblFilter = ((ExpressionColumn)expression).getTableFilter();
 
@@ -411,7 +403,8 @@ public class GridSqlQueryParser {
         }
 
         if (expression instanceof Alias)
-            return new GridSqlAlias(expression.getAlias(), parseExpression(expression.getNonAliasExpression()),
true);
+            return new GridSqlAlias(expression.getAlias(),
+                parseExpression(expression.getNonAliasExpression(), calcTypes), true);
 
         if (expression instanceof ValueExpression)
             return new GridSqlConst(expression.getValue(null));
@@ -424,12 +417,13 @@ public class GridSqlQueryParser {
             if (type == Operation.NEGATE) {
                 assert OPERATION_RIGHT.get(operation) == null;
 
-                return new GridSqlOperation(GridSqlOperationType.NEGATE, parseExpression(OPERATION_LEFT.get(operation)));
+                return new GridSqlOperation(GridSqlOperationType.NEGATE,
+                    parseExpression(OPERATION_LEFT.get(operation), calcTypes));
             }
 
             return new GridSqlOperation(OPERATION_OP_TYPES[type],
-                parseExpression(OPERATION_LEFT.get(operation)),
-                parseExpression(OPERATION_RIGHT.get(operation)));
+                parseExpression(OPERATION_LEFT.get(operation), calcTypes),
+                parseExpression(OPERATION_RIGHT.get(operation), calcTypes));
         }
 
         if (expression instanceof Comparison) {
@@ -439,18 +433,18 @@ public class GridSqlQueryParser {
 
             assert opType != null : COMPARISON_TYPE.get(cmp);
 
-            GridSqlElement left = parseExpression(COMPARISON_LEFT.get(cmp));
+            GridSqlElement left = parseExpression(COMPARISON_LEFT.get(cmp), calcTypes);
 
             if (opType.childrenCount() == 1)
                 return new GridSqlOperation(opType, left);
 
-            GridSqlElement right = parseExpression(COMPARISON_RIGHT.get(cmp));
+            GridSqlElement right = parseExpression(COMPARISON_RIGHT.get(cmp), calcTypes);
 
             return new GridSqlOperation(opType, left, right);
         }
 
         if (expression instanceof ConditionNot)
-            return new GridSqlOperation(NOT, parseExpression(expression.getNotIfPossible(null)));
+            return new GridSqlOperation(NOT, parseExpression(expression.getNotIfPossible(null),
calcTypes));
 
         if (expression instanceof ConditionAndOr) {
             ConditionAndOr andOr = (ConditionAndOr)expression;
@@ -460,7 +454,7 @@ public class GridSqlQueryParser {
             assert type == ConditionAndOr.AND || type == ConditionAndOr.OR;
 
             return new GridSqlOperation(type == ConditionAndOr.AND ? AND : OR,
-                parseExpression(ANDOR_LEFT.get(andOr)), parseExpression(ANDOR_RIGHT.get(andOr)));
+                parseExpression(ANDOR_LEFT.get(andOr), calcTypes), parseExpression(ANDOR_RIGHT.get(andOr),
calcTypes));
         }
 
         if (expression instanceof Subquery) {
@@ -474,12 +468,12 @@ public class GridSqlQueryParser {
         if (expression instanceof ConditionIn) {
             GridSqlOperation res = new GridSqlOperation(IN);
 
-            res.addChild(parseExpression(LEFT_CI.get((ConditionIn)expression)));
+            res.addChild(parseExpression(LEFT_CI.get((ConditionIn)expression), calcTypes));
 
             List<Expression> vals = VALUE_LIST_CI.get((ConditionIn)expression);
 
             for (Expression val : vals)
-                res.addChild(parseExpression(val));
+                res.addChild(parseExpression(val, calcTypes));
 
             return res;
         }
@@ -487,12 +481,12 @@ public class GridSqlQueryParser {
         if (expression instanceof ConditionInConstantSet) {
             GridSqlOperation res = new GridSqlOperation(IN);
 
-            res.addChild(parseExpression(LEFT_CICS.get((ConditionInConstantSet) expression)));
+            res.addChild(parseExpression(LEFT_CICS.get((ConditionInConstantSet)expression),
calcTypes));
 
             List<Expression> vals = VALUE_LIST_CICS.get((ConditionInConstantSet)expression);
 
             for (Expression val : vals)
-                res.addChild(parseExpression(val));
+                res.addChild(parseExpression(val, calcTypes));
 
             return res;
         }
@@ -506,7 +500,7 @@ public class GridSqlQueryParser {
             assert0(!all, expression);
             assert0(compareType == Comparison.EQUAL, expression);
 
-            res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect) expression)));
+            res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect) expression), calcTypes));
 
             Query qry = QUERY.get((ConditionInSelect)expression);
 
@@ -522,8 +516,9 @@ public class GridSqlQueryParser {
 
             boolean regexp = REGEXP_CL.get((CompareLike)expression);
 
-            return new GridSqlOperation(regexp ? REGEXP : LIKE, parseExpression(LEFT.get((CompareLike)
expression)),
-                parseExpression(RIGHT.get((CompareLike) expression)));
+            return new GridSqlOperation(regexp ? REGEXP : LIKE,
+                parseExpression(LEFT.get((CompareLike)expression), calcTypes),
+                parseExpression(RIGHT.get((CompareLike)expression), calcTypes));
         }
 
         if (expression instanceof Function) {
@@ -540,7 +535,7 @@ public class GridSqlQueryParser {
                         res.addChild(GridSqlPlaceholder.EMPTY);
                     }
                     else
-                        res.addChild(parseExpression(arg));
+                        res.addChild(parseExpression(arg, calcTypes));
                 }
             }
 
@@ -563,7 +558,7 @@ public class GridSqlQueryParser {
 
             if (f.getArgs() != null) {
                 for (Expression arg : f.getArgs())
-                    res.addChild(parseExpression(arg));
+                    res.addChild(parseExpression(arg, calcTypes));
             }
 
             return res;
@@ -579,7 +574,7 @@ public class GridSqlQueryParser {
             Expression on = ON.get((Aggregate)expression);
 
             if (on != null)
-                res.addChild(parseExpression(on));
+                res.addChild(parseExpression(on, calcTypes));
 
             return res;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
index adc8aeb..fe53101 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -89,6 +89,8 @@ public class GridSqlQuerySplitter {
         int c = 0;
 
         for (GridSqlElement expr : left.columns(true)) {
+            GridSqlType type = expr.resultType();
+
             String colName;
 
             if (expr instanceof GridSqlAlias)
@@ -106,6 +108,8 @@ public class GridSqlQuerySplitter {
 
             GridSqlColumn col = column(colName);
 
+            col.resultType(type);
+
             wrapQry.addColumn(col, true);
 
             c++;
@@ -218,7 +222,8 @@ public class GridSqlQuerySplitter {
             findParams(rdcQry, params, new ArrayList<>()).toArray()));
 
         res.addMapQuery(new GridCacheSqlQuery(mergeTable, mapQry.getSQL(),
-            findParams(mapQry, params, new ArrayList<>(params.length)).toArray()));
+            findParams(mapQry, params, new ArrayList<>(params.length)).toArray())
+            .columns(collectColumns(mapExps)));
 
         res.explain(explain);
 
@@ -226,6 +231,34 @@ public class GridSqlQuerySplitter {
     }
 
     /**
+     * @param cols Columns from SELECT clause.
+     * @return Map of columns with types.
+     */
+    private static LinkedHashMap<String,?> collectColumns(List<GridSqlElement>
cols) {
+        LinkedHashMap<String, GridSqlType> res = new LinkedHashMap<>(cols.size(),
1f, false);
+
+        for (int i = 0; i < cols.size(); i++) {
+            GridSqlElement col = cols.get(i);
+            GridSqlType t = col.resultType();
+
+            if (t == null || t == GridSqlType.UNKNOWN)
+                throw new IllegalStateException("Type: " + t + " -> " + col);
+
+            String alias;
+
+            if (col instanceof GridSqlAlias)
+                alias = ((GridSqlAlias)col).alias();
+            else
+                alias = columnName(i);
+
+            if (res.put(alias, t) != null)
+                throw new IllegalStateException("Alias already exists: " + alias);
+        }
+
+        return res;
+    }
+
+    /**
      * @param qry Query.
      * @param spaces Space names.
      * @return Query.
@@ -501,6 +534,8 @@ public class GridSqlQuerySplitter {
     ) {
         GridSqlAggregateFunction agg = parentExpr.child(aggIdx);
 
+        assert agg.resultType() != null;
+
         GridSqlElement mapAgg, rdcAgg;
 
         // Create stubbed map alias to fill it with correct expression later.
@@ -515,7 +550,8 @@ public class GridSqlQuerySplitter {
         switch (agg.type()) {
             case AVG: // SUM( AVG(CAST(x AS DOUBLE))*COUNT(x) )/SUM( COUNT(x) ).
                 //-- COUNT(x) map
-                GridSqlElement cntMapAgg = aggregate(agg.distinct(), COUNT).addChild(agg.child());
+                GridSqlElement cntMapAgg = aggregate(agg.distinct(), COUNT)
+                    .resultType(GridSqlType.BIGINT).addChild(agg.child());
 
                 // Add generated alias to COUNT(x).
                 // Using size as index since COUNT will be added as the last select element
to the map query.
@@ -526,7 +562,7 @@ public class GridSqlQuerySplitter {
                 mapSelect.add(cntMapAgg);
 
                 //-- AVG(CAST(x AS DOUBLE)) map
-                mapAgg = aggregate(agg.distinct(), AVG).addChild( // Add function argument.
+                mapAgg = aggregate(agg.distinct(), AVG).resultType(GridSqlType.DOUBLE).addChild(
                     function(CAST).resultType(GridSqlType.DOUBLE).addChild(agg.child()));
 
                 //-- SUM( AVG(x)*COUNT(x) )/SUM( COUNT(x) ) reduce
@@ -544,14 +580,14 @@ public class GridSqlQuerySplitter {
             case SUM: // SUM( SUM(x) )
             case MAX: // MAX( MAX(x) )
             case MIN: // MIN( MIN(x) )
-                mapAgg = aggregate(agg.distinct(), agg.type()).addChild(agg.child());
+                mapAgg = aggregate(agg.distinct(), agg.type()).resultType(agg.resultType()).addChild(agg.child());
                 rdcAgg = aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias()));
 
                 break;
 
             case COUNT_ALL: // CAST(SUM( COUNT(*) ) AS BIGINT)
             case COUNT: // CAST(SUM( COUNT(x) ) AS BIGINT)
-                mapAgg = aggregate(agg.distinct(), agg.type());
+                mapAgg = aggregate(agg.distinct(), agg.type()).resultType(GridSqlType.BIGINT);
 
                 if (agg.type() == COUNT)
                     mapAgg.addChild(agg.child());
@@ -566,9 +602,11 @@ public class GridSqlQuerySplitter {
         }
 
         assert !(mapAgg instanceof GridSqlAlias);
+        assert mapAgg.resultType() != null;
 
         // Fill the map alias with aggregate.
         mapAggAlias.child(0, mapAgg);
+        mapAggAlias.resultType(mapAgg.resultType());
 
         // Replace in original expression aggregate with reduce aggregate.
         parentExpr.child(aggIdx, rdcAgg);
@@ -597,7 +635,11 @@ public class GridSqlQuerySplitter {
      * @return Alias.
      */
     private static GridSqlAlias alias(String alias, GridSqlElement child) {
-        return new GridSqlAlias(alias, child);
+        GridSqlAlias res = new GridSqlAlias(alias, child);
+
+        res.resultType(child.resultType());
+
+        return res;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
index e96ae69..aeee562 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
@@ -17,12 +17,13 @@
 
 package org.apache.ignite.internal.processors.query.h2.sql;
 
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.h2.value.*;
 
 /**
  * SQL Data type based on H2.
  */
-public class GridSqlType {
+public final class GridSqlType {
     /** */
     public static final GridSqlType UNKNOWN = new GridSqlType(Value.UNKNOWN, 0, 0, 0, null);
 
@@ -107,4 +108,9 @@ public class GridSqlType {
     public String sql() {
         return sql;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridSqlType.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d82df227/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index cde3288..e34ddd6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.processors.query.h2.*;
+import org.apache.ignite.internal.processors.query.h2.sql.*;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -36,9 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.plugin.extensions.communication.*;
-import org.h2.command.*;
 import org.h2.command.ddl.*;
-import org.h2.command.dml.*;
 import org.h2.engine.*;
 import org.h2.expression.*;
 import org.h2.index.*;
@@ -55,7 +54,6 @@ import javax.cache.*;
 import java.lang.reflect.*;
 import java.sql.*;
 import java.util.*;
-import java.util.Set;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
 
@@ -1053,17 +1051,24 @@ public class GridReduceQueryExecutor {
             data.create = true;
 
             if (!explain) {
-                Prepared prepare = ses.prepare(qry.query(), false);
+                LinkedHashMap<String,?> colsMap = qry.columns();
 
-                List<org.h2.expression.Parameter> parsedParams = prepare.getParameters();
+                assert colsMap != null;
 
-                for (int i = Math.min(parsedParams.size(), qry.parameters().length); --i
>= 0; ) {
-                    Object val = qry.parameters()[i];
+                ArrayList<Column> cols = new ArrayList<>(colsMap.size());
 
-                    parsedParams.get(i).setValue(DataType.convertToValue(ses, val, Value.UNKNOWN));
+                for (Map.Entry<String,?> e : colsMap.entrySet()) {
+                    String alias = e.getKey();
+                    GridSqlType t = (GridSqlType)e.getValue();
+
+                    assert !F.isEmpty(alias);
+
+                    Column c = new Column(alias, t.type(), t.precision(), t.scale(), t.displaySize());
+
+                    cols.add(c);
                 }
 
-                data.columns = generateColumnsFromQuery((Query)prepare);
+                data.columns = cols;
             }
             else
                 data.columns = planColumns();


Mime
View raw message