Yingyi Bu has uploaded a new change for review.

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

Change subject: ASTERIXDB-1539: add function mapping for AQL.
......................................................................

ASTERIXDB-1539: add function mapping for AQL.

Change-Id: I6ab87a02c8c270535059bdec8281c72801418551
---
M 
asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/AqlQueryRewriter.java
A 
asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/visitor/AqlBuiltinFunctionRewriteVisitor.java
A 
asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/base/AbstractAqlSimpleExpressionVisitor.java
A 
asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
M 
asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
6 files changed, 362 insertions(+), 42 deletions(-)


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

diff --git 
a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/AqlQueryRewriter.java
 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/AqlQueryRewriter.java
index 4568309..e460316 100644
--- 
a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/AqlQueryRewriter.java
+++ 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/AqlQueryRewriter.java
@@ -30,6 +30,8 @@
 import org.apache.asterix.lang.aql.expression.UnionExpr;
 import org.apache.asterix.lang.aql.parser.AQLParserFactory;
 import org.apache.asterix.lang.aql.parser.FunctionParser;
+import 
org.apache.asterix.lang.aql.rewrites.visitor.AqlBuiltinFunctionRewriteVisitor;
+import org.apache.asterix.lang.common.util.CommonFunctionMapUtil;
 import org.apache.asterix.lang.aql.visitor.AQLInlineUdfsVisitor;
 import org.apache.asterix.lang.aql.visitor.base.IAQLVisitor;
 import org.apache.asterix.lang.common.base.Clause;
@@ -72,6 +74,7 @@
             wrapInLets();
         }
         inlineDeclaredUdfs();
+        rewriteFunctionName();
         topExpr.setVarCounter(context.getVarCounter());
     }
 
@@ -93,6 +96,14 @@
         }
     }
 
