You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2020/05/13 20:14:49 UTC

[asterixdb] branch master updated (199398a -> 43da2c5)

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

mblow pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git.


    from 199398a  [ASTERIXDB-2730][STO] Avoid Double Flushes in GVBC
     new 0ce5f5a  [NO ISSUE][COMP] Prohibit anonymous type use by CREATE DATASET
     new b564661  Merge commit '4bf7048' from 'gerrit/mad-hatter'
     new 43da2c5  Merge "Merge commit '4bf7048' from 'gerrit/mad-hatter'"

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../asterix/app/translator/QueryTranslator.java    | 17 +++++++++++++--
 .../create-dataset-inline-type-2.1.ddl.sqlpp}      | 24 +++++++++-------------
 .../create-dataset-inline-type-2.2.query.sqlpp}    | 10 ++++-----
 .../create-dataset-inline-type-2.3.ddl.sqlpp}      | 11 +++++-----
 .../create-dataset-inline-type-2.4.ddl.sqlpp}      | 11 +++++++---
 .../create-dataset-inline-type-2.2.adm             |  1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  7 +++++++
 .../metadata/declared/MetadataManagerUtil.java     | 12 +++++++++--
 .../metadata/declared/MetadataProvider.java        |  5 +++++
 9 files changed, 67 insertions(+), 31 deletions(-)
 copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/{json-parser/unsupported-type-duration/unsupported-type-duration.1.ddl.sqlpp => ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.1.ddl.sqlpp} (76%)
 copy asterixdb/asterix-app/src/test/resources/{metadata/queries/basic/meta03/builtin_type/meta03_builtin_type.2.update.aql => runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.query.sqlpp} (83%)
 copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/{misc/query-ASTERIXDB-971/query-ASTERIXDB-971.3.query.sqlpp => ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.3.ddl.sqlpp} (82%)
 copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/{create-dataset-inline-type-1/create-dataset-inline-type-1.4.query.sqlpp => create-dataset-inline-type-2/create-dataset-inline-type-2.4.ddl.sqlpp} (77%)
 create mode 100644 asterixdb/asterix-app/src/test/resources/runtimets/results/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.adm


[asterixdb] 03/03: Merge "Merge commit '4bf7048' from 'gerrit/mad-hatter'"

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 43da2c597bfb79647414cded49045b070ea560f9
Merge: 199398a b564661
Author: Apache AsterixDB Gerrit <de...@asterixdb.apache.org>
AuthorDate: Wed May 13 20:12:57 2020 +0000

    Merge "Merge commit '4bf7048' from 'gerrit/mad-hatter'"

 .../asterix/app/translator/QueryTranslator.java    | 17 ++++++++--
 .../create-dataset-inline-type-2.1.ddl.sqlpp       | 36 ++++++++++++++++++++++
 .../create-dataset-inline-type-2.2.query.sqlpp     | 25 +++++++++++++++
 .../create-dataset-inline-type-2.3.ddl.sqlpp       | 28 +++++++++++++++++
 .../create-dataset-inline-type-2.4.ddl.sqlpp       | 31 +++++++++++++++++++
 .../create-dataset-inline-type-2.2.adm             |  1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  7 +++++
 .../metadata/declared/MetadataManagerUtil.java     | 12 ++++++--
 .../metadata/declared/MetadataProvider.java        |  5 +++
 9 files changed, 158 insertions(+), 4 deletions(-)


