asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Lychagin (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [NO ISSUE] Function references cleanup
Date Sat, 04 Nov 2017 02:44:54 GMT
Dmitry Lychagin has uploaded a new change for review.

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

Change subject: [NO ISSUE] Function references cleanup
......................................................................

[NO ISSUE] Function references cleanup

Change-Id: Ib78e3267fd9b9ece40868076ba907ccb4a78da28
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
M asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedConstants.java
M asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
M asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AqlDeleteRewriteVisitor.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/OperatorType.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppBuiltinFunctionRewriteVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppDeleteRewriteVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppExpressionScopingVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
M asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ExpressionTypeComputer.java
M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/FunctionInfoRepository.java
19 files changed, 84 insertions(+), 68 deletions(-)


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

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
index 9cce91b..608769b 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
@@ -202,7 +202,7 @@
                 addArgs(feedConnection.getDataverseName(), feedConnection.getFeedId().getEntityName(),
                         feedConnection.getFeedId().getEntityName(), FeedRuntimeType.INTAKE.toString(),
                         feedConnection.getDatasetName(), feedConnection.getOutputType());
-        CallExpr datasrouceCallFunction = new CallExpr(FeedConstants.FEED_COLLECT_FUN_SIGNATURE,
exprList);
+        CallExpr datasrouceCallFunction = new CallExpr(new FunctionSignature(FeedConstants.FEED_COLLECT_FUN),
exprList);
         FromTerm fromterm = new FromTerm(datasrouceCallFunction, fromTermLeftExpr, null,
null);
         FromClause fromClause = new FromClause(Arrays.asList(fromterm));
         // TODO: This can be the place to add select predicate for ingestion
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
index 736aff6..d4b4215 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
@@ -28,6 +28,10 @@
     private String name;
     private int arity;
 
+    public FunctionSignature(FunctionIdentifier fi) {
+        this(fi.getNamespace(), fi.getName(), fi.getArity());
+    }
+
     public FunctionSignature(String namespace, String name, int arity) {
         this.namespace = namespace;
         this.name = name;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedConstants.java
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedConstants.java
index f42c030..e2fa6db 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedConstants.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedConstants.java
@@ -18,13 +18,12 @@
  */
 package org.apache.asterix.external.util;
 
-import org.apache.asterix.common.functions.FunctionConstants;
-import org.apache.asterix.common.functions.FunctionSignature;
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 public class FeedConstants {
 
-    public static final FunctionSignature FEED_COLLECT_FUN_SIGNATURE =
-            new FunctionSignature(FunctionConstants.ASTERIX_NS, "feed_collect", 6);
+    public static final FunctionIdentifier FEED_COLLECT_FUN = BuiltinFunctions.FEED_COLLECT;
 
     public final static String FEEDS_METADATA_DV = "feeds_metadata";
     public final static String FAILED_TUPLE_DATASET = "failed_tuple";
diff --git a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
index 481dea7..8d84dbc 100644
--- a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
+++ b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
@@ -55,6 +55,7 @@
 import org.apache.asterix.lang.common.statement.InsertStatement;
 import org.apache.asterix.lang.common.statement.Query;
 import org.apache.asterix.lang.common.struct.Identifier;
+import org.apache.asterix.lang.common.struct.OperatorType;
 import org.apache.asterix.lang.common.struct.VarIdentifier;
 import org.apache.asterix.lang.common.visitor.FormatPrintVisitor;
 import org.apache.hyracks.algebricks.common.utils.Pair;
@@ -584,7 +585,7 @@
                     newWhereExpr.setExprList(expressions);
                     newWhereExpr.setCurrentop(true);
                     for (int operatorIndex = 0; operatorIndex < expressions.size(); ++operatorIndex)
{
-                        newWhereExpr.addOperator("and");
+                        newWhereExpr.addOperator(OperatorType.AND);
                     }
                     results.add(new WhereClause(newWhereExpr));
                 } else {
diff --git a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AqlDeleteRewriteVisitor.java
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AqlDeleteRewriteVisitor.java
index 57370c5..e90f9a9 100644
--- a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AqlDeleteRewriteVisitor.java
+++ b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AqlDeleteRewriteVisitor.java
@@ -36,6 +36,7 @@
 import org.apache.asterix.lang.common.statement.DeleteStatement;
 import org.apache.asterix.lang.common.statement.Query;
 import org.apache.asterix.lang.common.struct.Identifier;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 
 public class AqlDeleteRewriteVisitor extends AbstractAqlAstVisitor<Void, Void> {
 
@@ -48,8 +49,7 @@
                 : dataverseName.getValue() + "." + datasetName.getValue();
         LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg));
         arguments.add(argumentLiteral);
-        CallExpr callExpression =
-                new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, "dataset",
1), arguments);
+        CallExpr callExpression = new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET),
arguments);
 
         List<Clause> clauseList = new ArrayList<>();
         VariableExpr var = deleteStmt.getVariableExpr();
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
index 30b7297..ebdaac7 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
@@ -30,7 +30,6 @@
 public class CallExpr extends AbstractExpression {
     private FunctionSignature functionSignature;
     private List<Expression> exprList;
-    private boolean isBuiltin;
 
     public CallExpr(FunctionSignature functionSignature, List<Expression> exprList)
{
         this.functionSignature = functionSignature;
@@ -43,10 +42,6 @@
 
     public List<Expression> getExprList() {
         return exprList;
-    }
-
-    public boolean isBuiltin() {
-        return isBuiltin;
     }
 
     @Override
@@ -74,7 +69,7 @@
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCodeMulti(exprList, functionSignature, isBuiltin);
+        return ObjectUtils.hashCodeMulti(exprList, functionSignature);
     }
 
     @Override
@@ -87,6 +82,6 @@
         }
         CallExpr target = (CallExpr) object;
         return ObjectUtils.equals(exprList, target.exprList)
