You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2016/10/27 18:31:35 UTC
phoenix git commit: Revert "PHOENIX-3242 Support UDF in
Phoenix-Calcite Integration-addendum(Rajeshbabu)"
Repository: phoenix
Updated Branches:
refs/heads/calcite 0b156dc64 -> c3613fd2b
Revert "PHOENIX-3242 Support UDF in Phoenix-Calcite Integration-addendum(Rajeshbabu)"
This reverts commit 0b156dc64612e2df2914e423f4ed872cce40ab8c.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c3613fd2
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c3613fd2
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c3613fd2
Branch: refs/heads/calcite
Commit: c3613fd2b66f69a6565b3e1970f4a91e5272ad65
Parents: 0b156dc
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Fri Oct 28 00:10:15 2016 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Fri Oct 28 00:10:15 2016 +0530
----------------------------------------------------------------------
.../phoenix/end2end/UserDefinedFunctionsIT.java | 5 +-
.../apache/phoenix/calcite/CalciteUtils.java | 27 +-------
.../apache/phoenix/parse/FunctionParseNode.java | 73 +++++++++-----------
3 files changed, 36 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/c3613fd2/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
index dfd4de9..f8d36f6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
@@ -619,7 +619,7 @@ public class UserDefinedFunctionsIT extends BaseOwnClusterIT {
public void testDropFunction() throws Exception {
Connection conn = driver.connect(calciteUrl, UDF_PROPS);
Statement stmt = conn.createStatement();
- String query = "select count(*) from "+"\""+ SYSTEM_CATALOG_SCHEMA + "\".\"" + SYSTEM_FUNCTION_TABLE + "\"";
+ String query = "select count(*) from "+ SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_FUNCTION_TABLE + "\"";
ResultSet rs = stmt.executeQuery(query);
rs.next();
int numRowsBefore = rs.getInt(1);
@@ -665,7 +665,7 @@ public class UserDefinedFunctionsIT extends BaseOwnClusterIT {
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
Connection conn = DriverManager.getConnection(calciteUrl, props);
Statement stmt = conn.createStatement();
- String query = "select count(*) from \""+ SYSTEM_CATALOG_SCHEMA + "\".\"" + SYSTEM_FUNCTION_TABLE + "\"";
+ String query = "select count(*) from "+ SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_FUNCTION_TABLE + "\"";
ResultSet rs = stmt.executeQuery(query);
rs.next();
int numRowsBefore = rs.getInt(1);
@@ -673,7 +673,6 @@ public class UserDefinedFunctionsIT extends BaseOwnClusterIT {
+ "'"+util.getConfiguration().get(DYNAMIC_JARS_DIR_KEY) + "/myjar2.jar"+"'");
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
conn = DriverManager.getConnection(calciteUrl, props);
- stmt = conn.createStatement();
rs = stmt.executeQuery(query);
rs.next();
int numRowsAfter= rs.getInt(1);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/c3613fd2/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
index b312954..7e6bd20 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
@@ -2,7 +2,6 @@ package org.apache.phoenix.calcite;
import java.sql.SQLException;
import java.sql.Timestamp;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.GregorianCalendar;
import java.util.List;
@@ -108,8 +107,6 @@ import org.apache.phoenix.expression.function.SumAggregateFunction;
import org.apache.phoenix.expression.function.TrimFunction;
import org.apache.phoenix.expression.function.UDFExpression;
import org.apache.phoenix.expression.function.UpperFunction;
-import org.apache.phoenix.parse.FunctionParseNode;
-import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo;
import org.apache.phoenix.parse.JoinTableNode.JoinType;
import org.apache.phoenix.parse.SequenceValueParseNode;
import org.apache.phoenix.schema.PTableType;
@@ -737,13 +734,6 @@ public class CalciteUtils {
}
}
});
- EXPRESSION_MAP.put(SqlKind.DEFAULT, new ExpressionFactory() {
- @SuppressWarnings("rawtypes")
- @Override
- public Expression newExpression(RexNode node, PhoenixRelImplementor implementor) {
- return null;
- }
- });
EXPRESSION_MAP.put(SqlKind.OTHER_FUNCTION, new ExpressionFactory() {
@Override
public Expression newExpression(RexNode node,
@@ -757,19 +747,6 @@ public class CalciteUtils {
Function func = udf.getFunction();
if (func instanceof PhoenixScalarFunction) {
PhoenixScalarFunction scalarFunc = (PhoenixScalarFunction) func;
- BuiltInFunctionInfo info = new BuiltInFunctionInfo(scalarFunc.getFunctionInfo());
- if (info.getArgs().length > children.size()) {
- List<Expression> moreChildren = new ArrayList<Expression>(children);
- for (int i = children.size(); i < info.getArgs().length; i++) {
- if(info.getArgs()[i].getDefaultValue() != null) {
- moreChildren.add(info.getArgs()[i].getDefaultValue());
- }
- }
- children = moreChildren;
- }
- for(int i = 0; i < children.size(); i++) {
- FunctionParseNode.validateFunctionArguement(info, i, children.get(i));
- }
return new UDFExpression(children, scalarFunc.getFunctionInfo());
}
} else if (op == SqlStdOperatorTable.SQRT) {
@@ -989,9 +966,7 @@ public class CalciteUtils {
List<Expression> children = Lists.newArrayListWithExpectedSize(call.getOperands().size());
for (RexNode op : call.getOperands()) {
Expression child = getFactory(op).newExpression(op, implementor);
- if(child != null) {
- children.add(child);
- }
+ children.add(child);
}
return children;
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/c3613fd2/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java
index 952d0d3..0dd021b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java
@@ -186,51 +186,44 @@ public class FunctionParseNode extends CompoundParseNode {
}
}
} else {
- validateFunctionArguement(info, i, child);
- }
- }
- return children;
- }
-
- public static void validateFunctionArguement(BuiltInFunctionInfo info,
- int childIndex, Expression child)
- throws ArgumentTypeMismatchException, ValueRangeExcpetion {
- BuiltInFunctionArgInfo arg = info.getArgs()[childIndex];
- if (arg.getAllowedTypes().length > 0) {
- boolean isCoercible = false;
- for (Class<? extends PDataType> type :arg.getAllowedTypes()) {
- if (child.getDataType().isCoercibleTo(
- PDataTypeFactory.getInstance().instanceFromClass(type))) {
- isCoercible = true;
- break;
+ if (allowedTypes.length > 0) {
+ boolean isCoercible = false;
+ for (Class<? extends PDataType> type : allowedTypes) {
+ if (child.getDataType().isCoercibleTo(
+ PDataTypeFactory.getInstance().instanceFromClass(type))) {
+ isCoercible = true;
+ break;
+ }
+ }
+ if (!isCoercible) {
+ throw new ArgumentTypeMismatchException(args[i].getAllowedTypes(),
+ child.getDataType(), info.getName() + " argument " + (i + 1));
+ }
+ if (child instanceof LiteralExpression) {
+ LiteralExpression valueExp = (LiteralExpression) child;
+ LiteralExpression minValue = args[i].getMinValue();
+ LiteralExpression maxValue = args[i].getMaxValue();
+ if (minValue != null && minValue.getDataType().compareTo(minValue.getValue(), valueExp.getValue(), valueExp.getDataType()) > 0) {
+ throw new ValueRangeExcpetion(minValue, maxValue == null ? "" : maxValue, valueExp.getValue(), info.getName() + " argument " + (i + 1));
+ }
+ if (maxValue != null && maxValue.getDataType().compareTo(maxValue.getValue(), valueExp.getValue(), valueExp.getDataType()) < 0) {
+ throw new ValueRangeExcpetion(minValue == null ? "" : minValue, maxValue, valueExp.getValue(), info.getName() + " argument " + (i + 1));
+ }
+ }
}
- }
- if (!isCoercible) {
- throw new ArgumentTypeMismatchException(arg.getAllowedTypes(),
- child.getDataType(), info.getName() + " argument " + (childIndex + 1));
- }
- if (child instanceof LiteralExpression) {
- LiteralExpression valueExp = (LiteralExpression) child;
- LiteralExpression minValue = arg.getMinValue();
- LiteralExpression maxValue = arg.getMaxValue();
- if (minValue != null && minValue.getDataType().compareTo(minValue.getValue(), valueExp.getValue(), valueExp.getDataType()) > 0) {
- throw new ValueRangeExcpetion(minValue, maxValue == null ? "" : maxValue, valueExp.getValue(), info.getName() + " argument " + (childIndex + 1));
+ if (args[i].isConstant() && ! (child instanceof LiteralExpression) ) {
+ throw new ArgumentTypeMismatchException("constant", child.toString(), info.getName() + " argument " + (i + 1));
}
- if (maxValue != null && maxValue.getDataType().compareTo(maxValue.getValue(), valueExp.getValue(), valueExp.getDataType()) < 0) {
- throw new ValueRangeExcpetion(minValue == null ? "" : minValue, maxValue, valueExp.getValue(), info.getName() + " argument " + (childIndex + 1));
+ if (!args[i].getAllowedValues().isEmpty()) {
+ Object value = ((LiteralExpression)child).getValue();
+ if (!args[i].getAllowedValues().contains(value.toString().toUpperCase())) {
+ throw new ArgumentTypeMismatchException(Arrays.toString(args[i].getAllowedValues().toArray(new String[0])),
+ value.toString(), info.getName() + " argument " + (i + 1));
+ }
}
}
}
- if (arg.isConstant() && ! (child instanceof LiteralExpression) ) {
- throw new ArgumentTypeMismatchException("constant", child.toString(), info.getName() + " argument " + (childIndex + 1));
- }
- if (!arg.getAllowedValues().isEmpty()) {
- Object value = ((LiteralExpression)child).getValue();
- if (!arg.getAllowedValues().contains(value.toString().toUpperCase())) {
- throw new ArgumentTypeMismatchException(Arrays.toString(arg.getAllowedValues().toArray(new String[0])),
- value.toString(), info.getName() + " argument " + (childIndex + 1));
- }
- }
+ return children;
}
/**