Enabled Datasets to use Datatypes from foreign Dataverses

Removed broken Metadata Secondary Indexes
Added DatatypeDataverse field to Dataset
Cleaned up Metadata Tests
Added tests for dropping used Datatypes
User-facing changes are:
1) Allow qualified datatype when creating dataset
2) Metadata queries for datasets will now
include the type dataverse

Change-Id: I24dbc04dcb2a4126fc8361ebe3104877a0d1f2bb
Reviewed-on: https://asterix-gerrit.ics.uci.edu/558
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterix-lang-aql/src/main/javacc/AQL.jj b/asterix-lang-aql/src/main/javacc/AQL.jj
index 78c9abd..12e7897 100644
--- a/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -402,7 +402,7 @@
 {
   Pair<Identifier,Identifier> nameComponents = null;
   boolean ifNotExists = false;
-  String typeName = null;
+  Pair<Identifier,Identifier> typeComponents = null;
   String adapterName = null;
   Map<String,String> properties = null;
   Map<String,String> compactionPolicyProperties = null;
@@ -419,7 +419,7 @@
 {
   (
     "external" <DATASET> nameComponents = QualifiedName()
-    <LEFTPAREN> typeName = Identifier() <RIGHTPAREN>
+    <LEFTPAREN> typeComponents = TypeName() <RIGHTPAREN>
     ifNotExists = IfNotExists()
     "using" adapterName = AdapterName() properties = Configuration()
     ("on" nodeGroupName = Identifier() )?
@@ -431,7 +431,8 @@
         edd.setProperties(properties);
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
-                                   new Identifier(typeName),
+                                   typeComponents.first,
+                                   typeComponents.second,
                                    nodeGroupName != null? new Identifier(nodeGroupName): null,
                                    compactionPolicy,
                                    compactionPolicyProperties,
@@ -446,7 +447,7 @@
         }
       )? 
     <DATASET> nameComponents = QualifiedName()
-    <LEFTPAREN> typeName = Identifier() <RIGHTPAREN>
+    <LEFTPAREN> typeComponents = TypeName() <RIGHTPAREN>
     ifNotExists = IfNotExists()
     primaryKeyFields = PrimaryKey()
     ("autogenerated" { autogenerated = true; } )?
@@ -461,7 +462,8 @@
                                                           temp);
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
-                                   new Identifier(typeName),
+                                   typeComponents.first,
+                                   typeComponents.second,
                                    nodeGroupName != null ? new Identifier(nodeGroupName) : null,
                                    compactionPolicy,
                                    compactionPolicyProperties,