asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xi...@apache.org
Subject asterixdb git commit: Fix ASTERIXDB-1876 Projection "*" with UDF inline
Date Tue, 11 Apr 2017 18:49:05 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 96fd4026a -> 97d571a3a


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 <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/97d571a3
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/97d571a3
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/97d571a3

Branch: refs/heads/master
Commit: 97d571a3a0095f6a2e6e8afb9e5ac6c1929ba704
Parents: 96fd402
Author: Xikui Wang <xkkwww@gmail.com>
Authored: Sat Apr 8 12:21:57 2017 -0700
Committer: Xikui Wang <xkkwww@gmail.com>
Committed: Tue Apr 11 11:48:49 2017 -0700

----------------------------------------------------------------------
 .../query-ASTERIXDB-1876.1.ddl.sqlpp            | 34 ++++++++++++++++++++
 .../query-ASTERIXDB-1876.2.query.sqlpp          | 23 +++++++++++++
 .../query-ASTERIXDB-1876.1.adm                  |  0
 .../asterix/lang/sqlpp/clause/SelectBlock.java  | 12 +++----
 .../visitor/SqlppInlineUdfsVisitor.java         |  3 ++
 5 files changed, 66 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/97d571a3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.ddl.sqlpp
----------------------------------------------------------------------
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] }
+
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/97d571a3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.2.query.sqlpp
----------------------------------------------------------------------
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;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/97d571a3/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1876/query-ASTERIXDB-1876.1.adm
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/97d571a3/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectBlock.java
----------------------------------------------------------------------
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 @@ public class SelectBlock implements Clause {
         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();
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/97d571a3/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppInlineUdfsVisitor.java
----------------------------------------------------------------------
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 @@ public class SqlppInlineUdfsVisitor extends AbstractInlineUdfsVisitor
 
     @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;


Mime
View raw message