ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [07/24] incubator-ignite git commit: # IGNITE-540 Sql param substitution does not work in a case.
Date Mon, 06 Apr 2015 15:47:30 GMT
# IGNITE-540 Sql param substitution does not work in a case.


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

Branch: refs/heads/ignite-593
Commit: 8a5180c5f83013eff0e09f7698313fb947fdc756
Parents: 3af6914
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Fri Apr 3 16:18:26 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri Apr 3 16:18:26 2015 +0300

----------------------------------------------------------------------
 .../h2/twostep/GridReduceQueryExecutor.java     | 43 ++++++++++++++------
 1 file changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a5180c5/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 b660f7e..7941f12 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
@@ -445,20 +445,28 @@ public class GridReduceQueryExecutor implements GridMessageListener
{
             String name = expr.getAlias();
             long precision = expr.getPrecision();
             int displaySize = expr.getDisplaySize();
-            DataType dt = DataType.getDataType(type);
-            if (precision > 0 && (dt.defaultPrecision == 0 ||
-                (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE)))
{
-                // dont' set precision to MAX_VALUE if this is the default
-                precision = dt.defaultPrecision;
-            }
             int scale = expr.getScale();
-            if (scale > 0 && (dt.defaultScale == 0 ||
-                (dt.defaultScale > scale && dt.defaultScale < precision)))
{
-                scale = dt.defaultScale;
+
+            if (type != Value.UNKNOWN) {
+                DataType dt = DataType.getDataType(type);
+
+                if (precision > 0 && (dt.defaultPrecision == 0 ||
+                    (dt.defaultPrecision > precision && dt.defaultPrecision <
Byte.MAX_VALUE))) {
+                    // dont' set precision to MAX_VALUE if this is the default
+                    precision = dt.defaultPrecision;
+                }
+
+                if (scale > 0 && (dt.defaultScale == 0 ||
+                    (dt.defaultScale > scale && dt.defaultScale < precision)))
+                    scale = dt.defaultScale;
+
+                if (scale > precision)
+                    precision = scale;
             }
-            if (scale > precision) {
-                precision = scale;
+            else {
+                System.out.println("1");
             }
+
             Column col = new Column(name, type, precision, scale, displaySize);
             cols.add(col);
         }
@@ -481,7 +489,18 @@ public class GridReduceQueryExecutor implements GridMessageListener {
             data.tableName = "T___";
             data.schema = ses.getDatabase().getSchema(ses.getCurrentSchemaName());
             data.create = true;
-            data.columns = generateColumnsFromQuery((Query)ses.prepare(qry.query(), false));
+
+            Query prepare = (Query)ses.prepare(qry.query(), false);
+
+            ArrayList<Parameter> parsedParams = prepare.getParameters();
+
+            for (int i = Math.min(parsedParams.size(), qry.parameters().length); --i >=
0; ) {
+                Object val = qry.parameters()[i];
+
+                parsedParams.get(i).setValue(DataType.convertToValue(ses, val, Value.UNKNOWN));
+            }
+
+            data.columns = generateColumnsFromQuery(prepare);
 
             return new GridMergeTable(data);
         }


Mime
View raw message