Dmitry Lychagin has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/3420
Change subject: [NO ISSUE][SQLPP] Improve error message for unsupported EXPLAIN ...................................................................... [NO ISSUE][SQLPP] Improve error message for unsupported EXPLAIN - user model changes: no - storage format changes: no - interface changes: no Details: - Improve error message raised when EXPLAIN is not supported for a given statement Change-Id: Idd7844ca3d9e3c2c0de0b070e4a76282cb96e278 --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.2.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.4.query.sqlpp M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 6 files changed, 124 insertions(+), 13 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/20/3420/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.1.ddl.sqlpp new file mode 100644 index 0000000..741c9be --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.1.ddl.sqlpp @@ -0,0 +1,33 @@ +/* + * 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: EXPLAIN not supported for statement kind + */ + +DROP DATAVERSE dvExplain IF EXISTS; +CREATE DATAVERSE dvExplain; + +USE dvExplain; + +CREATE TYPE EmployeeType AS { + id : string, + x : string +}; + +CREATE DATASET Employee(EmployeeType) PRIMARY KEY id; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.2.query.sqlpp new file mode 100644 index 0000000..a309a92 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.2.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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 : EXPLAIN not supported for CREATE DATAVERSE + * Expected Res : Failure + */ + +EXPLAIN CREATE DATAVERSE dvExplain2; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.3.query.sqlpp new file mode 100644 index 0000000..11fe3d2 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.3.query.sqlpp @@ -0,0 +1,26 @@ +/* + * 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 : EXPLAIN not supported for CREATE DATASET + * Expected Res : Failure + */ + +USE dvExplain; + +EXPLAIN CREATE DATASET Employee2(EmployeeType) PRIMARY KEY id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.4.query.sqlpp new file mode 100644 index 0000000..9f74ef8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/explain/explain_negative/explain_negative.4.query.sqlpp @@ -0,0 +1,26 @@ +/* + * 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 : EXPLAIN not supported for CREATE INDEX + * Expected Res : Failure + */ + +USE dvExplain; + +EXPLAIN CREATE INDEX idx1 on Employee(x) type btree; 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 d5fa013..2e7adfd 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -174,6 +174,14 @@ <output-dir compare="Text">explain_field_access_closed</output-dir> </compilation-unit> </test-case> + <test-case FilePath="explain"> + <compilation-unit name="explain_negative"> + <output-dir compare="Text">explain_simple</output-dir> + <expected-error>ASX1001: Syntax error: EXPLAIN is not supported for this kind of statement</expected-error> + <expected-error>ASX1001: Syntax error: EXPLAIN is not supported for this kind of statement</expected-error> + <expected-error>ASX1001: Syntax error: EXPLAIN is not supported for this kind of statement</expected-error> + </compilation-unit> + </test-case> </test-group> <test-case FilePath="flwor"> <compilation-unit name="let33"> diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index c0f1725..5a8b0ea 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -448,8 +448,11 @@ Statement SingleStatement() throws ParseException: { Statement stmt = null; + boolean explain = false; + Token explainToken = null; } { + ( <EXPLAIN> { explain = true; explainToken = token; } )? ( stmt = DataverseDeclaration() | stmt = FunctionDeclaration() @@ -464,11 +467,13 @@ | stmt = UpsertStatement() | stmt = ConnectionStatement() | stmt = CompactStatement() - | stmt = ExplainStatement() - | stmt = Query(false) + | stmt = Query(explain) | stmt = RefreshExternalDatasetStatement() ) { + if (explain && stmt.getKind() != Statement.Kind.QUERY) { + throw new SqlppParseException(getSourceLocation(explainToken), "EXPLAIN is not supported for this kind of statement"); + } return stmt; } } @@ -1847,17 +1852,6 @@ FunctionDecl stmt = new FunctionDecl(signature, paramList, funcBody); removeCurrentScope(); return addSourceLocation(stmt, startToken); - } -} - -Query ExplainStatement() throws ParseException: -{ - Query query; -} -{ - <EXPLAIN> query = Query(true) - { - return query; } } -- To view, visit https://asterix-gerrit.ics.uci.edu/3420 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Idd7844ca3d9e3c2c0de0b070e4a76282cb96e278 Gerrit-Change-Number: 3420 Gerrit-PatchSet: 1 Gerrit-Owner: Dmitry Lychagin <[email protected]>
