>From Peeyush Gupta <[email protected]>:

Peeyush Gupta has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17803 )

Change subject: [NO ISSUE][COMP] NullPointerException with invalid PK 
specfication
......................................................................

[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]>
---
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.01.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-negative/create-dataset-negative.02.ddl.sqlpp
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
4 files changed, 83 insertions(+), 0 deletions(-)

Approvals:
  Murtadha Hubail: Looks good to me, approved
  Peeyush Gupta: Looks good to me, but someone else must approve; Verified
  Jenkins: Verified




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 0000000..bf78c3c
--- /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 0000000..c7e7400
--- /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 ce3c3c1..7374028 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4164,6 +4164,13 @@
       </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>
       </compilation-unit>
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 4bdcbf9..426aa29 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 @@
         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 @@
       }

       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 @@
           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);

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17803
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Id76bbbbe9155c5b87ff6bd0419d0a29ffa3456da
Gerrit-Change-Number: 17803
Gerrit-PatchSet: 3
Gerrit-Owner: Peeyush Gupta <[email protected]>
Gerrit-Reviewer: Ali Alsuliman <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: Peeyush Gupta <[email protected]>
Gerrit-MessageType: merged

Reply via email to