Xikui Wang has submitted this change and it was merged.

Change subject: Fix ASTERIXDB-1876 Projection "*" with UDF inline
......................................................................


Fix ASTERIXDB-1876 Projection "*" with UDF inline

1. Add check to inline UDF visitor to avoid expression examination on
   "*".
2. Add test case.
3. Small tweak to select block by adding space between clause.
Change-Id: I921e720bdfc33a0298d0ac96e5bd8aab0cefd60f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1670
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyin...@gmail.com>
---
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.2.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.adm
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
5 files changed, 66 insertions(+), 6 deletions(-)

Approvals:
  Yingyi Bu: Looks good to me, approved
  Jenkins: Verified; No violations found; Verified



diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.ddl.sqlpp
new file mode 100644
index 0000000..186fd2b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.ddl.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+drop dataverse channels if exists;
+create dataverse channels;
+use channels;
+
+create type UserLocation as closed {
+recordId: integer,
+userName: string
+}
+
+create dataset UserLocations(UserLocation)
+primary key recordId;
+
+create function RecentEmergenciesNearUser(userName) { [1] }
+
+
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.2.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.2.query.sqlpp
new file mode 100644
index 0000000..4490678
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.2.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+select *
+from channels.UserLocations location,
+channels.RecentEmergenciesNearUser(location.userName) result;
+
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.adm
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
index 51e4ab4..155e576 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
@@ -152,22 +152,22 @@
         StringBuilder sb = new StringBuilder();
         sb.append(selectClause);
         if (hasFromClause()) {
-            sb.append(fromClause);
+            sb.append(" " + fromClause);
         }
         if (hasLetClauses()) {
-            sb.append(letClauses);
+            sb.append(" " + letClauses);
         }
         if (hasWhereClause()) {
-            sb.append(whereClause);
+            sb.append(" " + whereClause);
         }
         if (hasGroupbyClause()) {
-            sb.append(groupbyClause);
+            sb.append(" " + groupbyClause);
         }
         if (hasLetClausesAfterGroupby()) {
-            sb.append(letClausesAfterGby);
+            sb.append(" " + letClausesAfterGby);
         }
         if (hasHavingClause()) {
-            sb.append(havingClause);
+            sb.append(" " + havingClause);
         }
         return sb.toString();
     }
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
index b2f56a5..640b9b08 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
@@ -119,6 +119,9 @@
 
     @Override
     public Boolean visit(Projection projection, List<FunctionDecl> funcs) 
throws CompilationException {
+        if (projection.star() == true) {
+            return false;
+        }
         Pair<Boolean, Expression> p = 
inlineUdfsInExpr(projection.getExpression(), funcs);
         projection.setExpression(p.second);
         return p.first;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I921e720bdfc33a0298d0ac96e5bd8aab0cefd60f
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Xikui Wang <xkk...@gmail.com>
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Xikui Wang <xkk...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <buyin...@gmail.com>

Reply via email to