You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2020/10/14 03:09:50 UTC

[asterixdb] branch master updated: [NO ISSUE][COMP] Fail CREATE SYNONYM if dataverse not found

This is an automated email from the ASF dual-hosted git repository.

dlych 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 916282c  [NO ISSUE][COMP] Fail CREATE SYNONYM if dataverse not found
916282c is described below

commit 916282c29b7af26d00b5bcdf2a57f7dae6396b2f
Author: Dmitry Lychagin <dm...@couchbase.com>
AuthorDate: Tue Oct 13 16:53:37 2020 -0700

    [NO ISSUE][COMP] Fail CREATE SYNONYM if dataverse not found
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - CREATE SYNONYM should fail if the synonym
      is created in an unknown dataverse
    
    Change-Id: Ia00ba58fc068d0f98d523522f7c9cae261d5a99c
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/8404
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Dmitry Lychagin <dm...@couchbase.com>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../asterix/app/translator/QueryTranslator.java      |  4 ++++
 .../synonym-02-negative.1.ddl.sqlpp                  | 20 ++++++++++++++++++++
 .../src/test/resources/runtimets/testsuite_sqlpp.xml |  6 ++++++
 3 files changed, 30 insertions(+)

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index bccd2a9..256ba2c 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -2624,6 +2624,10 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
         try {
+            Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverseName);
+            if (dv == null) {
+                throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, css.getSourceLocation(), dataverseName);
+            }
             Synonym synonym = MetadataManager.INSTANCE.getSynonym(metadataProvider.getMetadataTxnContext(),
                     dataverseName, synonymName);
             if (synonym != null) {
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/synonym/synonym-02-negative/synonym-02-negative.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/synonym/synonym-02-negative/synonym-02-negative.1.ddl.sqlpp
new file mode 100644
index 0000000..abd9314
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/synonym/synonym-02-negative/synonym-02-negative.1.ddl.sqlpp
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+create synonym UNKNOWN_DATAVERSE.MyDs for `Metadata`.`Dataset`;
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 3c383b0..66cb684 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -10336,6 +10336,12 @@
         <output-dir compare="Text">synonym-01</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="synonym">
+      <compilation-unit name="synonym-02-negative">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>ASX1063: Cannot find dataverse with name UNKNOWN_DATAVERSE</expected-error>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="tokenizers">
     <test-case FilePath="tokenizers">