You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ti...@apache.org on 2015/10/21 20:44:00 UTC

incubator-asterixdb git commit: ASTERIXDB-922: trailing commas in lists

Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 5b79000c3 -> 812f69cc4


ASTERIXDB-922: trailing commas in lists

Change-Id: I608f8bd94bf61c37709d3c9df0fc20dd28ea52b5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/410
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <bu...@gmail.com>


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

Branch: refs/heads/master
Commit: 812f69cc4fd3c7c49313281d40654604e2fdec84
Parents: 5b79000
Author: Till Westmann <ti...@apache.org>
Authored: Wed Oct 21 10:14:14 2015 -0700
Committer: Till Westmann <ti...@apache.org>
Committed: Wed Oct 21 11:40:35 2015 -0700

----------------------------------------------------------------------
 .../ordered-list-constructor_04.1.ddl.aql       | 21 +++++++++
 .../ordered-list-constructor_04.2.update.aql    | 18 +++++++
 .../ordered-list-constructor_04.3.query.aql     | 24 ++++++++++
 .../unordered-list-constructor_04.1.ddl.aql     | 21 +++++++++
 .../unordered-list-constructor_04.2.update.aql  | 18 +++++++
 .../unordered-list-constructor_04.3.query.aql   | 25 ++++++++++
 .../ordered-list-constructor_04.1.adm           |  2 +
 .../unordered-list-constructor_04.1.adm         |  2 +
 .../src/test/resources/runtimets/testsuite.xml  | 10 ++++
 asterix-aql/src/main/javacc/AQL.jj              | 49 +++++++++++---------
 10 files changed, 168 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.aql
new file mode 100644
index 0000000..d17ea60
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.aql
@@ -0,0 +1,21 @@
+/*
+ * 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 test if exists;
+create dataverse test;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.aql
new file mode 100644
index 0000000..042f3ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.aql
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.aql
new file mode 100644
index 0000000..d0de5a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.aql
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+use dataverse test;
+
+[
+[ 1, "two", null, ],
+[,],
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.aql
new file mode 100644
index 0000000..d17ea60
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.aql
@@ -0,0 +1,21 @@
+/*
+ * 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 test if exists;
+create dataverse test;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.aql
new file mode 100644
index 0000000..042f3ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.aql
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.aql
new file mode 100644
index 0000000..60915a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.aql
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+use dataverse test;
+
+{{
+{{ 1, "two", null, }},
+{{,}},
+}}
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/results/list/ordered-list-constructor_04/ordered-list-constructor_04.1.adm
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results/list/ordered-list-constructor_04/ordered-list-constructor_04.1.adm b/asterix-app/src/test/resources/runtimets/results/list/ordered-list-constructor_04/ordered-list-constructor_04.1.adm
new file mode 100644
index 0000000..612e1ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/list/ordered-list-constructor_04/ordered-list-constructor_04.1.adm
@@ -0,0 +1,2 @@
+[ [ [ 1, "two", null ], [  ]
+ ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/results/list/unordered-list-constructor_04/unordered-list-constructor_04.1.adm
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results/list/unordered-list-constructor_04/unordered-list-constructor_04.1.adm b/asterix-app/src/test/resources/runtimets/results/list/unordered-list-constructor_04/unordered-list-constructor_04.1.adm
new file mode 100644
index 0000000..1b3bfe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/list/unordered-list-constructor_04/unordered-list-constructor_04.1.adm
@@ -0,0 +1,2 @@
+[ {{ {{ 1, "two", null }}, {{  }} }}
+ ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-app/src/test/resources/runtimets/testsuite.xml
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index d378dca..aef2b54 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -2827,6 +2827,11 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="list">
+            <compilation-unit name="ordered-list-constructor_04">
+                <output-dir compare="Text">ordered-list-constructor_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
             <compilation-unit name="scan-collection_01">
                 <output-dir compare="Text">scan-collection_01</output-dir>
             </compilation-unit>
@@ -2858,6 +2863,11 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="list">
+            <compilation-unit name="unordered-list-constructor_04">
+                <output-dir compare="Text">unordered-list-constructor_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
             <compilation-unit name="query-issue428">
                 <output-dir compare="Text">query-issue428</output-dir>
             </compilation-unit>

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/812f69cc/asterix-aql/src/main/javacc/AQL.jj
----------------------------------------------------------------------
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index a149700..ef69a5f 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -1946,23 +1946,11 @@ Expression ListConstructor() throws ParseException:
 ListConstructor OrderedListConstructor() throws ParseException:
 {
       ListConstructor expr = new ListConstructor();
-      Expression tmp = null;
-      List<Expression> exprList = new ArrayList<Expression>();
+      List<Expression> exprList = null;
       expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
 }
 {
-
-    <LEFTBRACKET>
-        ( tmp = Expression()
-            {
-              exprList.add(tmp);
-            }
-
-            (<COMMA> tmp = Expression() { exprList.add(tmp);  })*
-        )?
-
-    <RIGHTBRACKET>
-
+    <LEFTBRACKET> exprList = ExpressionList() <RIGHTBRACKET>
     {
       expr.setExprList(exprList);
       return expr;
@@ -1972,23 +1960,40 @@ ListConstructor OrderedListConstructor() throws ParseException:
 ListConstructor UnorderedListConstructor() throws ParseException:
 {
       ListConstructor expr = new ListConstructor();
-      Expression tmp = null;
-      List<Expression> exprList = new ArrayList<Expression>();
+      List<Expression> exprList = null;
       expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
 }
 {
-
-    <LEFTDBLBRACE> ( tmp = Expression()
-    {
-      exprList.add(tmp);
-    }
-    (<COMMA> tmp = Expression() { exprList.add(tmp);  })*)? <RIGHTDBLBRACE>
+    <LEFTDBLBRACE> exprList = ExpressionList() <RIGHTDBLBRACE>
     {
       expr.setExprList(exprList);
       return expr;
     }
 }
 
+List<Expression> ExpressionList() throws ParseException:
+{
+      Expression expr = null;
+      List<Expression> list = null;
+      List<Expression> exprList = new ArrayList<Expression>();
+}
+{
+    ( LOOKAHEAD(2)
+      expr = Expression() { exprList.add(expr); }
+      (<COMMA> list = ExpressionList() { exprList.addAll(list); })?
+    )?
+    (Comma())?
+    {
+        return exprList;
+    }
+}
+
+void Comma():
+{}
+{
+   <COMMA>
+}
+
 RecordConstructor RecordConstructor() throws ParseException:
 {
       RecordConstructor expr = new RecordConstructor();