Repository: asterixdb Updated Branches: refs/heads/master 92f7cb582 -> 9c83efbe5
[ASTERIXDB-2247][SQLPP] Allow "_" as the first character in a variable name - user model changes: yes - storage format changes: no - interface changes: no Details: - Allow "_" as the first character in a variable name and other identifiers Change-Id: Ic530ccfd2a7d3f1e893fd2292b8605feb6241675 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2283 Sonar-Qube: Jenkins <[email protected]> Reviewed-by: Michael Blow <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/9c83efbe Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/9c83efbe Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/9c83efbe Branch: refs/heads/master Commit: 9c83efbe5e8be9ea62153eda49be43d86cbfb67b Parents: 92f7cb5 Author: Dmitry Lychagin <[email protected]> Authored: Tue Jan 16 14:31:58 2018 -0800 Committer: Dmitry Lychagin <[email protected]> Committed: Wed Jan 17 13:52:29 2018 -0800 ---------------------------------------------------------------------- .../parserts/queries_sqlpp/variables.sqlpp | 5 +++-- .../parserts/results_parser_sqlpp/variables.ast | 5 +++++ .../identifier_01/identifier_01.1.query.sqlpp | 22 ++++++++++++++++++++ .../misc/identifier_01/identifier_01.1.adm | 1 + .../resources/runtimets/testsuite_sqlpp.xml | 5 +++++ .../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj | 6 ++++-- 6 files changed, 40 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp b/asterixdb/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp index 7611e3e..417bea8 100644 --- a/asterixdb/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp @@ -18,6 +18,7 @@ */ with a as 1, - b as 1 -select element (b - a) + b as 1, + _c as 0 +select element (b - a - _c) ; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast index 698f469..9f6906c 100644 --- a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast +++ b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast @@ -5,10 +5,15 @@ Let Variable [ Name=$a ] Let Variable [ Name=$b ] := LiteralExpr [LONG] [1] +Let Variable [ Name=$_c ] + := + LiteralExpr [LONG] [0] SELECT ELEMENT [ OperatorExpr [ Variable [ Name=$b ] - Variable [ Name=$a ] + - + Variable [ Name=$_c ] ] ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/identifier_01/identifier_01.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/identifier_01/identifier_01.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/identifier_01/identifier_01.1.query.sqlpp new file mode 100644 index 0000000..17ad534 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/identifier_01/identifier_01.1.query.sqlpp @@ -0,0 +1,22 @@ +/* + * 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 _x as 1 + +SELECT _x AS _y http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/identifier_01/identifier_01.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/identifier_01/identifier_01.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/identifier_01/identifier_01.1.adm new file mode 100644 index 0000000..864e169 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/identifier_01/identifier_01.1.adm @@ -0,0 +1 @@ +{ "_y": 1 } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml ---------------------------------------------------------------------- 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 14784d6..0b8fd8c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -3518,6 +3518,11 @@ </compilation-unit> </test-case> <test-case FilePath="misc"> + <compilation-unit name="identifier_01"> + <output-dir compare="Text">identifier_01</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="misc"> <compilation-unit name="ifthenelse_01"> <output-dir compare="Text">ifthenelse_01</output-dir> </compilation-unit> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c83efbe/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index a11aaf4..fd5de86 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -3399,7 +3399,8 @@ TOKEN: TOKEN : { <#LETTER : ["A" - "Z", "a" - "z"]> - | <SPECIALCHARS : ["$", "_"]> + | <#IDENTIFIER_SPECIALCHARS_START : ["_"]> + | <#IDENTIFIER_SPECIALCHARS_REST : ["$"]> } <DEFAULT,IN_DBL_BRACE> @@ -3450,7 +3451,8 @@ TOKEN : <DEFAULT,IN_DBL_BRACE> TOKEN : { - <IDENTIFIER : <LETTER> (<LETTER> | <DIGIT> | <SPECIALCHARS>)*> + <IDENTIFIER : ( <LETTER> | <IDENTIFIER_SPECIALCHARS_START> ) + ( <LETTER> | <DIGIT> | <IDENTIFIER_SPECIALCHARS_START> | <IDENTIFIER_SPECIALCHARS_REST> )*> } <DEFAULT,IN_DBL_BRACE>
