This is an automated email from the ASF dual-hosted git repository.
peeyush 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 0616fa1a15 [NO ISSUE][COMP] NullPointerException with invalid PK
specfication
0616fa1a15 is described below
commit 0616fa1a158e3efe67e9cbb030e63915d6d45558
Author: Peeyush Gupta <[email protected]>
AuthorDate: Sun Sep 24 19:14:39 2023 -0700
[NO ISSUE][COMP] NullPointerException with invalid PK specfication
- user model changes: no
- storage format changes: no
- interface changes: no
Change-Id: Id76bbbbe9155c5b87ff6bd0419d0a29ffa3456da
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17803
Integration-Tests: Jenkins <[email protected]>
Reviewed-by: Murtadha Hubail <[email protected]>
Reviewed-by: Peeyush Gupta <[email protected]>
Tested-by: Peeyush Gupta <[email protected]>
---
.../create-dataset-negative.01.ddl.sqlpp | 25 ++++++++++++++++++++++
.../create-dataset-negative.02.ddl.sqlpp | 25 ++++++++++++++++++++++
.../test/resources/runtimets/testsuite_sqlpp.xml | 7 ++++++
.../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj | 8 +++++++
4 files changed, 65 insertions(+)
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.01.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.01.ddl.sqlpp
new file mode 100644
index 0000000000..bf78c3c2c7
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.01.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create dataset orders primary key my_id;
+
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.02.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.02.ddl.sqlpp
new file mode 100644
index 0000000000..c7e740008b
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.02.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type orderstype as {id:int};
+create dataset orders(orderstype) primary key (id:int);
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 ce3c3c1133..73740281f2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4163,6 +4163,13 @@
<expected-error>ASX1077: Cannot find dataset non_existent in dataverse
test nor an alias with name non_existent (in line 23, at column
21)</expected-error>
</compilation-unit>
</test-case>
+ <test-case FilePath="ddl">
+ <compilation-unit name="create-dataset-negative">
+ <output-dir compare="Clean-JSON">create-dataset-negative</output-dir>
+ <expected-error>ASX1001: Syntax error: Invalid primary key
specification</expected-error>
+ <expected-error>ASX1001: Syntax error: Invalid primary key
specification</expected-error>
+ </compilation-unit>
+ </test-case>
<test-case FilePath="ddl">
<compilation-unit name="analyze-dataset-1">
<output-dir compare="Text">analyze-dataset-1</output-dir>
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 4bdcbf912b..426aa295e3 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -876,6 +876,12 @@ class SQLPPParser extends ScopeChecker implements IParser {
throw pe;
}
}
+
+ private void validatePKFields(Object primaryKeyFields, Token startToken)
throws SqlppParseException {
+ if (primaryKeyFields == null) {
+ throw new SqlppParseException(getSourceLocation(startToken), "Invalid
primary key specification.");
+ }
+ }
}
PARSER_END(SQLPPParser)
@@ -1162,6 +1168,7 @@ DatasetDecl DatasetSpecification(Token startStmtToken)
throws ParseException:
}
if (typeExpr == null) {
+ validatePKFields(primaryKeyFieldsWithTypes, startStmtToken);
InternalDetailsDecl idd = new
InternalDetailsDecl(primaryKeyFieldsWithTypes.second,
primaryKeyFieldsWithTypes.first, autogenerated, filterField == null?
null : filterField.first,
filterField == null? null : filterField.second,
primaryKeyFieldsWithTypes.third);
@@ -1172,6 +1179,7 @@ DatasetDecl DatasetSpecification(Token startStmtToken)
throws ParseException:
DatasetType.INTERNAL, idd, withRecord, ifNotExists, query);
return addSourceLocation(stmt, startStmtToken);
} else {
+ validatePKFields(primaryKeyFields, startStmtToken);
InternalDetailsDecl idd = new
InternalDetailsDecl(primaryKeyFields.second, primaryKeyFields.first,
autogenerated,
filterField == null? null : filterField.first, filterField == null?
null : filterField.second);
DatasetDeclParametersUtil.adjustInlineTypeDecl(typeExpr,
primaryKeyFields.second, primaryKeyFields.first, false);