Yingyi Bu has uploaded a new change for review.

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

Change subject: Add name mapping for SQL++ functions.
......................................................................

Add name mapping for SQL++ functions.

-Also allows SQL++ builtin functions to be case-insensitive.

Change-Id: Idb5a7c6780669b27065b0928bec7e4700cfb53a9
---
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
M 
asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
M 
asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
M 
asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
A 
asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
A 
asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppBuiltinFunctionRewriteVisitor.java
A 
asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppSimpleExpressionVisitor.java
67 files changed, 610 insertions(+), 130 deletions(-)


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

diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
index 8ccf4ef..845a5e6 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
@@ -22,7 +22,7 @@
 USE TinySocial;
 
 SELECT ELEMENT avg((
-select element "string-length"(message.message)
+select element LENGTH(message.message)
 FROM FacebookMessages AS message
 WHERE message."in-response-to" >= 1 and
       message."in-response-to" < 11
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
index 7c22f59..63ebe19 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
@@ -20,7 +20,7 @@
 USE TinySocial;
 
 SELECT ELEMENT avg((
-select element "string-length"(message.message)
+select element LENGTH(message.message)
 FROM FacebookMessages AS message
 WHERE message."in-response-to" >= 1 and
       message."in-response-to" < 11
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
index 94b313f..d2c1cb5 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
@@ -22,28 +22,28 @@
 
 set "import-private-functions" "true";
 
-select element 
{'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+select element 
{'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':SUM((
         select element i.l_quantity
         from  l as i
-    )),'sum_base_price':tpch.sum((
+    )),'sum_base_price':SUM((
         select element i.l_extendedprice
         from  l as i
-    )),'sum_disc_price':tpch.sum((
+    )),'sum_disc_price':SUM((
         select element (i.l_extendedprice * (1 - i.l_discount))
         from  l as i
-    )),'sum_charge':tpch.sum((
+    )),'sum_charge':SUM((
         select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
         from  l as i
-    )),'ave_qty':tpch.avg((
+    )),'ave_qty':AVG((
         select element i.l_quantity
         from  l as i
-    )),'ave_price':tpch.avg((
+    )),'ave_price':AVG((
         select element i.l_extendedprice
         from  l as i
-    )),'ave_disc':tpch.avg((
+    )),'ave_disc':AVG((
         select element i.l_discount
         from  l as i
-    )),'count_order':tpch.count(l)}
+    )),'count_order':COUNT(l)}
 from  LineItem as l
 where (l.l_shipdate <= '1998-09-02')
 /* +hash */
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
index a55c74d..795bdc7 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
@@ -45,7 +45,7 @@
 };
 declare function tmp2() {
 (
-    select element {'p_partkey':p_partkey,'ps_min_supplycost':tpch.min((
+    select element {'p_partkey':p_partkey,'ps_min_supplycost':MIN((
             select element i.ps_supplycost
             from  pssrn as i
         ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
index d30c6d3..e46182e 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
@@ -27,7 +27,7 @@
 where (((c.c_mktsegment = 'BUILDING') and (c.c_custkey = o.o_custkey)) and 
((l.l_orderkey = o.o_orderkey) and (o.o_orderdate < '1995-03-15') and 
(l.l_shipdate > '1995-03-15')))
 /* +hash */
 group by l.l_orderkey as l_orderkey,o.o_orderdate as 
o_orderdate,o.o_shippriority as o_shippriority
-with  revenue as tpch.sum((
+with  revenue as SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  l as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
index faca581..088e35b 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
@@ -27,7 +27,7 @@
     where (l.l_commitdate < l.l_receiptdate)
 )
 };
-select element {'order_priority':o_orderpriority,'count':tpch.count(o)}
+select element {'order_priority':o_orderpriority,'count':COUNT(o)}
 from  Orders as o,
       tpch.tmp() as t
 where ((o.o_orderkey = t.o_orderkey) and (o.o_orderdate >= '1993-07-01') and 
(o.o_orderdate < '1993-10-01'))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
index 150e4b1..e3ddd5b 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
@@ -46,7 +46,7 @@
 where ((c.c_nationkey = o1.s_nationkey) and (c.c_custkey = o1.o_custkey))
 /* +hash */
 group by o1.n_name as n_name
-with  revenue as tpch.sum((
+with  revenue as SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  o1 as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
index 9dee61f..35fbfcf 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
@@ -20,7 +20,7 @@
 use tpch;
 
 
-{'revenue':tpch.sum((
+{'revenue':SUM((
     select element (l.l_extendedprice * l.l_discount)
     from  LineItem as l
     where ((l.l_shipdate >= '1994-01-01') and (l.l_shipdate < '1995-01-01') 
and (l.l_discount >= 0.05) and (l.l_discount <= 0.07) and (l.l_quantity < 24))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
index 74d3b5a..dc69063 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
@@ -49,7 +49,7 @@
 with  l_year0 as tpch."get-year"(locs.l_shipdate)
 where ((locs.c_nationkey = t.c_nationkey) and (locs.s_nationkey = 
t.s_nationkey))
 group by t.supp_nation as supp_nation,t.cust_nation as cust_nation,l_year0 as 
l_year
-with  revenue as tpch.sum((
+with  revenue as SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  locs as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
index 77d3881..1824478 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
@@ -20,10 +20,10 @@
 use tpch;
 
 
-select element {'year':year,'mkt_share':(tpch.sum((
+select element {'year':year,'mkt_share':(SUM((
           select element tpch."switch-case"((i.s_name = 
'BRAZIL'),true,i.revenue,false,0.0)
           from  t as i
-      )) / tpch.sum((
+      )) / SUM((
           select element i.revenue
           from  t as i
       )))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
index f7e2e8f..c1a2bc5 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
@@ -20,7 +20,7 @@
 use tpch;
 
 
-select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+select element {'nation':nation,'o_year':o_year,'sum_profit':SUM((
         select element pr.amount
         from  profit as pr
     ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
index f75030c..65835b9 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
@@ -34,7 +34,7 @@
     where ((l.l_orderkey = ocn.o_orderkey) and (l.l_selectflag = 'R'))
 ) as locn
 group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as 
c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as 
c_address,locn.c_comment as c_comment
-with  revenue as tpch.sum((
+with  revenue as SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  locn as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
index f75030c..65835b9 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
@@ -34,7 +34,7 @@
     where ((l.l_orderkey = ocn.o_orderkey) and (l.l_selectflag = 'R'))
 ) as locn
 group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as 
c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as 
c_address,locn.c_comment as c_comment
-with  revenue as tpch.sum((
+with  revenue as SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  locn as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
index ea3bd5a..c76a6ea 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
@@ -20,7 +20,7 @@
 use tpch;
 
 
-with  sum as tpch.sum((
+with  sum as SUM((
       select element (ps.ps_supplycost * ps.ps_availqty)
       from  Partsupp as ps,
             (
@@ -33,7 +33,7 @@
   ))
 select element {'partkey':t1.ps_partkey,'part_value':t1.part_value}
 from  (
-    select element {'ps_partkey':ps_partkey,'part_value':tpch.sum((
+    select element {'ps_partkey':ps_partkey,'part_value':SUM((
             select element (i.ps_supplycost * i.ps_availqty)
             from  ps as i
         ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
index 61b685e..18d12b4 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
@@ -20,10 +20,10 @@
 use tpch;
 
 
-select element {'l_shipmode':l_shipmode,'high_line_count':tpch.sum((
+select element {'l_shipmode':l_shipmode,'high_line_count':SUM((
         select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or 
(i.o_orderpriority = '2-HIGH')),true,1,false,0)
         from  o as i
-    )),'low_line_count':tpch.sum((
+    )),'low_line_count':SUM((
         select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or 
(i.o_orderpriority = '2-HIGH')),true,0,false,1)
         from  o as i
     ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
index afa7c9b..83c8959 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
@@ -24,7 +24,7 @@
 
 select element {'c_count':c_count,'custdist':custdist}
 from  (
-    select element {'c_custkey':c_custkey,'c_count':tpch.sum((
+    select element {'c_custkey':c_custkey,'c_count':SUM((
             select element i.o_orderkey_count
             from  co as i
         ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
index 559dfc8..4971c3a 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
@@ -20,10 +20,10 @@
 use tpch;
 
 
-select element (100.0 * tpch.sum((
-      select element 
tpch."switch-case"(tpch.like(i.p_type,'PROMO%'),true,(i.l_extendedprice * (1 - 
i.l_discount)),false,0.0)
+select element (100.0 * SUM((
+      select element 
tpch."switch-case"(LIKE(i.p_type,'PROMO%'),true,(i.l_extendedprice * (1 - 
i.l_discount)),false,0.0)
       from  l as i
-  )) / tpch.sum((
+  )) / SUM((
       select element (i.l_extendedprice * (1 - i.l_discount))
       from  l as i
   )))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
index e21104b..daf74bf 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
@@ -22,7 +22,7 @@
 
 declare function revenue() {
 (
-    select element {'supplier_no':l_suppkey,'total_revenue':tpch.sum((
+    select element {'supplier_no':l_suppkey,'total_revenue':SUM((
             select element (i.l_extendedprice * (1 - i.l_discount))
             from  l as i
         ))}
@@ -31,7 +31,7 @@
     group by l.l_suppkey as l_suppkey
 )
 };
-with  m as tpch.max((
+with  m as MAX((
       select element r2.total_revenue
       from  tpch.revenue() as r2
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
index cc4d01a..b695120 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
@@ -27,10 +27,10 @@
         select element 
{'p_brand':p.p_brand,'p_type':p.p_type,'p_size':p.p_size,'ps_suppkey':ps.ps_suppkey}
         from  Partsupp as ps,
               Part as p
-        where ((p.p_partkey = ps.ps_partkey) and (p.p_brand != 'Brand#45') and 
tpch.not(tpch.like(p.p_type,'MEDIUM POLISHED%')))
+        where ((p.p_partkey = ps.ps_partkey) and (p.p_brand != 'Brand#45') and 
NOT(tpch.like(p.p_type,'MEDIUM POLISHED%')))
     ) as psp,
           Supplier as s
-    where ((psp.ps_suppkey = s.s_suppkey) and 
tpch.not(tpch.like(s.s_comment,'%Customer%Complaints%')))
+    where ((psp.ps_suppkey = s.s_suppkey) and 
tpch.not(LIKE(s.s_comment,'%Customer%Complaints%')))
 )
 };
 select element 
{'p_brand':p_brand,'p_type':p_type,'p_size':p_size,'supplier_cnt':supplier_cnt}
@@ -41,7 +41,7 @@
     group by t.p_brand as p_brand1,t.p_type as p_type1,t.p_size as 
p_size1,t.ps_suppkey as ps_suppkey1
 ) as t2
 group by t2.p_brand as p_brand,t2.p_type as p_type,t2.p_size as p_size
-with  supplier_cnt as tpch.count((
+with  supplier_cnt as COUNT((
       select element i.ps_suppkey
       from  t2 as i
   ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
index ada4f75..60c1cc4 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
@@ -20,34 +20,34 @@
 use tpch;
 
 
-select element 
{'t_partkey':l_partkey,'t_count':tpch.count(l),'t_avg_quantity':(0.2 * 
tpch.avg((
+select element {'t_partkey':l_partkey,'t_count':COUNT(l),'t_avg_quantity':(0.2 
* AVG((
           select element i.l_quantity
           from  l as i
-      ))),'t_max_suppkey':tpch.max((
+      ))),'t_max_suppkey':MAX((
         select element i.l_suppkey
         from  l as i
-    )),'t_max_linenumber':tpch.max((
+    )),'t_max_linenumber':MAX((
         select element i.l_linenumber
         from  l as i
-    )),'t_avg_extendedprice':tpch.avg((
+    )),'t_avg_extendedprice':AVG((
         select element i.l_extendedprice
         from  l as i
-    )),'t_avg_discount':tpch.avg((
+    )),'t_avg_discount':AVG((
         select element i.l_discount
         from  l as i
-    )),'t_avg_tax':tpch.avg((
+    )),'t_avg_tax':AVG((
         select element i.l_tax
         from  l as i
-    )),'t_max_shipdate':tpch.max((
+    )),'t_max_shipdate':MAX((
         select element i.l_shipdate
         from  l as i
-    )),'t_min_commitdate':tpch.min((
+    )),'t_min_commitdate':MIN((
         select element i.l_commitdate
         from  l as i
-    )),'t_min_receiptdate':tpch.min((
+    )),'t_min_receiptdate':MIN((
         select element i.l_receiptdate
         from  l as i
-    )),'t_max_comment':tpch.max((
+    )),'t_max_comment':MAX((
         select element i.l_comment
         from  l as i
     ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
index 5aa971e..9819965 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
@@ -22,7 +22,7 @@
 
 declare function tmp() {
 (
-    select element {'t_partkey':l_partkey,'t_avg_quantity':(0.2 * tpch.avg((
+    select element {'t_partkey':l_partkey,'t_avg_quantity':(0.2 * AVG((
               select element i.l_quantity
               from  l as i
           )))}
@@ -31,7 +31,7 @@
 )
 };
 
-select element (tpch.sum((
+select element (SUM((
       select element l.l_extendedprice
       from  LineItem as l,
             Part as p,
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
index 15081ff..6fa2a65 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
@@ -20,14 +20,14 @@
 use tpch;
 
 
-select element 
{'c_name':c_name,'c_custkey':c_custkey,'o_orderkey':o_orderkey,'o_orderdate':o_orderdate,'o_totalprice':o_totalprice,'sum_quantity':tpch.sum((
+select element 
{'c_name':c_name,'c_custkey':c_custkey,'o_orderkey':o_orderkey,'o_orderdate':o_orderdate,'o_totalprice':o_totalprice,'sum_quantity':SUM((
         select element j.l_quantity
         from  l as j
     ))}
 from  Customer as c,
       Orders as o,
       (
-    select element {'l_orderkey':l_orderkey,'t_sum_quantity':tpch.sum((
+    select element {'l_orderkey':l_orderkey,'t_sum_quantity':SUM((
             select element i.l_quantity
             from  l as i
         ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
index 7065f87..9c80a67 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
@@ -22,7 +22,7 @@
 
 set "import-private-functions" "true";
 
-select element tpch.sum((
+select element SUM((
     select element (l.l_extendedprice * (1 - l.l_discount))
     from  LineItem as l,
           Part as p
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
index 0657ad3..25ee43c 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
@@ -24,7 +24,7 @@
 from  (
     select distinct element {'ps_suppkey':pst1.ps_suppkey}
     from  (
-        select element 
{'l_partkey':l_partkey,'l_suppkey':l_suppkey,'sum_quantity':(0.5 * tpch.sum((
+        select element 
{'l_partkey':l_partkey,'l_suppkey':l_suppkey,'sum_quantity':(0.5 * SUM((
                   select element i.l_quantity
                   from  l as i
               )))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
index 5382019..b25d826 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
@@ -22,7 +22,7 @@
 
 declare function tmp1() {
 (
-    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+    select element {'l_orderkey':l_orderkey,'count_suppkey':COUNT((
             select element i.l_suppkey
             from  l2 as i
         )),'max_suppkey':tpch.max((
@@ -39,10 +39,10 @@
 };
 declare function tmp2() {
 (
-    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+    select element {'l_orderkey':l_orderkey,'count_suppkey':COUNT((
             select element i.l_suppkey
             from  l2 as i
-        )),'max_suppkey':tpch.max((
+        )),'max_suppkey':MAX((
             select element i.l_suppkey
             from  l2 as i
         ))}
@@ -75,6 +75,6 @@
     where ((t2.count_suppkey >= 0) and (t3.l_orderkey = t2.l_orderkey))
 ) as t4
 group by t4.s_name as s_name
-with  numwait as tpch.count(t4)
+with  numwait as COUNT(t4)
 order by numwait desc,s_name
 ;
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
index 6136008..8f8bd30 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
@@ -22,7 +22,7 @@
 
 declare function q22_customer_tmp() {
 (
-    select element 
{'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':tpch.substring(c.c_phone,1,2)}
+    select element 
{'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':SUBSTR(c.c_phone,1,2)}
     from  Customer as c
 )
 };
@@ -31,7 +31,7 @@
       from  Customer as c
       where (c.c_acctbal > 0.0)
   ))
-select element 
{'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.sum((
+select element {'cntrycode':cntrycode,'numcust':COUNT(ct),'totacctbal':SUM((
         select element i.c_acctbal
         from  ct as i
     ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
index 44852ec..f49b744 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
@@ -26,7 +26,7 @@
 use tpch;
 
 
-select element {'l_linenumber':l_linenumber,'count_order':tpch.count(l)}
+select element {'l_linenumber':l_linenumber,'count_order':COUNT(l)}
 from  LineItem as l
 group by l.l_linenumber as l_linenumber
 ;
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
index d2e8a7e..9d1fd99 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
@@ -26,7 +26,7 @@
 use tpch;
 
 
-select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+select element {'nation':nation,'o_year':o_year,'sum_profit':SUM((
         select element pr.amount
         from  profit as pr
     ))}
@@ -52,7 +52,7 @@
             ) as l1
             where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = 
l1.l_partkey))
         ) as l2
-        where (tpch.contains(p.p_name,'green') and (p.p_partkey = 
l2.l_partkey))
+        where (CONTAINS(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
     ) as l3
     with  amount as ((l3.l_extendedprice * (1 - l3.l_discount)) - 
(l3.ps_supplycost * l3.l_quantity)),
           o_year as tpch."get-year"(o.o_orderdate)
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
index 341d824..be09a4d 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
@@ -39,7 +39,7 @@
             Orders as orders
       where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey 
= n.n_nationkey))
       group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
-      with  sum as tpch.sum((
+      with  sum as SUM((
             select element o.o_totalprice
             from  orders as o
         ))
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
index 0f31629..50dae4d 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
@@ -30,7 +30,7 @@
         select element {'orderdate':od,'sum_price':sum}
         from  x as i
         group by i.order_date as od
-        with  sum as tpch.sum((
+        with  sum as SUM((
               select element s.sum_price
               from  i as s
           ))
@@ -38,7 +38,7 @@
         limit 3
     )}
 from  (
-    select element 
{'nation_key':nation_key,'order_date':orderdate,'sum_price':tpch.sum((
+    select element 
{'nation_key':nation_key,'order_date':orderdate,'sum_price':SUM((
             select element o.o_totalprice
             from  orders as o
         ))}
diff --git 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
index c35853c..4e73306 100644
--- 
a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
+++ 
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
@@ -32,7 +32,7 @@
               Customer as customer
         where ((orders.o_custkey = customer.c_custkey) and 
(customer.c_nationkey = nation.n_nationkey))
         group by orders.o_orderdate as orderdate
-        with  sum as tpch.sum((
+        with  sum as SUM((
               select element o.o_totalprice
               from  orders as o
           ))
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
index cf21764..ed7d41b 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
@@ -4,7 +4,7 @@
 FunctionCall TinySocial.avg@1[
   (
     SELECT ELEMENT [
-    FunctionCall TinySocial.string-length@1[
+    FunctionCall TinySocial.LENGTH@1[
       FieldAccessor [
         Variable [ Name=message ]
         Field=message
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
index cf21764..ed7d41b 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
@@ -4,7 +4,7 @@
 FunctionCall TinySocial.avg@1[
   (
     SELECT ELEMENT [
-    FunctionCall TinySocial.string-length@1[
+    FunctionCall TinySocial.LENGTH@1[
       FieldAccessor [
         Variable [ Name=message ]
         Field=message
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
index 40474c7..7ab427b 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
@@ -16,7 +16,7 @@
   (
     LiteralExpr [STRING] [sum_qty]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -34,7 +34,7 @@
   (
     LiteralExpr [STRING] [sum_base_price]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -52,7 +52,7 @@
   (
     LiteralExpr [STRING] [sum_disc_price]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         OperatorExpr [
@@ -81,7 +81,7 @@
   (
     LiteralExpr [STRING] [sum_charge]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         OperatorExpr [
@@ -119,7 +119,7 @@
   (
     LiteralExpr [STRING] [ave_qty]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -137,7 +137,7 @@
   (
     LiteralExpr [STRING] [ave_price]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -155,7 +155,7 @@
   (
     LiteralExpr [STRING] [ave_disc]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -173,7 +173,7 @@
   (
     LiteralExpr [STRING] [count_order]
     :
-    FunctionCall tpch.count@1[
+    FunctionCall tpch.COUNT@1[
       Variable [ Name=l ]
     ]
   )
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
index 52df01f..4c067a0 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
@@ -344,7 +344,7 @@
       (
         LiteralExpr [STRING] [ps_min_supplycost]
         :
-        FunctionCall tpch.min@1[
+        FunctionCall tpch.MIN@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
index 8193892..c98dbff 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
@@ -125,7 +125,7 @@
 
 LetVariable [ Name=revenue ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
index 4dc7445..7cd4e01 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
@@ -43,7 +43,7 @@
   (
     LiteralExpr [STRING] [count]
     :
-    FunctionCall tpch.count@1[
+    FunctionCall tpch.COUNT@1[
       Variable [ Name=o ]
     ]
   )
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
index 2b505fb..13241e9 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
@@ -313,7 +313,7 @@
 
 LetVariable [ Name=revenue ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
index f802e5e..afcce58 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
@@ -4,7 +4,7 @@
   (
     LiteralExpr [STRING] [revenue]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
index deed492..8139ae2 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
@@ -382,7 +382,7 @@
 
 LetVariable [ Name=revenue ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
index f6dbd18..beb5022 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
@@ -11,7 +11,7 @@
     LiteralExpr [STRING] [mkt_share]
     :
     OperatorExpr [
-      FunctionCall tpch.sum@1[
+      FunctionCall tpch.SUM@1[
         (
           SELECT ELEMENT [
           FunctionCall tpch.switch-case@5[
@@ -39,7 +39,7 @@
         )
       ]
       /
-      FunctionCall tpch.sum@1[
+      FunctionCall tpch.SUM@1[
         (
           SELECT ELEMENT [
           FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
index 8052433..bee386c 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
@@ -15,7 +15,7 @@
   (
     LiteralExpr [STRING] [sum_profit]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
index 95cef5d..8218cf8 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
@@ -339,7 +339,7 @@
 
 LetVariable [ Name=revenue ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
index 95cef5d..8218cf8 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
@@ -339,7 +339,7 @@
 
 LetVariable [ Name=revenue ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
index 6fb853e..b9ab718 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
@@ -2,7 +2,7 @@
 Query:
 LetVariable [ Name=sum ]
   :=
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
@@ -109,7 +109,7 @@
       (
         LiteralExpr [STRING] [part_value]
         :
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
index c478139..1cd4af7 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
@@ -10,7 +10,7 @@
   (
     LiteralExpr [STRING] [high_line_count]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FunctionCall tpch.switch-case@5[
@@ -49,7 +49,7 @@
   (
     LiteralExpr [STRING] [low_line_count]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FunctionCall tpch.switch-case@5[
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
index 2b22632..4fa7144 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
@@ -26,7 +26,7 @@
       (
         LiteralExpr [STRING] [c_count]
         :
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
index 57b4c73..1ad910f 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
@@ -4,11 +4,11 @@
 OperatorExpr [
   LiteralExpr [DOUBLE] [100.0]
   *
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       FunctionCall tpch.switch-case@5[
-        FunctionCall tpch.like@2[
+        FunctionCall tpch.LIKE@2[
           FieldAccessor [
             Variable [ Name=i ]
             Field=p_type
@@ -42,7 +42,7 @@
     )
   ]
   /
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
index b19616d..fbd2d02 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
@@ -11,7 +11,7 @@
       (
         LiteralExpr [STRING] [total_revenue]
         :
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             OperatorExpr [
@@ -77,7 +77,7 @@
 Query:
 LetVariable [ Name=m ]
   :=
-  FunctionCall tpch.max@1[
+  FunctionCall tpch.MAX@1[
     (
       SELECT ELEMENT [
       FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
index dc55293..da8656b 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
@@ -105,7 +105,7 @@
               LiteralExpr [STRING] [Brand#45]
             ]
             and
-            FunctionCall tpch.not@1[
+            FunctionCall tpch.NOT@1[
               FunctionCall tpch.like@2[
                 FieldAccessor [
                   Variable [ Name=p ]
@@ -138,7 +138,7 @@
         ]
         and
         FunctionCall tpch.not@1[
-          FunctionCall tpch.like@2[
+          FunctionCall tpch.LIKE@2[
             FieldAccessor [
               Variable [ Name=s ]
               Field=s_comment
@@ -335,7 +335,7 @@
 
 LetVariable [ Name=supplier_cnt ]
   :=
-  FunctionCall tpch.count@1[
+  FunctionCall tpch.COUNT@1[
     (
       SELECT ELEMENT [
       FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
index 19e5d78..34835d4 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
@@ -10,7 +10,7 @@
   (
     LiteralExpr [STRING] [t_count]
     :
-    FunctionCall tpch.count@1[
+    FunctionCall tpch.COUNT@1[
       Variable [ Name=l ]
     ]
   )
@@ -20,7 +20,7 @@
     OperatorExpr [
       LiteralExpr [DOUBLE] [0.2]
       *
-      FunctionCall tpch.avg@1[
+      FunctionCall tpch.AVG@1[
         (
           SELECT ELEMENT [
           FieldAccessor [
@@ -39,7 +39,7 @@
   (
     LiteralExpr [STRING] [t_max_suppkey]
     :
-    FunctionCall tpch.max@1[
+    FunctionCall tpch.MAX@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -57,7 +57,7 @@
   (
     LiteralExpr [STRING] [t_max_linenumber]
     :
-    FunctionCall tpch.max@1[
+    FunctionCall tpch.MAX@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -75,7 +75,7 @@
   (
     LiteralExpr [STRING] [t_avg_extendedprice]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -93,7 +93,7 @@
   (
     LiteralExpr [STRING] [t_avg_discount]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -111,7 +111,7 @@
   (
     LiteralExpr [STRING] [t_avg_tax]
     :
-    FunctionCall tpch.avg@1[
+    FunctionCall tpch.AVG@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -129,7 +129,7 @@
   (
     LiteralExpr [STRING] [t_max_shipdate]
     :
-    FunctionCall tpch.max@1[
+    FunctionCall tpch.MAX@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -147,7 +147,7 @@
   (
     LiteralExpr [STRING] [t_min_commitdate]
     :
-    FunctionCall tpch.min@1[
+    FunctionCall tpch.MIN@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -165,7 +165,7 @@
   (
     LiteralExpr [STRING] [t_min_receiptdate]
     :
-    FunctionCall tpch.min@1[
+    FunctionCall tpch.MIN@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -183,7 +183,7 @@
   (
     LiteralExpr [STRING] [t_max_comment]
     :
-    FunctionCall tpch.max@1[
+    FunctionCall tpch.MAX@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
index 845240a..79cfea1 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
@@ -14,7 +14,7 @@
         OperatorExpr [
           LiteralExpr [DOUBLE] [0.2]
           *
-          FunctionCall tpch.avg@1[
+          FunctionCall tpch.AVG@1[
             (
               SELECT ELEMENT [
               FieldAccessor [
@@ -50,7 +50,7 @@
 Query:
 SELECT ELEMENT [
 OperatorExpr [
-  FunctionCall tpch.sum@1[
+  FunctionCall tpch.SUM@1[
     (
       SELECT ELEMENT [
       FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
index edf6190..a4ce1d4 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
@@ -30,7 +30,7 @@
   (
     LiteralExpr [STRING] [sum_quantity]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -70,7 +70,7 @@
       (
         LiteralExpr [STRING] [t_sum_quantity]
         :
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
index 46e01a7..ef0c098 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
@@ -2,7 +2,7 @@
 Set import-private-functions=true
 Query:
 SELECT ELEMENT [
-FunctionCall tpch.sum@1[
+FunctionCall tpch.SUM@1[
   (
     SELECT ELEMENT [
     OperatorExpr [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
index fda99ec..7f7888e 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
@@ -52,7 +52,7 @@
             OperatorExpr [
               LiteralExpr [DOUBLE] [0.5]
               *
-              FunctionCall tpch.sum@1[
+              FunctionCall tpch.SUM@1[
                 (
                   SELECT ELEMENT [
                   FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
index c471683..e0c31fc 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
@@ -11,7 +11,7 @@
       (
         LiteralExpr [STRING] [count_suppkey]
         :
-        FunctionCall tpch.count@1[
+        FunctionCall tpch.COUNT@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
@@ -106,7 +106,7 @@
       (
         LiteralExpr [STRING] [count_suppkey]
         :
-        FunctionCall tpch.count@1[
+        FunctionCall tpch.COUNT@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
@@ -124,7 +124,7 @@
       (
         LiteralExpr [STRING] [max_suppkey]
         :
-        FunctionCall tpch.max@1[
+        FunctionCall tpch.MAX@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
@@ -456,7 +456,7 @@
 
 LetVariable [ Name=numwait ]
   :=
-  FunctionCall tpch.count@1[
+  FunctionCall tpch.COUNT@1[
     Variable [ Name=t4 ]
   ]
 Orderby
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
index 8efbfe5..08f7f5a 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
@@ -22,7 +22,7 @@
       (
         LiteralExpr [STRING] [cntrycode]
         :
-        FunctionCall tpch.substring@3[
+        FunctionCall tpch.SUBSTR@3[
           FieldAccessor [
             Variable [ Name=c ]
             Field=c_phone
@@ -78,14 +78,14 @@
   (
     LiteralExpr [STRING] [numcust]
     :
-    FunctionCall tpch.count@1[
+    FunctionCall tpch.COUNT@1[
       Variable [ Name=ct ]
     ]
   )
   (
     LiteralExpr [STRING] [totacctbal]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
index 3776535..b81fe14 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
@@ -10,7 +10,7 @@
   (
     LiteralExpr [STRING] [count_order]
     :
-    FunctionCall tpch.count@1[
+    FunctionCall tpch.COUNT@1[
       Variable [ Name=l ]
     ]
   )
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
index 8052433..0404c45 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
@@ -15,7 +15,7 @@
   (
     LiteralExpr [STRING] [sum_profit]
     :
-    FunctionCall tpch.sum@1[
+    FunctionCall tpch.SUM@1[
       (
         SELECT ELEMENT [
         FieldAccessor [
@@ -351,7 +351,7 @@
         ]
         Where
           OperatorExpr [
-            FunctionCall tpch.contains@2[
+            FunctionCall tpch.CONTAINS@2[
               FieldAccessor [
                 Variable [ Name=p ]
                 Field=p_name
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
index 715999d..5afd7a2 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
@@ -133,7 +133,7 @@
 
     LetVariable [ Name=sum ]
       :=
-      FunctionCall tpch.sum@1[
+      FunctionCall tpch.SUM@1[
         (
           SELECT ELEMENT [
           FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
index f69a6be..2e634b7 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
@@ -43,7 +43,7 @@
 
       LetVariable [ Name=sum ]
         :=
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
@@ -83,7 +83,7 @@
       (
         LiteralExpr [STRING] [sum_price]
         :
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
diff --git 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
index dcd0269..5cb62dc 100644
--- 
a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
+++ 
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
@@ -89,7 +89,7 @@
 
       LetVariable [ Name=sum ]
         :=
-        FunctionCall tpch.sum@1[
+        FunctionCall tpch.SUM@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
diff --git 
a/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
 
b/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
index 8cff0e8..c7d48b6 100644
--- 
a/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
+++ 
b/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
@@ -27,7 +27,7 @@
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
 
 public class CallExpr extends AbstractExpression {
-    private final FunctionSignature functionSignature;
+    private FunctionSignature functionSignature;
     private List<Expression> exprList;
     private boolean isBuiltin;
 
@@ -53,6 +53,10 @@
         return Kind.CALL_EXPRESSION;
     }
 
+    public void setFunctionSignature(FunctionSignature functionSignature) {
+        this.functionSignature = functionSignature;
+    }
+
     public void setExprList(List<Expression> exprList) {
         this.exprList = exprList;
     }
diff --git 
a/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
index 3143214..0a34520 100644
--- 
a/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
+++ 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/SqlppQueryRewriter.java
@@ -49,7 +49,9 @@
 import org.apache.asterix.lang.sqlpp.parser.FunctionParser;
 import org.apache.asterix.lang.sqlpp.parser.SqlppParserFactory;
 import org.apache.asterix.lang.sqlpp.struct.SetOperationRight;
+import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil;
 import org.apache.asterix.lang.sqlpp.visitor.InlineColumnAliasVisitor;
+import 
org.apache.asterix.lang.sqlpp.visitor.SqlppBuiltinFunctionRewriteVisitor;
 import org.apache.asterix.lang.sqlpp.visitor.SqlppInlineUdfsVisitor;
 import org.apache.asterix.lang.sqlpp.visitor.VariableCheckAndRewriteVisitor;
 import org.apache.asterix.lang.sqlpp.visitor.base.ISqlppVisitor;
@@ -94,8 +96,21 @@
         // Replace global variable access with the dataset function for 
inlined expressions.
         variableCheckAndRewrite(true);
 
+        // Rewrites function names.
+        // This should be done after inlineDeclaredUdfs() because user-defined 
function
+        // names could be case sensitive.
+        rewriteFunctionNames();
+
         // Sets the var counter of the query.
         topExpr.setVarCounter(context.getVarCounter());
+    }
+
+    protected void rewriteFunctionNames() throws AsterixException {
+        if (topExpr == null) {
+            return;
+        }
+        SqlppBuiltinFunctionRewriteVisitor functionNameMapVisitor = new 
SqlppBuiltinFunctionRewriteVisitor();
+        functionNameMapVisitor.visit(topExpr, null);
     }
 
     protected void inlineColumnAlias() throws AsterixException {
@@ -155,7 +170,8 @@
 
             Function function = lookupUserDefinedFunctionDecl(signature);
             if (function == null) {
-                if 
(AsterixBuiltinFunctions.isBuiltinCompilerFunction(signature, 
includePrivateFunctions)) {
+                FunctionSignature normalizedSignature = 
FunctionMapUtil.normalizeBuiltinFunctionSignature(signature);
+                if 
(AsterixBuiltinFunctions.isBuiltinCompilerFunction(normalizedSignature, 
includePrivateFunctions)) {
                     continue;
                 }
                 StringBuilder messageBuilder = new StringBuilder();
diff --git 
a/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
new file mode 100644
index 0000000..b090c40
--- /dev/null
+++ 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
@@ -0,0 +1,68 @@
+/*
+ * 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.sqlpp.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.asterix.common.functions.FunctionSignature;
+
+public class FunctionMapUtil {
+
+    // 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
+    }
+
+    /**
+     * 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 normalizeBuiltinFunctionName(String name) {
+        String lowerCaseName = name.toLowerCase();
+        String mappedName = FUNCTION_NAME_MAP.get(lowerCaseName);
+        if (mappedName != null) {
+            return mappedName;
+        }
+        return lowerCaseName;
+    }
+
+    /**
+     * 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) {
+        String mappedName = normalizeBuiltinFunctionName(fs.getName());
+        return new FunctionSignature(fs.getNamespace(), mappedName, 
fs.getArity());
+    }
+}
diff --git 
a/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppBuiltinFunctionRewriteVisitor.java
 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppBuiltinFunctionRewriteVisitor.java
new file mode 100644
index 0000000..5e61a3e
--- /dev/null
+++ 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppBuiltinFunctionRewriteVisitor.java
@@ -0,0 +1,48 @@
+/*
+ * 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.sqlpp.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.base.Expression;
+import org.apache.asterix.lang.common.expression.CallExpr;
+import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil;
+import 
org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppSimpleExpressionVisitor;
+
+public class SqlppBuiltinFunctionRewriteVisitor extends 
AbstractSqlppSimpleExpressionVisitor {
+
+    @Override
+    public Expression visit(CallExpr callExpr, Void arg) throws 
AsterixException {
+        //TODO(buyingyi):
+        // 1. rewrite SQL++ core aggregation functions.
+        // 2. rewrite SQL temporal functions
+        FunctionSignature functionSignature = callExpr.getFunctionSignature();
+        
callExpr.setFunctionSignature(FunctionMapUtil.normalizeBuiltinFunctionSignature(functionSignature));
+        List<Expression> newExprList = new ArrayList<Expression>();
+        for (Expression expr : callExpr.getExprList()) {
+            newExprList.add(expr.accept(this, arg));
+        }
+        callExpr.setExprList(newExprList);
+        return callExpr;
+    }
+
+}
diff --git 
a/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppSimpleExpressionVisitor.java
 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppSimpleExpressionVisitor.java
new file mode 100644
index 0000000..e60f3a5
--- /dev/null
+++ 
b/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/base/AbstractSqlppSimpleExpressionVisitor.java
@@ -0,0 +1,344 @@
+/*
+ * 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.sqlpp.visitor.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.common.base.Expression;
+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;
+import org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause;
+import org.apache.asterix.lang.sqlpp.clause.FromClause;
+import org.apache.asterix.lang.sqlpp.clause.FromTerm;
+import org.apache.asterix.lang.sqlpp.clause.HavingClause;
+import org.apache.asterix.lang.sqlpp.clause.JoinClause;
+import org.apache.asterix.lang.sqlpp.clause.NestClause;
+import org.apache.asterix.lang.sqlpp.clause.Projection;
+import org.apache.asterix.lang.sqlpp.clause.SelectBlock;
+import org.apache.asterix.lang.sqlpp.clause.SelectClause;
+import org.apache.asterix.lang.sqlpp.clause.SelectElement;
+import org.apache.asterix.lang.sqlpp.clause.SelectRegular;
+import org.apache.asterix.lang.sqlpp.clause.SelectSetOperation;
+import org.apache.asterix.lang.sqlpp.clause.UnnestClause;
+import org.apache.asterix.lang.sqlpp.expression.SelectExpression;
+import org.apache.asterix.lang.sqlpp.struct.SetOperationRight;
+
+public class AbstractSqlppSimpleExpressionVisitor extends 
AbstractSqlppQueryExpressionVisitor<Expression, Void> {
+
+    @Override
+    public Expression visit(FromClause fromClause, Void arg) throws 
AsterixException {
+        for (FromTerm fromTerm : fromClause.getFromTerms()) {
+            fromTerm.accept(this, arg);
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(FromTerm fromTerm, Void arg) throws 
AsterixException {
+        // Visit the left expression of a from term.
+        fromTerm.setLeftExpression(fromTerm.getLeftExpression().accept(this, 
arg));
+
+        // Visits join/unnest/nest clauses.
+        for (AbstractBinaryCorrelateClause correlateClause : 
fromTerm.getCorrelateClauses()) {
+            correlateClause.accept(this, arg);
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(JoinClause joinClause, Void arg) throws 
AsterixException {
+        
joinClause.setRightExpression(joinClause.getRightExpression().accept(this, 
arg));
+        
joinClause.setConditionExpression(joinClause.getConditionExpression().accept(this,
 arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(NestClause nestClause, Void arg) throws 
AsterixException {
+        
nestClause.setRightExpression(nestClause.getRightExpression().accept(this, 
arg));
+        
nestClause.setConditionExpression(nestClause.getConditionExpression().accept(this,
 arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(UnnestClause unnestClause, Void arg) throws 
AsterixException {
+        
unnestClause.setRightExpression(unnestClause.getRightExpression().accept(this, 
arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(Projection projection, Void arg) throws 
AsterixException {
+        projection.setExpression(projection.getExpression().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectBlock selectBlock, Void arg) throws 
AsterixException {
+        // Traverses the select block in the order of "from", "let"s, "where",
+        // "group by", "let"s, "having" and "select".
+        if (selectBlock.hasFromClause()) {
+            selectBlock.getFromClause().accept(this, arg);
+        }
+        if (selectBlock.hasLetClauses()) {
+            List<LetClause> letList = selectBlock.getLetList();
+            for (LetClause letClause : letList) {
+                letClause.accept(this, arg);
+            }
+        }
+        if (selectBlock.hasWhereClause()) {
+            selectBlock.getWhereClause().accept(this, arg);
+        }
+        if (selectBlock.hasGroupbyClause()) {
+            selectBlock.getGroupbyClause().accept(this, arg);
+        }
+        if (selectBlock.hasLetClausesAfterGroupby()) {
+            List<LetClause> letListAfterGby = 
selectBlock.getLetListAfterGroupby();
+            for (LetClause letClauseAfterGby : letListAfterGby) {
+                letClauseAfterGby.accept(this, arg);
+            }
+        }
+        if (selectBlock.hasHavingClause()) {
+            selectBlock.getHavingClause().accept(this, arg);
+        }
+        selectBlock.getSelectClause().accept(this, arg);
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectClause selectClause, Void arg) throws 
AsterixException {
+        if (selectClause.selectElement()) {
+            selectClause.getSelectElement().accept(this, arg);
+        }
+        if (selectClause.selectRegular()) {
+            selectClause.getSelectRegular().accept(this, arg);
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectElement selectElement, Void arg) throws 
AsterixException {
+        selectElement.setExpression(selectElement.getExpression().accept(this, 
arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectRegular selectRegular, Void arg) throws 
AsterixException {
+        for (Projection projection : selectRegular.getProjections()) {
+            projection.accept(this, arg);
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectSetOperation selectSetOperation, Void arg) 
throws AsterixException {
+        selectSetOperation.getLeftInput().accept(this, arg);
+        for (SetOperationRight right : selectSetOperation.getRightInputs()) {
+            right.getSetOperationRightInput().accept(this, arg);
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(HavingClause havingClause, Void arg) throws 
AsterixException {
+        
havingClause.setFilterExpression(havingClause.getFilterExpression().accept(this,
 arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(Query q, Void arg) throws AsterixException {
+        q.setBody(q.getBody().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(FunctionDecl fd, Void arg) throws AsterixException 
{
+        fd.setFuncBody(fd.getFuncBody().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(WhereClause whereClause, Void arg) throws 
AsterixException {
+        whereClause.setWhereExpr(whereClause.getWhereExpr().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(OrderbyClause oc, Void arg) throws 
AsterixException {
+        List<Expression> newOrderbyList = new ArrayList<Expression>();
+        for (Expression orderExpr : oc.getOrderbyList()) {
+            newOrderbyList.add(orderExpr.accept(this, arg));
+        }
+        oc.setOrderbyList(newOrderbyList);
+        return null;
+    }
+
+    @Override
+    public Expression visit(GroupbyClause gc, Void arg) throws 
AsterixException {
+        for (GbyVariableExpressionPair gbyVarExpr : gc.getGbyPairList()) {
+            gbyVarExpr.setExpr(gbyVarExpr.getExpr().accept(this, arg));
+        }
+        return null;
+    }
+
+    @Override
+    public Expression visit(LimitClause limitClause, Void arg) throws 
AsterixException {
+        limitClause.setLimitExpr(limitClause.getLimitExpr().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(LetClause letClause, Void arg) throws 
AsterixException {
+        letClause.setBindingExpr(letClause.getBindingExpr().accept(this, arg));
+        return null;
+    }
+
+    @Override
+    public Expression visit(SelectExpression selectExpression, Void arg) 
throws AsterixException {
+        // visit let list
+        if (selectExpression.hasLetClauses()) {
+            for (LetClause letClause : selectExpression.getLetList()) {
+                letClause.accept(this, arg);
+            }
+        }
+
+        // visit the main select.
+        selectExpression.getSelectSetOperation().accept(this, arg);
+
+        // visit order by
+        if (selectExpression.hasOrderby()) {
+            for (Expression orderExpr : 
selectExpression.getOrderbyClause().getOrderbyList()) {
+                orderExpr.accept(this, arg);
+            }
+        }
+
+        // visit limit
+        if (selectExpression.hasLimit()) {
+            selectExpression.getLimitClause().accept(this, arg);
+        }
+        return selectExpression;
+    }
+
+    @Override
+    public Expression visit(LiteralExpr l, Void arg) throws AsterixException {
+        return l;
+    }
+
+    @Override
+    public Expression visit(ListConstructor lc, Void arg) throws 
AsterixException {
+        List<Expression> newExprList = new ArrayList<Expression>();
+        for (Expression expr : lc.getExprList()) {
+            newExprList.add(expr.accept(this, arg));
+        }
+        lc.setExprList(newExprList);
+        return lc;
+    }
+
+    @Override
+    public Expression visit(RecordConstructor rc, Void arg) throws 
AsterixException {
+        for (FieldBinding binding : rc.getFbList()) {
+            binding.setLeftExpr(binding.getLeftExpr().accept(this, arg));
+            binding.setRightExpr(binding.getRightExpr().accept(this, arg));
+        }
+        return rc;
+    }
+
+    @Override
+    public Expression visit(OperatorExpr operatorExpr, Void arg) throws 
AsterixException {
+        List<Expression> newExprList = new ArrayList<Expression>();
+        for (Expression expr : operatorExpr.getExprList()) {
+            newExprList.add(expr.accept(this, arg));
+        }
+        operatorExpr.setExprList(newExprList);
+        return operatorExpr;
+    }
+
+    @Override
+    public Expression visit(IfExpr ifExpr, Void arg) throws AsterixException {
+        ifExpr.setCondExpr(ifExpr.getCondExpr().accept(this, arg));
+        ifExpr.setThenExpr(ifExpr.getThenExpr().accept(this, arg));
+        ifExpr.setElseExpr(ifExpr.getElseExpr().accept(this, arg));
+        return ifExpr;
+    }
+
+    @Override
+    public Expression visit(QuantifiedExpression qe, Void arg) throws 
AsterixException {
+        for (QuantifiedPair pair : qe.getQuantifiedList()) {
+            pair.setExpr(pair.getExpr().accept(this, arg));
+        }
+        qe.setSatisfiesExpr(qe.getSatisfiesExpr().accept(this, arg));
+        return qe;
+    }
+
+    @Override
+    public Expression visit(CallExpr callExpr, Void arg) throws 
AsterixException {
+        List<Expression> newExprList = new ArrayList<Expression>();
+        for (Expression expr : callExpr.getExprList()) {
+            newExprList.add(expr.accept(this, arg));
+        }
+        callExpr.setExprList(newExprList);
+        return callExpr;
+    }
+
+    @Override
+    public Expression visit(VariableExpr varExpr, Void arg) throws 
AsterixException {
+        return varExpr;
+    }
+
+    @Override
+    public Expression visit(UnaryExpr u, Void arg) throws AsterixException {
+        u.setExpr(u.getExpr().accept(this, arg));
+        return u;
+    }
+
+    @Override
+    public Expression visit(FieldAccessor fa, Void arg) throws 
AsterixException {
+        fa.setExpr(fa.getExpr().accept(this, arg));
+        return fa;
+    }
+
+    @Override
+    public Expression visit(IndexAccessor ia, Void arg) throws 
AsterixException {
+        ia.setExpr(ia.getExpr().accept(this, arg));
+        if (ia.getIndexExpr() != null) {
+            ia.setIndexExpr(ia.getIndexExpr());
+        }
+        return ia;
+    }
+
+}

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

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

Reply via email to