[asterixdb] 01/03: [NO ISSUE][COMP] Prohibit anonymous type use by CREATE DATASET

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 0ce5f5afe70b192a6bed851f55289a238f8e960a
Author: Dmitry Lychagin <dm...@couchbase.com>
AuthorDate: Thu Apr 9 11:02:56 2020 -0700

    [NO ISSUE][COMP] Prohibit anonymous type use by CREATE DATASET
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - CREATE DATASET should not be able to use anonymous types
    
    Change-Id: I0dcdd2684180b054ff48f0f0a8ccd6041e8bd00c
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/5664
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Hussain Towaileb <hu...@gmail.com>
---
 .../asterix/app/translator/QueryTranslator.java    | 17 ++++++++--
 .../create-dataset-inline-type-2.1.ddl.sqlpp       | 36 ++++++++++++++++++++++
 .../create-dataset-inline-type-2.2.query.sqlpp     | 25 +++++++++++++++
 .../create-dataset-inline-type-2.3.ddl.sqlpp       | 28 +++++++++++++++++
 .../create-dataset-inline-type-2.4.ddl.sqlpp       | 31 +++++++++++++++++++
 .../create-dataset-inline-type-2.2.adm             |  1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  7 +++++
 .../metadata/declared/MetadataManagerUtil.java     | 12 ++++++--
 .../metadata/declared/MetadataProvider.java        |  5 +++
 9 files changed, 158 insertions(+), 4 deletions(-)

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 81dce6d..c1eea7c 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
@@ -628,7 +628,13 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
             IAType itemType;
             switch (itemTypeExpr.getTypeKind()) {
                 case TYPEREFERENCE:
-                    itemType = metadataProvider.findType(itemTypeDataverseName, itemTypeName);
+                    Datatype itemTypeEntity = metadataProvider.findTypeEntity(itemTypeDataverseName, itemTypeName);
+                    if (itemTypeEntity == null || itemTypeEntity.getIsAnonymous()) {
+                        // anonymous types cannot be referred from CREATE DATASET
+                        throw new AsterixException(ErrorCode.UNKNOWN_TYPE, sourceLoc,
+                                itemTypeDataverseName + "." + itemTypeName);
+                    }
+                    itemType = itemTypeEntity.getDatatype();
                     break;
                 case RECORD:
                     itemTypeDataverseName = dataverseName;
@@ -664,7 +670,14 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
                     if (metaItemTypeExpr != null) {
                         switch (metaItemTypeExpr.getTypeKind()) {
                             case TYPEREFERENCE:
-                                metaItemType = metadataProvider.findType(metaItemTypeDataverseName, metaItemTypeName);
+                                Datatype metaItemTypeEntity =
+                                        metadataProvider.findTypeEntity(metaItemTypeDataverseName, metaItemTypeName);
+                                if (metaItemTypeEntity == null || metaItemTypeEntity.getIsAnonymous()) {
+                                    // anonymous types cannot be referred from CREATE DATASET
+                                    throw new AsterixException(ErrorCode.UNKNOWN_TYPE, sourceLoc,
+                                            metaItemTypeDataverseName + "." + metaItemTypeName);
+                                }
+                                metaItemType = metaItemTypeEntity.getDatatype();
                                 if (metaItemType.getTypeTag() != ATypeTag.OBJECT) {
                                     throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                             "Dataset meta type has to be a record type.");
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.1.ddl.sqlpp
new file mode 100644
index 0000000..d10d096
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/* Prepare: create datasets with inline type */
+
+CREATE DATASET Cust1(
+  c_custkey integer not null,
+  c_name string not null
+) PRIMARY KEY c_custkey;
+
+CREATE DATASET Cust2(
+  c_custkey integer not null,
+  c_name string not null,
+  c_phone string
+) PRIMARY KEY c_custkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.query.sqlpp
new file mode 100644
index 0000000..00cad73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.query.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.
+ */
+
+SELECT count(*) as cnt
+FROM Metadata.`Datatype` dt
+WHERE dt.DataverseName = "test"
+ AND starts_with(dt.DatatypeName, "$d$t$i$Cust")
+ AND dt.Derived.IsAnonymous
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.3.ddl.sqlpp
new file mode 100644
index 0000000..81572f6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.3.ddl.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * 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 dataset that attempts to use first dataset's type
+   as its item type -> Expect error: unknown type */
+
+USE test;
+
+CREATE DATASET Cust1X(
+  `$d$t$i$Cust1`
+)
+PRIMARY KEY c_custkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.4.ddl.sqlpp
new file mode 100644
index 0000000..2ad4888
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.4.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * 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 dataset that attempts to use first dataset's type
+ * as its meta item type -> Expect error: unknown type
+ */
+
+USE test;
+
+CREATE DATASET Cust2X(
+  c_custkey integer not null,
+  c_name string not null
+)
+WITH META(`$d$t$i$Cust2`)
+PRIMARY KEY c_custkey;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.adm
new file mode 100644
index 0000000..3591912
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/ddl/create-dataset-inline-type-2/create-dataset-inline-type-2.2.adm
@@ -0,0 +1 @@
+{ "cnt": 2 }
\ No newline at end of file
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 0d17fb1..63db153 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3865,6 +3865,13 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="ddl">
+      <compilation-unit name="create-dataset-inline-type-2">
+        <output-dir compare="Text">create-dataset-inline-type-2</output-dir>
+        <expected-error>ASX1082: Cannot find datatype with name test.$d$t$i$Cust1</expected-error>
+        <expected-error>ASX1082: Cannot find datatype with name test.$d$t$i$Cust2</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="ddl">
       <compilation-unit name="drop-primary-index">
         <output-dir compare="Text">drop-primary-index</output-dir>
         <expected-error>Cannot drop index "ds". Drop dataset "ds" to remove this index</expected-error>
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
index e819d65..6317d94 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
@@ -23,6 +23,8 @@ import java.util.List;
 
 import org.apache.asterix.common.cluster.IClusterStateManager;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.entities.Dataset;
@@ -48,14 +50,20 @@ public class MetadataManagerUtil {
 
     public static IAType findType(MetadataTransactionContext mdTxnCtx, String dataverse, String typeName)
             throws AlgebricksException {
+        Datatype type = findTypeEntity(mdTxnCtx, dataverse, typeName);
+        return type != null ? type.getDatatype() : null;
+    }
+
+    public static Datatype findTypeEntity(MetadataTransactionContext mdTxnCtx, String dataverse, String typeName)
+            throws AlgebricksException {
         if (dataverse == null || typeName == null) {
             return null;
         }
         Datatype type = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, dataverse, typeName);
         if (type == null) {
-            throw new AlgebricksException("Type name '" + typeName + "' unknown in dataverse '" + dataverse + "'");
+            throw new AsterixException(ErrorCode.UNKNOWN_TYPE, dataverse + "." + typeName);
         }
-        return type.getDatatype();
+        return type;
     }
 
     public static ARecordType findOutputRecordType(MetadataTransactionContext mdTxnCtx, String dataverse,
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
index 5bdf2a7..6b6cc78 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
@@ -72,6 +72,7 @@ import org.apache.asterix.metadata.bootstrap.MetadataBuiltinEntities;
 import org.apache.asterix.metadata.dataset.hints.DatasetHints.DatasetCardinalityHint;
 import org.apache.asterix.metadata.entities.Dataset;
 import org.apache.asterix.metadata.entities.DatasourceAdapter;
+import org.apache.asterix.metadata.entities.Datatype;
 import org.apache.asterix.metadata.entities.Dataverse;
 import org.apache.asterix.metadata.entities.ExternalDatasetDetails;
 import org.apache.asterix.metadata.entities.Feed;
@@ -345,6 +346,10 @@ public class MetadataProvider implements IMetadataProvider<DataSourceId, String>
         return MetadataManagerUtil.findNodes(mdTxnCtx, nodeGroupName);
     }
 
+    public Datatype findTypeEntity(String dataverse, String typeName) throws AlgebricksException {
+        return MetadataManagerUtil.findTypeEntity(mdTxnCtx, dataverse, typeName);
+    }
+
     public IAType findType(String dataverse, String typeName) throws AlgebricksException {
         return MetadataManagerUtil.findType(mdTxnCtx, dataverse, typeName);
     }


[asterixdb] 02/03: Merge commit '4bf7048' from 'gerrit/mad-hatter'

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit b56466186c5f5a9eca1741ca56e4ae250e322f53
Merge: d7072db 0ce5f5a
Author: Michael Blow <mb...@apache.org>
AuthorDate: Wed May 13 07:43:09 2020 -0400

    Merge commit '4bf7048' from 'gerrit/mad-hatter'
    
    Change-Id: I06432e8daa1669862d1f23a04efdfec5b1e6d7b5

 .../asterix/app/translator/QueryTranslator.java    | 17 ++++++++--
 .../create-dataset-inline-type-2.1.ddl.sqlpp       | 36 ++++++++++++++++++++++
 .../create-dataset-inline-type-2.2.query.sqlpp     | 25 +++++++++++++++
 .../create-dataset-inline-type-2.3.ddl.sqlpp       | 28 +++++++++++++++++
 .../create-dataset-inline-type-2.4.ddl.sqlpp       | 31 +++++++++++++++++++
 .../create-dataset-inline-type-2.2.adm             |  1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  7 +++++
 .../metadata/declared/MetadataManagerUtil.java     | 12 ++++++--
 .../metadata/declared/MetadataProvider.java        |  5 +++
 9 files changed, 158 insertions(+), 4 deletions(-)

diff --cc asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
index 72d989a,6317d94..6ba8ba8
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
@@@ -23,7 -23,8 +23,9 @@@ import java.util.List
  
  import org.apache.asterix.common.cluster.IClusterStateManager;
  import org.apache.asterix.common.config.DatasetConfig.DatasetType;
+ import org.apache.asterix.common.exceptions.AsterixException;
+ import org.apache.asterix.common.exceptions.ErrorCode;
 +import org.apache.asterix.common.metadata.DataverseName;
  import org.apache.asterix.metadata.MetadataManager;
  import org.apache.asterix.metadata.MetadataTransactionContext;
  import org.apache.asterix.metadata.entities.Dataset;
@@@ -48,19 -48,25 +50,25 @@@ public class MetadataManagerUtil 
          throw new AssertionError("This util class should not be initialized.");
      }
  
 -    public static IAType findType(MetadataTransactionContext mdTxnCtx, String dataverse, String typeName)
 +    public static IAType findType(MetadataTransactionContext mdTxnCtx, DataverseName dataverseName, String typeName)
              throws AlgebricksException {
 -        Datatype type = findTypeEntity(mdTxnCtx, dataverse, typeName);
++        Datatype type = findTypeEntity(mdTxnCtx, dataverseName, typeName);
+         return type != null ? type.getDatatype() : null;
+     }
+ 
 -    public static Datatype findTypeEntity(MetadataTransactionContext mdTxnCtx, String dataverse, String typeName)
 -            throws AlgebricksException {
 -        if (dataverse == null || typeName == null) {
++    public static Datatype findTypeEntity(MetadataTransactionContext mdTxnCtx, DataverseName dataverseName,
++            String typeName) throws AlgebricksException {
 +        if (dataverseName == null || typeName == null) {
              return null;
          }
 -        Datatype type = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, dataverse, typeName);
 +        Datatype type = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, dataverseName, typeName);
          if (type == null) {
-             throw new AlgebricksException("Type name '" + typeName + "' unknown in dataverse '" + dataverseName + "'");
 -            throw new AsterixException(ErrorCode.UNKNOWN_TYPE, dataverse + "." + typeName);
++            throw new AsterixException(ErrorCode.UNKNOWN_TYPE, dataverseName + "." + typeName);
          }
-         return type.getDatatype();
+         return type;
      }
  
 -    public static ARecordType findOutputRecordType(MetadataTransactionContext mdTxnCtx, String dataverse,
 +    public static ARecordType findOutputRecordType(MetadataTransactionContext mdTxnCtx, DataverseName dataverseName,
              String outputRecordType) throws AlgebricksException {
          if (outputRecordType == null) {
              return null;
diff --cc asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
index 93e214e,6b6cc78..3107a00
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
@@@ -360,8 -346,12 +361,12 @@@ public class MetadataProvider implement
          return MetadataManagerUtil.findNodes(mdTxnCtx, nodeGroupName);
      }
  
 -    public Datatype findTypeEntity(String dataverse, String typeName) throws AlgebricksException {
 -        return MetadataManagerUtil.findTypeEntity(mdTxnCtx, dataverse, typeName);
++    public Datatype findTypeEntity(DataverseName dataverseName, String typeName) throws AlgebricksException {
++        return MetadataManagerUtil.findTypeEntity(mdTxnCtx, dataverseName, typeName);
+     }
+ 
 -    public IAType findType(String dataverse, String typeName) throws AlgebricksException {
 -        return MetadataManagerUtil.findType(mdTxnCtx, dataverse, typeName);
 +    public IAType findType(DataverseName dataverseName, String typeName) throws AlgebricksException {
 +        return MetadataManagerUtil.findType(mdTxnCtx, dataverseName, typeName);
      }
  
      public IAType findType(Dataset dataset) throws AlgebricksException {