This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit e577fb05a502fdc046e20bd5167a47ef18fddbff Author: Dmitry Lychagin <[email protected]> AuthorDate: Fri Mar 12 12:53:15 2021 -0800 [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 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11824 Tested-by: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> --- .../ASTERIXDB-2844_unnest_syntax.1.query.sqlpp | 23 ++++++++++++++++++++++ .../ASTERIXDB-2844_unnest_syntax.1.adm | 4 ++++ .../test/resources/runtimets/testsuite_sqlpp.xml | 5 +++++ .../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj | 6 +++--- 4 files changed, 35 insertions(+), 3 deletions(-) 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 0015fa6..11c9634 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -12481,6 +12481,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 @@ JoinClause JoinClause(JoinType joinType) throws ParseException : 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);
