This is an automated email from the ASF dual-hosted git repository.
vsarathy1 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new a19254aedf [ASTERIXDB-3380][COMP] Internal error on a syntax error
with productivity hint
a19254aedf is described below
commit a19254aedf1c1b2d4e749d5f21e2f2e4984c37fc
Author: Vijay Sarathy <[email protected]>
AuthorDate: Thu Apr 18 16:29:04 2024 -0700
[ASTERIXDB-3380][COMP] Internal error on a syntax error with productivity
hint
Change-Id: I42399559414f94204b22897d0fae43ea8c0f54d4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18238
Reviewed-by: Vijay Sarathy <[email protected]>
Reviewed-by: Ali Alsuliman <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
---
.../multiple-hints-warning.05.query.sqlpp | 30 ++++++++++++++
.../multiple-hints-warning.06.query.sqlpp | 30 ++++++++++++++
.../multiple-hints-warning.07.query.sqlpp | 30 ++++++++++++++
.../multiple-hints-warning.08.query.sqlpp | 30 ++++++++++++++
.../multiple-hints-warning.09.query.sqlpp | 30 ++++++++++++++
.../multiple-hints-warning.05.adm | 1 +
.../multiple-hints-warning.06.adm | 1 +
.../multiple-hints-warning.07.adm | 1 +
.../multiple-hints-warning.08.adm | 1 +
.../multiple-hints-warning.09.adm | 1 +
.../src/test/resources/runtimets/sqlpp_queries.xml | 8 ++++
.../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj | 46 ++++++++++++++++------
12 files changed, 196 insertions(+), 13 deletions(-)
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.05.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.05.query.sqlpp
new file mode 100644
index 0000000000..64d8d905a3
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.05.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/*
+* Description : Test warnings for multiple hints
+* Expected Res : Warning, ignore hint
+* Date : 11/20/2022
+*/
+// requesttype=application/json
+// param max-warnings:json=10
+
+use tpch;
+
+SELECT COUNT(*) FROM customer c JOIN nation n
+ON c.c_nationkey /*+ hashjoin build (n) */ /*+ productivit y 100.0 */ =
n.n_nationkey;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.06.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.06.query.sqlpp
new file mode 100644
index 0000000000..2cdd902e5f
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.06.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/*
+* Description : Test warnings for multiple hints
+* Expected Res : Warning, ignore hint
+* Date : 11/20/2022
+*/
+// requesttype=application/json
+// param max-warnings:json=10
+
+use tpch;
+
+SELECT COUNT(*) FROM customer c JOIN nation n
+ON c.c_nationkey /*+ productivit y 100.0 */ /*+ hashjoin build (n) */ =
n.n_nationkey;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.07.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.07.query.sqlpp
new file mode 100644
index 0000000000..75493409f8
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.07.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/*
+* Description : Test warnings for multiple hints
+* Expected Res : Warning, ignore hint
+* Date : 11/20/2022
+*/
+// requesttype=application/json
+// param max-warnings:json=10
+
+use tpch;
+
+SELECT COUNT(*) FROM customer c JOIN nation n
+ON c.c_nationkey /*+ hashjoin build (n) */ /*+ productivit y 100.0 */ /*+
100.0 */ = n.n_nationkey;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.08.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.08.query.sqlpp
new file mode 100644
index 0000000000..d580eaadf4
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.08.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/*
+* Description : Test warnings for multiple hints
+* Expected Res : Warning, ignore hint
+* Date : 11/20/2022
+*/
+// requesttype=application/json
+// param max-warnings:json=10
+
+use tpch;
+
+SELECT COUNT(*) FROM customer c JOIN nation n
+ON c.c_nationkey /*+ productivit y 100.0 */ /*+ hashjoin build (n) */ /*+
100.0 */ = n.n_nationkey;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.09.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.09.query.sqlpp
new file mode 100644
index 0000000000..760ca89667
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/warnings/multiple-hints-warning/multiple-hints-warning.09.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/*
+* Description : Test warnings for multiple hints
+* Expected Res : Warning, ignore hint
+* Date : 11/20/2022
+*/
+// requesttype=application/json
+// param max-warnings:json=10
+
+use tpch;
+
+SELECT COUNT(*) FROM customer c JOIN nation n
+ON c.c_nationkey /*+ productivit y 100.0 */ /*+ 100.0 */ /*+ hashjoin build
(n) */ = n.n_nationkey;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.05.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.05.adm
new file mode 100644
index 0000000000..3ff59f66ac
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.05.adm
@@ -0,0 +1 @@
+{ "$1": 0 }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.06.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.06.adm
new file mode 100644
index 0000000000..3ff59f66ac
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.06.adm
@@ -0,0 +1 @@
+{ "$1": 0 }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.07.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.07.adm
new file mode 100644
index 0000000000..3ff59f66ac
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.07.adm
@@ -0,0 +1 @@
+{ "$1": 0 }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.08.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.08.adm
new file mode 100644
index 0000000000..3ff59f66ac
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.08.adm
@@ -0,0 +1 @@
+{ "$1": 0 }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.09.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.09.adm
new file mode 100644
index 0000000000..3ff59f66ac
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/warnings/multiple-hints-warning/multiple-hints-warning.09.adm
@@ -0,0 +1 @@
+{ "$1": 0 }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 72f11b6339..783727aee1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -15655,6 +15655,14 @@
<expected-warn><![CDATA[ASX1132: Invalid specification for hint
productivity. Invalid format for productivity values (in line 30, at column
46)]]></expected-warn>
<expected-warn><![CDATA[ASX1132: Invalid specification for hint
productivity. Invalid format for productivity values (in line 30, at column
45)]]></expected-warn>
<expected-warn><![CDATA[ASX1132: Invalid specification for hint
hashjoin. ASX1001: Syntax error: In line 1 >>build ()<< Encountered ")" at
column 8. (in line 30, at column 20)]]></expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: productivit y 100.0.
"hash-bcast", "indexnl", "hashjoin", "skip-index", "use-index", "selectivity",
"productivity" expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: productivit y 100.0.
"hash-bcast", "indexnl", "hashjoin", "skip-index", "use-index", "selectivity",
"productivity" expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: productivit y 100.0.
"hash-bcast", "indexnl", "hashjoin", "skip-index", "use-index", "selectivity",
"productivity" expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: 100.0. "hash-bcast",
"indexnl", "hashjoin", "skip-index", "use-index", "selectivity", "productivity"
expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: 100.0. "hash-bcast",
"indexnl", "hashjoin", "skip-index", "use-index", "selectivity", "productivity"
expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: productivit y 100.0.
"hash-bcast", "indexnl", "hashjoin", "skip-index", "use-index", "selectivity",
"productivity" expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: 100.0. "hash-bcast",
"indexnl", "hashjoin", "skip-index", "use-index", "selectivity", "productivity"
expected at this location</expected-warn>
+ <expected-warn>ASX1107: Unexpected hint: productivit y 100.0.
"hash-bcast", "indexnl", "hashjoin", "skip-index", "use-index", "selectivity",
"productivity" expected at this location</expected-warn>
</compilation-unit>
</test-case>
<test-case FilePath="warnings" check-warnings="true">
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index a1b7daf3cc..da5f0ab9b8 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -693,6 +693,25 @@ class SQLPPParser extends ScopeChecker implements IParser {
}
}
+ private List<Token> fetchHints(Token token, SqlppHint... expectedHints) {
+ Token hintToken = token.specialToken;
+ List<Token> hintTokenList = new ArrayList<Token>();
+ while (hintToken != null) {
+ SourceLocation sourceLoc = getSourceLocation(hintToken);
+ hintCollector.remove(sourceLoc);
+ if (hintToken.hint == null) {
+ warnUnexpectedHint(hintToken.hintParams, sourceLoc,
expectedHints);
+ } else if (!ArrayUtils.contains(expectedHints, hintToken.hint)) {
+ warnUnexpectedHint(hintToken.hint.getIdentifier(), sourceLoc,
expectedHints);
+ } else {
+ hintTokenList.add(hintToken);
+ }
+ hintToken = hintToken.specialToken;
+ }
+ return hintTokenList;
+ }
+
+
private void reportUnclaimedHints() {
for (Map.Entry<SourceLocation, String> me : hintCollector.entrySet()) {
warnUnexpectedHint(me.getValue(), me.getKey(), "None");
@@ -3996,22 +4015,17 @@ Expression RelExpr() throws ParseException:
if (opToken == null) {
opToken = token;
}
- Token hintToken = fetchHint(token,
+ List<Token> hintTokens = fetchHints(token,
SqlppHint.HASH_BROADCAST_JOIN_HINT,
SqlppHint.INDEXED_NESTED_LOOP_JOIN_HINT,
SqlppHint.HASH_JOIN_HINT,
SqlppHint.SKIP_SECONDARY_INDEX_SEARCH_HINT,
SqlppHint.USE_SECONDARY_INDEX_SEARCH_HINT,
SqlppHint.SINGLE_DATASET_PREDICATE_SELECTIVITY_HINT,
SqlppHint.JOIN_PREDICATE_PRODUCTIVITY_HINT
);
- while (hintToken != null) {
+ for (Token hintToken : hintTokens) {
annotation = parseExpressionAnnotation(hintToken);
if (annotation != null) {
// annotation may be null if hints are malformed
annotationList.add(annotation);
}
- hintToken = hintToken.specialToken;
- if (hintToken != null) {
- SourceLocation sourceLoc = getSourceLocation(hintToken);
- hintCollector.remove(sourceLoc);
- }
}
String operator = opToken.image.toLowerCase();
if (operator.equals("<>")){
@@ -4040,7 +4054,7 @@ Expression RelExpr() throws ParseException:
)?
{
- if (annotation != null) {
+ if (annotationList.size() > 0) {
op.addHints(annotationList);
}
return op==null? operand: op;
@@ -4053,6 +4067,7 @@ Expression BetweenExpr() throws ParseException:
OperatorExpr op = null;
Expression operand = null;
IExpressionAnnotation annotation = null;
+ List<IExpressionAnnotation> annotationList = new
ArrayList<IExpressionAnnotation>();
}
{
operand = IsExpr()
@@ -4060,13 +4075,18 @@ Expression BetweenExpr() throws ParseException:
LOOKAHEAD(2)
(<NOT> { not = true; })? <BETWEEN>
{
- Token hintToken = fetchHint(token,
+ List<Token> hintTokens = fetchHints(token,
SqlppHint.INDEXED_NESTED_LOOP_JOIN_HINT,
SqlppHint.SKIP_SECONDARY_INDEX_SEARCH_HINT, SqlppHint.HASH_JOIN_HINT,
SqlppHint.USE_SECONDARY_INDEX_SEARCH_HINT,
SqlppHint.SINGLE_DATASET_PREDICATE_SELECTIVITY_HINT
);
- if (hintToken != null) {
- annotation = parseExpressionAnnotation(hintToken);
+ for (Token hintToken : hintTokens) {
+ annotation = parseExpressionAnnotation(hintToken);
+ if (annotation != null) {
+ // annotation may be null if hints are malformed
+ annotationList.add(annotation);
+ }
}
+
String operator = token.image.toLowerCase();
if(not){
operator = "not_" + operator;
@@ -4098,8 +4118,8 @@ Expression BetweenExpr() throws ParseException:
)?
{
- if (annotation != null) {
- op.addHint(annotation);
+ if (annotationList.size() > 0) {
+ op.addHints(annotationList);
}
return op==null ? operand: op;
}