-                && ObjectUtils.equals(functionSignature, target.functionSignature)
&& isBuiltin == target.isBuiltin;
+                && ObjectUtils.equals(functionSignature, target.functionSignature);
     }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
index 954f715..5a141f3 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
@@ -91,13 +91,19 @@
         return cmp;
     }
 
+    public void addOperator(OperatorType op) throws CompilationException {
+        if (op == null) {
+            throw new NullPointerException();
+        }
+        opList.add(op);
+    }
+
     public void addOperator(String strOp) throws CompilationException {
-        Optional<OperatorType> op = OperatorType.fromSymbol(strOp);
-        if (op.isPresent()) {
-            opList.add(op.get());
-        } else {
+        OperatorType op = OperatorType.fromSymbol(strOp);
+        if (op == null) {
             throw new CompilationException("Unsupported operator: " + strOp);
         }
+        addOperator(op);
     }
 
     @Override
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/OperatorType.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/OperatorType.java
index f00d3ca..e11f169 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/OperatorType.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/OperatorType.java
@@ -18,9 +18,6 @@
  */
 package org.apache.asterix.lang.common.struct;
 
-import java.util.Arrays;
-import java.util.Optional;
-
 public enum OperatorType {
     OR("or"),
     AND("and"),
@@ -47,6 +44,8 @@
     BETWEEN("between"),
     NOT_BETWEEN("not_between");
 
+    private static final OperatorType[] VALUES = values();
+
     private final String symbol;
 
     OperatorType(String s) {
@@ -58,7 +57,12 @@
         return symbol;
     }
 
-    public static Optional<OperatorType> fromSymbol(String symbol) {
-        return Arrays.stream(OperatorType.values()).filter(o -> o.symbol.equals(symbol)).findFirst();
+    public static OperatorType fromSymbol(String symbol) {
+        for (OperatorType opType : VALUES) {
+            if (opType.symbol.equals(symbol)) {
+                return opType;
+            }
+        }
+        return null;
     }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
index 8d8ab73..6ac9436 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
@@ -33,6 +33,7 @@
 import org.apache.asterix.metadata.declared.MetadataProvider;
 import org.apache.asterix.metadata.entities.Function;
 import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
 
@@ -101,8 +102,9 @@
             }
             String namespace = signature.getNamespace();
             // Checks the existence of the referred dataverse.
-            if (metadataProvider.findDataverse(namespace) == null
-                    && !namespace.equals(FunctionConstants.ASTERIX_NS)) {
+            if (!namespace.equals(FunctionConstants.ASTERIX_NS)
+                    && !namespace.equals(AlgebricksBuiltinFunctions.ALGEBRICKS_NS)
+                    && metadataProvider.findDataverse(namespace) == null) {
                 throw new CompilationException("In function call \"" + namespace + "." +
signature.getName()
                         + "(...)\", the dataverse \"" + namespace + "\" cannot be found!");
             }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
index aa337e3..43e62d1 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.functions.FunctionConstants;
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.base.ILangExpression;
@@ -35,12 +36,12 @@
 import org.apache.asterix.lang.common.rewrites.LangRewritingContext;
 import org.apache.asterix.lang.common.struct.OperatorType;
 import org.apache.asterix.lang.common.struct.QuantifiedPair;
+import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil;
 import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppExpressionScopingVisitor;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
 
 public class OperatorExpressionVisitor extends AbstractSqlppExpressionScopingVisitor {
-
-    private static final String CONCAT = "concat";
 
     public OperatorExpressionVisitor(LangRewritingContext context) {
         super(context);
@@ -75,12 +76,17 @@
     }
 
     private Expression processLikeOperator(OperatorExpr operatorExpr, OperatorType opType)
{
-        Expression likeExpr = new CallExpr(new FunctionSignature(null, "like", 2), operatorExpr.getExprList());
-        if (opType == OperatorType.LIKE) {
-            return likeExpr;
+        Expression likeExpr =
+                new CallExpr(new FunctionSignature(BuiltinFunctions.STRING_LIKE), operatorExpr.getExprList());
+        switch (opType) {
+            case LIKE:
+                return likeExpr;
+            case NOT_LIKE:
+                return new CallExpr(new FunctionSignature(BuiltinFunctions.NOT),
+                        new ArrayList<>(Collections.singletonList(likeExpr)));
+            default:
+                throw new IllegalArgumentException(String.valueOf(opType));
         }
-        return new CallExpr(new FunctionSignature(null, "not", 1),
- new ArrayList<>(Collections.singletonList(likeExpr)));
     }
 
     private Expression processInOperator(OperatorExpr operatorExpr, OperatorType opType)
throws CompilationException {
@@ -92,11 +98,11 @@
         comparison.addOperand(bindingVar);
         comparison.setCurrentop(true);
         if (opType == OperatorType.IN) {
-            comparison.addOperator("=");
+            comparison.addOperator(OperatorType.EQ);
             return new QuantifiedExpression(Quantifier.SOME, new ArrayList<>(
                     Collections.singletonList(new QuantifiedPair(bindingVar, collectionExpr))),
comparison);
         } else {
-            comparison.addOperator("!=");
+            comparison.addOperator(OperatorType.NEQ);
             return new QuantifiedExpression(Quantifier.EVERY, new ArrayList<>(
                     Collections.singletonList(new QuantifiedPair(bindingVar, collectionExpr))),
comparison);
         }
@@ -104,7 +110,8 @@
 
     private Expression processConcatOperator(OperatorExpr operatorExpr) {
         // All operators have to be "||"s (according to the grammar).
-        return new CallExpr(new FunctionSignature(null, CONCAT, 1), operatorExpr.getExprList());
+        return new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, FunctionMapUtil.CONCAT,
1),
+                operatorExpr.getExprList());
     }
 
     private Expression processBetweenOperator(OperatorExpr operatorExpr, OperatorType opType)
@@ -121,9 +128,9 @@
         OperatorExpr andExpr = new OperatorExpr();
         andExpr.addOperand(leftComparison);
         andExpr.addOperand(rightComparison);
-        andExpr.addOperator("and");
-        return opType == OperatorType.BETWEEN ? andExpr :
-                new CallExpr(new FunctionSignature(null, "not", 1),
+        andExpr.addOperator(OperatorType.AND);
+        return opType == OperatorType.BETWEEN ? andExpr
+                : new CallExpr(new FunctionSignature(BuiltinFunctions.NOT),
                         new ArrayList<>(Collections.singletonList(andExpr)));
     }
 
@@ -132,7 +139,7 @@
         OperatorExpr comparison = new OperatorExpr();
         comparison.addOperand(lhs);
         comparison.addOperand(rhs);
-        comparison.addOperator("<=");
+        comparison.addOperator(OperatorType.LE);
         if (hints != null) {
             for (IExpressionAnnotation hint : hints) {
                 comparison.addHint(hint);
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppBuiltinFunctionRewriteVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppBuiltinFunctionRewriteVisitor.java
index f168ebd..8d59a3b 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppBuiltinFunctionRewriteVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppBuiltinFunctionRewriteVisitor.java
@@ -29,12 +29,12 @@
 import org.apache.asterix.lang.common.expression.LiteralExpr;
 import org.apache.asterix.lang.common.expression.OperatorExpr;
 import org.apache.asterix.lang.common.literal.TrueLiteral;
+import org.apache.asterix.lang.common.struct.OperatorType;
 import org.apache.asterix.lang.sqlpp.expression.CaseExpression;
 import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil;
 import org.apache.asterix.lang.sqlpp.util.SqlppRewriteUtil;
 import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppSimpleExpressionVisitor;
-import org.apache.asterix.metadata.utils.MetadataConstants;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 
 public class SqlppBuiltinFunctionRewriteVisitor extends AbstractSqlppSimpleExpressionVisitor
{
 
@@ -63,8 +63,7 @@
             return newCaseExpr;
         }
         // If the CASE expression does not contain a subquery, we rewrite it to a switch-case
function call.
-        FunctionSignature functionSignature = new FunctionSignature(MetadataConstants.METADATA_DATAVERSE_NAME,
-                "switch-case", FunctionIdentifier.VARARGS);
+        FunctionSignature functionSignature = new FunctionSignature(BuiltinFunctions.SWITCH_CASE);
         List<Expression> whenExprList = newCaseExpr.getWhenExprs();
         List<Expression> thenExprList = newCaseExpr.getThenExprs();
         List<Expression> newExprList = new ArrayList<>();
@@ -90,7 +89,7 @@
             OperatorExpr operatorExpr = new OperatorExpr();
             operatorExpr.addOperand((Expression) SqlppRewriteUtil.deepCopy(expr));
             operatorExpr.addOperand(caseExpr.getConditionExpr());
-            operatorExpr.addOperator("=");
+            operatorExpr.addOperator(OperatorType.EQ);
             normalizedWhenExprs.add(operatorExpr);
         }
         return new CaseExpression(trueLiteral, normalizedWhenExprs, caseExpr.getThenExprs(),
caseExpr.getElseExpr());
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
index c56bb9d..fd50c8e 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
@@ -72,8 +72,7 @@
             Expression newExpr = rewriteArgument(expr);
             newExprList.add(newExpr.accept(this, arg));
         }
-        callExpr.setFunctionSignature(
-                new FunctionSignature(newAggFn.getNamespace(), newAggFn.getName(), newAggFn.getArity()));
+        callExpr.setFunctionSignature(new FunctionSignature(newAggFn));
         callExpr.setExprList(newExprList);
         return callExpr;
     }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
index c271365..6e6ffeb 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
@@ -39,13 +39,13 @@
 import org.apache.asterix.lang.sqlpp.visitor.CheckDatasetOnlyResolutionVisitor;
 import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppExpressionScopingVisitor;
 import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.metadata.utils.MetadataConstants;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 
 public class VariableCheckAndRewriteVisitor extends AbstractSqlppExpressionScopingVisitor
{
 
-    protected final FunctionSignature datasetFunction =
-            new FunctionSignature(MetadataConstants.METADATA_DATAVERSE_NAME, "dataset", 1);
+    private static final FunctionSignature FN_DATASET = new FunctionSignature(BuiltinFunctions.DATASET);
+
     protected final boolean overwrite;
     protected final MetadataProvider metadataProvider;
 
@@ -79,7 +79,7 @@
                     fa, parent);
             if (resolvedExpr.getKind() == Kind.CALL_EXPRESSION) {
                 CallExpr callExpr = (CallExpr) resolvedExpr;
-                if (callExpr.getFunctionSignature().equals(datasetFunction)) {
+                if (callExpr.getFunctionSignature().equals(FN_DATASET)) {
                     // The field access is resolved to be a dataset access in the form of
"dataverse.dataset".
                     return resolvedExpr;
                 }
@@ -172,7 +172,7 @@
         String fullyQualifiedName = dataverseName == null ? datasetName : dataverseName +
"." + datasetName;
         List<Expression> argList = new ArrayList<>();
         argList.add(new LiteralExpr(new StringLiteral(fullyQualifiedName)));
-        return new CallExpr(datasetFunction, argList);
+        return new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET), argList);
     }
 
     private boolean datasetExists(String dataverseName, String datasetName) throws CompilationException
{
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
index 8a8465d..06bb1b9 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
@@ -36,6 +36,7 @@
 
 public class FunctionMapUtil {
 
+    public static final String CONCAT = "concat";
     private final static String CORE_AGGREGATE_PREFIX = "coll_";
     private final static String CORE_SQL_AGGREGATE_PREFIX = "array_";
     private final static String INTERNAL_SQL_AGGREGATE_PREFIX = "sql-";
@@ -44,7 +45,7 @@
     private static final Map<String, String> LIST_INPUT_FUNCTION_MAP = new HashMap<>();
 
     static {
-        LIST_INPUT_FUNCTION_MAP.put("concat", "string-concat");
+        LIST_INPUT_FUNCTION_MAP.put(CONCAT, BuiltinFunctions.STRING_CONCAT.getName());
         LIST_INPUT_FUNCTION_MAP.put("greatest", CORE_SQL_AGGREGATE_PREFIX + "max");
         LIST_INPUT_FUNCTION_MAP.put("least", CORE_SQL_AGGREGATE_PREFIX + "min");
     }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppDeleteRewriteVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppDeleteRewriteVisitor.java
index 680ce55..4cda253 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppDeleteRewriteVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppDeleteRewriteVisitor.java
@@ -42,6 +42,7 @@
 import org.apache.asterix.lang.sqlpp.expression.SelectExpression;
 import org.apache.asterix.lang.sqlpp.struct.SetOperationInput;
 import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppAstVisitor;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 
 /**
  * This class rewrites delete statement to contain a query that specifying
@@ -58,8 +59,7 @@
                 : dataverseName.getValue() + "." + datasetName.getValue();
         LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg));
         arguments.add(argumentLiteral);
-        CallExpr callExpression =
-                new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, "dataset",
1), arguments);
+        CallExpr callExpression = new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET),
arguments);
 
         // From clause.
         VariableExpr var = deleteStmt.getVariableExpr();
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppExpressionScopingVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppExpressionScopingVisitor.java
index 96c5987..a935b3b 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppExpressionScopingVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppExpressionScopingVisitor.java
@@ -58,15 +58,12 @@
 import org.apache.asterix.lang.sqlpp.expression.SelectExpression;
 import org.apache.asterix.lang.sqlpp.struct.SetOperationRight;
 import org.apache.asterix.lang.sqlpp.util.SqlppVariableUtil;
-import org.apache.asterix.metadata.utils.MetadataConstants;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 import org.apache.hyracks.algebricks.core.algebra.base.Counter;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 public class AbstractSqlppExpressionScopingVisitor extends AbstractSqlppSimpleExpressionVisitor
{
 
-    protected final FunctionSignature resolveFunction =
-            new FunctionSignature(MetadataConstants.METADATA_DATAVERSE_NAME, "resolve", FunctionIdentifier.VARARGS);
     protected final ScopeChecker scopeChecker = new ScopeChecker();
     protected final LangRewritingContext context;
 
@@ -389,7 +386,7 @@
         String varName = SqlppVariableUtil.toUserDefinedVariableName(expr.getVar().getValue()).getValue();
         argList.add(new LiteralExpr(new StringLiteral(varName)));
         argList.addAll(liveVars);
-        return new CallExpr(resolveFunction, argList);
+        return new CallExpr(new FunctionSignature(BuiltinFunctions.RESOLVE), argList);
     }
 
     // Adds a new encountered alias identifier into a scope
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index d3a64d8..0af84a7 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -64,6 +64,7 @@
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.DatasetConfig.IndexType;
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.functions.FunctionConstants;
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.base.Literal;
@@ -165,6 +166,7 @@
 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.om.functions.BuiltinFunctions;
 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;
@@ -1856,7 +1858,7 @@
   (<NOT> { not = true; } )? inputExpr = RelExpr()
   {
     if(not){
-        FunctionSignature signature = new FunctionSignature(null, "not", 1);
+        FunctionSignature signature = new FunctionSignature(BuiltinFunctions.NOT);
         return new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(inputExpr)));
     } else {
         return inputExpr;
@@ -1991,10 +1993,10 @@
     ( <IS> (<NOT> { not = true; })? (<NULL> | <MISSING> | <UNKOWN>)
       {
         String functionName = "is-" + token.image.toLowerCase();
-        FunctionSignature signature = new FunctionSignature(null, functionName, 1);
+        FunctionSignature signature = new FunctionSignature(FunctionConstants.ASTERIX_NS,
functionName, 1);
         expr = new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(operand)));
         if(not) {
-           FunctionSignature notSignature = new FunctionSignature(null, "not", 1);
+           FunctionSignature notSignature = new FunctionSignature(BuiltinFunctions.NOT);
            expr = new CallExpr(notSignature, new ArrayList<Expression>(Collections.singletonList(expr)));
         }
       }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ExpressionTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ExpressionTypeComputer.java
index 5933dd9..e4cf000 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ExpressionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ExpressionTypeComputer.java
@@ -68,7 +68,7 @@
         FunctionIdentifier fi = expr.getFunctionIdentifier();
         // Note: built-in functions + udfs
         IResultTypeComputer rtc;
-        FunctionSignature signature = new FunctionSignature(fi.getNamespace(), fi.getName(),
fi.getArity());
+        FunctionSignature signature = new FunctionSignature(fi);
         if (BuiltinFunctions.isBuiltinCompilerFunction(signature, true)) {
             rtc = BuiltinFunctions.getResultTypeComputer(fi);
         } else {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/FunctionInfoRepository.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/FunctionInfoRepository.java
index b4622b5..20839f9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/FunctionInfoRepository.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/FunctionInfoRepository.java
@@ -29,12 +29,12 @@
     private final Map<FunctionSignature, IFunctionInfo> functionMap;
 
     public FunctionInfoRepository() {
-        functionMap = new ConcurrentHashMap<FunctionSignature, IFunctionInfo>();
+        functionMap = new ConcurrentHashMap<>();
     }
 
     public IFunctionInfo get(String namespace, String name, int arity) {
-        FunctionSignature fname = new FunctionSignature(namespace, name, arity);
-        return functionMap.get(fname);
+        FunctionSignature functionSignature = new FunctionSignature(namespace, name, arity);
+        return functionMap.get(functionSignature);
     }
 
     public IFunctionInfo get(FunctionIdentifier fid) {
@@ -42,7 +42,7 @@
     }
 
     public void put(FunctionIdentifier fid, IFunctionInfo fInfo) {
-        FunctionSignature functionSignature = new FunctionSignature(fid.getNamespace(), fid.getName(),
fid.getArity());
+        FunctionSignature functionSignature = new FunctionSignature(fid);
         functionMap.put(functionSignature, fInfo);
     }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib78e3267fd9b9ece40868076ba907ccb4a78da28
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Dmitry Lychagin <dmitry.lychagin@couchbase.com>

Mime
View raw message