asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AsterixDB Code Review <do-not-re...@asterix-gerrit.ics.uci.edu>
Subject Change in asterixdb[mad-hatter]: [ASTERIXDB-2844][COMP] Fix syntax error with UNNEST
Date Mon, 07 Jun 2021 22:09:52 GMT
>From Dmitry Lychagin <dmitry.lychagin@couchbase.com>:

Dmitry Lychagin has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11824
)


Change subject: [ASTERIXDB-2844][COMP] Fix syntax error with UNNEST
......................................................................

[ASTERIXDB-2844][COMP] Fix syntax error with UNNEST

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Do not require AS subclause in UNNEST
- Add testcase

Change-Id: I17f4f7743e873dcb773f7a68b14660637c58aa89
---
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
4 files changed, 35 insertions(+), 3 deletions(-)



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

diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.query.sqlpp
new file mode 100644
index 0000000..110eefd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.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.
+ */
+
+with t as (select r, [r*10,r*10+1] ra from range(1, 2) r)
+select *
+from t unnest t.ra
+order by ra
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.adm
new file mode 100644
index 0000000..6b71814
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/unnest/ASTERIXDB-2844_unnest_syntax/ASTERIXDB-2844_unnest_syntax.1.adm
@@ -0,0 +1,4 @@
+{ "t": { "r": 1, "ra": [ 10, 11 ] }, "ra": 10 }
+{ "t": { "r": 1, "ra": [ 10, 11 ] }, "ra": 11 }
+{ "t": { "r": 2, "ra": [ 20, 21 ] }, "ra": 20 }
+{ "t": { "r": 2, "ra": [ 20, 21 ] }, "ra": 21 }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index ce1303b..6162093 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -12471,6 +12471,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="unnest">
+      <compilation-unit name="ASTERIXDB-2844_unnest_syntax">
+        <output-dir compare="Text">ASTERIXDB-2844_unnest_syntax</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="unnest">
       <compilation-unit name="left-outer-unnest">
         <output-dir compare="Text">left-outer-unnest</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index f4061e1..4c924a4 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -3499,12 +3499,12 @@
 UnnestClause UnnestClause(JoinType joinType) throws ParseException :
 {
     Token startToken = null;
-    Expression rightExpr;
-    VariableExpr rightVar;
+    Expression rightExpr = null;
+    VariableExpr rightVar = null;
     VariableExpr posVar = null;
 }
 {
-  (<UNNEST>|<CORRELATE>|<FLATTEN>) { startToken = token; } rightExpr =
Expression() ((<AS>)? rightVar = Variable()) (<AT> posVar = Variable())?
+  (<UNNEST>|<CORRELATE>|<FLATTEN>) { startToken = token; } rightExpr =
Expression() ((<AS>)? rightVar = Variable())? (<AT> posVar = Variable())?
   {
     if (rightVar == null) {
       rightVar = ExpressionToVariableUtil.getGeneratedVariable(rightExpr, true);

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11824
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: mad-hatter
Gerrit-Change-Id: I17f4f7743e873dcb773f7a68b14660637c58aa89
Gerrit-Change-Number: 11824
Gerrit-PatchSet: 1
Gerrit-Owner: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Gerrit-MessageType: newchange

Mime
View raw message