You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/02/19 08:11:38 UTC
[4/6] ignite git commit: IGNITE-2563: More descriptive exception on
unsupported aggregation. - Fixes #476.
IGNITE-2563: More descriptive exception on unsupported aggregation. - Fixes #476.
Signed-off-by: shtykh_roman <rs...@yahoo.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ff062d95
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ff062d95
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ff062d95
Branch: refs/heads/ignite-1232
Commit: ff062d95094f5a08d7064b64d2ec66c0a63447bb
Parents: 078689b
Author: shtykh_roman <rs...@yahoo.com>
Authored: Fri Feb 19 11:40:20 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Fri Feb 19 11:40:20 2016 +0900
----------------------------------------------------------------------
.../query/h2/sql/GridSqlAggregateFunction.java | 12 +++++++-
.../query/h2/sql/GridSqlQueryParser.java | 30 +++++++++++---------
2 files changed, 28 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff062d95/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAggregateFunction.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAggregateFunction.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAggregateFunction.java
index d650b8c..edda030 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAggregateFunction.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAggregateFunction.java
@@ -32,7 +32,7 @@ import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunction
*/
public class GridSqlAggregateFunction extends GridSqlFunction {
/** */
- private static final GridSqlFunctionType[] TYPE_INDEX = new GridSqlFunctionType[]{
+ private static final GridSqlFunctionType[] TYPE_INDEX = new GridSqlFunctionType[] {
COUNT_ALL, COUNT, GROUP_CONCAT, SUM, MIN, MAX, AVG,
// STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP, BOOL_OR, BOOL_AND, SELECTIVITY, HISTOGRAM,
};
@@ -59,6 +59,16 @@ public class GridSqlAggregateFunction extends GridSqlFunction {
}
/**
+ * Checks if the aggregate type is valid.
+ *
+ * @param typeId Aggregate type id.
+ * @return True is valid, otherwise false.
+ */
+ protected static boolean isValidType(int typeId) {
+ return (typeId >= 0) && (typeId < TYPE_INDEX.length);
+ }
+
+ /**
* @return Distinct.
*/
public boolean distinct() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff062d95/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 2789796..7001717 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
@@ -91,10 +91,11 @@ import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlType.fro
@SuppressWarnings("TypeMayBeWeakened")
public class GridSqlQueryParser {
/** */
- private static final GridSqlOperationType[] OPERATION_OP_TYPES = new GridSqlOperationType[]{CONCAT, PLUS, MINUS, MULTIPLY, DIVIDE, null, MODULUS};
+ private static final GridSqlOperationType[] OPERATION_OP_TYPES = new GridSqlOperationType[] {CONCAT, PLUS, MINUS, MULTIPLY, DIVIDE, null, MODULUS};
/** */
- private static final GridSqlOperationType[] COMPARISON_TYPES = new GridSqlOperationType[]{EQUAL, BIGGER_EQUAL, BIGGER, SMALLER_EQUAL,
+ private static final GridSqlOperationType[] COMPARISON_TYPES = new GridSqlOperationType[] {
+ EQUAL, BIGGER_EQUAL, BIGGER, SMALLER_EQUAL,
SMALLER, NOT_EQUAL, IS_NULL, IS_NOT_NULL,
null, null, null, SPATIAL_INTERSECTS /* 11 */, null, null, null, null, EQUAL_NULL_SAFE /* 16 */, null, null, null, null,
NOT_EQUAL_NULL_SAFE /* 21 */};
@@ -208,7 +209,7 @@ public class GridSqlQueryParser {
private static final Getter<JavaFunction, FunctionAlias> FUNC_ALIAS = getter(JavaFunction.class, "functionAlias");
/** */
- private static final Getter<JdbcPreparedStatement,Command> COMMAND = getter(JdbcPreparedStatement.class, "command");
+ private static final Getter<JdbcPreparedStatement, Command> COMMAND = getter(JdbcPreparedStatement.class, "command");
/** */
private static final Getter<SelectUnion, SortOrder> UNION_SORT = getter(SelectUnion.class, "sort");
@@ -217,7 +218,7 @@ public class GridSqlQueryParser {
private static final Getter<Explain, Prepared> EXPLAIN_COMMAND = getter(Explain.class, "command");
/** */
- private static volatile Getter<Command,Prepared> prepared;
+ private static volatile Getter<Command, Prepared> prepared;
/** */
private final IdentityHashMap<Object, Object> h2ObjToGridObj = new IdentityHashMap<>();
@@ -229,7 +230,7 @@ public class GridSqlQueryParser {
public static GridSqlQuery parse(JdbcPreparedStatement stmt) {
Command cmd = COMMAND.get(stmt);
- Getter<Command,Prepared> p = prepared;
+ Getter<Command, Prepared> p = prepared;
if (p == null) {
Class<? extends Command> cls = cmd.getClass();
@@ -541,13 +542,13 @@ public class GridSqlQueryParser {
assert0(!all, expression);
assert0(compareType == Comparison.EQUAL, expression);
- res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect) expression), calcTypes));
+ res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect)expression), calcTypes));
Query qry = QUERY.get((ConditionInSelect)expression);
assert0(qry instanceof Select, qry);
- res.addChild(new GridSqlSubquery(parse((Select) qry)));
+ res.addChild(new GridSqlSubquery(parse((Select)qry)));
return res;
}
@@ -623,15 +624,18 @@ public class GridSqlQueryParser {
return new GridSqlParameter(((Parameter)expression).getIndex());
if (expression instanceof Aggregate) {
- GridSqlAggregateFunction res = new GridSqlAggregateFunction(DISTINCT.get((Aggregate)expression),
- TYPE.get((Aggregate)expression));
+ int typeId = TYPE.get((Aggregate)expression);
- Expression on = ON.get((Aggregate)expression);
+ if (GridSqlAggregateFunction.isValidType(typeId)) {
+ GridSqlAggregateFunction res = new GridSqlAggregateFunction(DISTINCT.get((Aggregate)expression), typeId);
- if (on != null)
- res.addChild(parseExpression(on, calcTypes));
+ Expression on = ON.get((Aggregate)expression);
- return res;
+ if (on != null)
+ res.addChild(parseExpression(on, calcTypes));
+
+ return res;
+ }
}
if (expression instanceof ExpressionList) {