Xikui Wang has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1666

Change subject: Fix ASTERIXDB-1875 UDF in SQLPP
......................................................................

Fix ASTERIXDB-1875 UDF in SQLPP

1. Fix the bug that if a function created with SQLPP, the callExpr in
   the function body is not normalzied to list input functions.
2. Fix the bug that in SQLPP Query Rewritter, the variables are not
   expanded before the inline the functions.

Change-Id: I7cf72c690b452dd141efe56f5d7098a6f00cab0f
---
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
2 files changed, 16 insertions(+), 16 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/66/1666/1

diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
index f303a6c..bed774f 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
@@ -117,20 +117,6 @@
         // Rewrites like/not-like expressions.
         rewriteOperatorExpression();
 
-        // Generate ids for variables (considering scopes) and replace global 
variable access with the dataset function.
-        variableCheckAndRewrite(true);
-
-        // Rewrites several variable-arg functions into their corresponding 
internal list-input functions.
-        rewriteListInputFunctions();
-
-        // Inlines functions.
-        inlineDeclaredUdfs();
-
-        // Rewrites function names.
-        // This should be done after inlineDeclaredUdfs() because user-defined 
function
-        // names could be case sensitive.
-        rewriteFunctionNames();
-
         // Resets the variable counter to the previous marked value.
         // Therefore, the variable ids in the final query plans will not be 
perturbed
         // by the additon or removal of intermediate AST rewrites.
@@ -145,6 +131,20 @@
 
         // Sets the var counter of the query.
         topStatement.setVarCounter(context.getVarCounter());
+
+        // Generate ids for variables (considering scopes) and replace global 
variable access with the dataset function.
+        variableCheckAndRewrite(true);
+
+        // Rewrites several variable-arg functions into their corresponding 
internal list-input functions.
+        rewriteListInputFunctions();
+
+        // Inlines functions.
+        inlineDeclaredUdfs();
+
+        // Rewrites function names.
+        // This should be done after inlineDeclaredUdfs() because user-defined 
function
+        // names could be case sensitive.
+        rewriteFunctionNames();
     }
 
     protected void rewriteGlobalAggregations() throws CompilationException {
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index e6a2951..67c742a 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -162,8 +162,8 @@
 import org.apache.asterix.lang.sqlpp.struct.SetOperationInput;
 import org.apache.asterix.lang.sqlpp.struct.SetOperationRight;
 import org.apache.asterix.lang.sqlpp.util.ExpressionToVariableUtil;
+import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil;
 import org.apache.asterix.lang.sqlpp.util.SqlppVariableUtil;
-import org.apache.asterix.metadata.utils.MetadataConstants;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 import org.apache.hyracks.algebricks.common.utils.Triple;
 import 
org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
@@ -2514,7 +2514,7 @@
       if (signature == null) {
         signature = new FunctionSignature(funcName.dataverse, fqFunctionName, 
arity);
       }
-      callExpr = new CallExpr(signature,argList);
+      callExpr = FunctionMapUtil.normalizedListInputFunctions(new 
CallExpr(signature,argList));
       if (hint != null) {
         if (hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) {
           callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE);

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1666
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7cf72c690b452dd141efe56f5d7098a6f00cab0f
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Xikui Wang <xkk...@gmail.com>

Reply via email to