Yingyi Bu has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1777
Change subject: ASTERIXDB-1918: support scientific math representation. ...................................................................... ASTERIXDB-1918: support scientific math representation. Change-Id: Ic0b6661416751a82a552cebc6248596b4eeff500 --- A asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/scientific/scientific.1.query.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific/scientific.1.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.1.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.2.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/scientific/scientific.1.adm M asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml M asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 9 files changed, 116 insertions(+), 5 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/77/1777/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/scientific/scientific.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/scientific/scientific.1.query.aql new file mode 100644 index 0000000..d668b0b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/scientific/scientific.1.query.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. + */ + +[2e5, 2e-5, .2e2, .2e-2, 0.5e3, 0.5e-3, 3.2e5, 3.2e-5] + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific/scientific.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific/scientific.1.query.sqlpp new file mode 100644 index 0000000..d668b0b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific/scientific.1.query.sqlpp @@ -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. + */ + +[2e5, 2e-5, .2e2, .2e-2, 0.5e3, 0.5e-3, 3.2e5, 3.2e-5] + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.1.query.sqlpp new file mode 100644 index 0000000..551e394 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.1.query.sqlpp @@ -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. + */ + +// This test makes sure the error message of undefined variable is still correct. + +WITH t AS 10 + +SELECT t-e-10 + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.2.query.sqlpp new file mode 100644 index 0000000..3f14a0e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/scientific_error/scientific_error.2.query.sqlpp @@ -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. + */ + +// This test makes sure the error message of undefined variable is still correct. + +WITH t AS 10 + +SELECT e-10 + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/scientific/scientific.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/scientific/scientific.1.adm new file mode 100644 index 0000000..f65c2fe --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/scientific/scientific.1.adm @@ -0,0 +1 @@ +[ 200000.0, 2.0E-5, 20.0, 0.002, 500.0, 5.0E-4, 320000.0, 3.2E-5 ] \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml index 83d5581..e2070c0 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml @@ -4527,6 +4527,11 @@ </compilation-unit> </test-case> <test-case FilePath="numeric"> + <compilation-unit name="scientific"> + <output-dir compare="Text">scientific</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="numeric"> <compilation-unit name="subtract_double"> <output-dir compare="Text">subtract_double</output-dir> </compilation-unit> 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 29917d4..f9ae2fa 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -4572,6 +4572,18 @@ </compilation-unit> </test-case> <test-case FilePath="numeric"> + <compilation-unit name="scientific"> + <output-dir compare="Text">scientific</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="numeric"> + <compilation-unit name="scientific_error"> + <output-dir compare="Text">none</output-dir> + <expected-error>Cannot find dataset e in dataverse Default nor an alias with name e</expected-error> + <expected-error>Cannot find dataset e in dataverse Default nor an alias with name e</expected-error> + </compilation-unit> + </test-case> + <test-case FilePath="numeric"> <compilation-unit name="sign"> <output-dir compare="Text">sign</output-dir> </compilation-unit> diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj index b92805b..8170eab 100644 --- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj +++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj @@ -2812,9 +2812,9 @@ <DEFAULT,IN_DBL_BRACE> TOKEN: { - < DOUBLE_LITERAL: <DIGITS> - | <DIGITS> ( "." <DIGITS> )? - | "." <DIGITS> + < DOUBLE_LITERAL: <DIGITS> ( "." <DIGITS> ) (("e"|"E") ("-")? <DIGITS>)? + | <DIGITS> (("e"|"E") ("-")? <DIGITS>) + | "." <DIGITS> (("e"|"E") ("-")? <DIGITS>)? > | < FLOAT_LITERAL: <DIGITS> ( "f" | "F" ) | <DIGITS> ( "." <DIGITS> ( "f" | "F" ) )? diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index 69bfbc5..ce81a91 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -3332,8 +3332,9 @@ <DEFAULT,IN_DBL_BRACE> TOKEN: { - < DOUBLE_LITERAL: <DIGITS> ( "." <DIGITS> ) - | "." <DIGITS> + < DOUBLE_LITERAL: <DIGITS> ( "." <DIGITS> ) (("e"|"E") ("-")? <DIGITS>)? + | <DIGITS> (("e"|"E") ("-")? <DIGITS>) + | "." <DIGITS> (("e"|"E") ("-")? <DIGITS>)? > | < FLOAT_LITERAL: <DIGITS> ( "f" | "F" ) | <DIGITS> ( "." <DIGITS> ( "f" | "F" ) )? -- To view, visit https://asterix-gerrit.ics.uci.edu/1777 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic0b6661416751a82a552cebc6248596b4eeff500 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Yingyi Bu <buyin...@gmail.com>