+    private void rewriteFunctionName() throws AsterixException {
+        if (topExpr == null) {
+            return;
+        }
+        AqlBuiltinFunctionRewriteVisitor visitor = new 
AqlBuiltinFunctionRewriteVisitor();
+        topExpr.accept(visitor, null);
+    }
+
     private void inlineDeclaredUdfs() throws AsterixException {
         if (topExpr == null) {
             return;
@@ -104,7 +115,8 @@
 
         List<FunctionDecl> storedFunctionDecls = 
FunctionUtil.retrieveUsedStoredFunctions(metadataProvider,
                 topExpr.getBody(), funIds, null,
-                expr -> getFunctionCalls(expr), func -> 
functionParser.getFunctionDecl(func), null);
+                expr -> getFunctionCalls(expr), func -> 
functionParser.getFunctionDecl(func),
+                signature -> 
CommonFunctionMapUtil.normalizeBuiltinFunctionSignature(signature));
         declaredFunctions.addAll(storedFunctionDecls);
         if (!declaredFunctions.isEmpty()) {
             AQLInlineUdfsVisitor visitor =
diff --git 
a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/visitor/AqlBuiltinFunctionRewriteVisitor.java
 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/visitor/AqlBuiltinFunctionRewriteVisitor.java
new file mode 100644
index 0000000..4c9a615
--- /dev/null
+++ 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/rewrites/visitor/AqlBuiltinFunctionRewriteVisitor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.lang.aql.rewrites.visitor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.functions.FunctionSignature;
+import org.apache.asterix.lang.common.util.CommonFunctionMapUtil;
+import 
org.apache.asterix.lang.aql.visitor.base.AbstractAqlSimpleExpressionVisitor;
+import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.base.ILangExpression;
+import org.apache.asterix.lang.common.expression.CallExpr;
+
+public class AqlBuiltinFunctionRewriteVisitor extends 
AbstractAqlSimpleExpressionVisitor {
+
+    @Override
+    public Expression visit(CallExpr callExpr, ILangExpression arg) throws 
AsterixException {
+        FunctionSignature functionSignature = callExpr.getFunctionSignature();
+        
callExpr.setFunctionSignature(CommonFunctionMapUtil.normalizeBuiltinFunctionSignature(functionSignature));
+        List<Expression> newExprList = new ArrayList<>();
+        for (Expression expr : callExpr.getExprList()) {
+            newExprList.add(expr.accept(this, arg));
+        }
+        callExpr.setExprList(newExprList);
+        return callExpr;
+    }
+
+}
diff --git 
a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/base/AbstractAqlSimpleExpressionVisitor.java
 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/base/AbstractAqlSimpleExpressionVisitor.java
new file mode 100644
index 0000000..2b71202
--- /dev/null
+++ 
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/base/AbstractAqlSimpleExpressionVisitor.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.lang.aql.visitor.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.aql.clause.DistinctClause;
+import org.apache.asterix.lang.aql.clause.ForClause;
+import org.apache.asterix.lang.aql.expression.FLWOGRExpression;
+import org.apache.asterix.lang.aql.expression.UnionExpr;
+import org.apache.asterix.lang.common.base.Clause;
+import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.base.ILangExpression;
+import org.apache.asterix.lang.common.clause.GroupbyClause;
+import org.apache.asterix.lang.common.clause.LetClause;
+import org.apache.asterix.lang.common.clause.LimitClause;
+import org.apache.asterix.lang.common.clause.OrderbyClause;
+import org.apache.asterix.lang.common.clause.WhereClause;
+import org.apache.asterix.lang.common.expression.CallExpr;
+import org.apache.asterix.lang.common.expression.FieldAccessor;
+import org.apache.asterix.lang.common.expression.FieldBinding;
+import org.apache.asterix.lang.common.expression.GbyVariableExpressionPair;
+import org.apache.asterix.lang.common.expression.IfExpr;
+import org.apache.asterix.lang.common.expression.IndexAccessor;
+import org.apache.asterix.lang.common.expression.ListConstructor;
+import org.apache.asterix.lang.common.expression.LiteralExpr;
+import org.apache.asterix.lang.common.expression.OperatorExpr;
+import org.apache.asterix.lang.common.expression.QuantifiedExpression;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
+import org.apache.asterix.lang.common.expression.UnaryExpr;
+import org.apache.asterix.lang.common.expression.VariableExpr;
+import org.apache.asterix.lang.common.statement.FunctionDecl;
+import org.apache.asterix.lang.common.statement.Query;
+import org.apache.asterix.lang.common.struct.QuantifiedPair;
+
+public class AbstractAqlSimpleExpressionVisitor extends 
AbstractAqlQueryExpressionVisitor<Expression, ILangExpression> {
+
+    @Override
+    public Expression visit(FLWOGRExpression flwogreExpr, ILangExpression arg) 
throws AsterixException {
+        for (Clause clause : flwogreExpr.getClauseList()) {
+            clause.accept(this, arg);
+        }
+        flwogreExpr.setReturnExpr(flwogreExpr.getReturnExpr().accept(this, 
arg));
+        return flwogreExpr;
+    }
+
+    @Override
+    public Expression visit(UnionExpr u, ILangExpression arg) throws 
AsterixException {
+        u.setExprs(visit(u.getExprs(), arg));
+        return u;
+    }
+
+    @Override
+    public Expression visit(ForClause forClause, ILangExpression arg) throws 
AsterixException {
+        forClause.setInExpr(forClause.getInExpr().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(DistinctClause distinctClause, ILangExpression 
arg) throws AsterixException {
+        
distinctClause.setDistinctByExpr(visit(distinctClause.getDistinctByExpr(), 
arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(Query q, ILangExpression arg) throws 
AsterixException {
+        q.setBody(visit(q.getBody(), q));
+        return null;
+    }
+
+    @Override
+    public Expression visit(FunctionDecl fd, ILangExpression arg) throws 
AsterixException {
+        fd.setFuncBody(visit(fd.getFuncBody(), fd));
+        return null;
+    }
+
+    @Override
+    public Expression visit(WhereClause whereClause, ILangExpression arg) 
throws AsterixException {
+        whereClause.setWhereExpr(visit(whereClause.getWhereExpr(), 
whereClause));
+        return null;
+    }
+
+    @Override
+    public Expression visit(OrderbyClause oc, ILangExpression arg) throws 
AsterixException {
+        oc.setOrderbyList(visit(oc.getOrderbyList(), arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(GroupbyClause gc, ILangExpression arg) throws 
AsterixException {
+        for (GbyVariableExpressionPair gbyVarExpr : gc.getGbyPairList()) {
+            gbyVarExpr.setExpr(visit(gbyVarExpr.getExpr(), gc));
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(LimitClause limitClause, ILangExpression arg) 
throws AsterixException {
+        limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), 
limitClause));
+        if (limitClause.hasOffset()) {
+            limitClause.setOffset(visit(limitClause.getOffset(), limitClause));
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(LetClause letClause, ILangExpression arg) throws 
AsterixException {
+        letClause.setBindingExpr(visit(letClause.getBindingExpr(), letClause));
+        return null;
+    }
+
+    @Override
+    public Expression visit(LiteralExpr l, ILangExpression arg) throws 
AsterixException {
+        return l;
+    }
+
+    @Override
+    public Expression visit(ListConstructor lc, ILangExpression arg) throws 
AsterixException {
+        lc.setExprList(visit(lc.getExprList(), arg));
+        return lc;
+    }
+
+    @Override
+    public Expression visit(RecordConstructor rc, ILangExpression arg) throws 
AsterixException {
+        for (FieldBinding binding : rc.getFbList()) {
+            binding.setLeftExpr(visit(binding.getLeftExpr(), rc));
+            binding.setRightExpr(visit(binding.getRightExpr(), rc));
+        }
+        return rc;
+    }
+
+    @Override
+    public Expression visit(OperatorExpr operatorExpr, ILangExpression arg) 
throws AsterixException {
+        operatorExpr.setExprList(visit(operatorExpr.getExprList(), arg));
+        return operatorExpr;
+    }
+
+    @Override
+    public Expression visit(IfExpr ifExpr, ILangExpression arg) throws 
AsterixException {
+        ifExpr.setCondExpr(visit(ifExpr.getCondExpr(), ifExpr));
+        ifExpr.setThenExpr(visit(ifExpr.getThenExpr(), ifExpr));
+        ifExpr.setElseExpr(visit(ifExpr.getElseExpr(), ifExpr));
+        return ifExpr;
+    }
+
+    @Override
+    public Expression visit(QuantifiedExpression qe, ILangExpression arg) 
throws AsterixException {
+        for (QuantifiedPair pair : qe.getQuantifiedList()) {
+            pair.setExpr(visit(pair.getExpr(), qe));
+        }
+        qe.setSatisfiesExpr(visit(qe.getSatisfiesExpr(), qe));
+        return qe;
+    }
+
+    @Override
+    public Expression visit(CallExpr callExpr, ILangExpression arg) throws 
AsterixException {
+        callExpr.setExprList(visit(callExpr.getExprList(), arg));
+        return callExpr;
+    }
+
+    @Override
+    public Expression visit(VariableExpr varExpr, ILangExpression arg) throws 
AsterixException {
+        return varExpr;
+    }
+
+    @Override
+    public Expression visit(UnaryExpr u, ILangExpression arg) throws 
AsterixException {
+        u.setExpr(visit(u.getExpr(), u));
+        return u;
+    }
+
+    @Override
+    public Expression visit(FieldAccessor fa, ILangExpression arg) throws 
AsterixException {
+        fa.setExpr(visit(fa.getExpr(), fa));
+        return fa;
+    }
+
+    @Override
+    public Expression visit(IndexAccessor ia, ILangExpression arg) throws 
AsterixException {
+        ia.setExpr(visit(ia.getExpr(), ia));
+        if (ia.getIndexExpr() != null) {
+            ia.setIndexExpr(visit(ia.getIndexExpr(), arg));
+        }
+        return ia;
+    }
+
+    protected Expression visit(Expression expr, ILangExpression arg) throws 
AsterixException {
+        return postVisit(preVisit(expr).accept(this, arg));
+    }
+
+    protected Expression preVisit(Expression expr) throws AsterixException {
+        return expr;
+    }
+
+    protected Expression postVisit(Expression expr) throws AsterixException {
+        return expr;
+    }
+
+    private List<Expression> visit(List<Expression> exprs, ILangExpression 
arg) throws AsterixException {
+        List<Expression> newExprList = new ArrayList<>();
+        for (Expression expr : exprs) {
+            newExprList.add(visit(expr, arg));
+        }
+        return newExprList;
+    }
+}
diff --git 
a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
 
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
new file mode 100644
index 0000000..ed2673f
--- /dev/null
+++ 
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.lang.common.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.functions.FunctionSignature;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+
+public class CommonFunctionMapUtil {
+
+    // Maps from a function name to an another internal function name (i.e., 
AsterixDB internal name).
+    private static final Map<String, String> FUNCTION_NAME_MAP = new 
HashMap<>();
+
+    static {
+        FUNCTION_NAME_MAP.put("ceil", "ceiling"); //ceil,  internal: ceiling
+        FUNCTION_NAME_MAP.put("length", "string-length"); // length,  
internal: string-length
+        FUNCTION_NAME_MAP.put("lower", "lowercase"); // lower, internal: 
lowercase
+        FUNCTION_NAME_MAP.put("substr", "substring"); // substr,  internal: 
substring
+        FUNCTION_NAME_MAP.put("upper", "uppercase"); // upper, internal: 
uppercase
+        FUNCTION_NAME_MAP.put("title", "initcap"); // title, internal: initcap
+        FUNCTION_NAME_MAP.put("regexp_contains", "matches"); // 
regexp_contains, internal: matches
+        FUNCTION_NAME_MAP.put("regexp_replace", "replace"); //regexp_replace, 
internal: replace
+        FUNCTION_NAME_MAP.put("power", "caret"); //pow, internal: caret
+        FUNCTION_NAME_MAP.put("int", "integer"); // int, internal: integer
+
+        // To be deprecated.
+        FUNCTION_NAME_MAP.put("int8", "tinyint"); // int64, internal: tinyint
+        FUNCTION_NAME_MAP.put("int16", "smallint"); // int16, internal: 
smallint
+        FUNCTION_NAME_MAP.put("int32", "integer"); // int32, internal: integer
+        FUNCTION_NAME_MAP.put("int64", "bigint"); // int64, internal: bigint
+    }
+
+    /**
+     * Maps a user invoked function signature to a system internal function 
signature.
+     *
+     * @param fs,
+     *            the user typed function.
+     * @return the system internal function.
+     */
+    public static FunctionSignature 
normalizeBuiltinFunctionSignature(FunctionSignature fs) throws AsterixException 
{
+        String name = fs.getName();
+        String lowerCaseName = name.toLowerCase();
+        String mappedName = FUNCTION_NAME_MAP.get(lowerCaseName);
+        if (mappedName != null) {
+            return new FunctionSignature(fs.getNamespace(), mappedName, 
fs.getArity());
+        }
+        String understoreName = lowerCaseName.replace('_', '-');
+        FunctionSignature newFs = new FunctionSignature(fs.getNamespace(), 
understoreName, fs.getArity());
+        return AsterixBuiltinFunctions.isBuiltinCompilerFunction(newFs, true) 
? newFs : fs;
+    }
+}
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 36e43de..c5d7a0a 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
@@ -28,6 +28,7 @@
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.lang.common.expression.CallExpr;
 import org.apache.asterix.lang.common.expression.ListConstructor;
+import org.apache.asterix.lang.common.util.CommonFunctionMapUtil;
 import org.apache.asterix.lang.common.util.FunctionUtil;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -37,25 +38,6 @@
 
     private final static String CORE_AGGREGATE_PREFIX = "array_";
     private final static String SQL_PREFIX = "sql-";
-
-    // Maps from a SQL function name to an AQL function name (i.e., AsterixDB 
internal name).
-    private static final Map<String, String> FUNCTION_NAME_MAP = new 
HashMap<>();
-
-    static {
-        FUNCTION_NAME_MAP.put("ceil", "ceiling"); //SQL: ceil,  AQL: ceiling
-        FUNCTION_NAME_MAP.put("length", "string-length"); // SQL: length,  
AQL: string-length
-        FUNCTION_NAME_MAP.put("lower", "lowercase"); // SQL: lower, AQL: 
lowercase
-        FUNCTION_NAME_MAP.put("substr", "substring"); // SQL: substr,  AQL: 
substring
-        FUNCTION_NAME_MAP.put("upper", "uppercase"); //SQL: upper, AQL: 
uppercase
-        FUNCTION_NAME_MAP.put("title", "initcap"); //SQL: title, SQL/AQL: 
initcap
-        FUNCTION_NAME_MAP.put("regexp_contains", "matches"); //SQL: 
regexp_contains, AQL: matches
-        FUNCTION_NAME_MAP.put("regexp_replace", "replace"); //SQL: 
regexp_replace, AQL: replace
-        FUNCTION_NAME_MAP.put("power", "caret"); //SQL: pow, AQL: caret
-        FUNCTION_NAME_MAP.put("tinyint", "int8"); //SQL: tinyint, AQL: int8
-        FUNCTION_NAME_MAP.put("smallint", "int16"); //SQL: smallint, AQL: int16
-        FUNCTION_NAME_MAP.put("integer", "int32"); //SQL: integer, AQL: int32
-        FUNCTION_NAME_MAP.put("bigint", "int64"); //SQL: bigint, AQL: int64
-    }
 
     // Maps from a variable-arg SQL function names to an internal list-arg 
function name.
     private static final Map<String, String> LIST_INPUT_FUNCTION_MAP = new 
HashMap<>();
@@ -130,7 +112,7 @@
      */
     public static FunctionSignature 
normalizeBuiltinFunctionSignature(FunctionSignature fs, boolean 
checkSql92Aggregate)
             throws AsterixException {
-        String mappedName = internalizeBuiltinScalarFunctionName(fs.getName());
+        String mappedName = 
CommonFunctionMapUtil.normalizeBuiltinFunctionSignature(fs).getName();
         if (isCoreAggregateFunction(fs)) {
             mappedName = internalizeCoreAggregateFunctionName(mappedName);
         } else if (checkSql92Aggregate && isSql92AggregateFunction(fs)) {
@@ -173,21 +155,4 @@
         return lowerCaseName.substring(CORE_AGGREGATE_PREFIX.length());
     }
 
-    /**
-     * Note: function name normalization can ONLY be called
-     * after all user-defined functions (by either "DECLARE FUNCTION" or 
"CREATE FUNCTION")
-     * are inlined, because user-defined function names are case-sensitive.
-     *
-     * @param name
-     *            the user-input function name in the query.
-     * @return the mapped internal name.
-     */
-    private static String internalizeBuiltinScalarFunctionName(String name) {
-        String lowerCaseName = name.toLowerCase();
-        String mappedName = FUNCTION_NAME_MAP.get(lowerCaseName);
-        if (mappedName != null) {
-            return mappedName;
-        }
-        return lowerCaseName.replace('_', '-');
-    }
 }
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
index a85d33b..f31d93d 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -511,13 +511,13 @@
     public static final FunctionIdentifier BINARY_BASE64_CONSTRUCTOR = new 
FunctionIdentifier(
             FunctionConstants.ASTERIX_NS, "base64", 1);
     public static final FunctionIdentifier INT8_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int8", 1);
+            "tinyint", 1);
     public static final FunctionIdentifier INT16_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int16", 1);
+            "smallint", 1);
     public static final FunctionIdentifier INT32_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int32", 1);
+            "integer", 1);
     public static final FunctionIdentifier INT64_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int64", 1);
+            "bigint", 1);
     public static final FunctionIdentifier FLOAT_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
             "float", 1);
     public static final FunctionIdentifier DOUBLE_CONSTRUCTOR = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ab87a02c8c270535059bdec8281c72801418551
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Yingyi Bu <[email protected]>

Reply via email to