Till Westmann has submitted this change and it was merged. Change subject: ASTERIXDB-922: trailing commas in lists ......................................................................
ASTERIXDB-922: trailing commas in lists Change-Id: I608f8bd94bf61c37709d3c9df0fc20dd28ea52b5 Reviewed-on: https://asterix-gerrit.ics.uci.edu/410 Tested-by: Jenkins <[email protected]> Reviewed-by: Yingyi Bu <[email protected]> --- A asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.aql A asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.aql A asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.aql A asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.aql A asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.aql A asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.aql A asterix-app/src/test/resources/runtimets/results/list/ordered-list-constructor_04/ordered-list-constructor_04.1.adm A asterix-app/src/test/resources/runtimets/results/list/unordered-list-constructor_04/unordered-list-constructor_04.1.adm M asterix-app/src/test/resources/runtimets/testsuite.xml M asterix-aql/src/main/javacc/AQL.jj 10 files changed, 168 insertions(+), 22 deletions(-) Approvals: Yingyi Bu: Looks good to me, approved Jenkins: Verified 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; + 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. + */ 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, ], +[,], +] 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; + 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. + */ 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, }}, +{{,}}, +}} + 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 ], [ ] + ] 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 }}, {{ }} }} + ] 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> 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 @@ 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 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(); -- To view, visit https://asterix-gerrit.ics.uci.edu/410 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I608f8bd94bf61c37709d3c9df0fc20dd28ea52b5 Gerrit-PatchSet: 4 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Till Westmann <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]>
