Merged asterix_stabilization -r 1189:1249

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_ioc@1253 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/pom.xml b/asterix-algebra/pom.xml
index 70f8c53..b81e77f 100644
--- a/asterix-algebra/pom.xml
+++ b/asterix-algebra/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 			<plugin>
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
index 704ccb5..5c54a4a 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -15,6 +15,7 @@
 
 package edu.uci.ics.asterix.optimizer.rules;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -93,40 +94,44 @@
             }
 
             IAType t = (IAType) env.getType(fce.getArguments().get(0).getValue());
-            switch (t.getTypeTag()) {
-                case ANY: {
-                    return false;
-                }
-                case RECORD: {
-                    ARecordType recType = (ARecordType) t;
-                    ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
-                    if (fai == null) {
+            try {
+                switch (t.getTypeTag()) {
+                    case ANY: {
                         return false;
                     }
-                    expressions.get(i).setValue(fai);
-                    changed = true;
-                    break;
-                }
-                case UNION: {
-                    AUnionType unionT = (AUnionType) t;
-                    if (unionT.isNullableType()) {
-                        IAType t2 = unionT.getUnionList().get(1);
-                        if (t2.getTypeTag() == ATypeTag.RECORD) {
-                            ARecordType recType = (ARecordType) t2;
-                            ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
-                            if (fai == null) {
-                                return false;
-                            }
-                            expressions.get(i).setValue(fai);
-                            changed = true;
-                            break;
+                    case RECORD: {
+                        ARecordType recType = (ARecordType) t;
+                        ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
+                        if (fai == null) {
+                            return false;
                         }
+                        expressions.get(i).setValue(fai);
+                        changed = true;
+                        break;
                     }
-                    throw new NotImplementedException("Union " + unionT);
+                    case UNION: {
+                        AUnionType unionT = (AUnionType) t;
+                        if (unionT.isNullableType()) {
+                            IAType t2 = unionT.getUnionList().get(1);
+                            if (t2.getTypeTag() == ATypeTag.RECORD) {
+                                ARecordType recType = (ARecordType) t2;
+                                ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
+                                if (fai == null) {
+                                    return false;
+                                }
+                                expressions.get(i).setValue(fai);
+                                changed = true;
+                                break;
+                            }
+                        }
+                        throw new NotImplementedException("Union " + unionT);
+                    }
+                    default: {
+                        throw new AlgebricksException("Cannot call field-access on data of type " + t);
+                    }
                 }
-                default: {
-                    throw new AlgebricksException("Cannot call field-access on data of type " + t);
-                }
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
             }
         }
         assign.removeAnnotation(AsterixOperatorAnnotations.PUSHED_FIELD_ACCESS);
@@ -134,7 +139,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    private static ILogicalExpression createFieldAccessByIndex(ARecordType recType, AbstractFunctionCallExpression fce) {
+    private static ILogicalExpression createFieldAccessByIndex(ARecordType recType, AbstractFunctionCallExpression fce)
+            throws IOException {
         String s = getStringSecondArgument(fce);
         if (s == null) {
             return null;
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
index bc61c49..b0ce342 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -16,6 +16,7 @@
 package edu.uci.ics.asterix.optimizer.rules;
 
 import java.io.DataInputStream;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
@@ -188,7 +189,12 @@
                 ARecordType rt = (ARecordType) _emptyTypeEnv.getType(expr.getArguments().get(0).getValue());
                 String str = ((AString) ((AsterixConstantValue) ((ConstantExpression) expr.getArguments().get(1)
                         .getValue()).getValue()).getObject()).getStringValue();
-                int k = rt.findFieldPosition(str);
+                int k;
+                try {
+                    k = rt.findFieldPosition(str);
+                } catch (IOException e) {
+                    throw new AlgebricksException(e);
+                }
                 if (k >= 0) {
                     // wait for the ByNameToByIndex rule to apply
                     return new Pair<Boolean, ILogicalExpression>(changed, expr);
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
index 6651ea3..ffd447c 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.optimizer.rules.am;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -44,7 +60,8 @@
  * Static helper functions for rewriting plans using indexes.
  */
 public class AccessMethodUtils {
-    public static void appendPrimaryIndexTypes(Dataset dataset, IAType itemType, List<Object> target) {
+    public static void appendPrimaryIndexTypes(Dataset dataset, IAType itemType, List<Object> target)
+            throws IOException {
         ARecordType recordType = (ARecordType) itemType;
         List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
         for (String partitioningKey : partitioningKeys) {
@@ -109,7 +126,7 @@
         analysisCtx.matchedFuncExprs.add(new OptimizableFuncExpr(funcExpr, fieldVar, constFilterVal));
         return true;
     }
-    
+
     public static boolean analyzeFuncExprArgsForTwoVars(AbstractFunctionCallExpression funcExpr,
             AccessMethodAnalysisContext analysisCtx) {
         LogicalVariable fieldVar1 = null;
@@ -180,7 +197,11 @@
         // Primary keys.
         List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
         for (String partitioningKey : partitioningKeys) {
-            dest.add(recordType.getFieldType(partitioningKey));
+            try {
+                dest.add(recordType.getFieldType(partitioningKey));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
         }
     }
 
@@ -229,14 +250,14 @@
     }
 
     /**
-     *  Returns the first expr optimizable by this index.
+     * Returns the first expr optimizable by this index.
      */
     public static IOptimizableFuncExpr chooseFirstOptFuncExpr(Index chosenIndex, AccessMethodAnalysisContext analysisCtx) {
         List<Integer> indexExprs = analysisCtx.getIndexExprs(chosenIndex);
         int firstExprIndex = indexExprs.get(0);
         return analysisCtx.matchedFuncExprs.get(firstExprIndex);
     }
-    
+
     public static UnnestMapOperator createSecondaryIndexUnnestMap(Dataset dataset, ARecordType recordType, Index index,
             ILogicalOperator inputOp, AccessMethodJobGenParams jobGenParams, IOptimizationContext context,
             boolean outputPrimaryKeysOnly, boolean retainInput) throws AlgebricksException {
@@ -299,7 +320,11 @@
         List<Object> primaryIndexOutputTypes = new ArrayList<Object>();
         // Append output variables/types generated by the primary-index search (not forwarded from input).
         primaryIndexUnnestVars.addAll(dataSourceScan.getVariables());
-        appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+        try {
+            appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
+        }
         // An index search is expressed as an unnest over an index-search function.
         IFunctionInfo primaryIndexSearch = FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.INDEX_SEARCH);
         AbstractFunctionCallExpression primaryIndexSearchFunc = new ScalarFunctionCallExpression(primaryIndexSearch,
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
index 5c65299..3b547e7 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.optimizer.rules.am;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashSet;
@@ -205,7 +221,7 @@
                 if (optFuncExpr.getNumLogicalVars() > 1) {
                     // If we are optimizing a join, the matching field may be the second field name.
                     keyPos = indexOf(optFuncExpr.getFieldName(1), chosenIndex.getKeyFieldNames());
-                }                
+                }
             }
             if (keyPos < 0) {
                 throw new AlgebricksException(
@@ -238,7 +254,7 @@
                     // If high and low keys are set, we exit for now.
                     if (setLowKeys.cardinality() == numSecondaryKeys && setHighKeys.cardinality() == numSecondaryKeys) {
                         doneWithExprs = true;
-                    }                    
+                    }
                     break;
                 }
                 case HIGH_EXCLUSIVE: {
@@ -390,7 +406,11 @@
                     secondaryIndexUnnestOp, context, true, retainInput, false);
         } else {
             List<Object> primaryIndexOutputTypes = new ArrayList<Object>();
-            AccessMethodUtils.appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+            try {
+                AccessMethodUtils.appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             primaryIndexUnnestOp = new UnnestMapOperator(dataSourceScan.getVariables(),
                     secondaryIndexUnnestOp.getExpressionRef(), primaryIndexOutputTypes, retainInput);
             primaryIndexUnnestOp.getInputs().add(new MutableObject<ILogicalOperator>(inputOp));
@@ -521,7 +541,7 @@
             return (optFuncExpr.getOperatorSubTree(0) == null || optFuncExpr.getOperatorSubTree(0) == probeSubTree);
         }
     }
-    
+
     private ILogicalExpression createSelectCondition(List<Mutable<ILogicalExpression>> predList) {
         if (predList.size() > 1) {
             IFunctionInfo finfo = AsterixBuiltinFunctions.getAsterixFunctionInfo(AlgebricksBuiltinFunctions.AND);
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
index 4047d9a..5abbd91 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.translator;
 
 import java.util.ArrayList;
@@ -29,6 +30,7 @@
 import edu.uci.ics.asterix.aql.expression.UnorderedListTypeDefinition;
 import edu.uci.ics.asterix.common.annotations.IRecordFieldDataGen;
 import edu.uci.ics.asterix.common.annotations.RecordDataGenAnnotation;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
@@ -89,41 +91,45 @@
             throw new AlgebricksException("Cannot redefine builtin type " + tdname + " .");
         }
         TypeSignature typeSignature = new TypeSignature(typeDataverse, tdname);
-        switch (texpr.getTypeKind()) {
-            case TYPEREFERENCE: {
-                TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
-                IAType t = solveTypeReference(typeSignature, typeMap);
-                if (t != null) {
-                    typeMap.put(typeSignature, t);
-                } else {
-                    addIncompleteTopLevelTypeReference(tdname, tre, incompleteTopLevelTypeReferences, typeDataverse);
+        try {
+            switch (texpr.getTypeKind()) {
+                case TYPEREFERENCE: {
+                    TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
+                    IAType t = solveTypeReference(typeSignature, typeMap);
+                    if (t != null) {
+                        typeMap.put(typeSignature, t);
+                    } else {
+                        addIncompleteTopLevelTypeReference(tdname, tre, incompleteTopLevelTypeReferences, typeDataverse);
+                    }
+                    break;
                 }
-                break;
+                case RECORD: {
+                    RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
+                    ARecordType recType = computeRecordType(typeSignature, rtd, typeMap, incompleteFieldTypes,
+                            incompleteItemTypes, typeDataverse);
+                    typeMap.put(typeSignature, recType);
+                    break;
+                }
+                case ORDEREDLIST: {
+                    OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
+                    AOrderedListType olType = computeOrderedListType(typeSignature, oltd, typeMap, incompleteItemTypes,
+                            incompleteFieldTypes, typeDataverse);
+                    typeMap.put(typeSignature, olType);
+                    break;
+                }
+                case UNORDEREDLIST: {
+                    UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
+                    AUnorderedListType ulType = computeUnorderedListType(typeSignature, ultd, typeMap,
+                            incompleteItemTypes, incompleteFieldTypes, typeDataverse);
+                    typeMap.put(typeSignature, ulType);
+                    break;
+                }
+                default: {
+                    throw new IllegalStateException();
+                }
             }
-            case RECORD: {
-                RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
-                ARecordType recType = computeRecordType(typeSignature, rtd, typeMap, incompleteFieldTypes,
-                        incompleteItemTypes, typeDataverse);
-                typeMap.put(typeSignature, recType);
-                break;
-            }
-            case ORDEREDLIST: {
-                OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
-                AOrderedListType olType = computeOrderedListType(typeSignature, oltd, typeMap, incompleteItemTypes,
-                        incompleteFieldTypes, typeDataverse);
-                typeMap.put(typeSignature, olType);
-                break;
-            }
-            case UNORDEREDLIST: {
-                UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
-                AUnorderedListType ulType = computeUnorderedListType(typeSignature, ultd, typeMap, incompleteItemTypes,
-                        incompleteFieldTypes, typeDataverse);
-                typeMap.put(typeSignature, ulType);
-                break;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
         }
     }
 
@@ -181,7 +187,7 @@
                 }
                 t = dt.getDatatype();
             } else {
-                t = typeMap.get(typeSignature);   
+                t = typeMap.get(typeSignature);
             }
             for (AbstractCollectionType act : incompleteItemTypes.get(typeSignature)) {
                 act.setItemType(t);
@@ -191,7 +197,8 @@
 
     private static AOrderedListType computeOrderedListType(TypeSignature typeSignature, OrderedListTypeDefinition oltd,
             Map<TypeSignature, IAType> typeMap, Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaultDataverse) {
+            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaultDataverse)
+            throws AsterixException {
         TypeExpression tExpr = oltd.getItemTypeExpression();
         String typeName = typeSignature != null ? typeSignature.getName() : null;
         AOrderedListType aolt = new AOrderedListType(null, typeName);
@@ -202,7 +209,8 @@
     private static AUnorderedListType computeUnorderedListType(TypeSignature typeSignature,
             UnorderedListTypeDefinition ultd, Map<TypeSignature, IAType> typeMap,
             Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaulDataverse) {
+            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaulDataverse)
+            throws AsterixException {
         TypeExpression tExpr = ultd.getItemTypeExpression();
         String typeName = typeSignature != null ? typeSignature.getName() : null;
         AUnorderedListType ault = new AUnorderedListType(null, typeName);
@@ -213,7 +221,7 @@
     private static void setCollectionItemType(TypeExpression tExpr, Map<TypeSignature, IAType> typeMap,
             Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
             Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, AbstractCollectionType act,
-            String defaultDataverse) {
+            String defaultDataverse) throws AsterixException {
         switch (tExpr.getTypeKind()) {
             case ORDEREDLIST: {
                 OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) tExpr;
@@ -306,7 +314,8 @@
 
     private static ARecordType computeRecordType(TypeSignature typeSignature, RecordTypeDefinition rtd,
             Map<TypeSignature, IAType> typeMap, Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
-            Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes, String defaultDataverse) {
+            Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes, String defaultDataverse)
+            throws AsterixException {
         List<String> names = rtd.getFieldNames();
         int n = names.size();
         String[] fldNames = new String[n];
@@ -318,14 +327,14 @@
         boolean isOpen = rtd.getRecordKind() == RecordKind.OPEN;
         ARecordType recType = new ARecordType(typeSignature == null ? null : typeSignature.getName(), fldNames,
                 fldTypes, isOpen);
-        
+
         List<IRecordFieldDataGen> fieldDataGen = rtd.getFieldDataGen();
         if (fieldDataGen.size() == n) {
             IRecordFieldDataGen[] rfdg = new IRecordFieldDataGen[n];
             rfdg = fieldDataGen.toArray(rfdg);
             recType.getAnnotations().add(new RecordDataGenAnnotation(rfdg, rtd.getUndeclaredFieldsDataGen()));
         }
-        
+
         for (int j = 0; j < n; j++) {
             TypeExpression texpr = rtd.getFieldTypes().get(j);
             switch (texpr.getTypeKind()) {
diff --git a/asterix-app/pom.xml b/asterix-app/pom.xml
index 2f80c30..7d6e64a 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -17,8 +17,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 			<plugin>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
index 8d804a4..075ddd3 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,9 +12,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.file;
 
 import java.io.File;
+import java.io.IOException;
 import java.rmi.RemoteException;
 import java.util.List;
 import java.util.logging.Logger;
@@ -172,6 +174,17 @@
             throw new AsterixException("Could not find dataset " + datasetName + " in datavetse " + dataverseName);
         }
         ARecordType itemType = (ARecordType) metadata.findType(dataverseName, dataset.getItemTypeName());
+        for (String keyField : DatasetUtils.getPartitioningKeys(dataset)) {
+            try {
+                if (!itemType.isClosedField(keyField)) {
+                    throw new AsterixException("Cannot partition dataset \"" + dataset.getDatasetName()
+                            + "\" by key \"" + keyField + "\" since it is not a valid field of \""
+                            + itemType.getTypeName() + "\"");
+                }
+            } catch (IOException e) {
+                throw new AsterixException(e);
+            }
+        }
         JobSpecification spec = new JobSpecification();
         IBinaryComparatorFactory[] comparatorFactories = DatasetUtils.computeKeysBinaryComparatorFactories(dataset,
                 itemType, format.getBinaryComparatorFactoryProvider());
@@ -329,7 +342,12 @@
         ISerializerDeserializer[] recordFields = new ISerializerDeserializer[1 + numKeys];
         recordFields[0] = payloadSerde;
         for (int i = 0; i < numKeys; i++) {
-            IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+            IAType keyType;
+            try {
+                keyType = itemType.getFieldType(partitioningKeys.get(i));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             ISerializerDeserializer keySerde = dataFormat.getSerdeProvider().getSerializerDeserializer(keyType);
             recordFields[i + 1] = keySerde;
         }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
index 34ba208..87d3b08 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
@@ -1,6 +1,22 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.file;
 
 import java.io.DataOutput;
+import java.io.IOException;
 import java.util.List;
 
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
@@ -137,13 +153,12 @@
         numPrimaryKeys = DatasetUtils.getPartitioningKeys(dataset).size();
         numSecondaryKeys = createIndexStmt.getKeyFields().size();
         Pair<IFileSplitProvider, AlgebricksPartitionConstraint> primarySplitsAndConstraint = metadataProvider
-                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
-                        dataverseName, datasetName, datasetName);
+                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName, datasetName);
         primaryFileSplitProvider = primarySplitsAndConstraint.first;
         primaryPartitionConstraint = primarySplitsAndConstraint.second;
         Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
-                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
-                        dataverseName, datasetName, secondaryIndexName);
+                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName,
+                        secondaryIndexName);
         secondaryFileSplitProvider = secondarySplitsAndConstraint.first;
         secondaryPartitionConstraint = secondarySplitsAndConstraint.second;
         // Must be called in this order.
@@ -159,7 +174,12 @@
         primaryComparatorFactories = new IBinaryComparatorFactory[numPrimaryKeys];
         ISerializerDeserializerProvider serdeProvider = metadataProvider.getFormat().getSerdeProvider();
         for (int i = 0; i < numPrimaryKeys; i++) {
-            IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+            IAType keyType;
+            try {
+                keyType = itemType.getFieldType(partitioningKeys.get(i));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             primaryRecFields[i] = serdeProvider.getSerializerDeserializer(keyType);
             primaryComparatorFactories[i] = AqlBinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(
                     keyType, true);
@@ -286,8 +306,8 @@
             fieldPermutation[i] = i;
         }
         Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
-                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
-                        dataverseName, datasetName, secondaryIndexName);
+                .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName,
+                        secondaryIndexName);
         TreeIndexBulkLoadOperatorDescriptor treeIndexBulkLoadOp = new TreeIndexBulkLoadOperatorDescriptor(spec,
                 AsterixStorageManagerInterface.INSTANCE, AsterixIndexRegistryProvider.INSTANCE,
                 secondarySplitsAndConstraint.first, secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories,
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
index 43c6c0c..10cba14 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
@@ -23,6 +23,8 @@
 import edu.uci.ics.asterix.api.java.AsterixJavaClient;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter;
+import edu.uci.ics.asterix.external.util.IdentitiyResolverFactory;
 import edu.uci.ics.asterix.test.base.AsterixTestHelper;
 import edu.uci.ics.asterix.test.common.TestHelper;
 
@@ -56,6 +58,10 @@
         File outdir = new File(PATH_ACTUAL);
         outdir.mkdirs();
         AsterixHyracksIntegrationUtil.init();
+        // Set the node resolver to be the identity resolver that expects node names 
+        // to be node controller ids; a valid assumption in test environment. 
+        System.setProperty(FileSystemBasedAdapter.NODE_RESOLVER_FACTORY_PROPERTY,
+                IdentitiyResolverFactory.class.getName());
     }
 
     @AfterClass
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
index 8eafd02..c705ea6 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
@@ -17,6 +17,8 @@
 
 import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter;
+import edu.uci.ics.asterix.external.util.IdentitiyResolverFactory;
 import edu.uci.ics.asterix.test.aql.TestsUtils;
 import edu.uci.ics.asterix.testframework.context.TestCaseContext;
 import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
@@ -51,8 +53,14 @@
 
         AsterixHyracksIntegrationUtil.init();
 
-        // TODO: Uncomment when hadoop version is upgraded and adapters are ported
+        // TODO: Uncomment when hadoop version is upgraded and adapters are
+        // ported. 
         HDFSCluster.getInstance().setup();
+
+        // Set the node resolver to be the identity resolver that expects node names 
+        // to be node controller ids; a valid assumption in test environment. 
+        System.setProperty(FileSystemBasedAdapter.NODE_RESOLVER_FACTORY_PROPERTY,
+                IdentitiyResolverFactory.class.getName());
     }
 
     @AfterClass
diff --git a/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql b/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
index 51e4344..1660e44 100644
--- a/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
+++ b/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
@@ -24,6 +24,6 @@
 create nodegroup group1  if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 drop dataset Customers;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql b/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
index f70de14..576a9da 100644
--- a/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
+++ b/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
@@ -24,7 +24,7 @@
 create nodegroup group1  if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/dapd/denorm_user_event.aql b/asterix-app/src/test/resources/dapd/denorm_user_event.aql
index a3b9fab..fe79872 100644
--- a/asterix-app/src/test/resources/dapd/denorm_user_event.aql
+++ b/asterix-app/src/test/resources/dapd/denorm_user_event.aql
@@ -27,8 +27,8 @@
 
 declare nodegroup group1 on nc1, nc2;
 
-declare dataset Users(UserType) partitioned by key u_name on group1;
-declare dataset Events(EventType) partitioned by key e_name on group1;
+declare dataset Users(UserType) primary key u_name on group1;
+declare dataset Events(EventType) primary key e_name on group1;
 
 write output to nc1:"/tmp/denorm_user_event.adm";
 
diff --git a/asterix-app/src/test/resources/dapd/q1.aql b/asterix-app/src/test/resources/dapd/q1.aql
index ae6b28f..934387b 100644
--- a/asterix-app/src/test/resources/dapd/q1.aql
+++ b/asterix-app/src/test/resources/dapd/q1.aql
@@ -23,7 +23,7 @@
 
 declare nodegroup group1 on nc1, nc2;
 
-declare dataset User(UserType) partitioned by key name on group1;
+declare dataset User(UserType) primary key name on group1;
 
 write output to nc1:"/tmp/q1.adm";
 
diff --git a/asterix-app/src/test/resources/dapd/q2.aql b/asterix-app/src/test/resources/dapd/q2.aql
index 3998b9e..fdb0469 100644
--- a/asterix-app/src/test/resources/dapd/q2.aql
+++ b/asterix-app/src/test/resources/dapd/q2.aql
@@ -37,7 +37,7 @@
 
 drop dataset Event;
 declare dataset Event(EventType) 
-  partitioned by key event_id on group1;
+  primary key event_id on group1;
 
 load dataset Event 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo0216/01-load-dblp-large.aql b/asterix-app/src/test/resources/demo0216/01-load-dblp-large.aql
index 0cb6b21..171c935 100644
--- a/asterix-app/src/test/resources/demo0216/01-load-dblp-large.aql
+++ b/asterix-app/src/test/resources/demo0216/01-load-dblp-large.aql
@@ -12,7 +12,7 @@
 rainbow-04, rainbow-05;
 
 declare dataset DBLP(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo0216/03-load-dblp-small.aql b/asterix-app/src/test/resources/demo0216/03-load-dblp-small.aql
index f4d8ae0..751179f 100644
--- a/asterix-app/src/test/resources/demo0216/03-load-dblp-small.aql
+++ b/asterix-app/src/test/resources/demo0216/03-load-dblp-small.aql
@@ -12,7 +12,7 @@
 rainbow-04, rainbow-05;
 
 declare dataset DBLPSmall(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 load dataset DBLPSmall 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo0216/110-self-join-dblp.aql b/asterix-app/src/test/resources/demo0216/110-self-join-dblp.aql
index 9077f33..dc40196 100644
--- a/asterix-app/src/test/resources/demo0216/110-self-join-dblp.aql
+++ b/asterix-app/src/test/resources/demo0216/110-self-join-dblp.aql
@@ -12,7 +12,7 @@
 rainbow-04, rainbow-05;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to rainbow-01:"/home/hyracks/dblp-self-join.adm";
 
diff --git a/asterix-app/src/test/resources/demo0216/120-self-join-dblp-small.aql b/asterix-app/src/test/resources/demo0216/120-self-join-dblp-small.aql
index 66ca6cb..5802236 100644
--- a/asterix-app/src/test/resources/demo0216/120-self-join-dblp-small.aql
+++ b/asterix-app/src/test/resources/demo0216/120-self-join-dblp-small.aql
@@ -12,7 +12,7 @@
 rainbow-04, rainbow-05;
 
 declare dataset DBLPSmall(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to rainbow-01:"/home/hyracks/small-dblp-self-join.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/local/create-index.aql b/asterix-app/src/test/resources/demo0927/local/create-index.aql
index 3ecd163..dd41fc8 100644
--- a/asterix-app/src/test/resources/demo0927/local/create-index.aql
+++ b/asterix-app/src/test/resources/demo0927/local/create-index.aql
@@ -20,6 +20,6 @@
 declare nodegroup group1 on nc1,nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 create index NameIndex on Customers(name);
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/demo0927/local/dataset-filter-int.aql b/asterix-app/src/test/resources/demo0927/local/dataset-filter-int.aql
index 3acb8f8..c50405b 100644
--- a/asterix-app/src/test/resources/demo0927/local/dataset-filter-int.aql
+++ b/asterix-app/src/test/resources/demo0927/local/dataset-filter-int.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/local/dataset-filter-str.aql b/asterix-app/src/test/resources/demo0927/local/dataset-filter-str.aql
index 35401cf..89242ea 100644
--- a/asterix-app/src/test/resources/demo0927/local/dataset-filter-str.aql
+++ b/asterix-app/src/test/resources/demo0927/local/dataset-filter-str.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/local/dataset-scan.aql b/asterix-app/src/test/resources/demo0927/local/dataset-scan.aql
index 2f8746c..230b6f2 100644
--- a/asterix-app/src/test/resources/demo0927/local/dataset-scan.aql
+++ b/asterix-app/src/test/resources/demo0927/local/dataset-scan.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/local/declare-index.aql b/asterix-app/src/test/resources/demo0927/local/declare-index.aql
index ecacc49..49c0a31 100644
--- a/asterix-app/src/test/resources/demo0927/local/declare-index.aql
+++ b/asterix-app/src/test/resources/demo0927/local/declare-index.aql
@@ -20,6 +20,6 @@
 declare nodegroup group1 on nc1,nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 declare index NameIndex on Customers(name);
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/demo0927/local/join-cust-ord.aql b/asterix-app/src/test/resources/demo0927/local/join-cust-ord.aql
index b262860..6630507 100644
--- a/asterix-app/src/test/resources/demo0927/local/join-cust-ord.aql
+++ b/asterix-app/src/test/resources/demo0927/local/join-cust-ord.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/local/load-cust.aql b/asterix-app/src/test/resources/demo0927/local/load-cust.aql
index b71731c..885b226 100644
--- a/asterix-app/src/test/resources/demo0927/local/load-cust.aql
+++ b/asterix-app/src/test/resources/demo0927/local/load-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo0927/local/load-ord.aql b/asterix-app/src/test/resources/demo0927/local/load-ord.aql
index 15ba4cf..6fba4b1 100644
--- a/asterix-app/src/test/resources/demo0927/local/load-ord.aql
+++ b/asterix-app/src/test/resources/demo0927/local/load-ord.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders from nc1:"/tmp/orderData.json";
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo0927/rainbow/01-load-cust.aql b/asterix-app/src/test/resources/demo0927/rainbow/01-load-cust.aql
index 74502a0..ed750e5 100644
--- a/asterix-app/src/test/resources/demo0927/rainbow/01-load-cust.aql
+++ b/asterix-app/src/test/resources/demo0927/rainbow/01-load-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers from rainbow-01:"/home/hyracks/demo-data/customerData.json";
 //  delete dataset Customers;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/demo0927/rainbow/02-filter-cust.aql b/asterix-app/src/test/resources/demo0927/rainbow/02-filter-cust.aql
index 2ed1304..d8070ef 100644
--- a/asterix-app/src/test/resources/demo0927/rainbow/02-filter-cust.aql
+++ b/asterix-app/src/test/resources/demo0927/rainbow/02-filter-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to rainbow-01:"/home/hyracks/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo0927/rainbow/03-load-ord.aql b/asterix-app/src/test/resources/demo0927/rainbow/03-load-ord.aql
index a9bfe61..0fb5398 100644
--- a/asterix-app/src/test/resources/demo0927/rainbow/03-load-ord.aql
+++ b/asterix-app/src/test/resources/demo0927/rainbow/03-load-ord.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders from rainbow-01:"/home/hyracks/demo-data/orderData.json";
 // delete dataset Orders;
diff --git a/asterix-app/src/test/resources/demo0927/rainbow/04-join-custord.aql b/asterix-app/src/test/resources/demo0927/rainbow/04-join-custord.aql
index 57cc397..d89a799 100644
--- a/asterix-app/src/test/resources/demo0927/rainbow/04-join-custord.aql
+++ b/asterix-app/src/test/resources/demo0927/rainbow/04-join-custord.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to rainbow-01:"/home/hyracks/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/demo1112/local/01-load-cust.aql b/asterix-app/src/test/resources/demo1112/local/01-load-cust.aql
index 8d764c3..dd7d2a9 100644
--- a/asterix-app/src/test/resources/demo1112/local/01-load-cust.aql
+++ b/asterix-app/src/test/resources/demo1112/local/01-load-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo1112/local/02-filter-cust.aql b/asterix-app/src/test/resources/demo1112/local/02-filter-cust.aql
index 24c5827..eb3f9a8 100644
--- a/asterix-app/src/test/resources/demo1112/local/02-filter-cust.aql
+++ b/asterix-app/src/test/resources/demo1112/local/02-filter-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo1112/local/03-load-ord.aql b/asterix-app/src/test/resources/demo1112/local/03-load-ord.aql
index 7db4f4e..83657df 100644
--- a/asterix-app/src/test/resources/demo1112/local/03-load-ord.aql
+++ b/asterix-app/src/test/resources/demo1112/local/03-load-ord.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo1112/local/04-join-custord.aql b/asterix-app/src/test/resources/demo1112/local/04-join-custord.aql
index 1238e7e..fa82c9a 100644
--- a/asterix-app/src/test/resources/demo1112/local/04-join-custord.aql
+++ b/asterix-app/src/test/resources/demo1112/local/04-join-custord.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/demo1112/rainbow/01-load-cust.aql b/asterix-app/src/test/resources/demo1112/rainbow/01-load-cust.aql
index ccb959d..f8c34fb 100644
--- a/asterix-app/src/test/resources/demo1112/rainbow/01-load-cust.aql
+++ b/asterix-app/src/test/resources/demo1112/rainbow/01-load-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers from rainbow-01:"/home/onose/demo-data/customerData.adm";
 // drop dataset Customers;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/demo1112/rainbow/02-filter-cust.aql b/asterix-app/src/test/resources/demo1112/rainbow/02-filter-cust.aql
index 2c08f34..2993b92 100644
--- a/asterix-app/src/test/resources/demo1112/rainbow/02-filter-cust.aql
+++ b/asterix-app/src/test/resources/demo1112/rainbow/02-filter-cust.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/mycustomers.adm";
 
diff --git a/asterix-app/src/test/resources/demo1112/rainbow/03-load-ord.aql b/asterix-app/src/test/resources/demo1112/rainbow/03-load-ord.aql
index 1329aa4..3134818 100644
--- a/asterix-app/src/test/resources/demo1112/rainbow/03-load-ord.aql
+++ b/asterix-app/src/test/resources/demo1112/rainbow/03-load-ord.aql
@@ -12,6 +12,6 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders from rainbow-01:"/home/onose/demo-data/orderData.adm";
diff --git a/asterix-app/src/test/resources/demo1112/rainbow/04-join-custord.aql b/asterix-app/src/test/resources/demo1112/rainbow/04-join-custord.aql
index 63c4670..18426d4 100644
--- a/asterix-app/src/test/resources/demo1112/rainbow/04-join-custord.aql
+++ b/asterix-app/src/test/resources/demo1112/rainbow/04-join-custord.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/demo1112/rainbow/05-count-custord.aql b/asterix-app/src/test/resources/demo1112/rainbow/05-count-custord.aql
index dcbea09..f55ccbd 100644
--- a/asterix-app/src/test/resources/demo1112/rainbow/05-count-custord.aql
+++ b/asterix-app/src/test/resources/demo1112/rainbow/05-count-custord.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/01-load-cust.aql b/asterix-app/src/test/resources/demo_aql/local/01-load-cust.aql
index cd7a682..0cbbf5b 100644
--- a/asterix-app/src/test/resources/demo_aql/local/01-load-cust.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/01-load-cust.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo_aql/local/02-filter-cust.aql b/asterix-app/src/test/resources/demo_aql/local/02-filter-cust.aql
index 38171ed..f631afc 100644
--- a/asterix-app/src/test/resources/demo_aql/local/02-filter-cust.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/02-filter-cust.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/02-filter-cust.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/03-count-cust-age.aql b/asterix-app/src/test/resources/demo_aql/local/03-count-cust-age.aql
index 37698a7..1bba3f6 100644
--- a/asterix-app/src/test/resources/demo_aql/local/03-count-cust-age.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/03-count-cust-age.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/03-count-cust-age.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/04-load-ord.aql b/asterix-app/src/test/resources/demo_aql/local/04-load-ord.aql
index b8898f5..00f4f10 100644
--- a/asterix-app/src/test/resources/demo_aql/local/04-load-ord.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/04-load-ord.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo_aql/local/05-count-param1.aql b/asterix-app/src/test/resources/demo_aql/local/05-count-param1.aql
index 02263c4..f7cc468 100644
--- a/asterix-app/src/test/resources/demo_aql/local/05-count-param1.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/05-count-param1.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/05-count-param1.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/06-count-custord.aql b/asterix-app/src/test/resources/demo_aql/local/06-count-custord.aql
index 86e6ea0..3ff3a43 100644
--- a/asterix-app/src/test/resources/demo_aql/local/06-count-custord.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/06-count-custord.aql
@@ -28,9 +28,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/06-count-custord.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/101-load-dblp.aql b/asterix-app/src/test/resources/demo_aql/local/101-load-dblp.aql
index 7d6dc62..03cf233 100644
--- a/asterix-app/src/test/resources/demo_aql/local/101-load-dblp.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/101-load-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/demo_aql/local/102-fuzzy-select.aql b/asterix-app/src/test/resources/demo_aql/local/102-fuzzy-select.aql
index e37b49a..2cea3c5 100644
--- a/asterix-app/src/test/resources/demo_aql/local/102-fuzzy-select.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/102-fuzzy-select.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 write output to nc1:"/tmp/102-fuzzy-select.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/local/110-self-join-dblp.aql b/asterix-app/src/test/resources/demo_aql/local/110-self-join-dblp.aql
index f51e455..64a65a5 100644
--- a/asterix-app/src/test/resources/demo_aql/local/110-self-join-dblp.aql
+++ b/asterix-app/src/test/resources/demo_aql/local/110-self-join-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:"/tmp/110-self-join-dblp.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/01-load-cust.aql b/asterix-app/src/test/resources/demo_aql/rainbow/01-load-cust.aql
index e75bce2..143f55f 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/01-load-cust.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/01-load-cust.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers from rainbow-01:"/home/onose/demo-data/semistructured/customer.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/02-filter-cust.aql b/asterix-app/src/test/resources/demo_aql/rainbow/02-filter-cust.aql
index 8af2368..a99e088 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/02-filter-cust.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/02-filter-cust.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/02-filter-cust.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/03-count-cust-age.aql b/asterix-app/src/test/resources/demo_aql/rainbow/03-count-cust-age.aql
index eda4015..714c60a 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/03-count-cust-age.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/03-count-cust-age.aql
@@ -18,7 +18,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/03-count-cust-age.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/04-load-ord.aql b/asterix-app/src/test/resources/demo_aql/rainbow/04-load-ord.aql
index bae97e8..be7a874 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/04-load-ord.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/04-load-ord.aql
@@ -12,6 +12,6 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders from rainbow-01:"/home/onose/demo-data/semistructured/orders.adm";
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/05-count-param1.aql b/asterix-app/src/test/resources/demo_aql/rainbow/05-count-param1.aql
index f5ec449..0ea243a 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/05-count-param1.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/05-count-param1.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/05-count-param1.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/06-count-custord.aql b/asterix-app/src/test/resources/demo_aql/rainbow/06-count-custord.aql
index ba5d5f4..2502d48a 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/06-count-custord.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/06-count-custord.aql
@@ -29,9 +29,9 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/06-count-custord.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/101-load-dblp.aql b/asterix-app/src/test/resources/demo_aql/rainbow/101-load-dblp.aql
index 20f0b51..9ed4a85 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/101-load-dblp.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/101-load-dblp.aql
@@ -12,7 +12,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset DBLP(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 load dataset DBLP from
   rainbow-01:"/home/onose/demo-data/dblp-id.txt" delimited by ":";
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/102-fuzzy-select.aql b/asterix-app/src/test/resources/demo_aql/rainbow/102-fuzzy-select.aql
index c9f072a..af129cb 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/102-fuzzy-select.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/102-fuzzy-select.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset DBLP(DBLPType)
- partitioned by key id on group1;
+ primary key id on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/102-fuzzy-select.adm";
 
diff --git a/asterix-app/src/test/resources/demo_aql/rainbow/110-self-join-dblp.aql b/asterix-app/src/test/resources/demo_aql/rainbow/110-self-join-dblp.aql
index c5b900b..37f06a0 100644
--- a/asterix-app/src/test/resources/demo_aql/rainbow/110-self-join-dblp.aql
+++ b/asterix-app/src/test/resources/demo_aql/rainbow/110-self-join-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on rainbow-01, rainbow-02, rainbow-03, rainbow-04, rainbow-05;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to rainbow-01:"/home/onose/hyracks-rainbow/results/110-self-join-dblp.adm";
 
diff --git a/asterix-app/src/test/resources/dmlts/scripts/enlist-scan-cust.aql b/asterix-app/src/test/resources/dmlts/scripts/enlist-scan-cust.aql
index ed44308..5bc029d 100644
--- a/asterix-app/src/test/resources/dmlts/scripts/enlist-scan-cust.aql
+++ b/asterix-app/src/test/resources/dmlts/scripts/enlist-scan-cust.aql
@@ -24,7 +24,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 enlist dataset Customers;
 
diff --git a/asterix-app/src/test/resources/dmlts/scripts/load-cust.aql b/asterix-app/src/test/resources/dmlts/scripts/load-cust.aql
index d55dfed..77d023e 100644
--- a/asterix-app/src/test/resources/dmlts/scripts/load-cust.aql
+++ b/asterix-app/src/test/resources/dmlts/scripts/load-cust.aql
@@ -24,7 +24,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx-small.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx-small.aql
index f7dcf0e..5e819bd 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx-small.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx-small.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset CSXSmall(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset CSXSmall 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx.aql
index b5787a1..0b6da50 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-csx.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset CSX 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-dblp.aql
index 3ca85bb..c726018f 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/10-load-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1; 
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/20-drop-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/20-drop-dblp.aql
index 868d534..66af9ce 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/20-drop-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/20-drop-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset DBLP;
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/30-filter-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/30-filter-dblp.aql
index 45bd1c8..4a6b486 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/30-filter-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/30-filter-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:"/tmp/amerix.adm";
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/40-self-join-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/40-self-join-dblp.aql
index bc024c3..60eafd3 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/40-self-join-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/40-self-join-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1; 
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:"/tmp/amerix.adm";
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/amerix/50-self-join-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/amerix/50-self-join-dblp.aql
index eb44be7..536b549 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/amerix/50-self-join-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/amerix/50-self-join-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:"/tmp/amerix.adm";
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/000-1-char-at.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/000-1-char-at.aql
index 43a595d..182a17d 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/000-1-char-at.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/000-1-char-at.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:"/tmp/dblp.adm";
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/010-load.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/010-load.aql
index a857935..ab93f83 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/010-load.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/010-load.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/020-drop.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/020-drop.aql
index 65213dd..c82183b 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/020-drop.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/020-drop.aql
@@ -11,6 +11,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset DBLP;
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/030-filter.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/030-filter.aql
index b539aba..2588e99 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/030-filter.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/030-filter.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/dblp.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/040-self-join-aql.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/040-self-join-aql.aql
index 63e1a1e..4ac1a60 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/040-self-join-aql.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/040-self-join-aql.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/dblp.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/dblp/050-self-join-op.aql b/asterix-app/src/test/resources/fuzzyjoin/dblp/050-self-join-op.aql
index f2467f2..e97df35 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/dblp/050-self-join-op.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/dblp/050-self-join-op.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/dblp.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/010-load-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/010-load-dblp.aql
index 49d07ec..7ae0e30 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/010-load-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/010-load-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 // load dataset DBLP from nc1:'/asterix/asterix-app/data/pub-small/dblp-small-id.txt'
 load dataset DBLP 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/020-drop-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/020-drop-dblp.aql
index 65213dd..c82183b 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/020-drop-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/020-drop-dblp.aql
@@ -11,6 +11,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset DBLP;
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/030-filter-dblp.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/030-filter-dblp.aql
index d67d58a..7950d12 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/030-filter-dblp.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/030-filter-dblp.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/pub.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/040-load-csx.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/040-load-csx.aql
index 06dfb4e..a87398d 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/040-load-csx.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/040-load-csx.aql
@@ -11,7 +11,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 // load dataset CSX from nc1:'/asterix/asterix-app/data/pub-small/csx-small-id.txt'
 load dataset  CSX
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/050-drop-csx.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/050-drop-csx.aql
index c37c8b5..62e53ca 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/050-drop-csx.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/050-drop-csx.aql
@@ -11,6 +11,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset CSX;
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/060-filter-csx.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/060-filter-csx.aql
index 56b6dc9..daf53d3 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/060-filter-csx.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/060-filter-csx.aql
@@ -13,7 +13,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/pub.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/070-join-aql.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/070-join-aql.aql
index ec88679..a72fa03 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/070-join-aql.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/070-join-aql.aql
@@ -19,10 +19,10 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/pub.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/pub/080-join-op.aql b/asterix-app/src/test/resources/fuzzyjoin/pub/080-join-op.aql
index 032031f..0466033 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/pub/080-join-op.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/pub/080-join-op.aql
@@ -19,10 +19,10 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 declare dataset CSX(CSXType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'/tmp/pub.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/010-load-users.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/010-load-users.aql
index be75fa6..affd0f3 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/010-load-users.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/010-load-users.aql
@@ -10,7 +10,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/020-drop-users.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/020-drop-users.aql
index 86525a7..71df5ae 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/020-drop-users.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/020-drop-users.aql
@@ -10,6 +10,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 drop dataset Users;
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/030-filter-users.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/030-filter-users.aql
index 298c0b1..4e6846f 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/030-filter-users.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/030-filter-users.aql
@@ -10,7 +10,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 write output to nc1:'/tmp/users.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/040-load-visitors.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/040-load-visitors.aql
index a75989a..0e07e69 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/040-load-visitors.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/040-load-visitors.aql
@@ -10,7 +10,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 load dataset Visitors 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/050-drop-visitors.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/050-drop-visitors.aql
index 15047b8..3a8e725 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/050-drop-visitors.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/050-drop-visitors.aql
@@ -10,6 +10,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 drop dataset Visitors;
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/060-fililter-visitors.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/060-fililter-visitors.aql
index dae180e..1fb0a4c 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/060-fililter-visitors.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/060-fililter-visitors.aql
@@ -10,7 +10,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 write output to nc1:'/tmp/visitors.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/070-join-aql-lottery_numbers.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/070-join-aql-lottery_numbers.aql
index aaa145f..c5a625a 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/070-join-aql-lottery_numbers.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/070-join-aql-lottery_numbers.aql
@@ -17,9 +17,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 write output to nc1:'/tmp/users-visitors.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/080-join-op-lottery_numbers.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/080-join-op-lottery_numbers.aql
index ca5bebb..4275067 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/080-join-op-lottery_numbers.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/080-join-op-lottery_numbers.aql
@@ -17,9 +17,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 write output to nc1:'/tmp/users-visitors.adm';
 
diff --git a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/090-join-op-interests.aql b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/090-join-op-interests.aql
index a7cf0a4..856e02f 100644
--- a/asterix-app/src/test/resources/fuzzyjoin/users-visitors/090-join-op-interests.aql
+++ b/asterix-app/src/test/resources/fuzzyjoin/users-visitors/090-join-op-interests.aql
@@ -17,9 +17,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 declare dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 write output to nc1:'/tmp/users-visitors.adm';
 
diff --git a/asterix-app/src/test/resources/integration/queries/dataset-scan.aql b/asterix-app/src/test/resources/integration/queries/dataset-scan.aql
index 1930be2..f7558c5 100644
--- a/asterix-app/src/test/resources/integration/queries/dataset-scan.aql
+++ b/asterix-app/src/test/resources/integration/queries/dataset-scan.aql
@@ -20,7 +20,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 for $c in dataset('Customers')
 return $c
diff --git a/asterix-app/src/test/resources/integration/updates/load-dataset.aql b/asterix-app/src/test/resources/integration/updates/load-dataset.aql
index c6faa6e..4041450 100644
--- a/asterix-app/src/test/resources/integration/updates/load-dataset.aql
+++ b/asterix-app/src/test/resources/integration/updates/load-dataset.aql
@@ -15,7 +15,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/metadata-transactions/init-state-queries/customers_orders.aql b/asterix-app/src/test/resources/metadata-transactions/init-state-queries/customers_orders.aql
index af15a23..87aa2fc 100644
--- a/asterix-app/src/test/resources/metadata-transactions/init-state-queries/customers_orders.aql
+++ b/asterix-app/src/test/resources/metadata-transactions/init-state-queries/customers_orders.aql
@@ -44,10 +44,10 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType)
-  partitioned by key cid, name on group1;
+  primary key cid, name on group1;
 
 create dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 create index ordCustId on Orders(cid);
 
diff --git a/asterix-app/src/test/resources/metadata-transactions/queries/create_duplicate_dataset.aql b/asterix-app/src/test/resources/metadata-transactions/queries/create_duplicate_dataset.aql
index 047eddf..b5c3c28 100644
--- a/asterix-app/src/test/resources/metadata-transactions/queries/create_duplicate_dataset.aql
+++ b/asterix-app/src/test/resources/metadata-transactions/queries/create_duplicate_dataset.aql
@@ -1,4 +1,4 @@
 use dataverse custord;
 
 create dataset Customers(CustomerType)
-  partitioned by key cid, name on group1;
+  primary key cid, name on group1;
diff --git a/asterix-app/src/test/resources/metadata-transactions/queries/rollback_new_dataset.aql b/asterix-app/src/test/resources/metadata-transactions/queries/rollback_new_dataset.aql
index aa76ae2..a9ad490 100644
--- a/asterix-app/src/test/resources/metadata-transactions/queries/rollback_new_dataset.aql
+++ b/asterix-app/src/test/resources/metadata-transactions/queries/rollback_new_dataset.aql
@@ -2,7 +2,7 @@
 
 // Creating this dataset should succeed.
 create dataset NewDataset(CustomerType)
-  partitioned by key cid, name on group1;
+  primary key cid, name on group1;
 
 
 // Creating this duplicate type should fail, and rollback should remove the new dataverse.
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_1.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_1.aql
index f7bad20..de0e870 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_1.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_1.aql
@@ -17,7 +17,7 @@
 write output to nc1:"mdtest/basic_issue_251_dataset_hint_1.adm";
 
 create dataset Book(LineType)
-partitioned by key id
+primary key id
 hints(  cardinality  =   2000);
 
 for $x in dataset('Metadata.Dataset')
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_2.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_2.aql
index 9377ea5..27d2c2c 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_2.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_2.aql
@@ -17,7 +17,7 @@
 write output to nc1:"mdtest/basic_issue_251_dataset_hint_2.adm";
 
 create dataset Book(LineType)
-partitioned by key id
+primary key id
 hints(cardinality=2000);
 
 for $x in dataset('Metadata.Dataset')
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_3.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_3.aql
index 15f45a7..b6a730f 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_3.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_3.aql
@@ -17,7 +17,7 @@
 write output to nc1:"mdtest/basic_issue_251_dataset_hint_3.adm";
 
 create dataset Book(LineType)
-partitioned by key id
+primary key id
 hints(CARDINALITY=2000);
 
 for $x in dataset('Metadata.Dataset')
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_4.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_4.aql
index c5d30e5..af7077a 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_4.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_251_dataset_hint_4.aql
@@ -17,7 +17,7 @@
 write output to nc1:"mdtest/basic_issue_251_dataset_hint_4.adm";
 
 create dataset Book(LineType)
-partitioned by key id;
+primary key id;
 
 for $x in dataset('Metadata.Dataset')
 where $x.DataverseName='test'
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
index 8bfc240..7778e99 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
@@ -13,7 +13,7 @@
 id : int32
 }
 
-create dataset testdv.dst01(testtype) partitioned by key id;
+create dataset testdv.dst01(testtype) primary key id;
 
 for $l in dataset('Metadata.Dataset')
 where $l.DataverseName = 'testdv' and $l.DatasetName = 'dst01'
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
index 9eb129d..201ab6e 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
@@ -14,7 +14,7 @@
 name : string
 }
 
-create dataset testdv.t1(testtype) partitioned by key id;
+create dataset testdv.t1(testtype) primary key id;
 
 create index idx1 on testdv.t1(name);
 
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
index 28a3794..56c6c7a 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
@@ -13,7 +13,7 @@
 id:int32
 }
 
-create dataset test.t1(testtype) partitioned by key id;
+create dataset test.t1(testtype) primary key id;
 
 insert into dataset test.t1({"id":123});
 insert into dataset test.t1({"id":133});
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
index d781114..0e02802 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
@@ -13,7 +13,7 @@
 id : int32
 }
 
-create dataset test.dst01(testtype) partitioned by key id;
+create dataset test.dst01(testtype) primary key id;
 
 drop dataset test.dst01;
 
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
index 1de7ac5..82e2eb0 100644
--- a/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
@@ -14,7 +14,7 @@
 name : string
 }
 
-create dataset test.dst01(testtype) partitioned by key id;
+create dataset test.dst01(testtype) primary key id;
 
 create index idx1 on test.dst01(name);
 
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_1.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_1.aql
index 9f849e3..eb3f3dc 100644
--- a/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_1.aql
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_1.aql
@@ -15,5 +15,5 @@
 }
 
 create dataset Book(LineType)
-partitioned by key id
+primary key id
 hints(size=2000,tuple_size=100);
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_2.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_2.aql
index 459b7f6..830370e 100644
--- a/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_2.aql
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_251_dataset_hint_error_2.aql
@@ -16,7 +16,7 @@
 }
 
 create dataset Book(LineType)
-partitioned by key id
+primary key id
 hints(cardinality="-20jh0",size=45);
 
 for $x in dataset('Metadata.Dataset')
diff --git a/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql b/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql
index d4678f2..19b87a2 100644
--- a/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql
+++ b/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql
@@ -37,7 +37,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType)
-  partitioned by key cid, name on group1;
+  primary key cid, name on group1;
 
 create nodegroup group1 on nc1, nc2;
 
diff --git a/asterix-app/src/test/resources/misc/split01.aql b/asterix-app/src/test/resources/misc/split01.aql
index 46b2403..de9ec5c 100644
--- a/asterix-app/src/test/resources/misc/split01.aql
+++ b/asterix-app/src/test/resources/misc/split01.aql
@@ -30,9 +30,9 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/split01.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/all-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/all-drop.aql
index 13a0414..0672b32 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/all-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/all-drop.aql
@@ -36,6 +36,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset All(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset All;
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/all-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/all-load.aql
index 73fa096..745562d 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/all-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/all-load.aql
@@ -36,7 +36,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset All(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset All from nc1:"/home/yasser/Dropbox/Research/data/allData.json";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/all-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/all-scan.aql
index 7006eb4..1bd4b73 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/all-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/all-scan.aql
@@ -36,7 +36,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset All(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_all_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/cust-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/cust-drop.aql
index b6a1913..23aeea8 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/cust-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/cust-drop.aql
@@ -23,6 +23,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 drop dataset Customers;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/cust-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/cust-load.aql
index fb57584..4af623a 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/cust-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/cust-load.aql
@@ -17,7 +17,7 @@
 declare nodegroup group1 on nc1;
 
 declare dataset Dataverse(DataverseType)
-  partitioned by key dataverseName on group1;        
+  primary key dataverseName on group1;        
       
 for $c in dataset('Dataverse')
 return $c
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/cust-q1.aql b/asterix-app/src/test/resources/nontagged/custord/local/cust-q1.aql
index bc7ac1f..bc1c623 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/cust-q1.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/cust-q1.aql
@@ -23,7 +23,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_cust_q1.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/cust-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/cust-scan.aql
index a54197f..cf8aacf 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/cust-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/cust-scan.aql
@@ -23,7 +23,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_cust_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/emp-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/emp-drop.aql
index 22230c1..0499a72 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/emp-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/emp-drop.aql
@@ -24,6 +24,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Emp(EmpType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 drop dataset Emp;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/emp-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/emp-load.aql
index c0cbfc3..e676ef6 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/emp-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/emp-load.aql
@@ -20,6 +20,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Emp(EmpType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Emp from nc1:"/home/yasser/Dropbox/Research/data/EmpData.json";
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/emp-q1.aql b/asterix-app/src/test/resources/nontagged/custord/local/emp-q1.aql
index 20b83f7..ef8ce90 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/emp-q1.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/emp-q1.aql
@@ -19,7 +19,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Emp(EmpType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_emp_q1.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/emp-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/emp-scan.aql
index df903bf..e69b361 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/emp-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/emp-scan.aql
@@ -20,7 +20,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Emp(EmpType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_emp_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/join-01.aql b/asterix-app/src/test/resources/nontagged/custord/local/join-01.aql
index d5a32f5..587fa4d 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/join-01.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/join-01.aql
@@ -34,9 +34,9 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_join_1.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/join-02.aql b/asterix-app/src/test/resources/nontagged/custord/local/join-02.aql
index 9b5caf1..ffcc6a0 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/join-02.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/join-02.aql
@@ -34,9 +34,9 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_join_2.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/join-03.aql b/asterix-app/src/test/resources/nontagged/custord/local/join-03.aql
index bff863c..a953d76 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/join-03.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/join-03.aql
@@ -34,9 +34,9 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_join_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/numeric-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/numeric-drop.aql
index b82bf84..a576214 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/numeric-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/numeric-drop.aql
@@ -15,6 +15,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Numeric(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
   
 drop dataset Numeric;
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/numeric-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/numeric-load.aql
index 5a7f162..491b391 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/numeric-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/numeric-load.aql
@@ -16,7 +16,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Numeric(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset Numeric from nc1:"/home/yasser/Dropbox/Research/data/numericData.json";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/numeric-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/numeric-scan.aql
index ec60095..c5bdb34 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/numeric-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/numeric-scan.aql
@@ -15,7 +15,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Numeric(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_numeric_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/ord-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/ord-drop.aql
index fd68e70..d4fa668 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/ord-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/ord-drop.aql
@@ -15,6 +15,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 drop dataset Orders;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/ord-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/ord-load.aql
index fe1d61d..81d25bc 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/ord-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/ord-load.aql
@@ -15,6 +15,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 load dataset Orders from nc1:"/home/yasser/Dropbox/Research/data/orderData.json";
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/ord-q1.aql b/asterix-app/src/test/resources/nontagged/custord/local/ord-q1.aql
index 97aa315..d008979 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/ord-q1.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/ord-q1.aql
@@ -15,7 +15,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_ord_q1.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/ord-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/ord-scan.aql
index e7c5236..9fc0faf 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/ord-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/ord-scan.aql
@@ -15,7 +15,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_ord_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/spatial-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/spatial-drop.aql
index 5e7b515..304ec7c 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/spatial-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/spatial-drop.aql
@@ -14,6 +14,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Spatial(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset Spatial;
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/spatial-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/spatial-load.aql
index b36808a..a0e7bae 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/spatial-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/spatial-load.aql
@@ -14,7 +14,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Spatial(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset Spatial from nc1:"/home/yasser/Dropbox/Research/data/spatialData.json";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/spatial-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/spatial-scan.aql
index e4faa16..5027c29 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/spatial-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/spatial-scan.aql
@@ -16,7 +16,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Spatial(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_spatial_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/temp-drop.aql b/asterix-app/src/test/resources/nontagged/custord/local/temp-drop.aql
index 80a86ac..df7e293 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/temp-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/temp-drop.aql
@@ -13,6 +13,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Temp(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset Temp;
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/temp-load.aql b/asterix-app/src/test/resources/nontagged/custord/local/temp-load.aql
index 0400db1..d75168a 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/temp-load.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/temp-load.aql
@@ -14,7 +14,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Temp(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset Temp from nc1:"/home/yasser/Dropbox/Research/data/tempData.json";
 
diff --git a/asterix-app/src/test/resources/nontagged/custord/local/temp-scan.aql b/asterix-app/src/test/resources/nontagged/custord/local/temp-scan.aql
index 8dc3cfa..7a369e6 100644
--- a/asterix-app/src/test/resources/nontagged/custord/local/temp-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/custord/local/temp-scan.aql
@@ -14,7 +14,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset Temp(ExampleType)
-  partitioned by key id on group1;
+  primary key id on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_temp_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/alltables-loadAsOpen.aql b/asterix-app/src/test/resources/nontagged/tpch/local/alltables-loadAsOpen.aql
index 7847546..0c4a5b3 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/alltables-loadAsOpen.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/alltables-loadAsOpen.aql
@@ -39,21 +39,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 //load dataset LineItems from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/lineitem.json" pre-sorted;
 //load dataset Orders from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/orders.json" pre-sorted;
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/alltablesAsopen-scan.aql b/asterix-app/src/test/resources/nontagged/tpch/local/alltablesAsopen-scan.aql
index cd32ae0..c147235 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/alltablesAsopen-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/alltablesAsopen-scan.aql
@@ -79,21 +79,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 write output to nc1:"/home/yasser/Desktop/result_scan.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-drop.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-drop.aql
index e8c56c1..a30757c 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-drop.aql
@@ -90,21 +90,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 drop dataset LineItems;
 //drop dataset Orders;
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-load.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-load.aql
index 9e05370..0bd1a39 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-load.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-load.aql
@@ -90,21 +90,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 //load dataset LineItems from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/lineitem.json" pre-sorted;
 //load dataset Orders from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/orders.json" pre-sorted;
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q1.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q1.aql
index 441ac43..f08d390 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q1.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q1.aql
@@ -24,7 +24,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_closed_1.adm";
  
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q3.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q3.aql
index e002ad9..6933881 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q3.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q3.aql
@@ -47,11 +47,11 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_closed_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q5.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q5.aql
index ceca8cd..d605099 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q5.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q5.aql
@@ -70,17 +70,17 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_closed_5.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q9.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q9.aql
index 2586561..acf2ae3 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q9.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-q9.aql
@@ -74,17 +74,17 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_closed_9.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-scan.aql b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-scan.aql
index f4f50b1..4b97d2e 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-scan.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/closedtables-scan.aql
@@ -90,21 +90,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 write output to nc1:"/home/yasser/Desktop/result_scan.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-drop.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-drop.aql
index 06d352c..61b6d85 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-drop.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-drop.aql
@@ -39,21 +39,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 drop dataset LineItems;
 //drop dataset Orders;
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-load.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-load.aql
index 4241366..fdcf15c 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-load.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-load.aql
@@ -39,21 +39,21 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 //load dataset LineItems from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/lineitem.json" pre-sorted;
 //load dataset Orders from nc1:"/home/yasser/Dropbox/Research/data/tpch_data/alldata/jsonformat/orders.json" pre-sorted;
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q1.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q1.aql
index ec5e202..6288b4f 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q1.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q1.aql
@@ -10,7 +10,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_open_1.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q3.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q3.aql
index 921cea6..955eba7 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q3.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q3.aql
@@ -18,11 +18,11 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_open_3.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q5.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q5.aql
index 82c996f..ffbd71d 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q5.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q5.aql
@@ -30,17 +30,17 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_open_5.adm";
 
diff --git a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q9.aql b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q9.aql
index 75b176d..8064099 100644
--- a/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q9.aql
+++ b/asterix-app/src/test/resources/nontagged/tpch/local/opentables-q9.aql
@@ -39,17 +39,17 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
   
 write output to nc1:"/home/yasser/Dropbox/Research/data/results/result_tpch_closed_9.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-multipred.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-multipred.aql
index 9b83718..f235220 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-multipred.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-multipred.aql
@@ -37,8 +37,8 @@
   total: float
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
-create dataset Orders(OrderType) partitioned by key oid;
+create dataset Customers(CustomerType) primary key cid;
+create dataset Orders(OrderType) primary key oid;
 
 write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_01.aql
index 75c522b..8e8324f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_02.aql
index 4dd0d00..8a62332 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join-neg_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_01.aql
index a0877ba..6950747 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is a HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_02.aql
index 59db20b..b7832fd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is a HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_03.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_03.aql
index d60a8ac..9268c2c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_03.aql
@@ -35,8 +35,8 @@
   total: float
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
-create dataset Orders(OrderType) partitioned by key oid;
+create dataset Customers(CustomerType) primary key cid;
+create dataset Orders(OrderType) primary key oid;
 
 write output to nc1:"rttest/btree-index-join_primary-equi-join_04.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_04.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_04.aql
index 56211e8..3c07154 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_04.aql
@@ -35,8 +35,8 @@
   total: float
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
-create dataset Orders(OrderType) partitioned by key oid;
+create dataset Customers(CustomerType) primary key cid;
+create dataset Orders(OrderType) primary key oid;
 
 write output to nc1:"rttest/btree-index-join_primary-equi-join_05.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_05.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_05.aql
index 0e6efe8..7da6b0c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-equi-join_05.aql
@@ -26,7 +26,7 @@
   }
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 write output to nc1:"rttest/btree-index-join_primary-equi-join_06.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_01.aql
index 559ede2..8bc306c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_02.aql
index 4948b6f..06be0e9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-ge-join_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_01.aql
index f48cfa3..67d75a1 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_02.aql
index b2f67b3..a7be083 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-gt-join_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_01.aql
index ef4dc05..66f2ace 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_02.aql
index 4c62ebb..39c1d51 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-le-join_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_01.aql
index 79e24cb..ef6a616 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_01.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_02.aql
index 9709acd..4924514 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/primary-lt-join_02.aql
@@ -15,8 +15,8 @@
           lname : string
 }
 
-create dataset test1.DsOne(TestType) partitioned by key key1;
-create dataset test1.DsTwo(TestType) partitioned by key key1;
+create dataset test1.DsOne(TestType) primary key key1;
+create dataset test1.DsTwo(TestType) primary key key1;
 
 // Please note content enclosed in the comment in the predicate is the HINT to the optimizer
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multiindex.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multiindex.aql
index 44cdef8..c596984 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multiindex.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multiindex.aql
@@ -39,10 +39,10 @@
 } 
 
 create dataset FacebookUsers(FacebookUserType)
-partitioned by key id;
+primary key id;
 
 create dataset FacebookMessages(FacebookMessageType)
-partitioned by key message-id;
+primary key message-id;
 
 create index fbmIdxAutId if not exists on FacebookMessages(author-id-copy);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
index 03cbf24..bb803b0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
@@ -27,9 +27,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index title_index on DBLP(title);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_01.aql
index e07eee5..8a4f056 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_01.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index title_index on DBLP(title);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_02.aql
index 2546244..fa68cd2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_02.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index title_index on CSX(title);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_03.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_03.aql
index 251c88e..3eedafd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join_03.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index title_index on DBLP(title);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql
index d3d8d69..0d096a7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index (composite key) defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Roger"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql
index eeded38..fbcdd50 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Susan"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql
index 1046edd..2047b62 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname < "Isa"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql
index 2bee1fe..84147ae 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname <= "Vanpatten"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql
index 0423290..0fbf179 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname != "Max"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql
index 313a4fa..08164fd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname = "Julio"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql
index e9063eb..2b635a5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql
@@ -20,7 +20,7 @@
 }
 
 // create internal dataset with primary index defined on fname,lname fields
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.lname = "Kim"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql
index 9919457..337072e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql
@@ -15,7 +15,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname = "Young Seok" and $emp.lname = "Kim"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql
index 8973d2d..cc52d2a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql
@@ -19,7 +19,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname = "Julio" or $emp.lname = "Malaika"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql
index 5076e97..4d0f85e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Alex" and $emp.lname < "Zach"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
index feeaaad..164e49a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Allan" and $emp.lname < "Zubi"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
index 740cca6..659d1ff 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
@@ -19,7 +19,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Allan" and $emp.lname = "Xu"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
index 47e81b2..3c49200 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
@@ -19,7 +19,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname = "Julio" and $emp.lname < "Xu"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
index 0ec31aa..e93061f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Michael" and $emp.lname <= "Xu"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql
index f595804..97a486a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql
index 022bd50..cf80ed2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
index ad114cd..db9c994 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname <= "Craig" and $emp.lname > "Kevin"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql
index 43b0bd3..9787005 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname != "Michael" and $emp.lname != "Carey"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql
index fe2dc41..0dff6af 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql
index c817492..ac9e374 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname,lname;
+create dataset testdst(TestType) primary key fname,lname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-21.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-21.aql
index 46c107c..afa241f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-21.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-21.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Max" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-22.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-22.aql
index 0f74980..4af86a0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-22.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-22.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Sofia" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-23.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-23.aql
index c942165..f73bd1f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-23.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-23.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname < "Chen" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-24.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-24.aql
index 0c66008..1faa37e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-24.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-24.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname <= "Julio" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-25.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-25.aql
index 770baf5..6b24b7c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-25.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-25.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname > "Neil" and $emp.fname < "Roger" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-26.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-26.aql
index ba5de37..05a69d2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-26.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-26.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key fname;
+create dataset testdst(TestType) primary key fname;
 
 for $emp in dataset('testdst') 
 where $emp.fname >= "Max" and $emp.fname <= "Roger" 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
index 5117da4..c2e6257 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql
index 37b46b3..d009e2e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
index 8f1b4d5..2b364e4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
index 5042bd9..f20b5a9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
index 2e38330..dfc5017 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
index 84bdcd4..7d72623 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
index 73133c2..7c155ce 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
index 3f844ee..dc63f05 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
index 3813e48..a9d32c3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
index 4e13597..25c6dec 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
index c724cbe..bc65009 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
index 06c93b0..289d1b4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
index 490becb..86e5d67 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
@@ -20,7 +20,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
index f75f3de..54e149e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
index 6717780..cc33e5a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
index 8a508b3..f486e44 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
index 70e8185..5d06a51 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
index bb6f24d..2dc1ab4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
index 6d11235..6175ba6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
@@ -19,7 +19,7 @@
 }
 
 // create internal dataset
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
index 3a91c09..04aefc3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
index 3be3875..5ae63a9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
@@ -18,7 +18,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
index 7b52ec9..e720742 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
@@ -17,7 +17,7 @@
     lname : string
 }
  
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
index 45536b5..65a9b6d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
index f1a3cb5..a18975a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
index bbeca00..94c1463 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
index 7ecfea9..53f8ca4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
index 2183f69..43cf54d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
@@ -17,7 +17,7 @@
     lname : string
 }
 
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
index bdf16b6..aa18136 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
@@ -17,7 +17,7 @@
     lname : string
 }
  
-create dataset testdst(TestType) partitioned by key id;
+create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/cell-aggregation-with-filtering.aql b/asterix-app/src/test/resources/optimizerts/queries/cell-aggregation-with-filtering.aql
index a328a1b..c883645 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/cell-aggregation-with-filtering.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/cell-aggregation-with-filtering.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if exists on nc1, nc2;
 
 create dataset TwitterData(Tweet)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 
 load dataset TwitterData 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-complex.aql b/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-complex.aql
index 313e9a4..7dfe817 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-complex.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-complex.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-simple.aql b/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-simple.aql
index 8a237d2..d21fa6e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-simple.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/consolidate-selects-simple.aql
@@ -16,7 +16,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"rttest/consolidate-selects-simple.aql";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/cust_group_no_agg.aql b/asterix-app/src/test/resources/optimizerts/queries/cust_group_no_agg.aql
index 6fdae88..6a86b8a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/cust_group_no_agg.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/cust_group_no_agg.aql
@@ -18,7 +18,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/denorm-cust-order.aql b/asterix-app/src/test/resources/optimizerts/queries/denorm-cust-order.aql
index acad4a1..389dad5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/denorm-cust-order.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/denorm-cust-order.aql
@@ -36,9 +36,9 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 create dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/custorder.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/distinct_aggregate.aql b/asterix-app/src/test/resources/optimizerts/queries/distinct_aggregate.aql
index a4784c1..6fc1dac 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/distinct_aggregate.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/distinct_aggregate.aql
@@ -24,7 +24,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems_q1(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 write output to nc1:"rttest/tpch_q1_pricing_summary_report_nt.adm";
  
diff --git a/asterix-app/src/test/resources/optimizerts/queries/fj-dblp-csx.aql b/asterix-app/src/test/resources/optimizerts/queries/fj-dblp-csx.aql
index 2898058..f748eae 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/fj-dblp-csx.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/fj-dblp-csx.aql
@@ -22,8 +22,8 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 
-create dataset DBLP(DBLPType) partitioned by key id on group1;
-create dataset CSX(CSXType) partitioned by key id on group1;
+create dataset DBLP(DBLPType) primary key id on group1;
+create dataset CSX(CSXType) primary key id on group1;
 
 write output to nc1:'rttest/fj-dblp-csx.adm';
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/fj-phase1.aql b/asterix-app/src/test/resources/optimizerts/queries/fj-phase1.aql
index 778232a..19ceda0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/fj-phase1.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/fj-phase1.aql
@@ -19,10 +19,10 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 create dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 
 // set simfunction "jaccard";
diff --git a/asterix-app/src/test/resources/optimizerts/queries/fj-phase2-with-hints.aql b/asterix-app/src/test/resources/optimizerts/queries/fj-phase2-with-hints.aql
index 866c027..a0973f4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/fj-phase2-with-hints.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/fj-phase2-with-hints.aql
@@ -15,7 +15,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP_fuzzyjoin_078(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 write output to nc1:'rttest/fuzzyjoin_078.adm';
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inlined_q18_large_volume_customer.aql b/asterix-app/src/test/resources/optimizerts/queries/inlined_q18_large_volume_customer.aql
index 49c4157..0db7a51 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inlined_q18_large_volume_customer.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inlined_q18_large_volume_customer.aql
@@ -49,11 +49,11 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/inlined_q18_large_volume_customer.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/introhashpartitionmerge.aql b/asterix-app/src/test/resources/optimizerts/queries/introhashpartitionmerge.aql
index 9427ab5..cd1d78c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/introhashpartitionmerge.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/introhashpartitionmerge.aql
@@ -9,7 +9,7 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 
-create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by key rank on group1;
+create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank on group1;
 
 write output to nc1:'rttest/introhashpartitionmerge.adm';
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains-panic.aql
index 31c0d03..d193238 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains-panic.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains.aql
index 9851cd8..137b1c7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-contains.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check-panic.aql
index 4608aeb..6f7f38c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check-panic.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check.aql
index 7b264b7..0d9db19 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-check.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-panic.aql
index 9412cf3..7decdb5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance-panic.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance.aql
index d6be7d4..c7a9ba4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-edit-distance.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
index b241311..3a3d7bb 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
index 33f9d5a..5e9ac0e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
index 376415f..dbb9c71 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
index ef7143a..f25fb8b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check-panic.aql
index 8209572..c105eab 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check-panic.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check.aql
index b55a516..b12037d1 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-check.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-panic.aql
index 63bead1..84bcbb9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance-panic.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance.aql
index 7958fb4..afafa37 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-edit-distance.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
index f156bd2..86b6474 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-jaccard.aql
index 6632189..64812db 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-fuzzyeq-jaccard.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard-check.aql
index 61dcc7f..4f8b8fe 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard-check.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard.aql
index 7af2161..62d6806 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/olist-jaccard.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
index d65a517..4ac02c8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard-check.aql
index 9551294..80e8aef 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard-check.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard.aql
index 6580bd0..588ca14 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ulist-jaccard.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-contains.aql
index eee681a..8d9cb02 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-contains.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-contains.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-fuzzyeq-jaccard.aql
index fb6d0e8..006398e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-fuzzyeq-jaccard.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard-check.aql
index 10ca5ce..4c814e4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard-check.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard.aql
index 7f544b6..53a5bbb 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/word-jaccard.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
index 4d6bfd9..1c96adc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
index a4d4163..e80443e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
index d6f58fc..d0d3035 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let.aql
index 24d3202..2d2f34f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-edit-distance-check-let.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
index de57848..fb59040 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
index 2eed598..b86c6b2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let-panic.aql
index 337eced..aa9bc59 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let-panic.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let-panic.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let.aql
index c3be0bd..8a78450 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-edit-distance-check-let.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-jaccard-check-let.aql
index 0652131..48ec727 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-jaccard-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/olist-jaccard-check-let.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ulist-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ulist-jaccard-check-let.aql
index 5a3b329..0757d41 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ulist-jaccard-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ulist-jaccard-check-let.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-let.aql
index 2c45ea8..ec97668 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-let.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-multi-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-multi-let.aql
index 8f8f014..bf1821e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-multi-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/word-jaccard-check-multi-let.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
index 78a285a..ee768d7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
index b05c0d1..ca2827d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.aql
index 87ebe4a..0e15708 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
index 77aa691..1a97936 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
index 9f6e66c..bf6bb82 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
index 1979201..dae2a78 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
index 25cdc53..21114fc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
@@ -25,7 +25,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
index e5dec4f..b90b4f7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.aql
index ae24f13..c78f65c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.aql
index f7df554..3bbcc28 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
index 61816b8..7dca72a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
@@ -25,7 +25,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
index d16776a..79d8baf 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.aql
index 0d4872b..0efb32d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
index c89fdc3..2bca24d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
@@ -25,7 +25,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
index 72d0341..8805542 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.aql
index 99a3c79..2d2e0cc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
index 24c66ac..0d5bf9c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard.aql
index ef91b89..5ffa92e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/word-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_01.aql
index f9cc7e9..d24ee17 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_02.aql
index 011afea..ec553a0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_03.aql
index 649c3b6..4de1680 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_04.aql
index e6a3c56..091676f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance-check_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_01.aql
index a94e84f..8a0282c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_02.aql
index 61edf5c..5d026db 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_03.aql
index 6c61de1..11b39c5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_04.aql
index 5925f47..b8952e9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-edit-distance_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_01.aql
index f6dd893..4704213 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_02.aql
index d9822aa..8454be9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_03.aql
index 0431a6c..4187d8f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-edit-distance_03.aql
@@ -15,7 +15,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(authors) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
index 933e5d0..84fb8f3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
index 1213935..d0c3c6f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
index 70c7640..a725edc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
index 4d7939a..c25e2e3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
index e0acebb..0e9f4d5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
index 808965d..bbd0f51 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
index e66cdc5..956f712 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
index a28a6af..742cb69 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
index a4ff58d..a620399 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index ngram_index on CSX(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
index 1a90cf9..d12bf98 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
index 7be6773..6b308c8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index ngram_index on DBLP(title) type ngram(3);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_01.aql
index 84d2f45..1afe025 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_02.aql
index b0ec650..aec4c85 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_03.aql
index 03a1a3f..47cea17 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_04.aql
index e7814af..9abc4e8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance-check_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_01.aql
index ac25ac2..b8f6144 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_02.aql
index a160c4d..7b17749 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_03.aql
index dba92b9..7132950 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_04.aql
index 4835727..84c7d5b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-edit-distance_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_01.aql
index 1dddf5e..c84bd28 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_02.aql
index 15b1001..c6b9d9c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_03.aql
index af4814f..962f05c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-edit-distance_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_01.aql
index 2b46707..4b3793a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_02.aql
index 4f188dd..60cdb07 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_03.aql
index 05cf635..2df41b5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-fuzzyeq-jaccard_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_01.aql
index 60fc705..8968ec6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_02.aql
index 9cdb78b..96b8622 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_03.aql
index b1c4d68..e8763b4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_04.aql
index a1e1478..3194e47 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard-check_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_01.aql
index cabdac1..1c4c7c2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_02.aql
index 49a7411..212b64b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_03.aql
index 639d782..22b4108 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_04.aql
index c3e34b0..32e8a6c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/olist-jaccard_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_01.aql
index c19ce47..cd391a4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_02.aql
index 6e3a274..a7d7118 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_03.aql
index 396af09..a5ec440 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-fuzzyeq-jaccard_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_01.aql
index 8792dd2..dead8cc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_02.aql
index 185df97..b18abf8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_03.aql
index 4d2b2e7..5afd428 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_04.aql
index acf4d71..3c8bdd7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard-check_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_01.aql
index 0d5ad31..2001a2a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_01.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_02.aql
index 8ac631e..95ce2ad 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_02.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 create index interests_index on Customers2(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_03.aql
index 94aedbb..e4fc27f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_03.aql
@@ -23,7 +23,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_04.aql
index e30fbcf..6356f79 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ulist-jaccard_04.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
 create index interests_index on Customers(interests) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_01.aql
index 8438509..ff39969 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_02.aql
index 6f6c5f6..f693855 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on CSX(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_03.aql
index 3f3a247..72f9bdc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-fuzzyeq-jaccard_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_01.aql
index 14f63bf..2a076bc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_02.aql
index 46932be..98b3972 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on CSX(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_03.aql
index 77ac9ba..dace174 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_04.aql
index 6129c52..fa68be2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard-check_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_01.aql
index 47d1192..df0b75e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_01.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_02.aql
index ac33cb0..1f227c8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_02.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 create index keyword_index on CSX(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_03.aql
index 128e500..7a719ff 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_03.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_04.aql
index 325f955..077803b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/word-jaccard_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 create index keyword_index on DBLP(title) type keyword;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/join-super-key_01.aql b/asterix-app/src/test/resources/optimizerts/queries/join-super-key_01.aql
index f0251ad..52b35b8 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/join-super-key_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/join-super-key_01.aql
@@ -66,9 +66,9 @@
 write output to nc1:"/tmp/join-super-key_01.adm";
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_partkey, l_linenumber on group1;
+  primary key l_partkey, l_linenumber on group1;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 for $li in dataset('LineItems')
diff --git a/asterix-app/src/test/resources/optimizerts/queries/join-super-key_02.aql b/asterix-app/src/test/resources/optimizerts/queries/join-super-key_02.aql
index 0904f37..98f7e9e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/join-super-key_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/join-super-key_02.aql
@@ -66,9 +66,9 @@
 write output to nc1:"/tmp/join-super-key_01.adm";
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_partkey, l_linenumber on group1;
+  primary key l_partkey, l_linenumber on group1;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 for $ps in dataset('PartSupp')
diff --git a/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_01.aql b/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_01.aql
index 1f43f73..4855576 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_01.aql
@@ -66,9 +66,9 @@
 write output to nc1:"/tmp/loj-super-key_01.adm";
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_partkey, l_linenumber on group1;
+  primary key l_partkey, l_linenumber on group1;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 for $li in dataset('LineItems')
diff --git a/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_02.aql b/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_02.aql
index ceab193..ce937c5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/loj-super-key_02.aql
@@ -66,9 +66,9 @@
 write output to nc1:"/tmp/loj-super-key_01.adm";
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_partkey, l_linenumber on group1;
+  primary key l_partkey, l_linenumber on group1;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 for $ps in dataset('PartSupp')
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested_loj2.aql b/asterix-app/src/test/resources/optimizerts/queries/nested_loj2.aql
index 0b77f55..d235b09 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/nested_loj2.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested_loj2.aql
@@ -47,11 +47,11 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/nested_loj.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested_loj3.aql b/asterix-app/src/test/resources/optimizerts/queries/nested_loj3.aql
index 3a1ef04..1616a67 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/nested_loj3.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested_loj3.aql
@@ -57,13 +57,13 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 write output to nc1:"/tmp/nested_loj.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/noncollocated.aql b/asterix-app/src/test/resources/optimizerts/queries/noncollocated.aql
index 3aa1855..26b5ab0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/noncollocated.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/noncollocated.aql
@@ -21,10 +21,10 @@
 create nodegroup group2 if not exists on nc2;
 
 create dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 create dataset Visitors(VisitorType) 
-  partitioned by key vid on group2;
+  primary key vid on group2;
 
 
 write output to nc1:"/tmp/fuzzy1.adm";
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orderby-desc-using-gby.aql b/asterix-app/src/test/resources/optimizerts/queries/orderby-desc-using-gby.aql
index 682800c..8cef009 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orderby-desc-using-gby.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orderby-desc-using-gby.aql
@@ -24,7 +24,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
   
 write output to nc1:"rttest/gby-using-orderby-desc.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-aggreg.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-aggreg.aql
index c2f96f6..960a8e6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-aggreg.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-aggreg.aql
@@ -16,7 +16,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key oid on group1;
+  primary key oid on group1;
 
 write output to nc1:"/tmp/orders-aggreg.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-composite-index-search.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-composite-index-search.aql
index d82be3c..73ec062 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-composite-index-search.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-composite-index-search.aql
@@ -14,7 +14,7 @@
   o_comment: string
 }
 
-create dataset Orders(OrderType) partitioned by key o_orderkey;
+create dataset Orders(OrderType) primary key o_orderkey;
 
 create index idx_Custkey_Orderstatus on Orders(o_custkey, o_orderstatus);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_01.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_01.aql
index 150e962..b5aa50d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_01.aql
@@ -19,7 +19,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_02.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_02.aql
index 725da3a..daef719 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive-open_02.aql
@@ -19,7 +19,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_01.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_01.aql
index 0a42fa6..21a7f5a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_01.aql
@@ -19,7 +19,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_02.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_02.aql
index fed390c..25a6d3f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-conjunctive_02.aql
@@ -19,7 +19,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-open.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-open.aql
index a6bfa42..31d41b6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-open.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search-open.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 create index idx_Orders_Custkey on Orders(o_custkey);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search.aql b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search.aql
index 75be90b..4e01059 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/orders-index-search.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/orders-index-search.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 create index idx_Orders_Custkey on Orders(o_custkey);
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search-open.aql b/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search-open.aql
index 09a1ef6..1f6f887 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search-open.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search-open.aql
@@ -21,7 +21,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 
 write output to nc1:"/tmp/prim_index_search.adm";
diff --git a/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search.aql b/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search.aql
index 7a22597..7939fed 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/prim-idx-search.aql
@@ -21,7 +21,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 
 write output to nc1:"/tmp/prim_index_search.adm";
diff --git a/asterix-app/src/test/resources/optimizerts/queries/pull_select_above_eq_join.aql b/asterix-app/src/test/resources/optimizerts/queries/pull_select_above_eq_join.aql
index dfc05ff..ee998cf 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/pull_select_above_eq_join.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/pull_select_above_eq_join.aql
@@ -21,10 +21,10 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Users(UserType) 
-  partitioned by key uid on group1;
+  primary key uid on group1;
 
 create dataset Visitors(VisitorType) 
-  partitioned by key vid on group1;
+  primary key vid on group1;
 
 
 write output to nc1:"/tmp/pull-select-above-eq-join.adm";
diff --git a/asterix-app/src/test/resources/optimizerts/queries/push-project-through-group.aql b/asterix-app/src/test/resources/optimizerts/queries/push-project-through-group.aql
index 5dd229b..3c0235c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/push-project-through-group.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/push-project-through-group.aql
@@ -15,7 +15,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 
 write output to nc1:'rttest/fuzzyjoin_080.adm';
diff --git a/asterix-app/src/test/resources/optimizerts/queries/push_limit.aql b/asterix-app/src/test/resources/optimizerts/queries/push_limit.aql
index a9c4fe7..0ffe2b0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/push_limit.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/push_limit.aql
@@ -16,7 +16,7 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 write output to nc1:"/tmp/push_limit.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q1.aql b/asterix-app/src/test/resources/optimizerts/queries/q1.aql
index 8f62292..ced342d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/q1.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/q1.aql
@@ -27,7 +27,7 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 
-create dataset User(UserType) partitioned by key name on group1;
+create dataset User(UserType) primary key name on group1;
 
 write output to nc1:"/tmp/q1.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql b/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
index af39b3f..b6de1fa 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q2.aql b/asterix-app/src/test/resources/optimizerts/queries/q2.aql
index 17b1f86..5fba695 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/q2.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/q2.aql
@@ -34,7 +34,7 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 
-create dataset Event(EventType) partitioned by key name on group1;
+create dataset Event(EventType) primary key name on group1;
 
 write output to nc1:"/tmp/q2.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql b/asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql
index 89c6fd9..8e6bf6e6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql
@@ -49,11 +49,11 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/q3_shipping_priority.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql b/asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql
index 6b5ccfa..670a392 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql
@@ -72,17 +72,17 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 create dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 create dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 create dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 create dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
   
 write output to nc1:"/tmp/q5_local_supplier.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_01.aql b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_01.aql
index 207b5c9..e95be99 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_01.aql
@@ -20,8 +20,8 @@
   rec: rectangle
 }
 
-create dataset MyData1(MyRecord) partitioned by key id;
-create dataset MyData2(MyRecord) partitioned by key id;
+create dataset MyData1(MyRecord) primary key id;
+create dataset MyData2(MyRecord) primary key id;
 
 create index rtree_index on MyData1(point) type rtree;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_02.aql b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_02.aql
index e70bedf..c0a8634 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_02.aql
@@ -20,8 +20,8 @@
   rec: rectangle
 }
 
-create dataset MyData1(MyRecord) partitioned by key id;
-create dataset MyData2(MyRecord) partitioned by key id;
+create dataset MyData1(MyRecord) primary key id;
+create dataset MyData2(MyRecord) primary key id;
 
 create index rtree_index on MyData2(point) type rtree;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_03.aql b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_03.aql
index 85fc22b..6fb79f3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/rtree-index-join/spatial-intersect-point_03.aql
@@ -20,7 +20,7 @@
   rec: rectangle
 }
 
-create dataset MyData(MyRecord) partitioned by key id;
+create dataset MyData(MyRecord) primary key id;
 
 create index rtree_index on MyData(point) type rtree;
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index-open.aql b/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index-open.aql
index 14416c8..b4a5796 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index-open.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index-open.aql
@@ -17,7 +17,7 @@
 create nodegroup group1  if not exists on nc1, nc2;
 
 create dataset MyData(MyRecord)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index.aql b/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index.aql
index c8525c1..41a5a91 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/rtree-secondary-index.aql
@@ -17,7 +17,7 @@
 create nodegroup group1  if not exists on nc1, nc2;
 
 create dataset MyData(MyRecord)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/scan-delete-all.aql b/asterix-app/src/test/resources/optimizerts/queries/scan-delete-all.aql
index d30b7f8..7b8215f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/scan-delete-all.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/scan-delete-all.aql
@@ -30,9 +30,9 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems_q1(LineItemType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 delete $l from dataset LineItems_q1;
diff --git a/asterix-app/src/test/resources/optimizerts/queries/scan-delete-rtree-secondary-index.aql b/asterix-app/src/test/resources/optimizerts/queries/scan-delete-rtree-secondary-index.aql
index 4d5de58..a307a1d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/scan-delete-rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/scan-delete-rtree-secondary-index.aql
@@ -17,7 +17,7 @@
 create nodegroup group1  if not exists on nc1, nc2;
 
 create dataset MyData(MyRecord)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/optimizerts/queries/scan-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/scan-delete.aql
index 9bf6a4c..57e1bd3 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/scan-delete.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/scan-delete.aql
@@ -31,9 +31,9 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems_q1(LineItemType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 delete $l from dataset LineItems_q1 where $l.l_shipdate <= '1998-09-02';
diff --git a/asterix-app/src/test/resources/optimizerts/queries/scan-insert-secondary-index.aql b/asterix-app/src/test/resources/optimizerts/queries/scan-insert-secondary-index.aql
index afecc04..97bc8df 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/scan-insert-secondary-index.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/scan-insert-secondary-index.aql
@@ -30,10 +30,10 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems_q1(LineItemType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
   
 create index idx_LineID_partkey on LineID(l_partkey);
 create index idx_LineID_suppkey on LineID(l_suppkey);
diff --git a/asterix-app/src/test/resources/optimizerts/queries/scan-insert.aql b/asterix-app/src/test/resources/optimizerts/queries/scan-insert.aql
index beb73a7..1c26a46 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/scan-insert.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/scan-insert.aql
@@ -30,10 +30,10 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset LineItems_q1(LineItemType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey on group1;
+  primary key l_orderkey on group1;
 
 insert into dataset LineID (
 for $l in dataset('LineItems_q1')
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_01.aql
index 96d3b1a..4d63c15 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_01.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_02.aql
index e0ef1aa..762b41c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_02.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_02.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_03.aql
index 75a584e..e14f329 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_03.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_03.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_04.aql
index 2f42ab0..f539938 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_04.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_04.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_05.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_05.aql
index 73f8ddb..b126f67 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_05.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_05.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_06.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_06.aql
index 221bfb8..f32285e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_06.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_06.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_06.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_07.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_07.aql
index 949ed2c..2dff7e5 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_07.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_07.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_07.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_08.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_08.aql
index 3f899a2..9bc10e6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_08.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-let-to-edit-distance-check_08.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_08.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_01.aql
index 0370fff..09e962c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_01.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_02.aql
index 77d78f8..35e28fc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_02.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_02.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_03.aql
index c34c28a..e05f85a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_03.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_03.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_04.aql
index 082dc39..b890967 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_04.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_05.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_05.aql
index 6d892df..bc66061 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_05.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_05.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_06.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_06.aql
index 20d4879..018d6d1 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_06.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_06.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_06.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_07.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_07.aql
index 49871f9..cdaefa9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_07.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_07.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_07.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_08.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_08.aql
index ed6d406..745044f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_08.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/edit-distance-to-edit-distance-check_08.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_08.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-edit-distance-check.aql
index 702b739..f6e9d52 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-edit-distance-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-edit-distance-check.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_fuzzyeq-to-edit-distance-check.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-jaccard-check.aql
index eaacc3e..5f57a3e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/fuzzyeq-to-jaccard-check.aql
@@ -16,7 +16,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_fuzzyeq-to-jaccard-check.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_01.aql
index 8647565..733c6d9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_01.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_02.aql
index b48eb24..a360ef1 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_02.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_03.aql
index 74dcf9d..ad8abca 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_03.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_04.aql
index e17d458..fd236de 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_04.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_05.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_05.aql
index 266f369..b750a5d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_05.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_06.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_06.aql
index 3beec4b..56b1471 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_06.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_06.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_07.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_07.aql
index 86401ac..6ae0444 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_07.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_07.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_08.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_08.aql
index 372a3e8..5d04402 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_08.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-let-to-jaccard-check_08.aql
@@ -18,7 +18,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_01.aql
index 8e8a0f8..33eb133 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_01.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_01.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_02.aql
index bee4595..3bdf01f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_02.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_02.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_03.aql
index 591c8f0..3a22a16 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_03.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_02.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_04.aql
index 2d10e1d..bdce095 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_04.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_03.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_05.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_05.aql
index f091dcd..977f22a 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_05.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_05.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_05.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_06.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_06.aql
index 7b98eaf..eb3f3ef 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_06.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_06.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_06.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_07.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_07.aql
index 71f087e..753ce3c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_07.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_07.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_07.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_08.aql b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_08.aql
index 13d11ed..2d1bd93 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_08.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/similarity/jaccard-to-jaccard-check_08.aql
@@ -17,7 +17,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_08.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/sort-cust.aql b/asterix-app/src/test/resources/optimizerts/queries/sort-cust.aql
index ec4f6f1..9605b37 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/sort-cust.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/sort-cust.aql
@@ -27,7 +27,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Customers(CustomerType)
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 write output to nc1:"/tmp/custlimit.adm";
 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/unnest_list_in_subplan.aql b/asterix-app/src/test/resources/optimizerts/queries/unnest_list_in_subplan.aql
index 5a943f1..3f34242 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/unnest_list_in_subplan.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/unnest_list_in_subplan.aql
@@ -17,8 +17,8 @@
 
 create nodegroup group1 if not exists on nc1, nc2;
 
-create dataset DBLP(DBLPType) partitioned by key id on group1;
-create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by key rank on group1;
+create dataset DBLP(DBLPType) primary key id on group1;
+create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank on group1;
 
 write output to nc1:'rttest/unnest_list_in_subplan.adm';
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql
index 3583ce0..2c4ba6a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql
@@ -13,7 +13,7 @@
   val: double
 }
 
-create dataset Test(TestType) partitioned by key id;
+create dataset Test(TestType) primary key id;
 
 write output to nc1:"rttest/aggregate_avg_empty_02.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql
index 0a6cc8e..9ab7168 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql
@@ -13,7 +13,7 @@
   val: double
 }
 
-create dataset Test(TestType) partitioned by key id;
+create dataset Test(TestType) primary key id;
 
 write output to nc1:"rttest/aggregate_count_empty_02.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql
index 79ae1d8..8b954e1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql
@@ -13,7 +13,7 @@
   val: double
 }
 
-create dataset Test(TestType) partitioned by key id;
+create dataset Test(TestType) primary key id;
 
 write output to nc1:"rttest/aggregate_max_empty_02.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql
index 99d49f4..6aa122c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql
@@ -13,7 +13,7 @@
   val: double
 }
 
-create dataset Test(TestType) partitioned by key id;
+create dataset Test(TestType) primary key id;
 
 write output to nc1:"rttest/aggregate_min_empty_02.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql
index a94457a..c3fd645 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql
@@ -13,7 +13,7 @@
   val: double
 }
 
-create dataset Test(TestType) partitioned by key id;
+create dataset Test(TestType) primary key id;
 
 write output to nc1:"rttest/aggregate_sum_empty_02.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql
index 10e952c..8c695c5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql
@@ -16,7 +16,7 @@
 sal:int32?
 }
 
-create dataset tdst(TestType) partitioned by key id;
+create dataset tdst(TestType) primary key id;
 
 insert into dataset tdst({"id":123,"sal":1000});
 insert into dataset tdst({"id":113,"sal":2000});
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql
index 9197e33..4c568b1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql
@@ -15,7 +15,7 @@
 sal:int32?
 }
 
-create dataset tdst(TestType) partitioned by key id;
+create dataset tdst(TestType) primary key id;
 
 // In AQL
 // sum(numeric + null) => null
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/datetime_range.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/datetime_range.aql
index 4268231..a1cbf52 100644
--- a/asterix-app/src/test/resources/runtimets/queries/comparison/datetime_range.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/datetime_range.aql
@@ -11,7 +11,7 @@
 }
 
 create dataset TwitterData(Tweet)
-  partitioned by key id;
+  primary key id;
 
 load dataset TwitterData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
index 683481f..58ae18d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
@@ -13,5 +13,4 @@
 let $c7 := int32("-320")
 let $c8 := int64("-640i64")
 let $c9 := int64("-9223372036854775808")
-return {"int8": $c1,"int16": $c2,"int32": $c3, "int64": $c4, "int8": $c5,"int16": $c6,"int32": $c7, "int64": $c8, "int64_min" : $c9}
-
+return {"int8": $c1,"int16": $c2,"int32": $c3, "int64": $c4, "int8_2": $c5,"int16_2": $c6,"int32_2": $c7, "int64_2": $c8, "int64_min" : $c9}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql
index e95d102..eaec65a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql
@@ -30,10 +30,10 @@
 dept : string
 }
 
-create dataset student.ugdstd(stdType) partitioned by key id;
-create dataset student.gdstd(stdType) partitioned by key id;
-create dataset teacher.prof(tchrType) partitioned by key id;
-create dataset teacher.pstdoc(tchrType) partitioned by key id;
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
 
 insert into dataset student.ugdstd({"id":457,"name":"John Doe","age":22,"sex":"M","dept":"Dance"});
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql
index 1257cac..4ab7c29 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql
@@ -30,10 +30,10 @@
 dept : string
 }
 
-create dataset student.ugdstd(stdType) partitioned by key id;
-create dataset student.gdstd(stdType) partitioned by key id;
-create dataset teacher.prof(tchrType) partitioned by key id;
-create dataset teacher.pstdoc(tchrType) partitioned by key id;
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
 
 insert into dataset student.ugdstd({"id":457,"name":"John Doe","age":22,"sex":"M","dept":"Dance"});
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql
index 0c80540..a68d428 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql
@@ -32,10 +32,10 @@
 dept : string
 }
 
-create dataset student.ugdstd(stdType) partitioned by key id;
-create dataset student.gdstd(stdType) partitioned by key id;
-create dataset teacher.prof(tchrType) partitioned by key id;
-create dataset teacher.pstdoc(tchrType) partitioned by key id;
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
 
 drop dataset student.ugdstd;
 drop dataset student.gdstd;
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql
index 20be103..55a3fa0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql
@@ -33,20 +33,20 @@
 dept : string
 }
 
-create dataset student.ugdstd(stdType) partitioned by key id;
-create dataset student.gdstd(stdType) partitioned by key id;
-create dataset teacher.prof(tchrType) partitioned by key id;
-create dataset teacher.pstdoc(tchrType) partitioned by key id;
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
 
 drop dataset student.ugdstd;
 drop dataset student.gdstd;
 drop dataset teacher.prof;
 drop dataset teacher.pstdoc;
 
-create dataset student.ugdstd(stdType) partitioned by key id;
-create dataset student.gdstd(stdType) partitioned by key id;
-create dataset teacher.prof(tchrType) partitioned by key id;
-create dataset teacher.pstdoc(tchrType) partitioned by key id;
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
 
 for $l in dataset('Metadata.Dataset')
 where $l.DataverseName='student' or $l.DataverseName='teacher'
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql
index 4bba053..25e5d67 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql
@@ -18,7 +18,7 @@
 dept:string
 }
 
-create dataset test.employee(Emp) partitioned by key id;
+create dataset test.employee(Emp) primary key id;
 
 load dataset test.employee
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql
index 10985e3..8b4a32d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql
@@ -22,8 +22,8 @@
 id : int32
 }
 
-create dataset test.t1(testtype) partitioned by key id;
-create dataset fest.t1(testtype) partitioned by key id;
+create dataset test.t1(testtype) primary key id;
+create dataset fest.t1(testtype) primary key id;
 
 insert into dataset test.t1({"id":24});
 insert into dataset test.t1({"id":23});
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql
index 26556e0..8e42043 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql
@@ -20,8 +20,8 @@
 id : int32
 }
 
-create dataset test.t1(testtype) partitioned by key id;
-create dataset fest.t1(testtype) partitioned by key id;
+create dataset test.t1(testtype) primary key id;
+create dataset fest.t1(testtype) primary key id;
 
 insert into dataset test.t1({"id":24});
 insert into dataset test.t1({"id":23});
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql
index 0d3bd53..69dd67d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql
@@ -21,8 +21,8 @@
 id : int32
 }
 
-create dataset test.t1(testtype) partitioned by key id;
-create dataset fest.t1(testtype) partitioned by key id;
+create dataset test.t1(testtype) primary key id;
+create dataset fest.t1(testtype) primary key id;
 
 insert into dataset test.t1({"id":24});
 insert into dataset test.t1({"id":23});
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql
index 335f11c..6a0cf97 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql
@@ -33,17 +33,17 @@
   text: string
 }
 
-create dataset test1.t1(testtype) partitioned by key id;
+create dataset test1.t1(testtype) primary key id;
 
-create dataset test2.t2(testtype) partitioned by key id;
+create dataset test2.t2(testtype) primary key id;
 
-create dataset test2.t3(testtype) partitioned by key id;
+create dataset test2.t3(testtype) primary key id;
 
-create dataset test1.t2(testtype) partitioned by key id;
+create dataset test1.t2(testtype) primary key id;
 
-create dataset test1.t3(testtype) partitioned by key id;
+create dataset test1.t3(testtype) primary key id;
 
-create dataset test2.t4(testtype) partitioned by key id;
+create dataset test2.t4(testtype) primary key id;
 
 create external dataset test1.TwitterData(Tweet)
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql
index 7b14957..860dd74 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql
@@ -20,7 +20,7 @@
 };
 
 create dataset test.Customers(CustomerType)
-partitioned by key cid;
+primary key cid;
 
 drop dataset test.Customers;
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql
index 7eebbaf..2395a48 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql
@@ -42,10 +42,10 @@
 };
 
 create dataset test1.Customers(CustomerType)
-partitioned by key cid;
+primary key cid;
 
 create dataset test2.Customers(CustomerType)
-partitioned by key cid;
+primary key cid;
 
 load dataset test1.Customers
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql
index 89180ef..3c96539 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql
@@ -14,7 +14,7 @@
 
 write output to nc1:"rttest/cross-dataverse_insert_from_source_dataset.adm";
 
-create dataset test.t1(testtype) partitioned by key id;
+create dataset test.t1(testtype) primary key id;
 
 insert into dataset test.t1({"id":456,"name":"Roger"});
 insert into dataset test.t1({"id":351,"name":"Bob"});
@@ -22,7 +22,7 @@
 insert into dataset test.t1({"id":926,"name":"Richard"});
 insert into dataset test.t1({"id":482,"name":"Kevin"});
 
-create dataset test.t2(testtype) partitioned by key id;
+create dataset test.t2(testtype) primary key id;
 
 insert into dataset test.t2({"id":438,"name":"Ravi"});
 insert into dataset test.t2({"id":321,"name":"Bobby"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
index d09755a..197baaa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
@@ -25,7 +25,7 @@
 };
 
 create dataset test1.Customers(CustomerType)
-partitioned by key cid;
+primary key cid;
 
 
 create type test2.OrderType as open {
@@ -39,7 +39,7 @@
 }
 
 create dataset test2.Orders(OrderType)
-partitioned by key oid;
+primary key oid;
 
 
 load dataset test1.Customers
@@ -57,4 +57,4 @@
 for $o in dataset('test2.Orders')
 where $c.cid = $o.cid
 order by $c.name, $o.total
-return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid], "orderList":{{$o.oid, $o.cid}}}
+return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/co.aql b/asterix-app/src/test/resources/runtimets/queries/custord/co.aql
index 879b2b8..2b9cc6b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/co.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/co.aql
@@ -37,11 +37,11 @@
 }
 
 create dataset Customers3(CustomerType) 
-  partitioned by key cid;
+  primary key cid;
 create dataset Orders3(OrderType)
-  partitioned by key oid;
+  primary key oid;
 create dataset CustomerOrders3(CustomerOrdersType)
-  partitioned by key cid;
+  primary key cid;
 
 write output to nc1:"rttest/custord_co.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01.aql
index decc8bb..bcc4079 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01.aql
@@ -37,11 +37,11 @@
 }
 
 create dataset Customers1(CustomerType) 
-  partitioned by key cid;
+  primary key cid;
 create dataset Orders1(OrderType)
-  partitioned by key oid;
+  primary key oid;
 create dataset CustomerOrders1(CustomerOrdersType)
-  partitioned by key cid;
+  primary key cid;
 
 load dataset Customers1 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02.aql
index 2ac6910..481adf4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02.aql
@@ -37,11 +37,11 @@
 }
 
 create dataset Customers2(CustomerType) 
-  partitioned by key cid;
+  primary key cid;
 create dataset Orders2(OrderType)
-  partitioned by key oid;
+  primary key oid;
 create dataset CustomerOrders2(CustomerOrdersType)
-  partitioned by key cid;
+  primary key cid;
 
 load dataset Customers2 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03.aql
index 324dbb0..92a049d5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03.aql
@@ -37,11 +37,11 @@
 }
 
 create dataset Customers3(CustomerType) 
-  partitioned by key cid;
+  primary key cid;
 create dataset Orders3(OrderType)
-  partitioned by key oid;
+  primary key oid;
 create dataset CustomerOrders3(CustomerOrdersType)
-  partitioned by key cid;
+  primary key cid;
 
 load dataset Customers3 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/freq-clerk.aql b/asterix-app/src/test/resources/runtimets/queries/custord/freq-clerk.aql
index cd4ef0e..9bc318a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/freq-clerk.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/freq-clerk.aql
@@ -28,7 +28,7 @@
 }
 
 create dataset CustomerOrders(CustomerOrderType) 
-  partitioned by key cid;
+  primary key cid;
 
 
 load dataset CustomerOrders
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql b/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
index ddde56e..f5d2080 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
@@ -47,4 +47,4 @@
 for $o in dataset('Orders')
 where $c.cid = $o.cid 
 order by $c.name, $o.total
-return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid], "orderList":{{$o.oid, $o.cid}}} 
+return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid]} 
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/load-test.aql b/asterix-app/src/test/resources/runtimets/queries/custord/load-test.aql
index 5f73e4b..6cafbe0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/load-test.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/load-test.aql
@@ -21,9 +21,9 @@
 }
 
 create dataset c1(CustomerType) 
-  partitioned by key cid;
+  primary key cid;
 create dataset c2(CustomerType) 
-  partitioned by key cid;  
+  primary key cid;  
   
 load dataset c1 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
index b930a10..52bc6d2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
@@ -26,4 +26,4 @@
 let $c2 := {{ $o.orderstatus, $o.clerk}}
 let $c3 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
 let $c4 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
-return { "orderid": $o.oid, "ordertot":$o.total, "list": $c1, "item1": $c1[0], "item1": $c1[?], "item2": $c1[1], "item3": $c1[2]}
+return { "orderid": $o.oid, "ordertot":$o.total, "list": $c1, "item1": $c1[0], "item2": $c1[1], "item3": $c1[2]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
index b2d55d9..e2fd5b6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
@@ -26,4 +26,4 @@
 let $c2 := {{ $o.orderstatus, $o.clerk}}
 let $c3 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
 let $c4 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
-return { "orderid": $o.oid, "ordertot":$o.total, "list": $c3, "item1": $c3[0], "item1": $c3[?], "item2": $c3[1], "item5": $c3[5], "item10": $c3[10]}
+return { "orderid": $o.oid, "ordertot":$o.total, "list": $c3, "item1": $c3[0], "item2": $c3[1], "item5": $c3[5], "item10": $c3[10]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
index 5693312..481c1fd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
@@ -24,4 +24,4 @@
 for $o in dataset('Orders')
 let $c1 := []
 let $c2 := {{}}
-return { "orderid": $o.oid, "ordertot":$o.total, "emptyorderedlist": $c1, "emptyunorderedlist": $c2, "olist_item1": $c1[0], "olist_item1": $c1[?], "olist_item5": $c1[4], "ulist_item1": $c2[?]}
+return { "orderid": $o.oid, "ordertot":$o.total, "emptyorderedlist": $c1, "emptyunorderedlist": $c2, "olist_item1": $c1[0], "olist_item5": $c1[4], "ulist_item1": $c2[?]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dapd/q3.aql b/asterix-app/src/test/resources/runtimets/queries/dapd/q3.aql
index 23e4557..63b9119 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dapd/q3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dapd/q3.aql
@@ -24,7 +24,7 @@
 }
 
 create dataset User(UserType)
- partitioned by key name;
+ primary key name;
 
 load dataset User 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset-with-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset-with-index.aql
index ab6b6c9..e642073 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset-with-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset-with-index.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset.aql b/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset.aql
index 1a445bf..ff66d65 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/delete-from-loaded-dataset.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/drop-empty-secondary-indexes.aql b/asterix-app/src/test/resources/runtimets/queries/dml/drop-empty-secondary-indexes.aql
index 2534e51..b25f028 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/drop-empty-secondary-indexes.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/drop-empty-secondary-indexes.aql
@@ -18,7 +18,7 @@
 
 write output to nc1:"rttest/dml_drop-empty-secondary-indexes.adm";
 
-create dataset t1(TestType) partitioned by key id;
+create dataset t1(TestType) primary key id;
 
 create index rtree_index_point on t1(locn) type rtree;
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql
index 0c87734..8b99487 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql
@@ -28,7 +28,7 @@
 string4:  string
 }
 
-create dataset t1(Schema) partitioned by key unique2;
+create dataset t1(Schema) primary key unique2;
 
 // Load data
 load dataset t1
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index.aql
index 4f22e84..45ec5e6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index.aql
@@ -29,7 +29,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create index part_index on LineItem(l_partkey);
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load.aql
index f9db086..63739d6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load.aql
@@ -29,7 +29,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create index part_index on LineItem(l_partkey);
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset-with-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset-with-index.aql
index 00b60cb..586226c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset-with-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset-with-index.aql
@@ -16,7 +16,7 @@
 }
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create index idx_LineID_partkey on LineID(l_linenumber);
 create index idx_LineID_suppkey on LineID(l_suppkey);
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset.aql
index 253f5e7..58548b6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-empty-dataset.aql
@@ -16,7 +16,7 @@
 }
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 insert into dataset LineID (
 let $x:=1
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_01.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_01.aql
index 7a3cce2..761066e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_01.aql
@@ -9,7 +9,7 @@
 }
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineID 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_02.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_02.aql
index 04a5043..475e6ab 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset-with-index_02.aql
@@ -28,10 +28,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_01.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_01.aql
index 1f211e8..7ece2ab 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_01.aql
@@ -9,7 +9,7 @@
 }
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineID 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_02.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_02.aql
index ef38109..f05844b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-into-loaded-dataset_02.aql
@@ -21,9 +21,9 @@
 string4:  string
 }
 
-create dataset onektup(Schema) partitioned by key unique2;
+create dataset onektup(Schema) primary key unique2;
 
-create dataset tenktup1(Schema) partitioned by key unique2;
+create dataset tenktup1(Schema) primary key unique2;
 
 load dataset onektup 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
@@ -33,7 +33,7 @@
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/wisc/tenktup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
 
-create dataset tmp(Schema) partitioned by key unique2;
+create dataset tmp(Schema) primary key unique2;
 
 load dataset tmp 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-src-dst-01.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-src-dst-01.aql
index c3dc7ba..7c055f7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-src-dst-01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-src-dst-01.aql
@@ -20,8 +20,8 @@
   id: string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds01 ({ "id": "001" });
 insert into dataset testds01 ({ "id": "002", "name": "John Doe" });
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert.aql
index 2b4622f..a0d4d5b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert.aql
@@ -28,10 +28,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert_less_nc.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert_less_nc.aql
index 7e133ae..c646c4c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert_less_nc.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert_less_nc.aql
@@ -28,10 +28,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/load-from-hdfs.aql b/asterix-app/src/test/resources/runtimets/queries/dml/load-from-hdfs.aql
index 0411145..908f515 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/load-from-hdfs.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/load-from-hdfs.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.HDFSAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/load-with-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/load-with-index.aql
index efab267..61b455c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/load-with-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/load-with-index.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create index idx_partkey on LineItem(l_partkey);
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive.aql
index 6c8264f..b2ec24f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive.aql
@@ -30,9 +30,9 @@
   id: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
-create dataset testds2(testtype2) partitioned by key id;
+create dataset testds2(testtype2) primary key id;
 
 insert into dataset testds (
 { "id": "001", "name": "Person One", "address": {"street": "3019 DBH",  "city": "Irvine", "zip": 92697}, "department": {{ {"name":"CS", "id":299, "review":5}, {"name":"EE", "id":399} }} }
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o.aql
index a63e2df..29d7d61 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o.aql
@@ -23,9 +23,9 @@
   id: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
-create dataset testds2(testtype2) partitioned by key id;
+create dataset testds2(testtype2) primary key id;
  
 insert into dataset testds (
 { "hobby": {{"music", "coding"}}, "id": "001", "name": "Person Three"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional.aql
index 94991be..b510ba4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional.aql
@@ -13,7 +13,7 @@
   id: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
 insert into dataset testds (
 { "id": "001", "name": "Person One"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert.aql
index 12248dd..9301ac5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert.aql
@@ -13,7 +13,7 @@
   name: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
  
  insert into dataset testds (
  { "id": "001", "name": "Person Three", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2.aql
index 1903bf2..e673c57 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2.aql
@@ -13,7 +13,7 @@
 	id:int32
 }
 
-create dataset testds(TestType) partitioned by key id;
+create dataset testds(TestType) primary key id;
 
 insert into dataset testds( for $i in range(1,10) return { "id":$i,"name":"John Doe" });
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand.aql
index c6ff1cd..bc408be 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand.aql
@@ -14,7 +14,7 @@
   id: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
 insert into dataset testds (
 { "id": "001", "name": "Person One"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive.aql
index 2070e20..92d2bce 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive.aql
@@ -31,9 +31,9 @@
   department: {{Dept}}?
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
-create dataset testds2(testtype2) partitioned by key id;
+create dataset testds2(testtype2) primary key id;
 
 insert into dataset testds (
 { "id": "001", "name": "Person One", "address": {"street": "3019 DBH",  "city": "Irvine", "zip": 92697}, "department": {{ {"name":"CS", "id":299}, {"name":"EE", "id":399} }} }
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c.aql
index 015aa7b..ae69e17 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c.aql
@@ -21,9 +21,9 @@
   name: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
-create dataset testds2(testtype2) partitioned by key id; 
+create dataset testds2(testtype2) primary key id; 
  
 insert into dataset testds (
 { "id": "001",  "hobby": {{"music"}}, "name": "Person Three"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o.aql b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o.aql
index 545790b..c836a69 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o.aql
@@ -21,9 +21,9 @@
   hobby: string
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
-create dataset testds2(testtype2) partitioned by key id;
+create dataset testds2(testtype2) primary key id;
  
 insert into dataset testds (
 { "name": "Person One",  "id": "001", "hobby": "music"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql b/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql
index e0a0695..3a2ad40 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql
@@ -21,7 +21,7 @@
 }
 
 create dataset Employees(EmployeeType)
-  partitioned by key id;
+  primary key id;
 
 insert into dataset Employees({"id":"1234", "stat":{ "age":50, "salary":120000}, "deptCode":32 });
 insert into dataset Employees({"id":"5678", "stat":{ "age":40, "salary":100000}, "deptCode":16 });
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-secondary-index-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-secondary-index-nullable.aql
index a35c8e5..36df10a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-secondary-index-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-secondary-index-nullable.aql
@@ -24,7 +24,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index-nullable.aql
index fc30529..c44c3e8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index-nullable.aql
@@ -21,7 +21,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
index 4e2ca6c..b6bc17b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
@@ -15,7 +15,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-secondary-index-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-secondary-index-nullable.aql
index d5d22d3..dde8892 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-secondary-index-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-secondary-index-nullable.aql
@@ -24,8 +24,8 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
-create dataset CustomersMini(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
+create dataset CustomersMini(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index-nullable.aql
index 161439a..a3d38eb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index-nullable.aql
@@ -26,14 +26,14 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm")) pre-sorted;
 
 create dataset MyMiniData(MyMiniRecord)
-  partitioned by key id;
+  primary key id;
 
 create index rtree_index_point on MyMiniData(point) type rtree;
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
index f1bc29d..0ed6488 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
@@ -20,14 +20,14 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
 
 create dataset MyMiniData(MyMiniRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyMiniData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql
index 465d94f..f883454 100644
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql
@@ -12,7 +12,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql
index cd4a922..7bf558b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql
@@ -23,7 +23,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree.aql
index 2ec32f4..9530df5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree.aql
@@ -17,7 +17,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
@@ -25,7 +25,7 @@
 
 
 create dataset MyMiniData(MyMiniRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyMiniData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert.aql
index a0ce842..0309b7c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/insert.aql
@@ -29,10 +29,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 create dataset LineID(LineIDType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure.aql b/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure.aql
index a0c7f87..58db4b8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure.aql
@@ -24,7 +24,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql
index d4dcd38..fe0e9e5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql
@@ -17,8 +17,8 @@
 
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
-(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
-partitioned by key id;
+(("output-type-name"="TweetType"),("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("tuple-interval"="10"))
+primary key id;
 
 write output to nc1:"rttest/feeds_feeds_01.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql
index 3129d63..d72e623 100644
--- a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql
@@ -19,7 +19,7 @@
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
 (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
-partitioned by key id;
+primary key id;
 
 begin feed TweetFeed; 
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql
index a4b22d0..615ee83 100644
--- a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql
@@ -21,9 +21,9 @@
 
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
-(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+(("output-type-name"="TweetType"),("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("tuple-interval"="10"))
 apply function feed_processor@1
-partitioned by key id;
+primary key id;
 
 write output to nc1:"rttest/feeds_feeds_03.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql
index c38cfd2..bea88fb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql
@@ -20,7 +20,7 @@
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
 (("fs"="hdfs"),("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/obamatweets.adm"),("format"="adm"),("input-format"="text-input-format"),("output-type-name"="TweetType"),("tuple-interval"="10"))
-partitioned by key id;
+primary key id;
 
 begin feed TweetFeed; 
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql
index a7dc4fa..a9f3236 100644
--- a/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql
@@ -19,7 +19,7 @@
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
 (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
-partitioned by key id;
+primary key id;
 
 begin feed feeds.TweetFeed; 
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1.aql
index 8438ae9..ffabe64 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1.aql
index d575424..a74bc3e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.aql
index f0b43d1..53771c1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.aql
index a96e933..923959b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1.aql
index f424166..3c7bb5b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2.aql
index 05304c5..d0eebcb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2.aql
@@ -17,8 +17,8 @@
   rank: int32
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by key rank;
+create dataset DBLP(DBLPType) primary key id;
+create dataset TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1.aql
index be6073b..b5ae4c6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2.aql
index 9d31f4a..d50b67c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3.aql
index 4bc6836..2e57a79 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4.aql
index 149a9b4..7f59c30 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1.aql
index 90e1b15..4f53db6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2.aql
index 2771589..67bd952 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1.aql
index 57cdab4..9944c93 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.aql
index e4e8cfd..0319117 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.aql
index 8d3c4c3..9a10925 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1.aql
index e65952d..2de6807 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2.aql
index 4a98706..a3b5bc5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.aql
index d998928..26f5e46 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
index fa0bfac..dd88883 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql
index 7bf7d5f..abd3425 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql
@@ -15,7 +15,7 @@
   id: int32
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1.aql
index a899a80..288194c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2.aql
index 4c30bb7..0010b8b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3.aql
index 5c49fd2..aa3c661 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4.aql
index fa8501c..2aa331c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1.aql
index 97d163f..a8f5eec 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2.aql
index 0329a87..d724b57 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1.aql
index 9d9c141..57dbb53 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 
 load dataset DBLP
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.aql
index 11d4327..fa9f11c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.aql
index 603077e..40fd306 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1.aql
index 2a3f6ec..59a881b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2.aql
index e942aa0..9352c3b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3.aql
index dbbc1b1..c1c6322 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4.aql
index a703037..75fe12b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1.aql
index c6d61e2..bfed5c6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2.aql
index f881151..b683acb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1.aql
index b0884f2..3134c41 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.aql
index 46bd31d..97e16c9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1.aql
index c8ed34b..175e4b1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.aql
index e4eab9d..e471d69 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.aql
index 55d508b..588591d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
index 30445bf..0195185 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
index 01ee281..085d139 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
index 4439af1..d379cc4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
index 77e32a2..cb774be 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
@@ -20,8 +20,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-lookup_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-lookup_1.aql
index 274f0c2..edec926 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-lookup_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-lookup_1.aql
@@ -12,7 +12,7 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
 load dataset DBLP
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/events-users-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/events-users-aqlplus_1.aql
index 500454f..b31ba58 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/events-users-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/events-users-aqlplus_1.aql
@@ -22,7 +22,7 @@
 }}
 }
 
-create dataset User(UserType) partitioned by key name;
+create dataset User(UserType) primary key name;
 
 load dataset User
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_1.aql
index 7598987..af327b4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_1.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_2.aql
index 5b3c828..2d81ddd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_2.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_3.aql
index c131c75..9785f52 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-int-aqlplus_3.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.1.aql
index 6a6248f..bdcaa36 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.1.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.aql
index 75eb9c8..db833d0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_1.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_2.aql
index 39168c6..9f6e758 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_2.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_3.aql
index c9e4ece..e438ec8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-lot-aqlplus_3.aql
@@ -9,7 +9,7 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
+create dataset Users(UserType) primary key uid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-3_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-3_1.aql
index fa63e8e..6dd9cbc 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-3_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-3_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_1.aql
index 5cea93e..40fa07b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_2.aql
index 6ec3fc6..e56c48c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_2.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_3.aql
index baf6d12..01c172e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-aqlplus_3.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1.aql
index ff94813..0746be5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-3_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-3_1.aql
index 9f2fd07..6654d07 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-3_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-3_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_1.aql
index 1cfaccf..a289015 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_2.aql
index b5eb560..59b7c9a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_2.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_3.aql
index 5b557ee..861db2f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_3.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_4.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_4.aql
index 1353960..49ac082 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_4.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_5.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_5.aql
index 58cc81f..08e8bf8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-aqlplus_5.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_1.aql
index 01ad330..4679eca 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_1.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_2.aql
index 35fde70..669284c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/user-vis-lot-int-aqlplus_2.aql
@@ -18,8 +18,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 load dataset Users 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql
index 7a0494f..8271f1d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql
@@ -13,7 +13,7 @@
 };
 
 create external dataset TextDataset(LineType)
-using "hdfs"
+using hdfs
 (("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="."));
 
 write output to nc1:"rttest/hdfs_hdfs_02.adm";
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql
index fc5b3ab..4ddf511 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql
@@ -15,7 +15,7 @@
 };
 
 create external dataset TextDataset(LineType)
-using "hdfs"
+using hdfs
 (("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/large_text"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
 
 write output to nc1:"rttest/hdfs_hdfs_03.adm";
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql
index c2a0963..4a42a20 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql
@@ -14,7 +14,7 @@
 };
 
 create external dataset TextDataset(LineType)
-using "hdfs"
+using hdfs
 (("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/asterix_info.txt"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
 
 write output to nc1:"rttest/hdfs_issue_245_hdfs.adm";
diff --git a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_5.aql b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_5.aql
index 5e5ecc8..544b37c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_5.aql
@@ -20,7 +20,7 @@
 }
 
 create dataset DBLPadm(DBLPType) 
-partitioned by key id
+primary key id
 hints(cardinality=200);
 
 // drop dataset DBLPadm;
diff --git a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_6.aql b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_6.aql
index 889daa7..0b7c20d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_6.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_6.aql
@@ -14,7 +14,7 @@
 };
 
 create external dataset TextDataset(LineType)
-using "hdfs"
+using hdfs
 (("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="."))
 hints(cardinality=10);
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_7.aql b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_7.aql
index d06e2a7..8f4a74d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_7.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/hints/issue_251_dataset_hint_7.aql
@@ -20,7 +20,7 @@
 create feed dataset TweetFeed(TweetType)
 using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
 (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
-partitioned by key id
+primary key id
 hints(cardinality=200);
 
 begin feed feeds.TweetFeed; 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql
index 1015e82..0800784 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql
@@ -37,8 +37,8 @@
   items: [int32]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
-create dataset Orders(OrderType) partitioned by key oid;
+create dataset Customers(CustomerType) primary key cid;
+create dataset Orders(OrderType) primary key oid;
 
 load dataset Customers
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql
index d1e9824..1bf3490 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql
@@ -25,8 +25,8 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
-create dataset CSX(CSXType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql
index ab79189..58fbf73 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql
@@ -21,8 +21,8 @@
   circle: circle
 }
 
-create dataset MyData1(MyRecord) partitioned by key id;
-create dataset MyData2(MyRecord) partitioned by key id;
+create dataset MyData1(MyRecord) primary key id;
+create dataset MyData2(MyRecord) primary key id;
 
 load dataset MyData1
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql
index dadb884..248c8ba 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql
@@ -19,7 +19,7 @@
 dept:string
 }
 
-create dataset employee(Emp) partitioned by key id;
+create dataset employee(Emp) primary key id;
 
 load dataset employee
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql
index 7b72a80..e3214de 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql
@@ -22,7 +22,7 @@
   o_comment: string
 }
 
-create dataset Orders(OrderType) partitioned by key o_orderkey;
+create dataset Orders(OrderType) primary key o_orderkey;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/cust-index-age-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/cust-index-age-nullable.aql
index 460a212..8fb416b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/cust-index-age-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/cust-index-age-nullable.aql
@@ -17,7 +17,7 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-contains.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-contains.aql
index ad85be7..e9b9540 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-contains.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-contains.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance-panic.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance-panic.aql
index b275423..3e637ed 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance-panic.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance-panic.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance.aql
index ddcdd4b..1fca0d4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-edit-distance.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-jaccard.aql
index 501ebce..1b8167b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ngram-jaccard.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic.aql
index deb51a7..79e728f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance.aql
index bb05fc1..793d578 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-jaccard.aql
index 8e2d1e7..aacb656 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-jaccard.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard.aql
index 6a0e266..a6ea348 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard.aql
@@ -20,7 +20,7 @@
 create nodegroup group1 if not exists on nc1;
 
 create dataset Customers(CustomerType) 
-  partitioned by key cid on group1;
+  primary key cid on group1;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-contains.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-contains.aql
index 348f686..f873dbb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-contains.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-contains.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-jaccard.aql
index 9852e67..051f4f8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-word-jaccard.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive-open.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive-open.aql
index 1a0ecbc..174c50f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive-open.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive-open.aql
@@ -15,7 +15,7 @@
 }
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive.aql
index ceca42e..6e4e659 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-conjunctive.aql
@@ -15,7 +15,7 @@
 }
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-open.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-open.aql
index 281f566..50088f4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-open.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey-open.aql
@@ -18,7 +18,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey.aql
index 365cfcb..9a950aa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/orders-index-custkey.aql
@@ -15,7 +15,7 @@
 }
 
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 
 load dataset Orders 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search-open.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search-open.aql
index 099e2d2..9a1906c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search-open.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search-open.aql
@@ -23,7 +23,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search.aql
index 62714ed..758e110 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/range-search.aql
@@ -23,7 +23,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-nullable.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-nullable.aql
index 6ca6d28..d920cfce 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-nullable.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-nullable.aql
@@ -14,7 +14,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-open.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-open.aql
index 44425cc..0a49ac1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-open.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-open.aql
@@ -14,7 +14,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
index c1e1890..19df2db 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
@@ -15,7 +15,7 @@
 }
 
 create dataset MyData(MyRecord)
-  partitioned by key id;
+  primary key id;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
index 0ea267c..c6e29e6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
@@ -25,9 +25,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
index f7e3a8b..46cd05c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
index 734a269..f2f330e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
@@ -26,9 +26,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
index 2e1a635..1df7a5b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
index 3b46c7d..a72d292 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
@@ -25,9 +25,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
index 3f025ed..ea05e33 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
index ea28721..e8b4b05 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
@@ -25,9 +25,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
index 458d31c..d33fc87 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
index e11b2f0..c46d534 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
@@ -25,9 +25,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
index 9732a51..c7534f3 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
index 1985878..ebec1d8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
@@ -26,9 +26,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
index 013b51e..29e17bc 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
index a602ca1..75ebe7b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
index 1c88536..9c305ec 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
index cd88072..048aee8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
index abb5e33..96c685d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
index bdac6f1..41e1d9e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
index 5e679e4..64e16ba 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
 
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
index 8fd8632..ef2730b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
index 50d13f1..d8af52c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
index a62c66d..c6b2252 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
@@ -24,9 +24,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
index 8c6570f..efdb925 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
@@ -23,9 +23,9 @@
   children: [ { name: string, age: int32? } ]
 }
 
-create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Customers(CustomerType) primary key cid;
   
-create dataset Customers2(CustomerType) partitioned by key cid;
+create dataset Customers2(CustomerType) primary key cid;
 
 load dataset Customers 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
index 3ac3583..b50a92b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
@@ -25,9 +25,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
index 7060fe6..6063e0b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
@@ -24,9 +24,9 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) partitioned by key id;
+create dataset DBLP(DBLPType) primary key id;
 
-create dataset CSX(CSXType) partitioned by key id;
+create dataset CSX(CSXType) primary key id;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql b/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql
index 9b25210..2127117 100644
--- a/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql
@@ -14,10 +14,10 @@
 }
 
 create dataset onektup(Schema) 
-partitioned by key id;
+primary key id;
 
 load dataset onektup 
-using "localfs"(("path"="nc1:///tmp/one.adm"));
+using localfs(("path"="nc1:///tmp/one.adm"));
 
 write output to nc1:"/tmp/foo.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
index f148d2e..a2e2c1d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
@@ -16,8 +16,8 @@
   interests: {{string}}
 }
 
-create dataset Users(UserType) partitioned by key uid;
-create dataset Visitors(VisitorType) partitioned by key vid;
+create dataset Users(UserType) primary key uid;
+create dataset Visitors(VisitorType) primary key vid;
 
 
 load dataset Users 
diff --git a/asterix-app/src/test/resources/runtimets/queries/misc/partition-by-nonexistent-field.aql b/asterix-app/src/test/resources/runtimets/queries/misc/partition-by-nonexistent-field.aql
new file mode 100644
index 0000000..10dbfc1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/partition-by-nonexistent-field.aql
@@ -0,0 +1,20 @@
+/*
+ * Description    : Tries to partition a dataset by a non-existent field
+ * Expected Result: An error reporting that this is not allowed
+ * Author: zheilbron
+ */
+ 
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open{
+name1:string
+}
+
+create dataset testds(TestType) primary key id;
+
+insert into dataset testds({"name1":"John","name2":"Smith"});
+
+for $l in dataset('testds')
+return $l
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/nestrecords/nestrecord.aql b/asterix-app/src/test/resources/runtimets/queries/nestrecords/nestrecord.aql
index c0b5e06..e038aeb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/nestrecords/nestrecord.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/nestrecords/nestrecord.aql
@@ -20,7 +20,7 @@
   address: AddressType?
 }
 
-create dataset testds(testtype) partitioned by key id;
+create dataset testds(testtype) primary key id;
 
 insert into dataset testds (
 { "id": "001", "name": "Person One", "address": {"street": "3019 DBH",  "city": "Irvine", "zip": 92697} }
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql
index 354757d..c5fb80c1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql
@@ -18,9 +18,9 @@
 optnl_fld:string?
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
-create dataset T2(TestType) partitioned by key id;
+create dataset T2(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql
index 9d4b90a..b31fe88 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql
@@ -19,9 +19,9 @@
 optnl_fld:string?
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
-create dataset T2(TestType) partitioned by key id;
+create dataset T2(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql
index 83888f3..9f923e7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql
@@ -17,10 +17,10 @@
 }
 
 // source dataset
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
 // target dataset
-create dataset T2(TestType) partitioned by key id;
+create dataset T2(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list-ordered01.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list-ordered01.aql
index 27935e0..b51c1fe 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list-ordered01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list-ordered01.aql
@@ -22,7 +22,7 @@
 batters:[[BatterType]]
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list01.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list01.aql
index 7ba1641..82823ce 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list01.aql
@@ -22,7 +22,7 @@
 batters:{{BatterType}}
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list02.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list02.aql
index 47dd921..45e4bac 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list02.aql
@@ -22,7 +22,7 @@
 batters:[[BatterType]]
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list03.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list03.aql
index 94a87c0..94faa44 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/heterog-list03.aql
@@ -23,7 +23,7 @@
 batters:[[BatterType]]?
 }
 
-create dataset T1(TestType) partitioned by key id;
+create dataset T1(TestType) primary key id;
 
 insert into dataset T1({
 "id":1234,
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-01.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-01.aql
index 0d26b5d..55d0497 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-01.aql
@@ -16,7 +16,7 @@
 name : string
 }
 
-create dataset testds(testType) partitioned by key id;
+create dataset testds(testType) primary key id;
 
 
 insert into dataset testds({"id": 123, "name": "John Doe", "hobbies": {{ "scuba", "music" }} }
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-12.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-12.aql
index ae21794..087ca36 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-12.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-12.aql
@@ -22,9 +22,9 @@
 name : string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "001", "name": "Person One", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-14.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-14.aql
index 6c517ca..7038437 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-14.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-14.aql
@@ -19,9 +19,9 @@
   id: string  
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds01 (
 { "id": "001" }
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-15.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-15.aql
index 2ac2567..d3547e2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-15.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-15.aql
@@ -26,7 +26,7 @@
 lat_lon: point
 }
 
-create dataset tdtst(Schema) partitioned by key id_32; 
+create dataset tdtst(Schema) primary key id_32; 
 
 insert into dataset tdtst(
 let $f1:=time("10:50:56:200+05:00")
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-16.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-16.aql
index 5e1a591..d07fce0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-16.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-16.aql
@@ -26,7 +26,7 @@
 lat_lon: point
 }
 
-create dataset tdtst(Schema) partitioned by key id_32; 
+create dataset tdtst(Schema) primary key id_32; 
 
 insert into dataset tdtst(
 let $f1:=time("10:50:56:200+05:00")
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-17.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-17.aql
index a590cf1..da83e0f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-17.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-17.aql
@@ -22,7 +22,7 @@
 lat_lon: point
 }
 
-create dataset tdtst(Schema) partitioned by key id_32; 
+create dataset tdtst(Schema) primary key id_32; 
 
 insert into dataset tdtst(
 let $f1:=time("10:50:56:200+05:00")
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-19.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-19.aql
index b406663..1d93992 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-19.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-19.aql
@@ -15,7 +15,7 @@
 id:int32
 }
 
-create dataset dtst01(TestType) partitioned by key id;
+create dataset dtst01(TestType) primary key id;
 
 insert into dtst01({"id":137});
 insert into dtst01({"id":117});
@@ -30,7 +30,7 @@
 dob:date
 }
 
-create dataset employee(Emp) partitioned by key id;
+create dataset employee(Emp) primary key id;
 
 insert into dataset employee({"id":201,"name":"John Doe","age":32,"sex":"M","dob":"1-1-82"});
 insert into dataset employee({"id":202,"name":"John Smith","age":30,"sex":"M","dob":"1-1-82"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-20.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-20.aql
index 29b4366..7f1be27 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-20.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-20.aql
@@ -16,7 +16,7 @@
 id:int32
 }
 
-create dataset dtst01(TestType) partitioned by key id;
+create dataset dtst01(TestType) primary key id;
 
 create type Emp as open {
 id:int32,
@@ -26,7 +26,7 @@
 dob:date?
 }
 
-create dataset employee(Emp) partitioned by key id;
+create dataset employee(Emp) primary key id;
 
 insert into dataset employee({"id":201,"name":"John Doe","age":32,"sex":"M","dob":date("1975-01-11")});
 insert into dataset employee({"id":202,"name":"John Smith","age":30,date("1982-05-23")});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-21.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-21.aql
index c52344e..3d955c8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-21.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-21.aql
@@ -14,7 +14,7 @@
 id:int32
 }
 
-create dataset dtst01(TestType) partitioned by key id;
+create dataset dtst01(TestType) primary key id;
 
 create type Emp as open {
 id:int32,
@@ -24,7 +24,7 @@
 dob:date
 }
 
-create dataset employee(Emp) partitioned by key id;
+create dataset employee(Emp) primary key id;
 
 insert into dataset employee({"id":201,"name":"John Doe","age":32,"sex":"M","dob":date("1975-01-11")});
 insert into dataset employee({"id":202,"name":"John Smith","age":30,"sex":"M","dob":date("1982-07-12")});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-22.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-22.aql
index cd9ac44..0b4c31f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-22.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-22.aql
@@ -20,7 +20,7 @@
 dob:date?
 }
 
-create dataset employee(Emp) partitioned by key id;
+create dataset employee(Emp) primary key id;
 
 //date("YYYY-MM-DD")
 insert into dataset employee({"id":201,"name":"John Doe","age":37,"dept":"HR","sex":"M","dob":date("1975-11-02")});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-24.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-24.aql
index 7012a5a..4123cf2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-24.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-24.aql
@@ -17,7 +17,7 @@
 opt_tag : {{ string }}
 }
 
-create dataset testds(testType) partitioned by key id;
+create dataset testds(testType) primary key id;
 
 insert into dataset testds({"id": 32,"name": "UCI","opt_tag":{{"optional text","put any text here","and more"}}});
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-25.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-25.aql
index b29b63a..ec0d4cd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-25.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-25.aql
@@ -17,7 +17,7 @@
 opt_tag : {{ string }}?
 }
 
-create dataset testds(testType) partitioned by key id;
+create dataset testds(testType) primary key id;
 
 insert into dataset testds({"id": 32,"name": "UCI","opt_tag":{{"optional text","put any text here","and more"}}});
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-26.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-26.aql
index f19e4a7..486b76e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-26.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-26.aql
@@ -18,7 +18,7 @@
 opt_tag : {{ string }}?
 }
 
-create dataset testds(testType) partitioned by key id;
+create dataset testds(testType) primary key id;
 
 insert into dataset testds({"id": 32,"name": "UCI"});
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-28.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-28.aql
index 8fdab75..acef21e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-28.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-28.aql
@@ -20,9 +20,9 @@
 name : string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "001", "name": "Person One", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-29.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-29.aql
index 9560430..5047342 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-29.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-29.aql
@@ -20,9 +20,9 @@
 name : string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "001", "name": "Person One", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-30.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-30.aql
index 42aa2e6..e52be74 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-30.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-30.aql
@@ -19,9 +19,9 @@
 name : string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "011", "name": "John Doe", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-31.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-31.aql
index 03b1754..5d5fa33 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-31.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-31.aql
@@ -18,9 +18,9 @@
 name : string
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "011", "name": "John Doe", "hobbies": {{"scuba", "music"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-32.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-32.aql
index f101e47..a79c53d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-32.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-32.aql
@@ -23,9 +23,9 @@
 interests : {{string}}
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-33.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-33.aql
index b75e6c6..809c93e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-33.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/open-closed-33.aql
@@ -24,9 +24,9 @@
 interests : {{string}}?
 }
 
-create dataset testds01(testtype01) partitioned by key id;
+create dataset testds01(testtype01) primary key id;
 
-create dataset testds02(testtype02) partitioned by key id;
+create dataset testds02(testtype02) primary key id;
 
 insert into dataset testds02 (
 { "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}});
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql
index e46286c..2094b4a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql
@@ -26,7 +26,7 @@
 }
 
 create dataset TweetMessages(TweetMessageType)
-partitioned by key tweetid;
+primary key tweetid;
 
 load dataset TweetMessages
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue236.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue236.aql
index 3d8ab69..7e859af 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue236.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue236.aql
@@ -31,7 +31,7 @@
 }
 
 create dataset TweetMessages(TweetMessageType)
-partitioned by key tweetid;
+primary key tweetid;
 
 
 insert into dataset TweetMessages(
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql
index a8d00f8..2668430 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql
@@ -26,7 +26,7 @@
 };
 
 create dataset TweetMessages(TweetMessageType)
-partitioned by key tweetid;
+primary key tweetid;
 
 insert into dataset TweetMessages(
    {
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql
index 36feac4..b3945a0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql
@@ -27,7 +27,7 @@
 };
 
 create dataset TweetMessages(TweetMessageType)
-partitioned by key tweetid;
+primary key tweetid;
 
 insert into dataset TweetMessages(
    {
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_02.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_02.aql
index 18f1c20..6718ff0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_02.aql
@@ -30,9 +30,9 @@
 }
 
 create dataset CustomerSomeSat02(CustomerType)
-  partitioned by key cid;
+  primary key cid;
 create dataset OrdersSomeSat02(OrderType)
-  partitioned by key oid;
+  primary key oid;
 
 load dataset CustomerSomeSat02 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..b356a56
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Tests whether a conflict between two closed field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+let $x := {"name": "john", "name": "smith"}
+return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql b/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql
index 2592c67..1b7cf02 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql
@@ -13,7 +13,7 @@
   name : string
 }
 
-create dataset testds(TestType) partitioned by key id;
+create dataset testds(TestType) primary key id;
 
 insert into dataset testds({"id": 123, "name": "John Doe", "address": { "zip": 92617} });
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..a5ac400
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests whether a conflict between an open and closed field name are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+ 
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+fname:string
+}
+
+create dataset testds(opentype) primary key id; 
+
+insert into dataset testds({'id': 1, 'fname': "name"});
+
+for $x in dataset('testds')
+return {$x.fname: "smith", lowercase("NAME"): "john"}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..225e596
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests whether a conflict between two open field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+ 
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+fname1: string,
+fname2: string
+}
+
+create dataset testds(opentype) primary key fname1; 
+
+insert into dataset testds({'fname1': "name", 'fname2': "name"});
+
+for $x in dataset('testds')
+return {$x.fname1: "john", $x.fname2: "smith"}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/10.aql b/asterix-app/src/test/resources/runtimets/queries/scan/10.aql
index 2d71d87..b255178 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/10.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/10.aql
@@ -12,7 +12,7 @@
 }
 
 create dataset DBLP1(DBLPType) 
-  partitioned by key id;
+  primary key id;
 
 // drop dataset DBLP1;
 load dataset DBLP1
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/20.aql b/asterix-app/src/test/resources/runtimets/queries/scan/20.aql
index 675f26d..17da0b0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/20.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/20.aql
@@ -13,7 +13,7 @@
 }
 
 create dataset DBLPadm(DBLPType) 
-  partitioned by key id;
+  primary key id;
 
 // drop dataset DBLPadm;
 load dataset DBLPadm 
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql
index ff04a36..86c8430 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql
@@ -21,7 +21,7 @@
 }
 
 create dataset DBLPadm(DBLPType) 
-  partitioned by key id;
+  primary key id;
 
 // drop dataset DBLPadm;
 load dataset DBLPadm 
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql
index 297e2f2..7dd319a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql
@@ -21,7 +21,7 @@
 }
 
 create dataset DBLPadm(DBLPType) 
-  partitioned by key id;
+  primary key id;
 
 // drop dataset DBLPadm;
 load dataset DBLPadm 
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/spatial_types_02.aql b/asterix-app/src/test/resources/runtimets/queries/scan/spatial_types_02.aql
index ea06b96..0997e4f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/spatial_types_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/spatial_types_02.aql
@@ -12,7 +12,7 @@
 }
 
 create dataset Spatial2(SpatialType) 
-	partitioned by key id;
+	primary key id;
 
 load dataset Spatial2 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/temp_types_02.aql b/asterix-app/src/test/resources/runtimets/queries/scan/temp_types_02.aql
index 064385c..a8654bd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/scan/temp_types_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/temp_types_02.aql
@@ -11,7 +11,7 @@
 }
 
 create dataset Temp2(TempType) 
-	partitioned by key id;
+	primary key id;
 
 load dataset Temp2 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-edit-distance.aql
index d3eed71..3d6dee4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-edit-distance.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-similarity-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-similarity-jaccard.aql
index 0c11edb..1bef743 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-similarity-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/fuzzyeq-similarity-jaccard.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-check_query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-check_query.aql
index 01bea0b..836fdb6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-check_query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-check_query.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query.aql
index aa5b067..ba3b85e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query.aql
index a2373af..25cb071 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query.aql
index 05f3a61..20afc67 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset DBLP(DBLPType) 
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset DBLP 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql
index 0face3b..81b8bd2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql
@@ -13,7 +13,7 @@
 create nodegroup group1 if not exists on nc1, nc2;
 
 create dataset TwitterData(Tweet)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 
 load dataset TwitterData 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql
index e755aa9..3fe1355 100644
--- a/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql
@@ -17,7 +17,7 @@
   circle: circle
 }
 
-create dataset MyData(SpatialType) partitioned by key id;
+create dataset MyData(SpatialType) primary key id;
 create index rtree_index1 on MyData(point) type rtree;
 create index rtree_index2 on MyData(line1) type rtree;
 create index rtree_index3 on MyData(poly1) type rtree;
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
index a66b00f..7516bea 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
@@ -16,7 +16,7 @@
 cpt:[int32]
 }
 
-create dataset testds(TestType) partitioned by key id;
+create dataset testds(TestType) primary key id;
 
 // insert codepoint data into internal dataset testds here into the cpt attribute
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
index 832efbc..257d992 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
@@ -15,7 +15,7 @@
 name:string
 }
 
-create dataset testds(TestType) partitioned by key name;
+create dataset testds(TestType) primary key name;
 
 insert into dataset testds({"name":"Jim Jones"});
 insert into dataset testds({"name":"Ravi Kumar"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
index 2f7b83e..4d9e5b2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
@@ -16,7 +16,7 @@
 id:int32
 }
 
-create dataset testds1(TestType1) partitioned by key id;
+create dataset testds1(TestType1) primary key id;
 
 insert into dataset testds1({"fname":"Test","lname":"Test","id":123});
 insert into dataset testds1({"fname":"Testa","lname":"Test","id":124});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
index 8aed603..baa7d0b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
@@ -15,7 +15,7 @@
 name:string
 }
 
-create dataset testds(TestType) partitioned by key name;
+create dataset testds(TestType) primary key name;
 
 insert into dataset testds({"name":"John Smith"});
 insert into dataset testds({"name":"John Doe"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
index 0b3941d..5266fa1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
@@ -17,7 +17,7 @@
 lname:string
 }
 
-create dataset testds(TestType) partitioned by key id;
+create dataset testds(TestType) primary key id;
 
 // insert string data into internal dataset testds into the name attribute
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
index bba2a7f..ddff7ed 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
@@ -15,7 +15,7 @@
 name:string
 }
 
-create dataset testds(TestType) partitioned by key name;
+create dataset testds(TestType) primary key name;
 
 insert into dataset testds({"name":"Maradona"});
 insert into dataset testds({"name":"Pele"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
index fbdcba4..1a33fdf 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
@@ -15,7 +15,7 @@
 name : string
 }
 
-create dataset testdst(TestType) partitioned by key name;
+create dataset testdst(TestType) primary key name;
 
 insert into dataset testdst({"name":"UC Berkeley"});
 insert into dataset testdst({"name":"UC Irvine"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
index 82d21c2..bfeff2d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
@@ -14,7 +14,7 @@
 name : string
 }
 
-create dataset testdst(TestType) partitioned by key name;
+create dataset testdst(TestType) primary key name;
 
 insert into dataset testdst({"name":"UC Berkeley"});
 insert into dataset testdst({"name":"UC Irvine"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
index 411dacf..301af52 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
@@ -17,7 +17,7 @@
 name:string
 }
 
-create dataset testds(TestType) partitioned by key name;
+create dataset testds(TestType) primary key name;
 
 insert into dataset testds({"name":"Maradona"});
 insert into dataset testds({"name":"Pele"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/distinct_by.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/distinct_by.aql
index 95d715e..3e41042 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/distinct_by.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/distinct_by.aql
@@ -24,7 +24,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/group_no_agg.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/group_no_agg.aql
index dedaa7f..8b941e4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/group_no_agg.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/group_no_agg.aql
@@ -10,7 +10,7 @@
 }
 
 create dataset Regions_group_no_agg(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 
 write output to nc1:"rttest/tpch_group_no_agg.adm";
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item.aql
index 3b641a4..b775f09 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item.aql
@@ -89,21 +89,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64.aql
index cfac014..27fa512 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64.aql
@@ -89,21 +89,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock.aql
index 245c7f5..9e4b165 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping.aql
index 9dcade8..b541615 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution.aql
index 9a91177..c4a987a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect.aql
index a38b1d6..4ea7988 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier.aql
index 49b0c03..29830a9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship.aql
index ad16d3c..978fb0f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue.aql
index 05cf693..92e4083 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer.aql
index 1347ff5..9ab4f83 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue.aql
index b856eed..c83f663 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
index af39b3f..b6de1fa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
@@ -22,7 +22,7 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion.aql
index bdb591f..2143cfa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting.aql
index f544e09..32cf149 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity.aql
index 29131c8..b2ac2d0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier.aql
index 5490213..c5e17d6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt.aql
index 68fb864..c3fcc25 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority.aql
index 3f1c7ec..6d755d2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume.aql
index d345b3b..e64d98a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change.aql
index 3ca0424..dee85bb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping.aql
index c91eca5..6432361 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share.aql
index 420a179..2e0eefb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share.aql
@@ -90,21 +90,21 @@
 }
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset Partsupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt.aql
index 33c2aad..21cdcdd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt.aql
@@ -91,21 +91,21 @@
 
 
 create dataset LineItem(LineItemType)
-  partitioned by key l_orderkey, l_linenumber;
+  primary key l_orderkey, l_linenumber;
 create dataset Orders(OrderType)
-  partitioned by key o_orderkey;
+  primary key o_orderkey;
 create dataset Supplier(SupplierType)
-  partitioned by key s_suppkey;
+  primary key s_suppkey;
 create dataset Region(RegionType) 
-  partitioned by key r_regionkey;
+  primary key r_regionkey;
 create dataset Nation(NationType) 
-  partitioned by key n_nationkey;
+  primary key n_nationkey;
 create dataset Part(PartType)
-  partitioned by key p_partkey;
+  primary key p_partkey;
 create dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey;  
+  primary key ps_partkey, ps_suppkey;  
 create dataset Customer(CustomerType) 
-  partitioned by key c_custkey;
+  primary key c_custkey;
 
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql
index b16e2dd..8a09ea2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql
@@ -13,7 +13,7 @@
 id : int32
 }
 
-create dataset test.t1(TestType) partitioned by key id;
+create dataset test.t1(TestType) primary key id;
 
 insert into dataset test.t1({"id":345});
 insert into dataset test.t1({"id":315});
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm b/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
index fb52e3b..470d1f8 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
@@ -1 +1 @@
-{ "int8": 80i8, "int16": 160i16, "int32": 320, "int64": 640i64, "int8": -80i8, "int16": -160i16, "int32": -320, "int64": -640i64, "int64_min": -9223372036854775808i64 }
\ No newline at end of file
+{ "int8": 80i8, "int16": 160i16, "int32": 320, "int64": 640i64, "int8_2": -80i8, "int16_2": -160i16, "int32_2": -320, "int64_2": -640i64, "int64_min": -9223372036854775808i64 }
diff --git a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
index 87619a8..e78ad8f 100644
--- a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
+++ b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ], "orderList": {{ 10, 5 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ], "orderList": {{ 10, 775 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ], "orderList": {{ 1000, 775 }} }
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ] }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
index 7648e4a..e78ad8f 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ], "orderList": {{ 10, 5 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ], "orderList": {{ 10, 775 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ], "orderList": {{ 1000, 775 }} }
\ No newline at end of file
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ] }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
index 903c00d..4e02c4b 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "list": [ "ORDER_DELIVERED", "Kathryne" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "Kathryne", "item3": null }
-{ "orderid": 10, "ordertot": 7.206f, "list": [ "ORDER_DELIVERED", "ALEX" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "ALEX", "item3": null }
-{ "orderid": 100, "ordertot": 124.26f, "list": [ "ORDER_DELIVERED", "YASSER" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "YASSER", "item3": null }
-{ "orderid": 10, "ordertot": 14.2326f, "list": [ "ORDER_DELIVERED", "MIKE" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "MIKE", "item3": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "list": [ "ORDER_DELIVERED", "Kathryne" ], "item1": "ORDER_DELIVERED", "item2": "Kathryne", "item3": null }
+{ "orderid": 10, "ordertot": 7.206f, "list": [ "ORDER_DELIVERED", "ALEX" ], "item1": "ORDER_DELIVERED", "item2": "ALEX", "item3": null }
+{ "orderid": 100, "ordertot": 124.26f, "list": [ "ORDER_DELIVERED", "YASSER" ], "item1": "ORDER_DELIVERED", "item2": "YASSER", "item3": null }
+{ "orderid": 10, "ordertot": 14.2326f, "list": [ "ORDER_DELIVERED", "MIKE" ], "item1": "ORDER_DELIVERED", "item2": "MIKE", "item3": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
index f22ea7f..3992f7d 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null, "item10": null }
-{ "orderid": 10, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null, "item10": null }
-{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null, "item10": null }
-{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f }, "item10": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null, "item10": null }
+{ "orderid": 10, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null, "item10": null }
+{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null, "item10": null }
+{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f }, "item10": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
index dd3420e..4d8b37c 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 10, "ordertot": 7.206f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 10, "ordertot": 7.206f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [  ], "emptyunorderedlist": {{  }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 6956e4b..e8e7d72 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -1963,6 +1963,12 @@
     </test-case>
   </test-group>
   <test-group name="misc">
+  <test-case FilePath="misc">
+      <compilation-unit name="partition-by-nonexistent-field">
+        <output-file compare="Text">partition-by-nonexistent-field.adm</output-file>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="misc">
       <compilation-unit name="float_01">
         <output-file compare="Text">float_01.adm</output-file>
@@ -2626,6 +2632,24 @@
         <output-file compare="Text">open-record-constructor_02.adm</output-file>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="records">
+      <compilation-unit name="closed-closed-fieldname-conflict_issue173">
+        <output-file compare="Text">closed-closed-fieldname-conflict_issue173.adm</output-file>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+  <test-case FilePath="records">
+      <compilation-unit name="open-closed-fieldname-conflict_issue173">
+        <output-file compare="Text">open-closed-fieldname-conflict_issue173.adm</output-file>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="records">
+      <compilation-unit name="open-open-fieldname-conflict_issue173">
+        <output-file compare="Text">open-open-fieldname-conflict_issue173.adm</output-file>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="scan">
     <test-case FilePath="scan">
diff --git a/asterix-app/src/test/resources/spatial/local/spatial-drop.aql b/asterix-app/src/test/resources/spatial/local/spatial-drop.aql
index 61d4913..fc881ad 100644
--- a/asterix-app/src/test/resources/spatial/local/spatial-drop.aql
+++ b/asterix-app/src/test/resources/spatial/local/spatial-drop.aql
@@ -11,6 +11,6 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset MyData(MyRecord)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 drop dataset MyData;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/spatial/local/spatial-load.aql b/asterix-app/src/test/resources/spatial/local/spatial-load.aql
index 6c135f3..1df33c0 100644
--- a/asterix-app/src/test/resources/spatial/local/spatial-load.aql
+++ b/asterix-app/src/test/resources/spatial/local/spatial-load.aql
@@ -11,7 +11,7 @@
 set format "edu.uci.ics.asterix.runtime.formats.nontagged.NonTaggedDataFormat";
 
 declare dataset MyData(MyRecord)
-  partitioned by key id on group1;
+  primary key id on group1;
 
 load dataset MyData 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/enlist_data.aql b/asterix-app/src/test/resources/tpch/queries/asterix/enlist_data.aql
index 2eb06f5..b0396f9 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/enlist_data.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/enlist_data.aql
@@ -89,21 +89,21 @@
   asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 enlist dataset Customers;
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/inlined_q18_large_volume_customer.aql b/asterix-app/src/test/resources/tpch/queries/asterix/inlined_q18_large_volume_customer.aql
index 1ac9c1c..bb21d7e 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/inlined_q18_large_volume_customer.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/inlined_q18_large_volume_customer.aql
@@ -46,11 +46,11 @@
       asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to asterix-001:"/tmp/inlined_q18_large_volume_customer.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_adm.aql b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_adm.aql
index e4b3a3b..7b872f0 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_adm.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_adm.aql
@@ -89,21 +89,21 @@
   asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 load dataset LineItems 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_100x.aql b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_100x.aql
index 1d40ba7..c4ccbe0 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_100x.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_100x.aql
@@ -89,21 +89,21 @@
   asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 load dataset Customers 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_1x.aql b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_1x.aql
index bb4a49d..654dcb6 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_1x.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/load_data_tbl_1x.aql
@@ -89,21 +89,21 @@
   asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 load dataset Customers 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/q1_pricing_summary_report.aql b/asterix-app/src/test/resources/tpch/queries/asterix/q1_pricing_summary_report.aql
index b29e7a6..411fdbb 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/q1_pricing_summary_report.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/q1_pricing_summary_report.aql
@@ -23,7 +23,7 @@
       asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 write output to asterix-001:"/home/onose/hyracks-asterix/results/q1_pricing_summary_report.adm";
  
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql b/asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql
index 71ed6db..6f52101 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql
@@ -46,11 +46,11 @@
       asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to asterix-001:"/home/onose/hyracks-asterix/results/q3_shipping_priority.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/q5_local_supplier_volume.aql b/asterix-app/src/test/resources/tpch/queries/asterix/q5_local_supplier_volume.aql
index 8d0d6dd..7544d19 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/q5_local_supplier_volume.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/q5_local_supplier_volume.aql
@@ -69,17 +69,17 @@
       asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
   
 write output to asterix-001:"/home/onose/hyracks-asterix/results/q5_local_supplier.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/q9_product_type_profit.aql b/asterix-app/src/test/resources/tpch/queries/asterix/q9_product_type_profit.aql
index 3067fbe..164869a 100644
--- a/asterix-app/src/test/resources/tpch/queries/asterix/q9_product_type_profit.aql
+++ b/asterix-app/src/test/resources/tpch/queries/asterix/q9_product_type_profit.aql
@@ -73,17 +73,17 @@
       asterix-005, asterix-006, asterix-007, asterix-008, asterix-009, asterix-010;
       
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
   
 write output to asterix-001:"/home/onose/hyracks-asterix/results/q9_product_type_profit.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/inlined_q18_large_volume_customer.aql b/asterix-app/src/test/resources/tpch/queries/local/inlined_q18_large_volume_customer.aql
index abd06af..280a1d0 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/inlined_q18_large_volume_customer.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/inlined_q18_large_volume_customer.aql
@@ -45,11 +45,11 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/inlined_q18_large_volume_customer.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/load_adm_data.aql b/asterix-app/src/test/resources/tpch/queries/local/load_adm_data.aql
index b7e5b3d..d31c421 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/load_adm_data.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/load_adm_data.aql
@@ -88,21 +88,21 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 load dataset LineItems 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_0.001x_2nodes.aql b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_0.001x_2nodes.aql
index 0d03e5d..47724fa 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_0.001x_2nodes.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_0.001x_2nodes.aql
@@ -88,21 +88,21 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 load dataset LineItems 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_10x_1node.aql b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_10x_1node.aql
index 7c8fc8c..49e2a9a 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_10x_1node.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_10x_1node.aql
@@ -88,21 +88,21 @@
 declare nodegroup group1 on nc1;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 load dataset LineItems 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_1x_1node.aql b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_1x_1node.aql
index b6cf6f8..3e6ccc4 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_1x_1node.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_1x_1node.aql
@@ -88,21 +88,21 @@
 declare nodegroup group1 on nc1;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 load dataset LineItems 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_20x_2node.aql b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_20x_2node.aql
index 606cde1..f44d388 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_20x_2node.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/load_tbl_data_20x_2node.aql
@@ -88,21 +88,21 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 load dataset LineItems 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/tpch/queries/local/orders-index-create.aql b/asterix-app/src/test/resources/tpch/queries/local/orders-index-create.aql
index e369f10..9c5e361 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/orders-index-create.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/orders-index-create.aql
@@ -17,6 +17,6 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 create index idx_Orders_Custkey on Orders(o_custkey);
diff --git a/asterix-app/src/test/resources/tpch/queries/local/orders-index-search.aql b/asterix-app/src/test/resources/tpch/queries/local/orders-index-search.aql
index f4c9fd9..66e88a5 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/orders-index-search.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/orders-index-search.aql
@@ -17,7 +17,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 
 declare index idx_Orders_Custkey on Orders(o_custkey);
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/q1_pricing_summary_report.aql b/asterix-app/src/test/resources/tpch/queries/local/q1_pricing_summary_report.aql
index a69528c..9ab0322 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/q1_pricing_summary_report.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/q1_pricing_summary_report.aql
@@ -22,7 +22,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 // for external datasets, use:
 //
diff --git a/asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql b/asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql
index b5c27cc..cadc5c9 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql
@@ -45,11 +45,11 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 
 write output to nc1:"/tmp/q3_shipping_priority.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/q5_local_supplier_volume.aql b/asterix-app/src/test/resources/tpch/queries/local/q5_local_supplier_volume.aql
index 9fe2ed6..724d58b 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/q5_local_supplier_volume.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/q5_local_supplier_volume.aql
@@ -68,17 +68,17 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
   
 write output to nc1:"/tmp/q5_local_supplier_volume.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/q9_product_type_profit.aql b/asterix-app/src/test/resources/tpch/queries/local/q9_product_type_profit.aql
index c0643b1..5407270 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/q9_product_type_profit.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/q9_product_type_profit.aql
@@ -72,17 +72,17 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
   
 write output to nc1:"/tmp/q9_product_type_profit.adm";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/scan_filter_lineitem.aql b/asterix-app/src/test/resources/tpch/queries/local/scan_filter_lineitem.aql
index 3855746..ccddad0 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/scan_filter_lineitem.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/scan_filter_lineitem.aql
@@ -22,7 +22,7 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 
 // load dataset LineItems from nc1:"/opt/tpch/tengigs/lineitem.tbl" delimited by "|";
 
diff --git a/asterix-app/src/test/resources/tpch/queries/local/write-custorder.aql b/asterix-app/src/test/resources/tpch/queries/local/write-custorder.aql
index 9757ff8..b767d57 100644
--- a/asterix-app/src/test/resources/tpch/queries/local/write-custorder.aql
+++ b/asterix-app/src/test/resources/tpch/queries/local/write-custorder.aql
@@ -50,13 +50,13 @@
 declare nodegroup group1 on nc1, nc2;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset CustOrder(CustOrderType)
-  partitioned by key co_custkey on group1;
+  primary key co_custkey on group1;
 
 write into dataset CustOrder 
 ( for $c in dataset('Customers')
diff --git a/asterix-app/src/test/resources/tpch/queries/rainbow/load_data_tbl_50x.aql b/asterix-app/src/test/resources/tpch/queries/rainbow/load_data_tbl_50x.aql
index 9635891..7d0295d 100644
--- a/asterix-app/src/test/resources/tpch/queries/rainbow/load_data_tbl_50x.aql
+++ b/asterix-app/src/test/resources/tpch/queries/rainbow/load_data_tbl_50x.aql
@@ -89,21 +89,21 @@
 rainbow-04, rainbow-05;
 
 declare dataset LineItems(LineItemType)
-  partitioned by key l_orderkey, l_linenumber on group1;
+  primary key l_orderkey, l_linenumber on group1;
 declare dataset Orders(OrderType)
-  partitioned by key o_orderkey on group1;
+  primary key o_orderkey on group1;
 declare dataset Customers(CustomerType) 
-  partitioned by key c_custkey on group1;
+  primary key c_custkey on group1;
 declare dataset Suppliers(SupplierType)
-  partitioned by key s_suppkey on group1;
+  primary key s_suppkey on group1;
 declare dataset Nations(NationType) 
-  partitioned by key n_nationkey on group1;
+  primary key n_nationkey on group1;
 declare dataset Regions(RegionType)
-  partitioned by key r_regionkey on group1;
+  primary key r_regionkey on group1;
 declare dataset Parts(PartType)
-  partitioned by key p_partkey on group1;
+  primary key p_partkey on group1;
 declare dataset PartSupp(PartSuppType)
-  partitioned by key ps_partkey, ps_suppkey on group1;  
+  primary key ps_partkey, ps_suppkey on group1;  
 
 
 load dataset Customers from 
diff --git a/asterix-aql/pom.xml b/asterix-aql/pom.xml
index 7ac2cbb..7617582 100644
--- a/asterix-aql/pom.xml
+++ b/asterix-aql/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -13,8 +14,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 			<plugin>
@@ -36,14 +37,15 @@
 						<goals>
 							<goal>jjdoc</goal>
 						</goals>
-                        <phase>process-sources</phase>
+						<phase>process-sources</phase>
 					</execution>
 				</executions>
 			</plugin>
 		</plugins>
 		<pluginManagement>
 			<plugins>
-				<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
 				<plugin>
 					<groupId>org.eclipse.m2e</groupId>
 					<artifactId>lifecycle-mapping</artifactId>
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 4d181ee..e296266 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -17,6 +17,7 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import edu.uci.ics.asterix.aql.literal.FloatLiteral;
 import edu.uci.ics.asterix.aql.literal.DoubleLiteral;
 import edu.uci.ics.asterix.aql.literal.FalseLiteral;
@@ -623,7 +624,7 @@
   Identifier dataverseName = null;
   Identifier datasetName = null;
   boolean alreadySorted = false;
-  String adapterClassname;
+  String adapterName;
   Map<String,String> properties;
   Pair<Identifier,Identifier> nameComponents = null;
 }
@@ -636,12 +637,11 @@
    }
    
    "using"
-
-    <STRING_LITERAL>
+  
     {
-      adapterClassname = removeQuotesAndEscapes(token.image);
+    	adapterName = getAdapterName();
     }
-
+   
     {
       properties = getConfiguration();
     }
@@ -652,11 +652,31 @@
         
   ";"
   {
-     return new LoadFromFileStatement(dataverseName, datasetName, adapterClassname, properties, alreadySorted);
+     return new LoadFromFileStatement(dataverseName, datasetName, adapterName, properties, alreadySorted);
   }   
 }
 
 
+String getAdapterName() throws ParseException :
+{
+	String adapterName = null;
+}
+{
+    ( 
+      <IDENTIFIER> {
+     	adapterName = (new Identifier(token.image)).getValue();; 
+      }
+      | 
+      <STRING_LITERAL>
+      {
+        adapterName = removeQuotesAndEscapes(token.image);
+      }
+    )
+    {
+	return adapterName;
+	}
+}
+
 
 DatasetDecl DatasetDeclaration(DatasetType datasetType) throws ParseException :
 {
@@ -721,21 +741,16 @@
 InternalDetailsDecl InternalDatasetDeclaration() throws ParseException :
 {
     InternalDetailsDecl idd = null;
-    List<String> partitioningExprs = new ArrayList<String>();
+    List<String> primaryKeyFields = new ArrayList<String>();
     Identifier nodeGroupName=null;
 }
 {
-  "partitioned" "by" "key"
-  < IDENTIFIER >
-  {
-         partitioningExprs.add(token.image); 
-  }
   (
-    "," < IDENTIFIER >
     {
-         partitioningExprs.add(token.image); 
+  	  primaryKeyFields = getPrimaryKeyFields();
     }
-  )*
+  )
+  
   (
   "on" < IDENTIFIER >
     {
@@ -744,7 +759,7 @@
   )?
   
   {
-    idd = new InternalDetailsDecl(nodeGroupName, partitioningExprs);
+    idd = new InternalDetailsDecl(nodeGroupName, primaryKeyFields);
     return idd;
   }
 }
@@ -752,7 +767,7 @@
 ExternalDetailsDecl ExternalDatasetDeclaration() throws ParseException :
 {
   ExternalDetailsDecl edd = null;
-  String adapterClassname = null;
+  String adapterName = null;
   Map < String, String > properties;
 }
 {
@@ -761,10 +776,8 @@
   }
  
     "using"
-    
-     <STRING_LITERAL>
     {
-      adapterClassname = removeQuotesAndEscapes(token.image);
+    	adapterName = getAdapterName();
     }
 
     {
@@ -773,7 +786,7 @@
 
     {
     	  edd = new ExternalDetailsDecl();
-		  edd.setAdapter(adapterClassname);
+		  edd.setAdapter(adapterName);
    		  edd.setProperties(properties);
     } 
  
@@ -785,10 +798,10 @@
 FeedDetailsDecl FeedDatasetDeclaration() throws ParseException :
 {
     FeedDetailsDecl fdd = null;
-    String adapterFactoryClassname = null;
+    String adapterName = null;
     Map < String, String > properties;
 	Pair<Identifier,Identifier> nameComponents;
-	List<String> partitioningExprs = new ArrayList<String>();
+	List<String> primaryKeyFields = new ArrayList<String>();
     Identifier nodeGroupName=null;
     FunctionSignature appliedFunction=null;
 	String dataverse;
@@ -797,10 +810,8 @@
 }
 {
    "using"
-   
-    <STRING_LITERAL>
     {
-      adapterFactoryClassname = removeQuotesAndEscapes(token.image);
+    	adapterName = getAdapterName();
     }
 
     {
@@ -824,17 +835,12 @@
   }   
   )?
   
-  "partitioned" "by" "key"
-  < IDENTIFIER >
-  {
-    	 partitioningExprs.add(token.image);
-  }
   (
-    "," < IDENTIFIER >
     {
-    	 partitioningExprs.add(token.image);
+  	  primaryKeyFields  = getPrimaryKeyFields();
     }
-  )*
+  )
+  
   (
   "on" < IDENTIFIER >
   {
@@ -843,11 +849,38 @@
   )?
   
   {
-    fdd = new FeedDetailsDecl(adapterFactoryClassname, properties, appliedFunction, nodeGroupName, partitioningExprs);
+    fdd = new FeedDetailsDecl(adapterName, properties, appliedFunction, nodeGroupName, primaryKeyFields);
     return fdd;
   }
 }
 
+List<String> getPrimaryKeyFields()  throws ParseException :
+{
+	List<String> primaryKeyFields = new ArrayList<String>();
+}
+{
+
+  "primary" "key"
+  < IDENTIFIER >
+  {
+    	 primaryKeyFields.add(token.image);
+  }
+  (
+    "," < IDENTIFIER >
+    {
+    	 primaryKeyFields.add(token.image);
+    }
+  )*
+  {
+   	return primaryKeyFields;
+  }
+  
+}
+
+
+
+
+
 ControlFeedStatement ControlFeedDeclaration(ControlFeedStatement.OperationType operationType) throws ParseException :
 {
   Pair<Identifier,Identifier> nameComponents = null;
@@ -882,7 +915,7 @@
 
 Map<String,String> getConfiguration()  throws ParseException :
 {
-	Map<String,String> configuration = new HashMap<String,String>();
+	Map<String,String> configuration = new LinkedHashMap<String,String>();
 	String key;
 	String value;
 }
diff --git a/asterix-common/pom.xml b/asterix-common/pom.xml
index ee81e75..0994109 100644
--- a/asterix-common/pom.xml
+++ b/asterix-common/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -15,8 +16,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 		</plugins>
diff --git a/asterix-external-data/pom.xml b/asterix-external-data/pom.xml
index 3076323..337da7f 100644
--- a/asterix-external-data/pom.xml
+++ b/asterix-external-data/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 			<plugin>
@@ -50,14 +51,12 @@
 				<artifactId>maven-surefire-plugin</artifactId>
 				<version>2.7.2</version>
 				<configuration>
-					<!--
-						doesn't work from m2eclipse, currently
-						<additionalClasspathElements>
-						<additionalClasspathElement>${basedir}/src/main/resources</additionalClasspathElement>
-						</additionalClasspathElements>
-					-->
+					<!-- doesn't work from m2eclipse, currently <additionalClasspathElements> 
+						<additionalClasspathElement>${basedir}/src/main/resources</additionalClasspathElement> 
+						</additionalClasspathElements> -->
 					<forkMode>pertest</forkMode>
-					<argLine>-enableassertions -Xmx${test.heap.size}m -Dfile.encoding=UTF-8
+					<argLine>-enableassertions -Xmx${test.heap.size}m
+						-Dfile.encoding=UTF-8
 						-Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
 					<includes>
 						<include>**/*TestSuite.java</include>
@@ -102,39 +101,39 @@
 			<version>1.3.1-201002241208</version>
 			<scope>test</scope>
 		</dependency>
-                <dependency>
-                        <groupId>org.twitter4j</groupId>
-                        <artifactId>twitter4j-core</artifactId>
-                        <version>2.2.3</version>
-                </dependency>
-                <dependency>
-                        <groupId>org.apache.hadoop</groupId>
-                        <artifactId>hadoop-core</artifactId>
-                        <version>0.20.2</version>
-                        <type>jar</type>
-                        <scope>compile</scope>
-                </dependency>
-                <dependency>
-                        <groupId>net.java.dev.rome</groupId>
-                        <artifactId>rome-fetcher</artifactId>
-                        <version>1.0.0</version>
-                        <type>jar</type>
-                        <scope>compile</scope>
-                </dependency>
-                <dependency>
-                         <groupId>rome</groupId>
-                         <artifactId>rome</artifactId>
-                         <version>1.0.1-modified-01</version>
-                </dependency>
-	        <dependency>
-		         <groupId>edu.uci.ics.hyracks</groupId>
-		         <artifactId>hyracks-dataflow-hadoop</artifactId>
-	        </dependency>
-<dependency>
-            <groupId>jdom</groupId>
-            <artifactId>jdom</artifactId>
-            <version>1.0</version>
-        </dependency>
+		<dependency>
+			<groupId>org.twitter4j</groupId>
+			<artifactId>twitter4j-core</artifactId>
+			<version>2.2.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.hadoop</groupId>
+			<artifactId>hadoop-core</artifactId>
+			<version>0.20.2</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>net.java.dev.rome</groupId>
+			<artifactId>rome-fetcher</artifactId>
+			<version>1.0.0</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>rome</groupId>
+			<artifactId>rome</artifactId>
+			<version>1.0.1-modified-01</version>
+		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.hyracks</groupId>
+			<artifactId>hyracks-dataflow-hadoop</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>jdom</groupId>
+			<artifactId>jdom</artifactId>
+			<version>1.0</version>
+		</dependency>
 	</dependencies>
 
 </project>
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/FileSystemBasedAdapter.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/FileSystemBasedAdapter.java
index e46705d..9f8cedc 100644
--- a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/FileSystemBasedAdapter.java
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/FileSystemBasedAdapter.java
@@ -17,8 +17,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.external.util.DNSResolverFactory;
+import edu.uci.ics.asterix.external.util.INodeResolver;
+import edu.uci.ics.asterix.external.util.INodeResolverFactory;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -36,12 +41,17 @@
 
     private static final long serialVersionUID = 1L;
 
-    protected ITupleParserFactory parserFactory;
-    protected ITupleParser parser;
-
+    public static final String NODE_RESOLVER_FACTORY_PROPERTY = "node.Resolver";
     public static final String KEY_DELIMITER = "delimiter";
     public static final String KEY_PATH = "path";
 
+    protected ITupleParserFactory parserFactory;
+    protected ITupleParser parser;
+    protected static INodeResolver nodeResolver;
+
+    private static final INodeResolver DEFAULT_NODE_RESOLVER = new DNSResolverFactory().createNodeResolver();
+    private static final Logger LOGGER = Logger.getLogger(FileSystemBasedAdapter.class.getName());
+
     public abstract InputStream getInputStream(int partition) throws IOException;
 
     public FileSystemBasedAdapter(IAType atype) {
@@ -118,4 +128,32 @@
         }
 
     }
+
+    protected INodeResolver getNodeResolver() {
+        if (nodeResolver == null) {
+            nodeResolver = initNodeResolver();
+        }
+        return nodeResolver;
+    }
+
+    private static INodeResolver initNodeResolver() {
+        INodeResolver nodeResolver = null;
+        String configuredNodeResolverFactory = System.getProperty(NODE_RESOLVER_FACTORY_PROPERTY);
+        if (configuredNodeResolverFactory != null) {
+            try {
+                nodeResolver = ((INodeResolverFactory) (Class.forName(configuredNodeResolverFactory).newInstance()))
+                        .createNodeResolver();
+
+            } catch (Exception e) {
+                if (LOGGER.isLoggable(Level.WARNING)) {
+                    LOGGER.log(Level.WARNING, "Unable to create node resolver from the configured classname "
+                            + configuredNodeResolverFactory + "\n" + e.getMessage());
+                }
+                nodeResolver = DEFAULT_NODE_RESOLVER;
+            }
+        } else {
+            nodeResolver = DEFAULT_NODE_RESOLVER;
+        }
+        return nodeResolver;
+    }
 }
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/NCFileSystemAdapter.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/NCFileSystemAdapter.java
index bcc90c8..ae9b412 100644
--- a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/NCFileSystemAdapter.java
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/NCFileSystemAdapter.java
@@ -21,6 +21,7 @@
 import java.io.InputStream;
 import java.util.Map;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
 import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
@@ -60,7 +61,7 @@
         return AdapterType.READ;
     }
 
-    private void configureFileSplits(String[] splits) {
+    private void configureFileSplits(String[] splits)  {
         if (fileSplits == null) {
             fileSplits = new FileSplit[splits.length];
             String nodeName;
@@ -77,10 +78,12 @@
         }
     }
 
-    private void configurePartitionConstraint() {
+    private void configurePartitionConstraint() throws AsterixException {
         String[] locs = new String[fileSplits.length];
+        String location;
         for (int i = 0; i < fileSplits.length; i++) {
-            locs[i] = fileSplits[i].getNodeName();
+            location = getNodeResolver().resolveNode(fileSplits[i].getNodeName());
+            locs[i] = location;
         }
         partitionConstraint = new AlgebricksAbsolutePartitionConstraint(locs);
     }
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/feed/lifecycle/FeedManager.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/feed/lifecycle/FeedManager.java
index 29e4486..8314267 100644
--- a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/feed/lifecycle/FeedManager.java
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/feed/lifecycle/FeedManager.java
@@ -43,9 +43,7 @@
                 for (LinkedBlockingQueue<IFeedMessage> queue : operatorQueues) {
                     queue.put(feedMessage);
                 }
-            } else {
-                throw new AsterixException("Unable to deliver message. Unknown feed :" + feedId);
-            }
+            } 
         } catch (Exception e) {
             throw new AsterixException(e);
         }
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolver.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolver.java
new file mode 100644
index 0000000..ff6bbdf
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolver.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+import java.util.Random;
+import java.util.Set;
+
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.om.util.AsterixRuntimeUtil;
+
+/**
+ * Resolves a value (DNS/IP Address) to the id of a Node Controller running at the location.
+ */
+public class DNSResolver implements INodeResolver {
+
+    private static Random random = new Random();
+
+    @Override
+    public String resolveNode(String value) throws AsterixException {
+        try {
+            String ipAddress = AsterixRuntimeUtil.getIPAddress(value);
+            Set<String> nodeControllers = AsterixRuntimeUtil.getNodeControllersOnIP(ipAddress);
+            if (nodeControllers == null || nodeControllers.isEmpty()) {
+                throw new AsterixException(" No node controllers found at the address: " + value);
+            }
+            String chosenNCId = nodeControllers.toArray(new String[]{})[random
+                    .nextInt(nodeControllers.size())];
+            return chosenNCId;
+        } catch (AsterixException ae) {
+            throw ae;
+        } catch (Exception e) {
+            throw new AsterixException(e);
+        }
+    }
+}
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolverFactory.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolverFactory.java
new file mode 100644
index 0000000..6b56601
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/DNSResolverFactory.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+/**
+ * Factory for creating instance of {@link DNSResolver}
+ */
+public class DNSResolverFactory implements INodeResolverFactory {
+
+    private static final INodeResolver INSTANCE = new DNSResolver();
+
+    @Override
+    public INodeResolver createNodeResolver() {
+        return INSTANCE;
+    }
+
+}
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolver.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolver.java
new file mode 100644
index 0000000..d0e8a64
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolver.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+
+/**
+ * A policy for resolving a name to a node controller id.   
+ *
+ */
+public interface INodeResolver {
+
+    /**
+     * Resolve a passed-in value to a node controller id.
+     * 
+     * @param value
+     *            string to be resolved
+     * @return resolved result (a node controller id)
+     * @throws AsterixException
+     */
+    public String resolveNode(String value) throws AsterixException;
+}
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolverFactory.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolverFactory.java
new file mode 100644
index 0000000..2abde9c
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/INodeResolverFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+/**
+ * Factory for creating an instance of INodeResolver
+ * 
+ *  @see INodeResolver
+ */
+public interface INodeResolverFactory {
+
+    /**
+     * Create an instance of {@link INodeResolver}
+     * 
+     * @return an instance of INodeResolver
+     */
+    public INodeResolver createNodeResolver();
+}
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentitiyResolverFactory.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentitiyResolverFactory.java
new file mode 100644
index 0000000..5161203
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentitiyResolverFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+/**
+ * Factory for creating an instance of @see {IdentityResolver}.
+ * Identity resolver simply resolves a value to itself and is useful when value being resolved
+ * is a node controller id.
+ */
+public class IdentitiyResolverFactory implements INodeResolverFactory {
+
+    private static INodeResolver INSTANCE = new IdentityResolver();
+
+    @Override
+    public INodeResolver createNodeResolver() {
+        return INSTANCE;
+    }
+
+}
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentityResolver.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentityResolver.java
new file mode 100644
index 0000000..7ff1f9b
--- /dev/null
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/util/IdentityResolver.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.external.util;
+
+/**
+ * Identity resolver simply resolves a value to itself and is useful when value being resolved
+ * is a node controller id.
+ */
+public class IdentityResolver implements INodeResolver {
+
+    @Override
+    public String resolveNode(String value) {
+        return value;
+    }
+
+}
diff --git a/asterix-hyracks-glue/pom.xml b/asterix-hyracks-glue/pom.xml
index 5f991a4..1a18d1c 100644
--- a/asterix-hyracks-glue/pom.xml
+++ b/asterix-hyracks-glue/pom.xml
@@ -1,51 +1,52 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>asterix</artifactId>
-    <groupId>edu.uci.ics.asterix</groupId>
-    <version>0.0.4-SNAPSHOT</version>
-  </parent>
-  <groupId>edu.uci.ics.asterix</groupId>
-  <artifactId>asterix-hyracks-glue</artifactId>
-  <version>0.0.4-SNAPSHOT</version>
-  <build>
-       <plugins>
-           <plugin>
-              <groupId>org.apache.maven.plugins</groupId>
-              <artifactId>maven-compiler-plugin</artifactId>
-              <version>2.0.2</version>
-              <configuration>
-                 <source>1.6</source>
-                 <target>1.6</target>
-              </configuration>
-           </plugin>
-       </plugins>
-  </build>     
-  <name>asterix-hyracks-glue</name>
-  <url>http://maven.apache.org</url>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-       <groupId>edu.uci.ics.asterix</groupId>
-       <artifactId>asterix-transactions</artifactId>
-       <version>0.0.4-SNAPSHOT</version>
-       <scope>compile</scope>
-    </dependency>
-    <dependency>
-    	<groupId>edu.uci.ics.asterix</groupId>
-    	<artifactId>asterix-common</artifactId>
-    	<version>0.0.4-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
-    </dependency>
-  </dependencies>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>asterix</artifactId>
+		<groupId>edu.uci.ics.asterix</groupId>
+		<version>0.0.4-SNAPSHOT</version>
+	</parent>
+	<groupId>edu.uci.ics.asterix</groupId>
+	<artifactId>asterix-hyracks-glue</artifactId>
+	<version>0.0.4-SNAPSHOT</version>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.0.2</version>
+				<configuration>
+					<source>1.7</source>
+					<target>1.7</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<name>asterix-hyracks-glue</name>
+	<url>http://maven.apache.org</url>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-transactions</artifactId>
+			<version>0.0.4-SNAPSHOT</version>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-common</artifactId>
+			<version>0.0.4-SNAPSHOT</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
 </project>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md b/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md
new file mode 100644
index 0000000..eeaffc9
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md
@@ -0,0 +1,53 @@
+The Asterix ADM Parser
+======================
+
+The ADM parser inside Asterix is composed by two different components:
+
+* **The Parser** AdmTupleParser, which converts the adm tokens in internal objects
+* **The Lexer**  AdmLexer, which scans the adm file and returns a list of adm tokens
+
+These two classes belong to the package:
+
+    edu.uci.ics.asterix.runtime.operators.file
+
+The Parser is loaded through a factory (*AdmSchemafullRecordParserFactory*) by
+
+    edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter extends AbstractDatasourceAdapter
+
+
+How to add a new datatype
+-------------------------
+The ADM format allows two different kinds of datatype:
+
+* primitive
+* with constructor
+
+A primitive datatype allows to write the actual value of the field without extra markup:
+
+    { name : "Diego", age : 23 }
+
+while the datatypes with constructor require to specify first the type of the value and then a string with the serialized value
+
+    { center : point3d("P2.1,3,8.5") }
+
+In order to add a new datatype the steps are:
+
+1.  Add the new token to the **Lexer**
+  * **if the datatype is primite** is necessary to create a TOKEN able to recognize **the format of the value**
+  * **if the datatype is with constructor** is necessary to create **only** a TOKEN able to recognize **the name of the constructor**
+
+2.  Change the **Parser** in order to convert correctly the new token in internal objects
+  * This will require to **add new cases to the switch-case statements** and the introduction of **a serializer/deserializer object** for that datatype.
+
+
+The Lexer
+----------
+To add new datatype or change the tokens definition you have to change ONLY the file adm.grammar located in 
+	asterix-runtime/src/main/resources/adm.grammar
+The lexer will be generated from that definition file during each maven building.
+
+The maven configuration in located in asterix-runtime/pom.xml
+
+
+> Author: Diego Giorgini - diegogiorgini@gmail.com   
+> 6 December 2012
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/README.md b/asterix-maven-plugins/lexer-generator-maven-plugin/README.md
new file mode 100644
index 0000000..b3632e6
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/README.md
@@ -0,0 +1,111 @@
+Lexer Generator
+===============
+
+This tool automate the creation of Hand-Coded-Like Lexers.   
+It was created to address the performance issues of other (more advanced) lexer generators like JavaCC that arise when you need to scan TB of data. In particular it is *~20x faster* than javacc and typically can parse the data from a normal harddisk at *more than 70MBs*.
+
+
+Maven Plugin (to put inside pom.xml)
+-------------------------------------
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0.2</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>edu.uci.ics.asterix</groupId>
+                <artifactId>lexer-generator-maven-plugin</artifactId>
+                <version>0.1-SNAPSHOT</version>
+                <configuration>
+                    <grammarFile>src/main/java/edu/uci/ics/asterix/runtime/operators/file/adm/adm.grammar</grammarFile>
+                    <outputDir>${project.build.directory}/generated-sources</outputDir>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>generate-lexer</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>generate-lexer</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+Command line
+-------------
+    LexerGenerator\nusage: java LexerGenerator <configuration file>
+
+
+
+What means Hand-Coded-Like and why it is so fast
+------------------------------------------------
+The most of the Lexers use a Finite State Machine encoded in data structure called [State Transition Table](http://en.wikipedia.org/wiki/State_transition_table).   
+While elegant and practical this approach require some extra controls and operations to deal with the data structure at runtime. A different approach consists in encoding the State Machine as actual code, in this way all the operations done are limited to the minumum amount needed to parse our grammar.   
+A common problem with this kind of hard-hand-coded lexers is that is almost impossible to do manutency and changes, this is the reason of this Lexer Generator able to produce a Hand-Coded-Like lexer starting from a grammar specification.
+
+Another big difference with the most of the LexerGenerator (expecially the ones for Java) is that since it is optimized for performance we **don't return objects** and we **use the minimum possible of objects internally**.    
+This actually is the main reason of the ~20x when compared with javacc.
+
+
+Configuration File
+------------------
+Is a simple *key: value* configuration file plus the *specification of your grammar*.   
+The four configuration keys are listed below:
+
+    # LEXER GENERATOR configuration file
+    # ---------------------------------------
+    # Place *first* the generic configuration
+    # then list your grammar.
+
+    PACKAGE:          edu.uci.ics.asterix.admfast.parser
+    LEXER_NAME:       AdmLexer
+    OUTPUT_DIR:       output/
+
+
+Specify The Grammar
+-------------------
+Your grammar has to be listed in the configuration file after the *TOKENS:* keyword.
+
+    TOKENS:
+
+    BOOLEAN_LIT        = string(boolean)
+    COMMA              = char(\,)
+    COLON              = char(:)
+    STRING_LITERAL     = char("), anythingUntil(")
+    INT_LITERAL        = signOrNothing(), digitSequence()
+    INT8_LITERAL       = token(INT_LITERAL), string(i8)
+    @EXPONENT          = caseInsensitiveChar(e), signOrNothing(), digitSequence()
+    DOUBLE_LITERAL     = signOrNothing(), digitSequence(), char(.), digitSequence(), token(@EXPONENT)
+    DOUBLE_LITERAL     = signOrNothing(), digitSequence(), token(@EXPONENT)
+
+Each token is composed by a **name** and a sequence of **rules**.   
+Each rule is then written with the format: **constructor(parameter)**  
+the list of the rules available is coded inside *NodeChainFactory.java*
+
+You can write more than a sequence of rules just addind more another line and repeating the token name.
+
+You can reuse the rules of a token inside another one with the special rule: **token(** *TOKEN_NAME* **)**
+
+Lastly you can define *auxiliary* token definitions that will not be encoded in the final lexer (but that can be useful inside other token definitions) just **startig the token name with @**.
+
+**Attention:** please pay attention to not write rules that once merged int the state machine would lead to a *conflict between transaction* like a transaction for a generic digit and one for a the digit 0 from the same node. 
+
+The result: MyLexer
+-------------------
+The result of the execution of the LexerGenerator is the creation of the Lexer inside the directory *components**.
+The lexer is extremly easy and minimal and can be used likewise an Iterator:
+
+     MyLexer myLexer = new MyLexer(new FileReader(file)));
+     while((token = MyLexer.next()) != MyLexer.TOKEN_EOF){
+        System.out.println(MyLexer.tokenKindToString(token));
+     }
+
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
new file mode 100644
index 0000000..269150d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
@@ -0,0 +1,36 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>edu.uci.ics.asterix</groupId>
+  <artifactId>lexer-generator-maven-plugin</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+  <name>lexer-generator-maven-plugin</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0.2</version>
+    </dependency>
+  </dependencies>    
+</project>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java
new file mode 100644
index 0000000..512f3d0
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.maven.plugin.logging.Log;
+
+public class LexerGenerator {
+    private LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+    private Log logger;
+
+    public LexerGenerator() {
+    }
+
+    public LexerGenerator(Log logger) {
+        this.logger = logger;
+    }
+
+    private void log(String info) {
+        if (logger == null) {
+            System.out.println(info);
+        } else {
+            logger.info(info);
+        }
+    }
+
+    public void addToken(String rule) throws Exception {
+        Token newToken;
+        if (rule.charAt(0) == '@') {
+            newToken = new TokenAux(rule, tokens);
+        } else {
+            newToken = new Token(rule, tokens);
+        }
+        Token existingToken = tokens.get(newToken.getName());
+        if (existingToken == null) {
+            tokens.put(newToken.getName(), newToken);
+        } else {
+            existingToken.merge(newToken);
+        }
+    }
+
+    public void generateLexer(HashMap<String, String> config) throws Exception {
+        LexerNode main = this.compile();
+        config.put("TOKENS_CONSTANTS", this.tokensConstants());
+        config.put("TOKENS_IMAGES", this.tokensImages());
+        config.put("LEXER_LOGIC", main.toJava());
+        config.put("LEXER_AUXFUNCTIONS", replaceParams(this.auxiliaryFunctions(main), config));
+        String[] files = { "/Lexer.java", "/LexerException.java" };
+        String outputDir = config.get("OUTPUT_DIR");
+        (new File(outputDir)).mkdirs();
+        for (String file : files) {
+            String input = readFile(LexerGenerator.class.getResourceAsStream(file));
+            String fileOut = file.replace("Lexer", config.get("LEXER_NAME"));
+            String output = replaceParams(input, config);
+            log("Generating: " + file + "\t>>\t" + fileOut);
+            FileWriter out = new FileWriter((new File(outputDir, fileOut)).toString());
+            out.write(output);
+            out.close();
+            log(" [done]\n");
+        }
+    }
+
+    public String printParsedGrammar() {
+        StringBuilder result = new StringBuilder();
+        for (Token token : tokens.values()) {
+            result.append(token.toString()).append("\n");
+        }
+        return result.toString();
+    }
+
+    private LexerNode compile() throws Exception {
+        LexerNode main = new LexerNode();
+        for (Token token : tokens.values()) {
+            if (token instanceof TokenAux)
+                continue;
+            main.merge(token.getNode());
+        }
+        return main;
+    }
+
+    private String tokensImages() {
+        StringBuilder result = new StringBuilder();
+        Set<String> uniqueTokens = tokens.keySet();
+        for (String token : uniqueTokens) {
+            result.append(", \"<").append(token).append(">\" ");
+        }
+        return result.toString();
+    }
+
+    private String tokensConstants() {
+        StringBuilder result = new StringBuilder();
+        Set<String> uniqueTokens = tokens.keySet();
+        int i = 2;
+        for (String token : uniqueTokens) {
+            result.append(", TOKEN_").append(token).append("=").append(i).append(" ");
+            i++;
+        }
+        return result.toString();
+    }
+
+    private String auxiliaryFunctions(LexerNode main) {
+        StringBuilder result = new StringBuilder();
+        Set<String> functions = main.neededAuxFunctions();
+        for (String token : functions) {
+            result.append("private int parse_" + token
+                    + "(char currentChar) throws IOException, [LEXER_NAME]Exception{\n");
+            result.append(tokens.get(token).getNode().toJavaAuxFunction());
+            result.append("\n}\n\n");
+        }
+        return result.toString();
+    }
+
+    private static String readFile(Reader input) throws FileNotFoundException, IOException {
+        StringBuffer fileData = new StringBuffer(1000);
+        BufferedReader reader = new BufferedReader(input);
+        char[] buf = new char[1024];
+        int numRead = 0;
+        while ((numRead = reader.read(buf)) != -1) {
+            String readData = String.valueOf(buf, 0, numRead);
+            fileData.append(readData);
+            buf = new char[1024];
+        }
+        reader.close();
+        return fileData.toString();
+    }
+
+    private static String readFile(InputStream input) throws FileNotFoundException, IOException {
+        if (input == null) {
+            throw new FileNotFoundException();
+        }
+        return readFile(new InputStreamReader(input));
+    }
+
+    private static String readFile(String fileName) throws FileNotFoundException, IOException {
+        return readFile(new FileReader(fileName));
+    }
+
+    private static String replaceParams(String input, HashMap<String, String> config) {
+        for (Entry<String, String> param : config.entrySet()) {
+            String key = "\\[" + param.getKey() + "\\]";
+            String value = param.getValue();
+            input = input.replaceAll(key, value);
+        }
+        return input;
+    }
+
+    public static void main(String args[]) throws Exception {
+        if (args.length == 0 || args[0] == "--help" || args[0] == "-h") {
+            System.out.println("LexerGenerator\nusage: java LexerGenerator <configuration file>");
+            return;
+        }
+
+        LexerGenerator lexer = new LexerGenerator();
+        HashMap<String, String> config = new HashMap<String, String>();
+
+        System.out.println("Config file:\t" + args[0]);
+        String input = readFile(args[0]);
+        boolean tokens = false;
+        for (String line : input.split("\r?\n")) {
+            line = line.trim();
+            if (line.length() == 0 || line.charAt(0) == '#')
+                continue;
+            if (tokens == false && !line.equals("TOKENS:")) {
+                config.put(line.split("\\s*:\\s*")[0], line.split("\\s*:\\s*")[1]);
+            } else if (line.equals("TOKENS:")) {
+                tokens = true;
+            } else {
+                lexer.addToken(line);
+            }
+        }
+
+        String parsedGrammar = lexer.printParsedGrammar();
+        lexer.generateLexer(config);
+        System.out.println("\nGenerated grammar:");
+        System.out.println(parsedGrammar);
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java
new file mode 100644
index 0000000..11ee1d5
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import edu.uci.ics.asterix.lexergenerator.LexerGenerator;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+
+/**
+ * @goal generate-lexer
+ * @phase generate-sources
+ * @requiresDependencyResolution compile
+ */
+public class LexerGeneratorMojo extends AbstractMojo {
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     * @required
+     */
+    private File grammarFile;
+
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     * @required
+     */
+    private File outputDir;
+
+    public void execute() throws MojoExecutionException {
+        LexerGenerator lexer = new LexerGenerator(getLog());
+        HashMap<String, String> config = new HashMap<String, String>();
+        getLog().info("--- Lexer Generator Maven Plugin - started with grammarFile: " + grammarFile.toString());
+        try {
+            String input = readFile(grammarFile);
+            config.put("OUTPUT_DIR", outputDir.toString());
+            boolean tokens = false;
+            for (String line : input.split("\r?\n")) {
+                line = line.trim();
+                if (line.length() == 0 || line.charAt(0) == '#')
+                    continue;
+                if (tokens == false && !line.equals("TOKENS:")) {
+                    config.put(line.split("\\s*:\\s*")[0], line.split("\\s*:\\s*")[1]);
+                } else if (line.equals("TOKENS:")) {
+                    tokens = true;
+                } else {
+                    lexer.addToken(line);
+                }
+            }
+            lexer.generateLexer(config);
+        } catch (Throwable e) {
+            throw new MojoExecutionException("Error while generating lexer", e);
+        }
+        String parsedGrammar = lexer.printParsedGrammar();
+        getLog().info("--- Generated grammar:\n" + parsedGrammar);
+    }
+
+    private String readFile(File file) throws FileNotFoundException, IOException {
+        StringBuffer fileData = new StringBuffer(1000);
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+        char[] buf = new char[1024];
+        int numRead = 0;
+        while ((numRead = reader.read(buf)) != -1) {
+            String readData = String.valueOf(buf, 0, numRead);
+            fileData.append(readData);
+            buf = new char[1024];
+        }
+        reader.close();
+        return fileData.toString();
+    }
+
+}
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java
new file mode 100644
index 0000000..7b8d059
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import edu.uci.ics.asterix.lexergenerator.rules.*;
+
+public class LexerNode {
+    private static String TOKEN_PREFIX = "TOKEN_";
+    private LinkedHashMap<Rule, LexerNode> actions = new LinkedHashMap<Rule, LexerNode>();
+    private String finalTokenName;
+    private Set<String> ongoingParsing = new HashSet<String>();
+
+    public LexerNode clone() {
+        LexerNode node = new LexerNode();
+        node.finalTokenName = this.finalTokenName;
+        for (Map.Entry<Rule, LexerNode> entry : this.actions.entrySet()) {
+            node.actions.put(entry.getKey().clone(), entry.getValue().clone());
+        }
+        for (String ongoing : this.ongoingParsing) {
+            node.ongoingParsing.add(ongoing);
+        }
+        return node;
+    }
+
+    public void add(Rule newRule) {
+        if (actions.get(newRule) == null) {
+            actions.put(newRule, new LexerNode());
+        }
+    }
+
+    public void append(Rule newRule) {
+        if (actions.size() == 0) {
+            add(newRule);
+        } else {
+            for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+                action.getValue().append(newRule);
+            }
+            if (actions.containsKey(new RuleEpsilon())) {
+                actions.remove(new RuleEpsilon());
+                add(newRule);
+            }
+        }
+    }
+
+    public void merge(LexerNode newNode) throws Exception {
+        for (Map.Entry<Rule, LexerNode> action : newNode.actions.entrySet()) {
+            if (this.actions.get(action.getKey()) == null) {
+                this.actions.put(action.getKey(), action.getValue());
+            } else {
+                this.actions.get(action.getKey()).merge(action.getValue());
+            }
+        }
+        if (newNode.finalTokenName != null) {
+            if (this.finalTokenName == null) {
+                this.finalTokenName = newNode.finalTokenName;
+            } else {
+                throw new Exception("Rule conflict between: " + this.finalTokenName + " and " + newNode.finalTokenName);
+            }
+        }
+        for (String ongoing : newNode.ongoingParsing) {
+            this.ongoingParsing.add(ongoing);
+        }
+    }
+
+    public void append(LexerNode node) throws Exception {
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            if (action.getKey() instanceof RuleEpsilon)
+                continue;
+            action.getValue().append(node);
+        }
+        if (actions.containsKey(new RuleEpsilon())) {
+            actions.remove(new RuleEpsilon());
+            merge(node.clone());
+        }
+        if (actions.size() == 0 || finalTokenName != null) {
+            finalTokenName = null;
+            merge(node.clone());
+        }
+    }
+
+    public void appendTokenName(String name) {
+        if (actions.size() == 0) {
+            this.finalTokenName = name;
+        } else {
+            ongoingParsing.add(TOKEN_PREFIX + name);
+            for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+                action.getValue().appendTokenName(name);
+            }
+        }
+    }
+
+    public LexerNode removeTokensName() {
+        this.finalTokenName = null;
+        this.ongoingParsing.clear();
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            action.getValue().removeTokensName();
+        }
+        return this;
+    }
+
+    public String toString() {
+        StringBuilder result = new StringBuilder();
+        if (finalTokenName != null)
+            result.append("! ");
+        if (actions.size() == 1)
+            result.append(actions.keySet().toArray()[0].toString() + actions.values().toArray()[0].toString());
+        if (actions.size() > 1) {
+            result.append(" ( ");
+            for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+                if (result.length() != 3) {
+                    result.append(" || ");
+                }
+                result.append(action.getKey().toString());
+                result.append(action.getValue().toString());
+            }
+            result.append(" ) ");
+        }
+        return result.toString();
+    }
+
+    public String toJava() {
+        StringBuffer result = new StringBuffer();
+        if (numberOfRuleChar() > 2) {
+            result.append(toJavaSingleCharRules());
+            result.append(toJavaComplexRules(false));
+        } else {
+            result.append(toJavaComplexRules(true));
+        }
+        if (this.finalTokenName != null) {
+            result.append("return " + TOKEN_PREFIX + finalTokenName + ";\n");
+        } else if (ongoingParsing != null) {
+            String ongoingParsingArgs = collectionJoin(ongoingParsing, ',');
+            result.append("return parseError(" + ongoingParsingArgs + ");\n");
+        }
+        return result.toString();
+    }
+
+    private int numberOfRuleChar() {
+        int singleCharRules = 0;
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            if (action.getKey() instanceof RuleChar)
+                singleCharRules++;
+        }
+        return singleCharRules;
+    }
+
+    private String toJavaSingleCharRules() {
+        StringBuffer result = new StringBuffer();
+        result.append("switch(currentChar){\n");
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            if (action.getKey() instanceof RuleChar) {
+                RuleChar rule = (RuleChar) action.getKey();
+                result.append("case '" + rule.expectedChar() + "':\n");
+                result.append(rule.javaAction()).append("\n");
+                result.append(action.getValue().toJava());
+            }
+        }
+        result.append("}\n");
+        return result.toString();
+    }
+
+    private String toJavaComplexRules(boolean all) {
+        StringBuffer result = new StringBuffer();
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            if (!all && action.getKey() instanceof RuleChar)
+                continue;
+            if (action.getKey() instanceof RuleEpsilon)
+                continue;
+            String act = action.getKey().javaAction();
+            if (act.length() > 0) {
+                act = "\n" + act;
+            }
+            result.append(action.getKey().javaMatch(act + "\n" + action.getValue().toJava()));
+        }
+        return result.toString();
+    }
+
+    public void expandFirstAction(LinkedHashMap<String, Token> tokens) throws Exception {
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            Rule first = action.getKey();
+            if (first instanceof RulePartial) {
+                if (tokens.get(((RulePartial) first).getPartial()) == null) {
+                    throw new Exception("Cannot find a token used as part of another definition, missing token: "
+                            + ((RulePartial) first).getPartial());
+                }
+                actions.remove(first);
+                LexerNode node = tokens.get(((RulePartial) first).getPartial()).getNode().clone();
+                merge(node);
+            }
+        }
+    }
+
+    public Set<String> neededAuxFunctions() {
+        HashSet<String> partials = new HashSet<String>();
+        for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+            Rule rule = action.getKey();
+            if (rule instanceof RulePartial) {
+                partials.add(((RulePartial) rule).getPartial());
+            }
+            partials.addAll(action.getValue().neededAuxFunctions());
+        }
+        return partials;
+    }
+
+    public String toJavaAuxFunction() {
+        String oldFinalTokenName = finalTokenName;
+        if (oldFinalTokenName == null)
+            finalTokenName = "AUX_NOT_FOUND";
+        String result = toJava();
+        finalTokenName = oldFinalTokenName;
+        return result;
+    }
+
+    private String collectionJoin(Collection<String> collection, char c) {
+        StringBuilder ongoingParsingArgs = new StringBuilder();
+        for (String token : collection) {
+            ongoingParsingArgs.append(token);
+            ongoingParsingArgs.append(c);
+        }
+        if (ongoingParsing.size() > 0) {
+            ongoingParsingArgs.deleteCharAt(ongoingParsingArgs.length() - 1);
+        }
+        return ongoingParsingArgs.toString();
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java
new file mode 100644
index 0000000..941f822
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import java.util.HashMap;
+
+import edu.uci.ics.asterix.lexergenerator.rulegenerators.*;
+
+public class NodeChainFactory {
+    static private HashMap<String, RuleGenerator> ruleGenerators = new HashMap<String, RuleGenerator>();
+
+    static {
+        ruleGenerators.put("char", new RuleGeneratorChar());
+        ruleGenerators.put("string", new RuleGeneratorString());
+        ruleGenerators.put("anythingUntil", new RuleGeneratorAnythingUntil());
+        ruleGenerators.put("signOrNothing", new RuleGeneratorSignOrNothing());
+        ruleGenerators.put("sign", new RuleGeneratorSign());
+        ruleGenerators.put("digitSequence", new RuleGeneratorDigitSequence());
+        ruleGenerators.put("caseInsensitiveChar", new RuleGeneratorCaseInsensitiveChar());
+        ruleGenerators.put("charOrNothing", new RuleGeneratorCharOrNothing());
+        ruleGenerators.put("token", new RuleGeneratorToken());
+        ruleGenerators.put("nothing", new RuleGeneratorNothing());
+    }
+
+    public static LexerNode create(String generator, String constructor) throws Exception {
+        constructor = constructor.replace("@", "aux_");
+        if (ruleGenerators.get(generator) == null)
+            throw new Exception("Rule Generator not found for '" + generator + "'");
+        return ruleGenerators.get(generator).generate(constructor);
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java
new file mode 100644
index 0000000..bb122c2
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import java.util.LinkedHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Token {
+    private String userDescription;
+    private String name;
+    private LexerNode node;
+
+    public Token(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+        userDescription = str;
+        node = new LexerNode();
+        parse(userDescription, tokens);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public LexerNode getNode() {
+        return node;
+    }
+
+    public String toString() {
+        return this.name + " => " + getNode().toString();
+    }
+
+    public void merge(Token newToken) throws Exception {
+        node.merge(newToken.getNode());
+    }
+
+    private void parse(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+        Pattern p = Pattern.compile("^(@?\\w+)\\s*=\\s*(.+)");
+        Matcher m = p.matcher(str);
+        if (!m.find())
+            throw new Exception("Token definition not correct: " + str);
+        this.name = m.group(1).replaceAll("@", "aux_");
+        String[] textRules = m.group(2).split("(?<!\\\\),\\s*");
+        for (String textRule : textRules) {
+            Pattern pRule = Pattern.compile("^(\\w+)(\\((.*)\\))?");
+            Matcher mRule = pRule.matcher(textRule);
+            mRule.find();
+            String generator = mRule.group(1);
+            String constructor = mRule.group(3);
+            if (constructor == null)
+                throw new Exception("Error in rule format: " + "\n " + str + " = " + generator + " : " + constructor);
+            constructor = constructor.replace("\\", "");
+            node.append(NodeChainFactory.create(generator, constructor));
+            node.expandFirstAction(tokens);
+        }
+        node.appendTokenName(name);
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java
new file mode 100644
index 0000000..a9c7ffc
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator;
+
+import java.util.LinkedHashMap;
+
+public class TokenAux extends Token {
+
+    public TokenAux(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+        super(str, tokens);
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java
new file mode 100644
index 0000000..3733746
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public interface RuleGenerator {
+    public LexerNode generate(String input) throws Exception;
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java
new file mode 100644
index 0000000..b14eb3e
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleAnythingUntil;
+
+public class RuleGeneratorAnythingUntil implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        if (input == null || input.length() != 1)
+            throw new Exception("Wrong rule format for generator anythingExcept: " + input);
+        result.append(new RuleAnythingUntil(input.charAt(0)));
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java
new file mode 100644
index 0000000..b789f59
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorCaseInsensitiveChar implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        if (input == null || input.length() != 1)
+            throw new Exception("Wrong rule format for generator char: " + input);
+        char cl = Character.toLowerCase(input.charAt(0));
+        char cu = Character.toUpperCase(cl);
+        result.add(new RuleChar(cl));
+        result.add(new RuleChar(cu));
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java
new file mode 100644
index 0000000..0b830e6
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorChar implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        if (input == null || input.length() != 1)
+            throw new Exception("Wrong rule format for generator char: " + input);
+        result.append(new RuleChar(input.charAt(0)));
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java
new file mode 100644
index 0000000..d01ff7d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorCharOrNothing implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        if (input == null || input.length() != 1)
+            throw new Exception("Wrong rule format for generator charOrNothing: " + input);
+        result.add(new RuleChar(input.charAt(0)));
+        result.add(new RuleEpsilon());
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java
new file mode 100644
index 0000000..d067ee7
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleDigitSequence;
+
+public class RuleGeneratorDigitSequence implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        result.append(new RuleDigitSequence());
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java
new file mode 100644
index 0000000..fec06a1
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorNothing implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode node = new LexerNode();
+        node.add(new RuleEpsilon());
+        return node;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java
new file mode 100644
index 0000000..0160f09
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorSign implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        result.add(new RuleChar('+'));
+        result.add(new RuleChar('-'));
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java
new file mode 100644
index 0000000..7c4297d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorSignOrNothing implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        LexerNode result = new LexerNode();
+        result.add(new RuleChar('+'));
+        result.add(new RuleChar('-'));
+        result.add(new RuleEpsilon());
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java
new file mode 100644
index 0000000..eb0471b
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorString implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) {
+        LexerNode result = new LexerNode();
+        if (input == null)
+            return result;
+        for (int i = 0; i < input.length(); i++) {
+            result.append(new RuleChar(input.charAt(i)));
+        }
+        return result;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java
new file mode 100644
index 0000000..b4c23d8
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RulePartial;
+
+public class RuleGeneratorToken implements RuleGenerator {
+
+    @Override
+    public LexerNode generate(String input) throws Exception {
+        if (input == null || input.length() == 0)
+            throw new Exception("Wrong rule format for generator token : " + input);
+        LexerNode node = new LexerNode();
+        node.add(new RulePartial(input));
+        return node;
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java
new file mode 100644
index 0000000..01cd1d5
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public interface Rule {
+    public int hashCode();
+
+    public boolean equals(Object o);
+
+    public String toString();
+
+    public String javaAction();
+
+    public String javaMatch(String action);
+
+    public Rule clone();
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java
new file mode 100644
index 0000000..8d45835
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public class RuleAnythingUntil implements Rule {
+
+    private char expected;
+
+    public RuleAnythingUntil clone() {
+        return new RuleAnythingUntil(expected);
+    }
+
+    public RuleAnythingUntil(char expected) {
+        this.expected = expected;
+    }
+
+    @Override
+    public String toString() {
+        return " .* " + String.valueOf(expected);
+    }
+
+    @Override
+    public int hashCode() {
+        return 10 * (int) expected;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (o instanceof RuleAnythingUntil) {
+            if (((RuleAnythingUntil) o).expected == this.expected) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String javaAction() {
+        return "currentChar = readNextChar();";
+    }
+
+    @Override
+    public String javaMatch(String action) {
+        StringBuilder result = new StringBuilder();
+        result.append("boolean escaped = false;");
+        result.append("while (currentChar!='").append(expected).append("' || escaped)");
+        result.append("{\nif(!escaped && currentChar=='\\\\\\\\'){escaped=true;}\nelse {escaped=false;}\ncurrentChar = readNextChar();\n}");
+        result.append("\nif (currentChar=='").append(expected).append("'){");
+        result.append(action);
+        result.append("}\n");
+        return result.toString();
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java
new file mode 100644
index 0000000..0e53374
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public class RuleChar implements Rule {
+
+    private char expected;
+
+    public RuleChar clone() {
+        return new RuleChar(expected);
+    }
+
+    public RuleChar(char expected) {
+        this.expected = expected;
+    }
+
+    @Override
+    public String toString() {
+        return String.valueOf(expected);
+    }
+
+    public char expectedChar() {
+        return expected;
+    }
+
+    @Override
+    public int hashCode() {
+        return (int) expected;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (o instanceof RuleChar) {
+            if (((RuleChar) o).expected == this.expected) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String javaAction() {
+        return "currentChar = readNextChar();";
+    }
+
+    @Override
+    public String javaMatch(String action) {
+        StringBuilder result = new StringBuilder();
+        result.append("if (currentChar=='");
+        result.append(expected);
+        result.append("'){");
+        result.append(action);
+        result.append("}");
+        return result.toString();
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java
new file mode 100644
index 0000000..13381e0
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public class RuleDigitSequence implements Rule {
+
+    public RuleDigitSequence clone() {
+        return new RuleDigitSequence();
+    }
+
+    @Override
+    public String toString() {
+        return " [0-9]+ ";
+    }
+
+    @Override
+    public int hashCode() {
+        return 1;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (o instanceof RuleDigitSequence) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public String javaAction() {
+        return "";
+    }
+
+    @Override
+    public String javaMatch(String action) {
+        StringBuilder result = new StringBuilder();
+        result.append("if(currentChar >= '0' && currentChar<='9'){" + "\ncurrentChar = readNextChar();"
+                + "\nwhile(currentChar >= '0' && currentChar<='9'){" + "\ncurrentChar = readNextChar();" + "\n}\n");
+        result.append(action);
+        result.append("\n}");
+        return result.toString();
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java
new file mode 100644
index 0000000..41b7535
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public class RuleEpsilon implements Rule {
+
+    public RuleEpsilon clone() {
+        return new RuleEpsilon();
+    }
+
+    @Override
+    public String toString() {
+        return "?";
+    }
+
+    @Override
+    public int hashCode() {
+        return 0;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (o instanceof RuleEpsilon) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public String javaAction() {
+        return "";
+    }
+
+    @Override
+    public String javaMatch(String action) {
+        StringBuilder result = new StringBuilder();
+        result.append("{").append(action).append("}");
+        return result.toString();
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java
new file mode 100644
index 0000000..89caf4f
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+package edu.uci.ics.asterix.lexergenerator.rules;
+
+public class RulePartial implements Rule {
+
+    private String partialName;
+
+    public RulePartial clone() {
+        return new RulePartial(partialName);
+    }
+
+    public RulePartial(String expected) {
+        this.partialName = expected;
+    }
+
+    public String getPartial() {
+        return this.partialName;
+    }
+
+    @Override
+    public String toString() {
+        return partialName;
+    }
+
+    @Override
+    public int hashCode() {
+        return (int) partialName.charAt(1);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (o instanceof RulePartial) {
+            if (((RulePartial) o).partialName.equals(this.partialName)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String javaAction() {
+        return "";
+    }
+
+    @Override
+    public String javaMatch(String action) {
+        StringBuilder result = new StringBuilder();
+        result.append("if (parse_" + partialName + "(currentChar)==TOKEN_" + partialName + "){");
+        result.append(action);
+        result.append("}");
+        return result.toString();
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
new file mode 100644
index 0000000..8cee79d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
@@ -0,0 +1,219 @@
+package [PACKAGE]; 
+
+import java.io.IOException;
+import [PACKAGE].[LEXER_NAME]Exception;
+
+public class [LEXER_NAME] {
+
+    public static final int
+        TOKEN_EOF = 0, TOKEN_AUX_NOT_FOUND = 1 [TOKENS_CONSTANTS];
+
+    // Human representation of tokens. Useful for debug.
+    // Is possible to convert a TOKEN_CONSTANT in its image through
+    // [LEXER_NAME].tokenKindToString(TOKEN_CONSTANT); 
+    private static final String[] tokenImage = {
+            "<EOF>", "<AUX_NOT_FOUND>" [TOKENS_IMAGES]
+          };
+    
+    private static final char EOF_CHAR = 4;
+    protected java.io.Reader inputStream;
+    protected int column;
+    protected int line;
+    protected boolean prevCharIsCR;
+    protected boolean prevCharIsLF;
+    protected char[] buffer;
+    protected int bufsize;
+    protected int bufpos;
+    protected int tokenBegin;
+    protected int endOf_USED_Buffer;
+    protected int endOf_UNUSED_Buffer;
+    protected int maxUnusedBufferSize;
+
+// ================================================================================
+//  Auxiliary functions. Can parse the tokens used in the grammar as partial/auxiliary
+// ================================================================================
+
+    [LEXER_AUXFUNCTIONS]
+
+// ================================================================================
+//  Main method. Return a TOKEN_CONSTANT
+// ================================================================================            
+            
+    public int next() throws [LEXER_NAME]Exception, IOException{
+        char currentChar = buffer[bufpos];
+        while (currentChar == ' ' || currentChar=='\t' || currentChar == '\n' || currentChar=='\r')
+            currentChar = readNextChar(); 
+        tokenBegin = bufpos;
+        if (currentChar==EOF_CHAR) return TOKEN_EOF;
+
+        [LEXER_LOGIC]
+    }
+
+// ================================================================================
+//  Public interface
+// ================================================================================
+    
+    public [LEXER_NAME](java.io.Reader stream) throws IOException{
+        reInit(stream);
+    }
+
+    public void reInit(java.io.Reader stream) throws IOException{
+        done();
+        inputStream    = stream;
+        bufsize        = 4096;
+        line           = 1;
+        column         = 0;
+        bufpos         = -1;
+        endOf_UNUSED_Buffer = bufsize;
+        endOf_USED_Buffer = 0;
+        prevCharIsCR   = false;
+        prevCharIsLF   = false;
+        buffer         = new char[bufsize];
+        tokenBegin     = -1;
+        maxUnusedBufferSize = 4096/2;
+        readNextChar();
+    }
+
+    public String getLastTokenImage() {
+        if (bufpos >= tokenBegin)
+            return new String(buffer, tokenBegin, bufpos - tokenBegin);
+          else
+            return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+                                  new String(buffer, 0, bufpos);
+    }
+    
+    public static String tokenKindToString(int token) {
+        return tokenImage[token]; 
+    }
+
+    public void done(){
+        buffer = null;
+    }
+
+// ================================================================================
+//  Parse error management
+// ================================================================================    
+    
+    protected int parseError(String reason) throws [LEXER_NAME]Exception {
+        StringBuilder message = new StringBuilder();
+        message.append(reason).append("\n");
+        message.append("Line: ").append(line).append("\n");
+        message.append("Row: ").append(column).append("\n");
+        throw new [LEXER_NAME]Exception(message.toString());
+    }
+
+    protected int parseError(int ... tokens) throws [LEXER_NAME]Exception {
+        StringBuilder message = new StringBuilder();
+        message.append("Error while parsing. ");
+        message.append(" Line: ").append(line);
+        message.append(" Row: ").append(column);
+        message.append(" Expecting:");
+        for (int tokenId : tokens){
+            message.append(" ").append([LEXER_NAME].tokenKindToString(tokenId));
+        }
+        throw new [LEXER_NAME]Exception(message.toString());
+    }
+    
+    protected void updateLineColumn(char c){
+        column++;
+    
+        if (prevCharIsLF)
+        {
+            prevCharIsLF = false;
+            line += (column = 1);
+        }
+        else if (prevCharIsCR)
+        {
+            prevCharIsCR = false;
+            if (c == '\n')
+            {
+                prevCharIsLF = true;
+            }
+            else
+            {
+                line += (column = 1);
+            }
+        }
+        
+        if (c=='\r') {
+            prevCharIsCR = true;
+        } else if(c == '\n') {
+            prevCharIsLF = true;
+        }
+    }
+    
+// ================================================================================
+//  Read data, buffer management. It uses a circular (and expandable) buffer
+// ================================================================================    
+
+    protected char readNextChar() throws IOException {
+        if (++bufpos >= endOf_USED_Buffer)
+            fillBuff();
+        char c = buffer[bufpos];
+        updateLineColumn(c);
+        return c;
+    }
+
+    protected boolean fillBuff() throws IOException {
+        if (endOf_UNUSED_Buffer == endOf_USED_Buffer) // If no more unused buffer space 
+        {
+          if (endOf_UNUSED_Buffer == bufsize)         // -- If the previous unused space was
+          {                                           // -- at the end of the buffer
+            if (tokenBegin > maxUnusedBufferSize)     // -- -- If the first N bytes before
+            {                                         //       the current token are enough
+              bufpos = endOf_USED_Buffer = 0;         // -- -- -- setup buffer to use that fragment 
+              endOf_UNUSED_Buffer = tokenBegin;
+            }
+            else if (tokenBegin < 0)                  // -- -- If no token yet
+              bufpos = endOf_USED_Buffer = 0;         // -- -- -- reuse the whole buffer
+            else
+              ExpandBuff(false);                      // -- -- Otherwise expand buffer after its end
+          }
+          else if (endOf_UNUSED_Buffer > tokenBegin)  // If the endOf_UNUSED_Buffer is after the token
+            endOf_UNUSED_Buffer = bufsize;            // -- set endOf_UNUSED_Buffer to the end of the buffer
+          else if ((tokenBegin - endOf_UNUSED_Buffer) < maxUnusedBufferSize)
+          {                                           // If between endOf_UNUSED_Buffer and the token
+            ExpandBuff(true);                         // there is NOT enough space expand the buffer                          
+          }                                           // reorganizing it
+          else 
+            endOf_UNUSED_Buffer = tokenBegin;         // Otherwise there is enough space at the start
+        }                                             // so we set the buffer to use that fragment
+        int i;
+        if ((i = inputStream.read(buffer, endOf_USED_Buffer, endOf_UNUSED_Buffer - endOf_USED_Buffer)) == -1)
+        {
+            inputStream.close();
+            buffer[endOf_USED_Buffer]=(char)EOF_CHAR;
+            endOf_USED_Buffer++;
+            return false;
+        }
+            else
+                endOf_USED_Buffer += i;
+        return true;
+    }
+
+
+    protected void ExpandBuff(boolean wrapAround)
+    {
+      char[] newbuffer = new char[bufsize + maxUnusedBufferSize];
+
+      try {
+        if (wrapAround) {
+          System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+          System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
+          buffer = newbuffer;
+          endOf_USED_Buffer = (bufpos += (bufsize - tokenBegin));
+        }
+        else {
+          System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+          buffer = newbuffer;
+          endOf_USED_Buffer = (bufpos -= tokenBegin);
+        }
+      } catch (Throwable t) {
+          throw new Error(t.getMessage());
+      }
+
+      bufsize += maxUnusedBufferSize;
+      endOf_UNUSED_Buffer = bufsize;
+      tokenBegin = 0;
+    }    
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
new file mode 100644
index 0000000..76aa8a4
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
@@ -0,0 +1,13 @@
+package [PACKAGE];
+
+public class [LEXER_NAME]Exception extends Exception {
+    
+    public [LEXER_NAME]Exception(String message) {
+        super(message);
+    }
+    
+    private static final long serialVersionUID = 1L;
+
+}
+
+
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
new file mode 100644
index 0000000..7efbeb8
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
@@ -0,0 +1,16 @@
+# LEXER GENERATOR configuration file
+# ---------------------------------------
+# Place *first* the generic configuration
+# then list your grammar.
+
+PACKAGE:          com.my.lexer
+LEXER_NAME:       MyLexer
+OUTPUT_DIR:       output
+
+TOKENS:
+
+BOOLEAN_LIT = string(boolean)
+FALSE_LIT   = string(false)
+BOMB_LIT    = string(bomb)
+BONSAI_LIT  = string(bonsai)
+HELLO_LIT   = string(hello)
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java
new file mode 100644
index 0000000..2ed2eaa
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java
@@ -0,0 +1,100 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import edu.uci.ics.asterix.lexergenerator.rules.Rule;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class Fixtures {
+    static  String token_name       = "MYTOKEN";
+    static  String token2_name       = "MYTOKEN2";
+    static  String token_return     = "return TOKEN_MYTOKEN;\n";
+    static  String token2_return     = "return TOKEN_MYTOKEN2;\n";
+    static  String token_parseerror = "return parseError(TOKEN_MYTOKEN);\n";
+    static  String token_tostring   = "! ";
+    static  String rule_action      = "myaction";
+    static  String rule_name        = "myrule";
+    static  String rule_match       = "matchCheck("+rule_name+")";
+    static  String rule2_action     = "myaction2";
+    static  String rule2_name       = "myrule2";
+    static  String rule2_match      = "matchCheck2("+rule_name+")";
+    
+    static public Rule createRule(final String name){
+        return new Rule(){
+            String rule_name        = name;
+            String rule_action      = "myaction";
+            String rule_match       = "matchCheck("+rule_name+")";
+            
+            @Override
+            public Rule clone(){
+                return Fixtures.createRule(name+"_clone");
+            }
+            
+            @Override
+            public String javaAction() {
+                return rule_action;
+            }
+
+            @Override
+            public String javaMatch(String action) {
+                return rule_match+"{"+action+"}";
+            }
+            
+            @Override
+            public String toString(){
+                return rule_name;
+            }
+            
+        }; 
+    }
+    
+    static Rule rule = new Rule(){
+        
+        public Rule clone(){
+            return null;
+        }
+        
+        @Override
+        public String javaAction() {
+            return rule_action;
+        }
+
+        @Override
+        public String javaMatch(String action) {
+            return rule_match+"{"+action+"}";
+        }
+        
+        @Override
+        public String toString(){
+            return rule_name;
+        }
+        
+    }; 
+
+    static Rule rule2 = new Rule(){
+
+        public Rule clone(){
+            return null;
+        }
+        
+        @Override
+        public String javaAction() {
+            return rule2_action;
+        }
+
+        @Override
+        public String javaMatch(String act) {
+            return rule2_match+"{"+act+"}";
+        }
+        
+        @Override
+        public String toString(){
+            return rule2_name;
+        }
+        
+    };
+    
+    static RuleChar ruleA = new RuleChar('a');
+    static RuleChar ruleB = new RuleChar('b');
+    static RuleChar ruleC = new RuleChar('c');
+    static String ruleABC_action = "currentChar = readNextChar();";
+    
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java
new file mode 100644
index 0000000..7541124
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java
@@ -0,0 +1,51 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeAddRuleTest {
+
+    @Test
+    public void NodeRuleRuleNodeNode() {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.add(rule2);
+        node.appendTokenName(token_name);
+        assertEquals(" ( " + rule_name +token_tostring + " || " + rule2_name + token_tostring + " ) ", node.toString());
+        assertEquals(rule_match+"{"
+                        +"\n" + rule_action
+                        +"\n" +token_return
+                     +"}"
+                     +rule2_match+"{"
+                        +"\n"+rule2_action
+                        +"\n"+token_return
+                     +"}"
+                     +token_parseerror , node.toJava());
+    }
+    
+    @Test
+    public void NodeSwitchCase() {
+        LexerNode node = new LexerNode();
+        node.append(ruleA);
+        node.add(ruleB);
+        node.add(ruleC);
+        node.appendTokenName(token_name);
+        assertEquals(" ( a" + token_tostring + " || b" + token_tostring + " || c" + token_tostring + " ) ", node.toString());
+        assertEquals("switch(currentChar){\n" +
+                "case 'a':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "case 'b':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "case 'c':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "}\n"+ token_parseerror , node.toJava());
+    }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java
new file mode 100644
index 0000000..5151e77
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java
@@ -0,0 +1,81 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class LexerNodeAppendNodeTest {
+
+    @Test
+    public void AppendIsMergeIfNoActions() throws Exception {
+        LexerNode node = new LexerNode();
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("rule"));
+        node2.appendTokenName(token_name);
+        node.append(node2);
+        assertEquals("rule_clone! ", node.toString());
+    }
+
+    @Test
+    public void AppendIsAppend() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(createRule("A"));
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("rule"));
+        node2.appendTokenName(token_name);
+        node.append(node2);
+        assertEquals("Arule_clone! ", node.toString());
+    }
+    
+    @Test
+    public void AppendedNodesAreCloned() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(createRule("A"));
+        node.appendTokenName(token_name);
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("B"));
+        node2.appendTokenName(token2_name);
+        node.append(node2);
+        // TODO
+        // assertEquals("A! B_clone! ", node.toString());
+        
+        LexerNode node3 = new LexerNode();
+        node3.append(createRule("C"));
+        node3.append(createRule("D"));
+        node3.appendTokenName(token2_name);
+        node.append(node3);
+        // TODO
+        // assertEquals("A! B_clone! C_cloneD_clone! ", node.toString());
+    }
+
+    @Test
+    public void EpsilonRuleDoesNotPropagateAppended() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(new RuleEpsilon());
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("A"));
+        node2.appendTokenName(token2_name);
+        node.append(node2);
+        assertEquals("A_clone! ", node.toString());
+    }
+
+    @Test
+    public void EpsilonRuleIsRemovedAndIssueMerge() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(new RuleEpsilon());
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("A"));
+        node2.appendTokenName(token2_name);
+        node.append(node2);
+        node.add(new RuleEpsilon());
+        node.append(node2);
+        // TODO
+        // assertEquals(" ( A_clone! A_clone!  || A_clone!  ) ", node.toString());
+  }
+    
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java
new file mode 100644
index 0000000..84fd292
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java
@@ -0,0 +1,47 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+
+public class LexerNodeAppendRuleTest {    
+    @Test
+    public void SingleNode() {
+        LexerNode node = new LexerNode();
+        node.appendTokenName(token_name);
+        assertEquals(token_tostring, node.toString());
+        assertEquals(token_return,   node.toJava());
+    }
+
+    @Test
+    public void NodeRuleNode() {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.appendTokenName(token_name);
+        assertEquals(rule_name+token_tostring, node.toString());
+        assertEquals(rule_match+"{"
+                        +"\n"+rule_action
+                        +"\n"+token_return
+                     +"}"+token_parseerror, node.toJava());
+    }
+
+    @Test
+    public void NodeRuleNodeRuleNode() {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.append(rule2);
+        node.appendTokenName(token_name);
+        assertEquals(rule_name+rule2_name+token_tostring, node.toString());
+        assertEquals(rule_match+"{"
+                        +"\n"+rule_action
+                        +"\n"+rule2_match+"{"
+                            +"\n"+rule2_action
+                            +"\n"+token_return
+                        +"}"
+                        +token_parseerror
+                     +"}"+token_parseerror, node.toJava());
+    }
+}
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
new file mode 100644
index 0000000..9f12c00
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
@@ -0,0 +1,111 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+import org.junit.Test;
+
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.Token;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+import edu.uci.ics.asterix.lexergenerator.rules.RulePartial;
+
+public class LexerNodeAuxFunctionsTest {
+    String expectedDifferentReturn = "return TOKEN_AUX_NOT_FOUND;\n"; 
+    
+    @Test
+    public void NodeRuleRuleNodeNode() {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.add(rule2);
+        node.appendTokenName(token_name);
+        assertEquals(" ( " + rule_name +token_tostring + " || " + rule2_name + token_tostring + " ) ", node.toString());
+        assertEquals(rule_match+"{"
+                        +"\n" + rule_action
+                        +"\n" +token_return
+                     +"}"
+                     +rule2_match+"{"
+                        +"\n"+rule2_action
+                        +"\n"+token_return
+                     +"}"
+                     +expectedDifferentReturn , node.toJavaAuxFunction());
+    }
+    
+    @Test
+    public void NodeSwitchCase() {
+        LexerNode node = new LexerNode();
+        node.append(ruleA);
+        node.add(ruleB);
+        node.add(ruleC);
+        node.appendTokenName(token_name);
+        assertEquals(" ( a" + token_tostring + " || b" + token_tostring + " || c" + token_tostring + " ) ", node.toString());
+        assertEquals("switch(currentChar){\n" +
+                "case 'a':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "case 'b':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "case 'c':" +
+                "\n" + ruleABC_action +
+                "\n" + token_return   +
+                "}\n"+ expectedDifferentReturn , node.toJavaAuxFunction());
+    }
+
+    @Test
+    public void NodeNeededAuxFunctions() {
+        LexerNode node = new LexerNode();
+        node.append(ruleA);
+        node.add(new RulePartial("token1"));
+        node.append(ruleC);
+        node.append(new RulePartial("token2"));
+        node.appendTokenName(token_name);
+        assertEquals(" ( actoken2!  || token1ctoken2!  ) ", node.toString());
+        Set<String> expectedNeededAuxFunctions = new HashSet<String>();
+        expectedNeededAuxFunctions.add("token1");
+        expectedNeededAuxFunctions.add("token2");
+        assertEquals(expectedNeededAuxFunctions, node.neededAuxFunctions());
+    }    
+
+    @Test(expected=Exception.class)
+    public void NodeExpandFirstActionError() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(ruleA);
+        node.add(new RulePartial("token1"));
+        node.append(ruleC);
+        node.add(new RuleEpsilon());
+        node.append(new RulePartial("token2"));
+        node.appendTokenName(token_name);
+        assertEquals(" ( actoken2!  || token1ctoken2!  || token2!  ) ", node.toString());
+        LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+        try {
+            node.expandFirstAction(tokens);
+        } catch (Exception e) {
+            assertEquals("Cannot find a token used as part of another definition, missing token: token1", e.getMessage());
+            throw e;
+        }
+    } 
+
+    public void NodeExpandFirstAction() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(ruleA);
+        node.add(new RulePartial("token1"));
+        node.append(ruleC);
+        node.add(new RuleEpsilon());
+        node.append(new RulePartial("token2"));
+        node.appendTokenName(token_name);
+        assertEquals(" ( actoken2!  || token1ctoken2!  || token2!  ) ", node.toString());
+        LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+        Token a = new Token("token1 = string(T1-blabla)", tokens);
+        Token b = new Token("token1 = string(T1-blabla)", tokens);
+        tokens.put("token1", a);
+        tokens.put("token2", b);
+        node.expandFirstAction(tokens);
+        assertEquals(" ( actoken2!  || T1-blablactoken2!  || T2-blabla!  ) ", node.toString());
+    }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java
new file mode 100644
index 0000000..87e3ff4
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java
@@ -0,0 +1,56 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeCloneTest {
+    
+    @Test
+    public void Depth1() throws Exception {
+        LexerNode node = new LexerNode();
+        LexerNode newNode = node.clone();
+        assertFalse(node == newNode);
+    }
+    
+    
+    @Test
+    public void Depth2() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(createRule("my1"));
+        node.add(createRule("my2"));
+        node.add(ruleA);
+        node.appendTokenName(token_name);
+        LexerNode newNode = node.clone();
+
+        assertEquals(" ( my1!  || my2!  || a!  ) ", node.toString());
+        assertEquals(" ( my1_clone!  || my2_clone!  || a!  ) ", newNode.toString());
+    }
+
+    @Test
+    public void Depth3() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(createRule("my1"));
+        node.add(createRule("my2"));
+        node.add(ruleA);
+        node.appendTokenName(token_name);
+        LexerNode node2 = new LexerNode();
+        node2.append(createRule("my3"));
+        node2.add(createRule("my4"));
+        node2.add(ruleB);
+        node2.appendTokenName(token2_name);
+        node.append(node2);
+        LexerNode newNode = node.clone();
+        // TODO
+        // assertEquals(" ( my1!  (  || my3_clone!  || my4_clone!  || b!  ) " +
+        //		     " || my2!  (  || my3_clone!  || my4_clone!  || b!  ) " +
+        //		     " || a!  (  || my3_clone!  || my4_clone!  || b!  )  ) ", node.toString());
+        // assertEquals(" ( my1_clone!  (  || my3_clone_clone!  || my4_clone_clone!  || b!  ) " +
+        //		     " || my2_clone!  (  || my3_clone_clone!  || my4_clone_clone!  || b!  ) " +
+        //		     " || a!  (  || my3_clone_clone!  || my4_clone_clone!  || b!  )  ) ", newNode.toString());
+    }
+    
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java
new file mode 100644
index 0000000..4b22d99
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java
@@ -0,0 +1,83 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeMergeNodeTest {
+
+    @Test
+    public void MergeIsAdd() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        LexerNode node2 = new LexerNode();
+        node2.append(rule2);
+        node2.append(rule);
+        node2.merge(node);
+        node2.appendTokenName(token_name);
+        
+        LexerNode expected = new LexerNode();
+        expected.append(rule2);
+        expected.append(rule);
+        expected.add(rule);
+        expected.appendTokenName(token_name);
+        
+        assertEquals(expected.toString(), node2.toString());
+        assertEquals(expected.toJava(), node2.toJava());
+    }
+
+    @Test
+    public void MergeTwoToken() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.appendTokenName(token_name);
+        LexerNode node2 = new LexerNode();
+        node2.append(rule2);
+        node2.appendTokenName(token2_name);
+        node.merge(node2);
+
+        assertEquals(" ( "+rule_name+token_tostring+" || "+rule2_name+token_tostring+" ) ", node.toString());
+        assertEquals(rule_match + "{"
+        		+ "\n" + rule_action
+        		+ "\n" + token_return
+        +"}"+rule2_match+"{" 
+        + "\n" + rule2_action
+        + "\n" + token2_return
+        +"}return parseError(TOKEN_MYTOKEN,TOKEN_MYTOKEN2);\n"
+, node.toJava());
+    }
+
+    @Test(expected=Exception.class)
+    public void MergeConflict() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.appendTokenName(token_name);
+        LexerNode node2 = new LexerNode();
+        node2.append(rule);
+        node2.appendTokenName(token2_name);
+        try {
+            node.merge(node2);
+        } catch (Exception e) {
+            assertEquals("Rule conflict between: "+token_name +" and "+token2_name, e.getMessage());
+            throw e;
+        }
+    }
+
+    @Test
+    public void MergeWithoutConflictWithRemoveTokensName() throws Exception {
+        LexerNode node = new LexerNode();
+        node.append(rule);
+        node.append(rule);
+        node.appendTokenName(token_name);
+        LexerNode node2 = new LexerNode();
+        node2.append(rule);
+        node2.append(rule);
+        node2.appendTokenName(token2_name);
+        node2.removeTokensName();
+        node.merge(node2);
+        assertEquals(rule_name+rule_name+token_tostring, node.toString());
+    }
+}
diff --git a/asterix-maven-plugins/pom.xml b/asterix-maven-plugins/pom.xml
new file mode 100644
index 0000000..0677ffb
--- /dev/null
+++ b/asterix-maven-plugins/pom.xml
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>edu.uci.ics.asterix</groupId>
+  <artifactId>asterix-maven-plugins</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <dependencies>
+  	<dependency>
+  		<groupId>org.apache.maven</groupId>
+  		<artifactId>maven-plugin-api</artifactId>
+  		<version>2.2.1</version>
+  		<type>jar</type>
+  		<scope>compile</scope>
+  	</dependency>
+  </dependencies>
+
+  <modules>
+    <module>lexer-generator-maven-plugin</module>
+  </modules>
+</project>
diff --git a/asterix-metadata/pom.xml b/asterix-metadata/pom.xml
index 58566f8..3e8e0f9 100644
--- a/asterix-metadata/pom.xml
+++ b/asterix-metadata/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 		</plugins>
@@ -54,12 +55,12 @@
 			<version>0.0.4-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
-                <dependency>
-                        <groupId>org.apache.hadoop</groupId>
-                        <artifactId>hadoop-core</artifactId>
-                        <version>0.20.2</version>
-                        <type>jar</type>
-                        <scope>compile</scope>
-                </dependency>
+		<dependency>
+			<groupId>org.apache.hadoop</groupId>
+			<artifactId>hadoop-core</artifactId>
+			<version>0.20.2</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
 	</dependencies>
 </project>
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
index df61cd9..9c9d02b 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -50,5 +50,5 @@
      *            Metadata entity to be written into a tuple.
      * @throws IOException
      */
-    public ITupleReference getTupleFromMetadataEntity(T metadataEntity) throws IOException;
+    public ITupleReference getTupleFromMetadataEntity(T metadataEntity) throws MetadataException, IOException;
 }
\ No newline at end of file
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
index 01c849b..679c2db 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -18,6 +18,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.AUnionType;
@@ -49,31 +51,34 @@
     /**
      * Create all metadata record types.
      */
-    public static void init() {
+    public static void init() throws MetadataException {
         // Attention: The order of these calls is important because some types
         // depend on other types being created first.
         // These calls are one "dependency chain".
-        DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
-        INTERNAL_DETAILS_RECORDTYPE = createInternalDetailsRecordType();
-        EXTERNAL_DETAILS_RECORDTYPE = createExternalDetailsRecordType();
-        FEED_DETAILS_RECORDTYPE = createFeedDetailsRecordType();
-        DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
-        DATASET_RECORDTYPE = createDatasetRecordType();
+        try {
+            DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
+            INTERNAL_DETAILS_RECORDTYPE = createInternalDetailsRecordType();
+            EXTERNAL_DETAILS_RECORDTYPE = createExternalDetailsRecordType();
+            FEED_DETAILS_RECORDTYPE = createFeedDetailsRecordType();
+            DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
+            DATASET_RECORDTYPE = createDatasetRecordType();
 
-        // Starting another dependency chain.
-        FIELD_RECORDTYPE = createFieldRecordType();
-        RECORD_RECORDTYPE = createRecordTypeRecordType();
-        DERIVEDTYPE_RECORDTYPE = createDerivedTypeRecordType();
-        DATATYPE_RECORDTYPE = createDatatypeRecordType();
+            // Starting another dependency chain.
+            FIELD_RECORDTYPE = createFieldRecordType();
+            RECORD_RECORDTYPE = createRecordTypeRecordType();
+            DERIVEDTYPE_RECORDTYPE = createDerivedTypeRecordType();
+            DATATYPE_RECORDTYPE = createDatatypeRecordType();
 
-        // Independent of any other types.
-        DATAVERSE_RECORDTYPE = createDataverseRecordType();
-        INDEX_RECORDTYPE = createIndexRecordType();
-        NODE_RECORDTYPE = createNodeRecordType();
-        NODEGROUP_RECORDTYPE = createNodeGroupRecordType();
-        FUNCTION_RECORDTYPE = createFunctionRecordType();
-        DATASOURCE_ADAPTER_RECORDTYPE = createDatasourceAdapterRecordType();
-
+            // Independent of any other types.
+            DATAVERSE_RECORDTYPE = createDataverseRecordType();
+            INDEX_RECORDTYPE = createIndexRecordType();
+            NODE_RECORDTYPE = createNodeRecordType();
+            NODEGROUP_RECORDTYPE = createNodeGroupRecordType();
+            FUNCTION_RECORDTYPE = createFunctionRecordType();
+            DATASOURCE_ADAPTER_RECORDTYPE = createDatasourceAdapterRecordType();
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
     }
 
     // Helper constants for accessing fields in an ARecord of type
@@ -82,7 +87,7 @@
     public static final int DATAVERSE_ARECORD_FORMAT_FIELD_INDEX = 1;
     public static final int DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
 
-    private static final ARecordType createDataverseRecordType() {
+    private static final ARecordType createDataverseRecordType() throws AsterixException {
         return new ARecordType("DataverseRecordType", new String[] { "DataverseName", "DataFormat", "Timestamp" },
                 new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING }, true);
     }
@@ -93,7 +98,7 @@
     public static final int DATASOURCE_PROPERTIES_NAME_FIELD_INDEX = 0;
     public static final int DATASOURCE_PROPERTIES_VALUE_FIELD_INDEX = 1;
 
-    private static final ARecordType createPropertiesRecordType() {
+    private static final ARecordType createPropertiesRecordType() throws AsterixException {
         String[] fieldNames = { "Name", "Value" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING };
         return new ARecordType(null, fieldNames, fieldTypes, true);
@@ -107,7 +112,7 @@
     public static final int INTERNAL_DETAILS_ARECORD_PRIMARYKEY_FIELD_INDEX = 3;
     public static final int INTERNAL_DETAILS_ARECORD_GROUPNAME_FIELD_INDEX = 4;
 
-    private static final ARecordType createInternalDetailsRecordType() {
+    private static final ARecordType createInternalDetailsRecordType() throws AsterixException {
         AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
         String[] fieldNames = { "FileStructure", "PartitioningStrategy", "PartitioningKey", "PrimaryKey", "GroupName" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, olType, olType, BuiltinType.ASTRING };
@@ -119,7 +124,7 @@
     public static final int EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX = 0;
     public static final int EXTERNAL_DETAILS_ARECORD_PROPERTIES_FIELD_INDEX = 1;
 
-    private static final ARecordType createExternalDetailsRecordType() {
+    private static final ARecordType createExternalDetailsRecordType() throws AsterixException {
 
         AOrderedListType orderedPropertyListType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null);
         String[] fieldNames = { "DatasourceAdapter", "Properties" };
@@ -137,7 +142,7 @@
     public static final int FEED_DETAILS_ARECORD_FUNCTION_FIELD_INDEX = 7;
     public static final int FEED_DETAILS_ARECORD_STATE_FIELD_INDEX = 8;
 
-    private static final ARecordType createFeedDetailsRecordType() {
+    private static final ARecordType createFeedDetailsRecordType() throws AsterixException {
         AOrderedListType orderedListType = new AOrderedListType(BuiltinType.ASTRING, null);
         AOrderedListType orderedListOfPropertiesType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE,
                 null);
@@ -168,7 +173,7 @@
     public static final int DATASET_ARECORD_HINTS_FIELD_INDEX = 7;
     public static final int DATASET_ARECORD_TIMESTAMP_FIELD_INDEX = 8;
 
-    private static final ARecordType createDatasetRecordType() {
+    private static final ARecordType createDatasetRecordType() throws AsterixException {
         String[] fieldNames = { "DataverseName", "DatasetName", "DataTypeName", "DatasetType", "InternalDetails",
                 "ExternalDetails", "FeedDetails", "Hints", "Timestamp" };
 
@@ -200,7 +205,7 @@
     public static final int FIELD_ARECORD_FIELDNAME_FIELD_INDEX = 0;
     public static final int FIELD_ARECORD_FIELDTYPE_FIELD_INDEX = 1;
 
-    private static final ARecordType createFieldRecordType() {
+    private static final ARecordType createFieldRecordType() throws AsterixException {
         String[] fieldNames = { "FieldName", "FieldType" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING };
         return new ARecordType(null, fieldNames, fieldTypes, true);
@@ -211,7 +216,7 @@
     public static final int RECORDTYPE_ARECORD_ISOPEN_FIELD_INDEX = 0;
     public static final int RECORDTYPE_ARECORD_FIELDS_FIELD_INDEX = 1;
 
-    private static final ARecordType createRecordTypeRecordType() {
+    private static final ARecordType createRecordTypeRecordType() throws AsterixException {
         AOrderedListType olType = new AOrderedListType(FIELD_RECORDTYPE, null);
         String[] fieldNames = { "IsOpen", "Fields" };
         IAType[] fieldTypes = { BuiltinType.ABOOLEAN, olType };
@@ -228,7 +233,7 @@
     public static final int DERIVEDTYPE_ARECORD_UNORDEREDLIST_FIELD_INDEX = 5;
     public static final int DERIVEDTYPE_ARECORD_ORDEREDLIST_FIELD_INDEX = 6;
 
-    private static final ARecordType createDerivedTypeRecordType() {
+    private static final ARecordType createDerivedTypeRecordType() throws AsterixException {
         String[] fieldNames = { "Tag", "IsAnonymous", "EnumValues", "Record", "Union", "UnorderedList", "OrderedList" };
         List<IAType> recordUnionList = new ArrayList<IAType>();
         recordUnionList.add(BuiltinType.ANULL);
@@ -257,7 +262,7 @@
     public static final int DATATYPE_ARECORD_DERIVED_FIELD_INDEX = 2;
     public static final int DATATYPE_ARECORD_TIMESTAMP_FIELD_INDEX = 3;
 
-    private static final ARecordType createDatatypeRecordType() {
+    private static final ARecordType createDatatypeRecordType() throws AsterixException {
         String[] fieldNames = { "DataverseName", "DatatypeName", "Derived", "Timestamp" };
         List<IAType> recordUnionList = new ArrayList<IAType>();
         recordUnionList.add(BuiltinType.ANULL);
@@ -277,7 +282,7 @@
     public static final int INDEX_ARECORD_ISPRIMARY_FIELD_INDEX = 5;
     public static final int INDEX_ARECORD_TIMESTAMP_FIELD_INDEX = 6;
 
-    private static final ARecordType createIndexRecordType() {
+    private static final ARecordType createIndexRecordType() throws AsterixException {
         AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
         String[] fieldNames = { "DataverseName", "DatasetName", "IndexName", "IndexStructure", "SearchKey",
                 "IsPrimary", "Timestamp" };
@@ -292,7 +297,7 @@
     public static final int NODE_ARECORD_NUMBEROFCORES_FIELD_INDEX = 1;
     public static final int NODE_ARECORD_WORKINGMEMORYSIZE_FIELD_INDEX = 2;
 
-    private static final ARecordType createNodeRecordType() {
+    private static final ARecordType createNodeRecordType() throws AsterixException {
         String[] fieldNames = { "NodeName", "NumberOfCores", "WorkingMemorySize" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.AINT32, BuiltinType.AINT32 };
         return new ARecordType("NodeRecordType", fieldNames, fieldTypes, true);
@@ -304,7 +309,7 @@
     public static final int NODEGROUP_ARECORD_NODENAMES_FIELD_INDEX = 1;
     public static final int NODEGROUP_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
 
-    private static final ARecordType createNodeGroupRecordType() {
+    private static final ARecordType createNodeGroupRecordType() throws AsterixException {
         AUnorderedListType ulType = new AUnorderedListType(BuiltinType.ASTRING, null);
         String[] fieldNames = { "GroupName", "NodeNames", "Timestamp" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, ulType, BuiltinType.ASTRING };
@@ -326,7 +331,7 @@
     public static final int FUNCTION_ARECORD_FUNCTION_LANGUAGE_FIELD_INDEX = 6;
     public static final int FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX = 7;
 
-    private static final ARecordType createFunctionRecordType() {
+    private static final ARecordType createFunctionRecordType() throws AsterixException {
 
         String[] fieldNames = { "DataverseName", "Name", "Arity", "Params", "ReturnType", "Definition", "Language",
                 "Kind" };
@@ -342,7 +347,7 @@
     public static final int DATASOURCE_ADAPTER_ARECORD_TYPE_FIELD_INDEX = 3;
     public static final int DATASOURCE_ADAPTER_ARECORD_TIMESTAMP_FIELD_INDEX = 4;
 
-    private static ARecordType createDatasourceAdapterRecordType() {
+    private static ARecordType createDatasourceAdapterRecordType() throws AsterixException {
         String[] fieldNames = { "DataverseName", "Name", "Classname", "Type", "Timestamp" };
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
                 BuiltinType.ASTRING };
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
index b7ba1a1..e4c7ba2 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -15,6 +15,7 @@
 
 package edu.uci.ics.asterix.metadata.declared;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -63,46 +64,54 @@
         this.id = id;
         this.dataset = dataset;
         this.datasourceType = datasourceType;
-        switch (datasourceType) {
-            case FEED:
-                initFeedDataset(itemType, dataset);
-            case INTERNAL: {
-                initInternalDataset(itemType);
-                break;
+        try {
+            switch (datasourceType) {
+                case FEED:
+                    initFeedDataset(itemType, dataset);
+                case INTERNAL: {
+                    initInternalDataset(itemType);
+                    break;
+                }
+                case EXTERNAL_FEED:
+                case EXTERNAL: {
+                    initExternalDataset(itemType);
+                    break;
+                }
+                default: {
+                    throw new IllegalArgumentException();
+                }
             }
-            case EXTERNAL_FEED:
-            case EXTERNAL: {
-                initExternalDataset(itemType);
-                break;
-            }
-            default: {
-                throw new IllegalArgumentException();
-            }
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
         }
     }
 
     public AqlDataSource(AqlSourceId id, Dataset dataset, IAType itemType) throws AlgebricksException {
         this.id = id;
         this.dataset = dataset;
-        switch (dataset.getDatasetType()) {
-            case FEED:
-                initFeedDataset(itemType, dataset);
-                break;
-            case INTERNAL:
-                initInternalDataset(itemType);
-                break;
-            case EXTERNAL: {
-                initExternalDataset(itemType);
-                break;
+        try {
+            switch (dataset.getDatasetType()) {
+                case FEED:
+                    initFeedDataset(itemType, dataset);
+                    break;
+                case INTERNAL:
+                    initInternalDataset(itemType);
+                    break;
+                case EXTERNAL: {
+                    initExternalDataset(itemType);
+                    break;
+                }
+                default: {
+                    throw new IllegalArgumentException();
+                }
             }
-            default: {
-                throw new IllegalArgumentException();
-            }
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
         }
     }
 
     // TODO: Seems like initFeedDataset() could simply call this method.
-    private void initInternalDataset(IAType itemType) {
+    private void initInternalDataset(IAType itemType) throws IOException {
         List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
         ARecordType recordType = (ARecordType) itemType;
         int n = partitioningKeys.size();
@@ -114,7 +123,7 @@
         domain = new AsterixNodeGroupDomain(DatasetUtils.getNodegroupName(dataset));
     }
 
-    private void initFeedDataset(IAType itemType, Dataset dataset) {
+    private void initFeedDataset(IAType itemType, Dataset dataset) throws IOException {
         if (dataset.getDatasetDetails() instanceof ExternalDatasetDetails) {
             initExternalDataset(itemType);
         } else {
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
index d92c76d..321a73c 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -16,6 +16,7 @@
 package edu.uci.ics.asterix.metadata.declared;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -851,7 +852,7 @@
                     splitsAndConstraint.first, typeTraits, comparatorFactories, fieldPermutation, indexOp,
                     new BTreeDataflowHelperFactory(), filterFactory, NoOpOperationCallbackProvider.INSTANCE, jobTxnId);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeInsert, splitsAndConstraint.second);
-        } catch (MetadataException e) {
+        } catch (MetadataException | IOException e) {
             throw new AlgebricksException(e);
         }
     }
@@ -918,8 +919,8 @@
                     new RTreeDataflowHelperFactory(valueProviderFactories), filterFactory,
                     NoOpOperationCallbackProvider.INSTANCE, jobTxnId);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(rtreeUpdate, splitsAndConstraint.second);
-        } catch (MetadataException me) {
-            throw new AlgebricksException(me);
+        } catch (MetadataException | IOException e) {
+            throw new AlgebricksException(e);
         }
     }
 
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
index 07da617..18cef340 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.metadata.entities;
 
 import java.io.DataOutput;
@@ -22,6 +23,7 @@
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.IDatasetDetails;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -76,7 +78,8 @@
         fieldValue.reset();
         aString.setValue(this.getAdapter());
         stringSerde.serialize(aString, fieldValue.getDataOutput());
-        externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX, fieldValue);
+        externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX,
+                fieldValue);
 
         // write field 1
         listBuilder.reset((AOrderedListType) externalRecordType.getFieldTypes()[1]);
@@ -93,8 +96,8 @@
 
         try {
             externalRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
-            throw new HyracksDataException(ioe);
+        } catch (IOException | AsterixException e) {
+            throw new HyracksDataException(e);
         }
 
     }
@@ -121,8 +124,8 @@
 
         try {
             propertyRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
-            throw new HyracksDataException(ioe);
+        } catch (IOException | AsterixException e) {
+            throw new HyracksDataException(e);
         }
     }
 }
\ No newline at end of file
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
index 367066b..22de3d3 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.metadata.entities;
 
 import java.io.DataOutput;
@@ -23,6 +24,7 @@
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.common.functions.FunctionSignature;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -160,8 +162,8 @@
 
         try {
             feedRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
-            throw new HyracksDataException(ioe);
+        } catch (IOException | AsterixException e) {
+            throw new HyracksDataException(e);
         }
 
     }
@@ -188,8 +190,8 @@
 
         try {
             propertyRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
-            throw new HyracksDataException(ioe);
+        } catch (IOException | AsterixException e) {
+            throw new HyracksDataException(e);
         }
     }
 
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
index 51d154a..4267af2 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.metadata.entities;
 
 import java.io.DataOutput;
@@ -22,6 +23,7 @@
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.IDatasetDetails;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -146,8 +148,8 @@
 
         try {
             internalRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
-            throw new HyracksDataException(ioe);
+        } catch (IOException | AsterixException e) {
+            throw new HyracksDataException(e);
         }
     }
 
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
index 483bb70..a0aa36e 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2012 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -30,9 +30,11 @@
 import edu.uci.ics.asterix.builders.RecordBuilder;
 import edu.uci.ics.asterix.builders.UnorderedListBuilder;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.common.functions.FunctionSignature;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.IDatasetDetails;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
@@ -212,7 +214,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Dataset dataset) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Dataset dataset) throws IOException, MetadataException {
         // write the key in the first 2 fields of the tuple
         tupleBuilder.reset();
         aString.setValue(dataset.getDataverseName());
@@ -277,7 +279,11 @@
         recordBuilder.addField(MetadataRecordTypes.DATASET_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
 
         // write record
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
@@ -342,7 +348,7 @@
 
         try {
             propertyRecordBuilder.write(out, true);
-        } catch (IOException ioe) {
+        } catch (IOException | AsterixException ioe) {
             throw new HyracksDataException(ioe);
         }
     }
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
index 6353e99..4a5e4dcf 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2012 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package edu.uci.ics.asterix.metadata.entitytupletranslators;
 
 import java.io.ByteArrayInputStream;
@@ -20,6 +21,7 @@
 import java.io.IOException;
 import java.util.Calendar;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.external.dataset.adapter.AdapterIdentifier;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.MetadataException;
@@ -64,7 +66,8 @@
 
     private DatasourceAdapter createAdapterFromARecord(ARecord adapterRecord) {
         String dataverseName = ((AString) adapterRecord
-                .getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
+                .getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX))
+                .getStringValue();
         String adapterName = ((AString) adapterRecord
                 .getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_NAME_FIELD_INDEX)).getStringValue();
         String classname = ((AString) adapterRecord
@@ -76,7 +79,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(DatasourceAdapter adapter) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(DatasourceAdapter adapter) throws IOException, MetadataException {
         // write the key in the first 2 fields of the tuple
         tupleBuilder.reset();
         aString.setValue(adapter.getAdapterIdentifier().getNamespace());
@@ -121,7 +124,11 @@
         recordBuilder.addField(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
 
         // write record
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
index d37fbc6..185f35b 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -28,6 +28,7 @@
 import edu.uci.ics.asterix.builders.IARecordBuilder;
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataNode;
@@ -140,8 +141,12 @@
                         fieldTypes[fieldId] = getTypeFromTypeName(dataverseName, fieldTypeName);
                         fieldId++;
                     }
-                    return new Datatype(dataverseName, datatypeName, new ARecordType(datatypeName, fieldNames,
-                            fieldTypes, isOpen), isAnonymous);
+                    try {
+                        return new Datatype(dataverseName, datatypeName, new ARecordType(datatypeName, fieldNames,
+                                fieldTypes, isOpen), isAnonymous);
+                    } catch (AsterixException e) {
+                        throw new MetadataException(e);
+                    }
                 }
                 case UNION: {
                     IACursor cursor = ((AOrderedList) derivedTypeRecord
@@ -189,7 +194,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Datatype dataType) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Datatype dataType) throws IOException, MetadataException {
         // write the key in the first two fields of the tuple
         tupleBuilder.reset();
         aString.setValue(dataType.getDataverseName());
@@ -218,7 +223,11 @@
         ATypeTag tag = dataType.getDatatype().getTypeTag();
         if (isDerivedType(tag)) {
             fieldValue.reset();
-            writeDerivedTypeRecord(dataType, fieldValue.getDataOutput());
+            try {
+                writeDerivedTypeRecord(dataType, fieldValue.getDataOutput());
+            } catch (AsterixException e) {
+                throw new MetadataException(e);
+            }
             recordBuilder.addField(MetadataRecordTypes.DATATYPE_ARECORD_DERIVED_FIELD_INDEX, fieldValue);
         }
 
@@ -229,14 +238,18 @@
         recordBuilder.addField(MetadataRecordTypes.DATATYPE_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
 
         // write record
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
         return tuple;
     }
 
-    public void writeDerivedTypeRecord(Datatype type, DataOutput out) throws IOException {
+    private void writeDerivedTypeRecord(Datatype type, DataOutput out) throws IOException, AsterixException {
         DerivedTypeTag tag;
         IARecordBuilder derivedRecordBuilder = new RecordBuilder();
         ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
@@ -348,7 +361,7 @@
         listBuilder.write(dataOutput, true);
     }
 
-    public void writeRecordType(Datatype instance, DataOutput out) throws IOException {
+    private void writeRecordType(Datatype instance, DataOutput out) throws IOException, AsterixException {
 
         ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
         ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
index 271bf90..1e32004 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -21,7 +21,9 @@
 import java.io.IOException;
 import java.util.Calendar;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.Dataverse;
@@ -61,7 +63,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Dataverse instance) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Dataverse instance) throws IOException, MetadataException {
         // write the key in the first field of the tuple
         tupleBuilder.reset();
         aString.setValue(instance.getDataverseName());
@@ -88,7 +90,11 @@
         stringSerde.serialize(aString, fieldValue.getDataOutput());
         recordBuilder.addField(MetadataRecordTypes.DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
 
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
index 8296a22..c34bc72 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -23,7 +23,9 @@
 import java.util.List;
 
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.Function;
@@ -48,7 +50,6 @@
     // Third key field.
     public static final int FUNCTION_FUNCTIONARITY_TUPLE_FIELD_INDEX = 2;
 
-    
     // Payload field containing serialized Function.
     public static final int FUNCTION_PAYLOAD_TUPLE_FIELD_INDEX = 3;
 
@@ -103,7 +104,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Function function) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Function function) throws IOException, MetadataException {
         // write the key in the first 2 fields of the tuple
         tupleBuilder.reset();
         aString.setValue(function.getDataverseName());
@@ -178,7 +179,11 @@
         recordBuilder.addField(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX, fieldValue);
 
         // write record
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
index d71480f..07d7cc9 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -25,7 +25,9 @@
 
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.Index;
@@ -106,7 +108,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Index instance) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Index instance) throws IOException, MetadataException {
         // write the key in the first 3 fields of the tuple
         tupleBuilder.reset();
         aString.setValue(instance.getDataverseName());
@@ -181,11 +183,19 @@
             aString.setValue(GRAM_LENGTH_FIELD_NAME);
             stringSerde.serialize(aString, nameValue.getDataOutput());
             intSerde.serialize(new AInt32(instance.getGramLength()), fieldValue.getDataOutput());
-            recordBuilder.addField(nameValue, fieldValue);
+            try {
+                recordBuilder.addField(nameValue, fieldValue);
+            } catch (AsterixException e) {
+                throw new MetadataException(e);
+            }
         }
 
         // write record
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
index da66d4b..ce72322 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -24,7 +24,9 @@
 import java.util.List;
 
 import edu.uci.ics.asterix.builders.UnorderedListBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.NodeGroup;
@@ -79,7 +81,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(NodeGroup instance) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(NodeGroup instance) throws IOException, MetadataException {
         // write the key in the first field of the tuple
         tupleBuilder.reset();
         aString.setValue(instance.getNodeGroupName());
@@ -114,7 +116,11 @@
         stringSerde.serialize(aString, fieldValue.getDataOutput());
         recordBuilder.addField(MetadataRecordTypes.NODEGROUP_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
 
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
 
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
index 8d324b4..9e276cc 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -17,7 +17,9 @@
 
 import java.io.IOException;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
 import edu.uci.ics.asterix.metadata.entities.Node;
@@ -80,7 +82,7 @@
     }
 
     @Override
-    public ITupleReference getTupleFromMetadataEntity(Node instance) throws IOException {
+    public ITupleReference getTupleFromMetadataEntity(Node instance) throws IOException, MetadataException {
         // write the key in the first field of the tuple
         tupleBuilder.reset();
         aString.setValue(instance.getNodeName());
@@ -121,7 +123,11 @@
         // listBuilder.write(fieldValue.getDataOutput());
         // recordBuilder.addField(3, fieldValue);
 
-        recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        try {
+            recordBuilder.write(tupleBuilder.getDataOutput(), true);
+        } catch (AsterixException e) {
+            throw new MetadataException(e);
+        }
         tupleBuilder.addFieldEndOffset();
         tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
         return tuple;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
index cead5f2..df41c6e 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.metadata.utils;
 
+import java.io.IOException;
 import java.util.List;
 
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
@@ -25,7 +41,12 @@
         List<String> partitioningKeys = getPartitioningKeys(dataset);
         IBinaryComparatorFactory[] bcfs = new IBinaryComparatorFactory[partitioningKeys.size()];
         for (int i = 0; i < partitioningKeys.size(); i++) {
-            IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+            IAType keyType;
+            try {
+                keyType = itemType.getFieldType(partitioningKeys.get(i));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             bcfs[i] = comparatorFactoryProvider.getBinaryComparatorFactory(keyType, true);
         }
         return bcfs;
@@ -39,7 +60,12 @@
         List<String> partitioningKeys = getPartitioningKeys(dataset);
         IBinaryHashFunctionFactory[] bhffs = new IBinaryHashFunctionFactory[partitioningKeys.size()];
         for (int i = 0; i < partitioningKeys.size(); i++) {
-            IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+            IAType keyType;
+            try {
+                keyType = itemType.getFieldType(partitioningKeys.get(i));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             bhffs[i] = hashFunProvider.getBinaryHashFunctionFactory(keyType);
         }
         return bhffs;
@@ -54,7 +80,12 @@
         int numKeys = partitioningKeys.size();
         ITypeTraits[] typeTraits = new ITypeTraits[numKeys + 1];
         for (int i = 0; i < numKeys; i++) {
-            IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+            IAType keyType;
+            try {
+                keyType = itemType.getFieldType(partitioningKeys.get(i));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
             typeTraits[i] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(keyType);
         }
         typeTraits[numKeys] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(itemType);
diff --git a/asterix-om/pom.xml b/asterix-om/pom.xml
index 8cceaa0..8ff3f84 100644
--- a/asterix-om/pom.xml
+++ b/asterix-om/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 		</plugins>
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
index 544b532..7cdb9a9 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -18,6 +18,7 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.hyracks.data.std.api.IValueReference;
 
@@ -49,8 +50,10 @@
      *            The field name.
      * @param out
      *            The field value.
+     * @throws AsterixException
+     *             if the field name conflicts with a closed field name
      */
-    public void addField(IValueReference name, IValueReference value);
+    public void addField(IValueReference name, IValueReference value) throws AsterixException;
 
     /**
      * @param out
@@ -59,8 +62,10 @@
      *            Whether to write a typetag as part of the record's serialized
      *            representation.
      * @throws IOException
+     * @throws AsterixException
+     *             if any open field names conflict with each other
      */
-    public void write(DataOutput out, boolean writeTypeTag) throws IOException;
+    public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException;
 
     public int getFieldId(String fieldName);
 
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
index 03f0e20..f5d07ae 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
@@ -1,40 +1,46 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.builders;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Arrays;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
 import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
 import edu.uci.ics.hyracks.data.std.api.IValueReference;
 import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
 
 public class RecordBuilder implements IARecordBuilder {
-    private int openPartOffset;
+    private final static int DEFAULT_NUM_OPEN_FIELDS = 10;
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
 
-    private ARecordType recType;
-
-    private ByteArrayOutputStream closedPartOutputStream;
-    private int[] closedPartOffsets;
-    private int numberOfClosedFields;
-    private byte[] nullBitMap;
-    private int nullBitMapSize;
-
-    private ByteArrayOutputStream openPartOutputStream;
-    private long[] openPartOffsets;
-    private long[] tempOpenPartOffsets;
-
-    private int numberOfOpenFields;
-
-    private int fieldNameHashCode;
-    private final IBinaryHashFunction utf8HashFunction;
-
-    // for write()
     private int openPartOffsetArraySize;
     private byte[] openPartOffsetArray;
     private int offsetPosition;
@@ -42,25 +48,40 @@
     private boolean isOpen;
     private boolean isNullable;
     private int numberOfSchemaFields;
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
+
+    private int openPartOffset;
+    private ARecordType recType;
+
+    private final IBinaryHashFunction utf8HashFunction;
+    private final IBinaryComparator utf8Comparator;
+
+    private final ByteArrayOutputStream closedPartOutputStream;
+    private int[] closedPartOffsets;
+    private int numberOfClosedFields;
+    private byte[] nullBitMap;
+    private int nullBitMapSize;
+
+    private final ByteArrayAccessibleOutputStream openPartOutputStream;
+    private long[] openPartOffsets;
+    private int[] openFieldNameLengths;
+
+    private int numberOfOpenFields;
 
     public RecordBuilder() {
 
         this.closedPartOutputStream = new ByteArrayOutputStream();
         this.numberOfClosedFields = 0;
 
-        this.openPartOutputStream = new ByteArrayOutputStream();
-        this.openPartOffsets = new long[20];
-        this.tempOpenPartOffsets = new long[20];
-
+        this.openPartOutputStream = new ByteArrayAccessibleOutputStream();
+        this.openPartOffsets = new long[DEFAULT_NUM_OPEN_FIELDS];
+        this.openFieldNameLengths = new int[DEFAULT_NUM_OPEN_FIELDS];
         this.numberOfOpenFields = 0;
 
-        this.fieldNameHashCode = 0;
         this.utf8HashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
                 .createBinaryHashFunction();
+        this.utf8Comparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+                .createBinaryComparator();
 
-        // for write()
         this.openPartOffsetArray = null;
         this.openPartOffsetArraySize = 0;
         this.offsetPosition = 0;
@@ -135,23 +156,31 @@
     }
 
     @Override
-    public void addField(IValueReference name, IValueReference value) {
+    public void addField(IValueReference name, IValueReference value) throws AsterixException {
         if (numberOfOpenFields == openPartOffsets.length) {
-            tempOpenPartOffsets = openPartOffsets;
-            openPartOffsets = new long[numberOfOpenFields + 20];
-            for (int i = 0; i < tempOpenPartOffsets.length; i++)
-                openPartOffsets[i] = tempOpenPartOffsets[i];
+            openPartOffsets = Arrays.copyOf(openPartOffsets, openPartOffsets.length + DEFAULT_NUM_OPEN_FIELDS);
+            openFieldNameLengths = Arrays.copyOf(openFieldNameLengths, openFieldNameLengths.length
+                    + DEFAULT_NUM_OPEN_FIELDS);
         }
-        fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset() + 1, name.getLength());
+        int fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset() + 1, name.getLength());
+        if (recType != null) {
+            int cFieldPos = recType.findFieldPosition(name.getByteArray(), name.getStartOffset() + 1,
+                    name.getLength() - 1);
+            if (cFieldPos >= 0) {
+                throw new AsterixException("Open field \"" + recType.getFieldNames()[cFieldPos]
+                        + "\" has the same field name as closed field at index " + cFieldPos);
+            }
+        }
         openPartOffsets[this.numberOfOpenFields] = fieldNameHashCode;
         openPartOffsets[this.numberOfOpenFields] = (openPartOffsets[numberOfOpenFields] << 32);
-        openPartOffsets[numberOfOpenFields++] += openPartOutputStream.size();
+        openPartOffsets[numberOfOpenFields] += openPartOutputStream.size();
+        openFieldNameLengths[numberOfOpenFields++] = name.getLength() - 1;
         openPartOutputStream.write(name.getByteArray(), name.getStartOffset() + 1, name.getLength() - 1);
         openPartOutputStream.write(value.getByteArray(), value.getStartOffset(), value.getLength());
     }
 
     @Override
-    public void write(DataOutput out, boolean writeTypeTag) throws IOException {
+    public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException {
         int h = headerSize;
         int recordLength;
         // prepare the open part
@@ -163,13 +192,27 @@
                 openPartOffsetArray = new byte[openPartOffsetArraySize];
 
             Arrays.sort(this.openPartOffsets, 0, numberOfOpenFields);
+            if (numberOfOpenFields > 1) {
+                byte[] openBytes = openPartOutputStream.getByteArray();
+                for (int i = 1; i < numberOfOpenFields; i++) {
+                    if (utf8Comparator.compare(openBytes, (int) openPartOffsets[i - 1], openFieldNameLengths[i - 1],
+                            openBytes, (int) openPartOffsets[i], openFieldNameLengths[i]) == 0) {
+                        String field = UTF8StringSerializerDeserializer.INSTANCE
+                                .deserialize(new DataInputStream(new ByteArrayInputStream(openBytes,
+                                        (int) openPartOffsets[i], openFieldNameLengths[i])));
+                        throw new AsterixException("Open fields " + (i - 1) + " and " + i
+                                + " have the same field name \"" + field + "\"");
+                    }
+                }
+            }
 
             openPartOffset = h + numberOfSchemaFields * 4 + closedPartOutputStream.size();
+            int fieldNameHashCode;
             for (int i = 0; i < numberOfOpenFields; i++) {
                 fieldNameHashCode = (int) (openPartOffsets[i] >> 32);
                 SerializerDeserializerUtil.writeIntToByteArray(openPartOffsetArray, (int) fieldNameHashCode,
                         offsetPosition);
-                int fieldOffset = (int) ((openPartOffsets[i] << 64) >> 64);
+                int fieldOffset = (int) openPartOffsets[i];
                 SerializerDeserializerUtil.writeIntToByteArray(openPartOffsetArray, fieldOffset + openPartOffset + 4
                         + openPartOffsetArraySize, offsetPosition + 4);
                 offsetPosition += 8;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
index 393f634..a450f27 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -21,6 +21,7 @@
 
 import edu.uci.ics.asterix.builders.IARecordBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -149,7 +150,7 @@
             } else {
                 return new ARecord(this.recordType, closedFields);
             }
-        } catch (IOException e) {
+        } catch (IOException | AsterixException e) {
             throw new HyracksDataException(e);
         }
     }
@@ -166,7 +167,7 @@
         return fields;
     }
 
-    private ARecordType mergeRecordTypes(ARecordType recType1, ARecordType recType2) {
+    private ARecordType mergeRecordTypes(ARecordType recType1, ARecordType recType2) throws AsterixException {
 
         String[] fieldNames = new String[recType1.getFieldNames().length + recType2.getFieldNames().length];
         IAType[] fieldTypes = new IAType[recType1.getFieldTypes().length + recType2.getFieldTypes().length];
@@ -199,7 +200,7 @@
             }
             try {
                 recordBuilder.write(out, false);
-            } catch (IOException e) {
+            } catch (IOException | AsterixException e) {
                 throw new HyracksDataException(e);
             }
         } else {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
index 9184616..45ae5c5 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -15,6 +15,8 @@
 
 package edu.uci.ics.asterix.om.pointables.base;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -27,13 +29,19 @@
  * fields in the open part, e.g., a "record" (nested) field in the open part is
  * always a fully open one, and a "list" field in the open part is always a list
  * of "ANY".
- * 
  */
 public class DefaultOpenFieldType {
 
     // nested open field rec type
-    public static ARecordType NESTED_OPEN_RECORD_TYPE = new ARecordType("nested-open", new String[] {},
-            new IAType[] {}, true);
+    public static ARecordType NESTED_OPEN_RECORD_TYPE;
+
+    static {
+        try {
+            NESTED_OPEN_RECORD_TYPE = new ARecordType("nested-open", new String[] {}, new IAType[] {}, true);
+        } catch (AsterixException e) {
+            throw new AsterixRuntimeException();
+        }
+    }
 
     // nested open list type
     public static AOrderedListType NESTED_OPEN_AORDERED_LIST_TYPE = new AOrderedListType(BuiltinType.ANY,
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
index daf7164..8ed2084 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -19,6 +19,7 @@
 
 import org.apache.commons.lang3.mutable.Mutable;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -49,7 +50,7 @@
         ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
         if (type != null)
             return type;
-        
+
         int n = f.getArguments().size() / 2;
         String[] fieldNames = new String[n];
         IAType[] fieldTypes = new IAType[n];
@@ -68,6 +69,10 @@
             fieldTypes[i] = (IAType) env.getType(e2);
             i++;
         }
-        return new ARecordType(null, fieldNames, fieldTypes, false);
+        try {
+            return new ARecordType(null, fieldNames, fieldTypes, false);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
index 8b54197..ee52425 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
@@ -1,8 +1,24 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.om.typecomputer.impl;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.AUnionType;
@@ -23,7 +39,11 @@
         List<IAType> unionList = new ArrayList<IAType>();
         unionList.add(BuiltinType.ANULL);
         unionList.add(BuiltinType.ADOUBLE);
-        return new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+        try {
+            return new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                    new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
index c46c59b..0c6fc55 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 by The Regents of the University of California
  * Licensed 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 from
@@ -21,6 +21,7 @@
 
 import org.apache.commons.lang3.mutable.Mutable;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -72,6 +73,10 @@
         IAType[] fieldTypes = new IAType[n];
         fieldNames = namesList.toArray(fieldNames);
         fieldTypes = typesList.toArray(fieldTypes);
-        return new ARecordType(null, fieldNames, fieldTypes, true);
+        try {
+            return new ARecordType(null, fieldNames, fieldTypes, true);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
index d20f43b..1f072f0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
@@ -1,9 +1,25 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.om.typecomputer.impl;
 
 import java.util.Iterator;
 
 import org.apache.commons.lang3.mutable.Mutable;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -58,6 +74,10 @@
             }
             i++;
         }
-        return new ARecordType(null, fieldNames, fieldTypes, isOpen);
+        try {
+            return new ARecordType(null, fieldNames, fieldTypes, isOpen);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
index 1cf6ba7..82320e4 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
@@ -1,15 +1,38 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.om.types;
 
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import edu.uci.ics.asterix.common.annotations.IRecordTypeAnnotation;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
 
 public class ARecordType extends AbstractComplexType {
 
@@ -18,16 +41,110 @@
     private IAType[] fieldTypes;
     private boolean isOpen;
     private final List<IRecordTypeAnnotation> annotations = new ArrayList<IRecordTypeAnnotation>();
-    private final Map<String, Integer> typeMap = new HashMap<String, Integer>();
 
-    public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean isOpen) {
+    private transient IBinaryHashFunction fieldNameHashFunction;
+    private transient IBinaryComparator fieldNameComparator;
+    private final byte serializedFieldNames[];
+    private final int serializedFieldNameOffsets[];
+    private final long hashCodeIndexPairs[];
+
+    /**
+     * @param typeName
+     *            the name of the type
+     * @param fieldNames
+     *            the names of the closed fields
+     * @param fieldTypes
+     *            the types of the closed fields
+     * @param isOpen
+     *            whether the record is open
+     * @throws AsterixException
+     *             if there are duplicate field names or if there is an error serializing the field names
+     */
+    public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean isOpen)
+            throws AsterixException {
         super(typeName);
         this.fieldNames = fieldNames;
         this.fieldTypes = fieldTypes;
         this.isOpen = isOpen;
+
+        fieldNameComparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+                .createBinaryComparator();
+        fieldNameHashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
+                .createBinaryHashFunction();
+        ByteArrayAccessibleOutputStream baaos = new ByteArrayAccessibleOutputStream();
+        DataOutputStream dos = new DataOutputStream(baaos);
+        serializedFieldNameOffsets = new int[fieldNames.length];
+        hashCodeIndexPairs = new long[fieldNames.length];
+
+        int length = 0;
         for (int i = 0; i < fieldNames.length; i++) {
-            typeMap.put(fieldNames[i], i);
+            serializedFieldNameOffsets[i] = baaos.size();
+            try {
+                dos.writeUTF(fieldNames[i]);
+            } catch (IOException e) {
+                throw new AsterixException(e);
+            }
+            length = baaos.size() - serializedFieldNameOffsets[i];
+            hashCodeIndexPairs[i] = fieldNameHashFunction.hash(baaos.getByteArray(), serializedFieldNameOffsets[i],
+                    length);
+            hashCodeIndexPairs[i] = hashCodeIndexPairs[i] << 32;
+            hashCodeIndexPairs[i] = hashCodeIndexPairs[i] | i;
         }
+        serializedFieldNames = baaos.getByteArray();
+
+        Arrays.sort(hashCodeIndexPairs);
+        int j;
+        for (int i = 0; i < fieldNames.length; i++) {
+            j = findFieldPosition(serializedFieldNames, serializedFieldNameOffsets[i],
+                    UTF8StringPointable.getStringLength(serializedFieldNames, serializedFieldNameOffsets[i]));
+            if (j != i) {
+                throw new AsterixException("Closed fields " + j + " and " + i + " have the same field name \""
+                        + fieldNames[i] + "\"");
+            }
+        }
+    }
+
+    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+        ois.defaultReadObject();
+        fieldNameComparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+                .createBinaryComparator();
+        fieldNameHashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
+                .createBinaryHashFunction();
+    }
+
+    /**
+     * Returns the position of the field in the closed schema or -1 if the field does not exist.
+     * 
+     * @param bytes
+     *            the serialized bytes of the field name
+     * @param start
+     *            the starting offset of the field name in bytes
+     * @param length
+     *            the length of the field name in bytes
+     * @return the position of the field in the closed schema or -1 if the field does not exist.
+     */
+    public int findFieldPosition(byte[] bytes, int start, int length) {
+        if (hashCodeIndexPairs.length == 0) {
+            return -1;
+        }
+
+        int fIndex;
+        int probeFieldHash = fieldNameHashFunction.hash(bytes, start, length);
+        int i = Arrays.binarySearch(hashCodeIndexPairs, ((long) probeFieldHash) << 32);
+        i = (i < 0) ? (i = -1 * (i + 1)) : i;
+
+        while (i < hashCodeIndexPairs.length && (int) (hashCodeIndexPairs[i] >>> 32) == probeFieldHash) {
+            fIndex = (int) hashCodeIndexPairs[i];
+            int cFieldLength = UTF8StringPointable.getStringLength(serializedFieldNames,
+                    serializedFieldNameOffsets[fIndex]);
+            if (fieldNameComparator.compare(serializedFieldNames, serializedFieldNameOffsets[fIndex], cFieldLength,
+                    bytes, start, length) == 0) {
+                return fIndex;
+            }
+            i++;
+        }
+
+        return -1;
     }
 
     public final String[] getFieldNames() {
@@ -73,17 +190,48 @@
         return isOpen;
     }
 
-    public int findFieldPosition(String fldName) {
-        for (int i = 0; i < fieldNames.length; i++) {
-            if (fieldNames[i].equals(fldName)) {
-                return i;
-            }
-        }
-        return -1;
+    /**
+     * Returns the position of the field in the closed schema or -1 if the field does not exist.
+     * 
+     * @param fieldName
+     *            the name of the field whose position is sought
+     * @return the position of the field in the closed schema or -1 if the field does not exist.
+     */
+    public int findFieldPosition(String fieldName) throws IOException {
+        ByteArrayAccessibleOutputStream baaos = new ByteArrayAccessibleOutputStream();
+        DataOutputStream dos = new DataOutputStream(baaos);
+        UTF8StringSerializerDeserializer.INSTANCE.serialize(fieldName, dos);
+        return findFieldPosition(baaos.getByteArray(), 0, baaos.getByteArray().length);
     }
 
-    public IAType getFieldType(String fieldName) {
-        return fieldTypes[typeMap.get(fieldName)];
+    /**
+     * Returns the field type of the field name if it exists, otherwise null.
+     * 
+     * @param fieldName
+     *            the fieldName whose type is sought
+     * @return the field type of the field name if it exists, otherwise null
+     * @throws IOException
+     *             if an error occurs while serializing the field name
+     */
+    public IAType getFieldType(String fieldName) throws IOException {
+        int fieldPos = findFieldPosition(fieldName);
+        if (fieldPos < 0 || fieldPos >= fieldTypes.length) {
+            return null;
+        }
+        return fieldTypes[fieldPos];
+    }
+
+    /**
+     * Returns true or false indicating whether or not a field is closed.
+     * 
+     * @param fieldName
+     *            the name of the field to check
+     * @return true if fieldName is a closed field, otherwise false
+     * @throws IOException
+     *             if an error occurs while serializing fieldName
+     */
+    public boolean isClosedField(String fieldName) throws IOException {
+        return findFieldPosition(fieldName) != -1;
     }
 
     @Override
@@ -115,12 +263,11 @@
     public int hash() {
         int h = 0;
         for (int i = 0; i < fieldNames.length; i++) {
-            h += 31 * h + fieldNames[i].hashCode();
+            h += 31 * h + (int) (hashCodeIndexPairs[i] >> 32);
         }
         for (int i = 0; i < fieldTypes.length; i++) {
             h += 31 * h + fieldTypes[i].hashCode();
         }
         return h;
     }
-
 }
diff --git a/asterix-runtime/pom.xml b/asterix-runtime/pom.xml
index 93b38df..be64661 100644
--- a/asterix-runtime/pom.xml
+++ b/asterix-runtime/pom.xml
@@ -16,27 +16,84 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
-			<plugin>
-				<groupId>org.codehaus.mojo</groupId>
-				<artifactId>javacc-maven-plugin</artifactId>
-				<version>2.6</version>
-				<executions>
-					<execution>
-						<id>javacc</id>
-						<goals>
-							<goal>javacc</goal>
-						</goals>
-						<configuration>
-							<isStatic>false</isStatic>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
+	      	<plugin>
+	        	<groupId>edu.uci.ics.asterix</groupId>
+	        	<artifactId>lexer-generator-maven-plugin</artifactId>
+	        	<version>0.1</version>
+	        	<configuration>
+	        	  	<grammarFile>src/main/resources/adm.grammar</grammarFile>
+	        	  	<outputDir>${project.build.directory}/generated-sources/edu/uci/ics/asterix/runtime/operators/file/adm</outputDir>
+	        	</configuration>
+	        	<executions>
+		          	<execution>
+		          		<id>generate-lexer</id>
+            			<phase>generate-sources</phase>
+			            <goals>
+	              			<goal>generate-lexer</goal>
+	            		</goals>
+	          		</execution>
+	        	</executions>
+	      	</plugin>
+	      	 <plugin>
+			    <groupId>org.codehaus.mojo</groupId>
+			    <artifactId>build-helper-maven-plugin</artifactId>
+			    <executions>
+			        <execution>
+			            <id>add-source</id>
+			            <phase>generate-sources</phase>
+			            <goals>
+			                <goal>add-source</goal>
+			            </goals>
+			            <configuration>
+			                <sources>
+			                    <source>${project.build.directory}/generated-sources/</source>
+			                </sources>
+			            </configuration>
+			        </execution>
+			    </executions>
+ 			</plugin>
+	    </plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											edu.uci.ics.asterix
+										</groupId>
+										<artifactId>
+											lexer-generator-maven-plugin
+										</artifactId>
+										<versionRange>
+											[0.1,)
+										</versionRange>
+										<goals>
+											<goal>generate-lexer</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<execute>
+											<runOnIncremental>false</runOnIncremental>
+										</execute>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
 	</build>
 
 	<dependencies>
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
index 89081ab..f720434 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.aggregates.serializable.std;
 
 import java.io.DataOutput;
@@ -6,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
@@ -59,8 +75,15 @@
         List<IAType> unionList = new ArrayList<IAType>();
         unionList.add(BuiltinType.ANULL);
         unionList.add(BuiltinType.ADOUBLE);
-        final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+        ARecordType _recType;
+        try {
+            _recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                    new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
+
+        final ARecordType recType = _recType;
 
         return new ICopySerializableAggregateFunctionFactory() {
             private static final long serialVersionUID = 1L;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
index 41047f7..219204b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.aggregates.serializable.std;
 
 import java.io.DataOutput;
@@ -6,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -63,8 +79,15 @@
         List<IAType> unionList = new ArrayList<IAType>();
         unionList.add(BuiltinType.ANULL);
         unionList.add(BuiltinType.ADOUBLE);
-        final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+        ARecordType tmpRecType;
+        try {
+            tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                    new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
+
+        final ARecordType recType = tmpRecType;
 
         return new ICopySerializableAggregateFunctionFactory() {
             private static final long serialVersionUID = 1L;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
index 4fe5e35..93c7026 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
 import java.io.DataOutput;
@@ -7,6 +22,7 @@
 import java.util.List;
 
 import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -64,8 +80,15 @@
         List<IAType> unionList = new ArrayList<IAType>();
         unionList.add(BuiltinType.ANULL);
         unionList.add(BuiltinType.ADOUBLE);
-        final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, true);
+        ARecordType tmpRecType;
+        try {
+            tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                    new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, true);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
+
+        final ARecordType recType = tmpRecType;
 
         return new ICopyAggregateFunctionFactory() {
             private static final long serialVersionUID = 1L;
@@ -78,7 +101,7 @@
 
                     private DataOutput out = provider.getDataOutput();
                     private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval = args[0].createEvaluator(inputVal);                    
+                    private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
                     private double sum;
                     private int count;
                     private ATypeTag aggType;
@@ -115,13 +138,13 @@
                     @Override
                     public void step(IFrameTupleReference tuple) throws AlgebricksException {
                         inputVal.reset();
-                        eval.evaluate(tuple);                        
+                        eval.evaluate(tuple);
                         ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
                                 .deserialize(inputVal.getByteArray()[0]);
                         if (typeTag == ATypeTag.NULL || aggType == ATypeTag.NULL) {
                             aggType = ATypeTag.NULL;
                             return;
-                        } else if (aggType == ATypeTag.SYSTEM_NULL) {                           
+                        } else if (aggType == ATypeTag.SYSTEM_NULL) {
                             aggType = typeTag;
                         } else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
                             throw new AlgebricksException("Unexpected type " + typeTag
@@ -129,7 +152,7 @@
                         }
                         if (typeTag != ATypeTag.SYSTEM_NULL) {
                             ++count;
-                        }                        
+                        }
                         switch (typeTag) {
                             case INT8: {
                                 byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
index 347f5e7..d262ef4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
 import java.io.DataOutput;
@@ -6,7 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
@@ -61,8 +76,15 @@
         List<IAType> unionList = new ArrayList<IAType>();
         unionList.add(BuiltinType.ANULL);
         unionList.add(BuiltinType.ADOUBLE);
-        final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+        ARecordType tmpRecType;
+        try {
+            tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                    new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+        } catch (AsterixException e) {
+            throw new AlgebricksException(e);
+        }
+
+        final ARecordType recType = tmpRecType;
 
         return new ICopyAggregateFunctionFactory() {
             private static final long serialVersionUID = 1L;
@@ -114,7 +136,7 @@
                         inputVal.reset();
                         eval.evaluate(tuple);
                         byte[] serBytes = inputVal.getByteArray();
-                        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serBytes[0]);                        
+                        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serBytes[0]);
                         switch (typeTag) {
                             case NULL: {
                                 metNull = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
index de02246..5400d78 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
 import java.io.DataOutput;
@@ -6,7 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -72,8 +87,15 @@
                 List<IAType> unionList = new ArrayList<IAType>();
                 unionList.add(BuiltinType.ANULL);
                 unionList.add(BuiltinType.ADOUBLE);
-                final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
-                        new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+                ARecordType tmpRecType;
+                try {
+                    tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+                            new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+                } catch (AsterixException e) {
+                    throw new AlgebricksException(e);
+                }
+
+                final ARecordType recType = tmpRecType;
 
                 return new ICopyAggregateFunction() {
 
@@ -204,5 +226,4 @@
             }
         };
     }
-
 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
index 38983e2..db3bc40 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.evaluators.common;
 
 import java.io.DataOutput;
@@ -5,6 +20,7 @@
 
 import edu.uci.ics.asterix.builders.IARecordBuilder;
 import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -72,8 +88,8 @@
                     }
                 }
                 recBuilder.write(out, true);
-            } catch (IOException ioe) {
-                throw new AlgebricksException(ioe);
+            } catch (IOException | AsterixException e) {
+                throw new AlgebricksException(e);
             }
         }
     }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
index 77869ba..81ae62b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
@@ -1,9 +1,25 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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.
+ */
+
 package edu.uci.ics.asterix.runtime.evaluators.functions;
 
 import java.io.DataOutput;
 import java.io.IOException;
 
 import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -86,8 +102,8 @@
                                 }
                             }
                             recBuilder.write(out, true);
-                        } catch (IOException ioe) {
-                            throw new AlgebricksException(ioe);
+                        } catch (IOException | AsterixException e) {
+                            throw new AlgebricksException(e);
                         }
                     }
                 };
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index 8606088..2e64ad4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -22,10 +22,8 @@
 import java.util.List;
 import java.util.Queue;
 
-import edu.uci.ics.asterix.adm.parser.nontagged.AdmLexer;
-import edu.uci.ics.asterix.adm.parser.nontagged.AdmLexerConstants;
-import edu.uci.ics.asterix.adm.parser.nontagged.ParseException;
-import edu.uci.ics.asterix.adm.parser.nontagged.Token;
+import edu.uci.ics.asterix.runtime.operators.file.adm.AdmLexer;
+import edu.uci.ics.asterix.runtime.operators.file.adm.AdmLexerException;
 import edu.uci.ics.asterix.builders.IARecordBuilder;
 import edu.uci.ics.asterix.builders.IAsterixListBuilder;
 import edu.uci.ics.asterix.builders.OrderedListBuilder;
@@ -36,6 +34,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ALineSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APoint3DSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
@@ -55,7 +54,7 @@
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 /**
- * Parser for ADM formatted data. 
+ * Parser for ADM formatted data.
  */
 public class ADMDataParser extends AbstractDataParser implements IDataParser {
 
@@ -82,21 +81,25 @@
     }
 
     @Override
-    public void initialize(InputStream in, ARecordType recordType, boolean datasetRec) {
-        admLexer = new AdmLexer(in);
+    public void initialize(InputStream in, ARecordType recordType, boolean datasetRec) throws AsterixException {
         this.recordType = recordType;
         this.datasetRec = datasetRec;
+        try {
+            admLexer = new AdmLexer(new java.io.InputStreamReader(in));
+        } catch (IOException e) {
+            throw new AsterixException(e);
+        }
     }
 
     protected boolean parseAdmInstance(IAType objectType, boolean datasetRec, DataOutput out) throws AsterixException,
             IOException {
-        Token token;
+        int token;
         try {
             token = admLexer.next();
-        } catch (ParseException pe) {
-            throw new AsterixException(pe);
+        } catch (AdmLexerException e) {
+            throw new AsterixException(e);
         }
-        if (token.kind == AdmLexerConstants.EOF) {
+        if (token == AdmLexer.TOKEN_EOF) {
             return false;
         } else {
             admFromLexerStream(token, objectType, out, datasetRec);
@@ -104,157 +107,212 @@
         }
     }
 
-    private void admFromLexerStream(Token token, IAType objectType, DataOutput out, Boolean datasetRec)
+    private void admFromLexerStream(int token, IAType objectType, DataOutput out, Boolean datasetRec)
             throws AsterixException, IOException {
 
-        switch (token.kind) {
-            case AdmLexerConstants.NULL_LITERAL: {
+        switch (token) {
+            case AdmLexer.TOKEN_NULL_LITERAL: {
                 if (checkType(ATypeTag.NULL, objectType, out)) {
                     nullSerde.serialize(ANull.NULL, out);
                 } else
                     throw new AsterixException(" This field can not be null ");
                 break;
             }
-            case AdmLexerConstants.TRUE_LITERAL: {
+            case AdmLexer.TOKEN_TRUE_LITERAL: {
                 if (checkType(ATypeTag.BOOLEAN, objectType, out)) {
                     booleanSerde.serialize(ABoolean.TRUE, out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.BOOLEAN_CONS: {
+            case AdmLexer.TOKEN_BOOLEAN_CONS: {
                 parseConstructor(ATypeTag.BOOLEAN, objectType, out);
                 break;
             }
-            case AdmLexerConstants.FALSE_LITERAL: {
+            case AdmLexer.TOKEN_FALSE_LITERAL: {
                 if (checkType(ATypeTag.BOOLEAN, objectType, out)) {
                     booleanSerde.serialize(ABoolean.FALSE, out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.DOUBLE_LITERAL: {
+            case AdmLexer.TOKEN_DOUBLE_LITERAL: {
                 if (checkType(ATypeTag.DOUBLE, objectType, out)) {
-                    aDouble.setValue(Double.parseDouble(token.image));
+                    aDouble.setValue(Double.parseDouble(admLexer.getLastTokenImage()));
                     doubleSerde.serialize(aDouble, out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.DOUBLE_CONS: {
+            case AdmLexer.TOKEN_DOUBLE_CONS: {
                 parseConstructor(ATypeTag.DOUBLE, objectType, out);
                 break;
             }
-            case AdmLexerConstants.FLOAT_LITERAL: {
+            case AdmLexer.TOKEN_FLOAT_LITERAL: {
                 if (checkType(ATypeTag.FLOAT, objectType, out)) {
-                    aFloat.setValue(Float.parseFloat(token.image));
+                    aFloat.setValue(Float.parseFloat(admLexer.getLastTokenImage()));
                     floatSerde.serialize(aFloat, out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.FLOAT_CONS: {
+            case AdmLexer.TOKEN_FLOAT_CONS: {
                 parseConstructor(ATypeTag.FLOAT, objectType, out);
                 break;
             }
-            case AdmLexerConstants.INT8_LITERAL: {
+            case AdmLexer.TOKEN_INT8_LITERAL: {
                 if (checkType(ATypeTag.INT8, objectType, out)) {
-                    parseInt8(token.image, out);
+                    parseInt8(admLexer.getLastTokenImage(), out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.INT8_CONS: {
+            case AdmLexer.TOKEN_INT8_CONS: {
                 parseConstructor(ATypeTag.INT8, objectType, out);
                 break;
             }
-            case AdmLexerConstants.INT16_LITERAL: {
+            case AdmLexer.TOKEN_INT16_LITERAL: {
                 if (checkType(ATypeTag.INT16, objectType, out)) {
-                    parseInt16(token.image, out);
+                    parseInt16(admLexer.getLastTokenImage(), out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.INT16_CONS: {
+            case AdmLexer.TOKEN_INT16_CONS: {
                 parseConstructor(ATypeTag.INT16, objectType, out);
                 break;
             }
-            case AdmLexerConstants.INT_LITERAL:
-            case AdmLexerConstants.INT32_LITERAL: {
+            case AdmLexer.TOKEN_INT_LITERAL:
+            case AdmLexer.TOKEN_INT32_LITERAL: {
                 if (checkType(ATypeTag.INT32, objectType, out)) {
-                    parseInt32(token.image, out);
+                    parseInt32(admLexer.getLastTokenImage(), out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.INT32_CONS: {
+            case AdmLexer.TOKEN_INT32_CONS: {
                 parseConstructor(ATypeTag.INT32, objectType, out);
                 break;
             }
-            case AdmLexerConstants.INT64_LITERAL: {
+            case AdmLexer.TOKEN_INT64_LITERAL: {
                 if (checkType(ATypeTag.INT64, objectType, out)) {
-                    parseInt64(token.image, out);
+                    parseInt64(admLexer.getLastTokenImage(), out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.INT64_CONS: {
+            case AdmLexer.TOKEN_INT64_CONS: {
                 parseConstructor(ATypeTag.INT64, objectType, out);
                 break;
             }
-            case AdmLexerConstants.STRING_LITERAL: {
+            case AdmLexer.TOKEN_STRING_LITERAL: {
                 if (checkType(ATypeTag.STRING, objectType, out)) {
-                    aString.setValue(token.image.substring(1, token.image.length() - 1));
+                    aString.setValue(admLexer.getLastTokenImage().substring(1,
+                            admLexer.getLastTokenImage().length() - 1));
                     stringSerde.serialize(aString, out);
                 } else
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
                 break;
             }
-            case AdmLexerConstants.STRING_CONS: {
+            case AdmLexer.TOKEN_STRING_CONS: {
                 parseConstructor(ATypeTag.STRING, objectType, out);
                 break;
             }
-            case AdmLexerConstants.DATE_CONS: {
+            case AdmLexer.TOKEN_DATE_CONS: {
                 parseConstructor(ATypeTag.DATE, objectType, out);
                 break;
             }
-            case AdmLexerConstants.TIME_CONS: {
+            case AdmLexer.TOKEN_TIME_CONS: {
                 parseConstructor(ATypeTag.TIME, objectType, out);
                 break;
             }
-            case AdmLexerConstants.DATETIME_CONS: {
+            case AdmLexer.TOKEN_DATETIME_CONS: {
                 parseConstructor(ATypeTag.DATETIME, objectType, out);
                 break;
             }
-            case AdmLexerConstants.DURATION_CONS: {
+            case AdmLexer.TOKEN_INTERVAL_DATE_CONS: {
+                try {
+                    if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+                        if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+                            if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+                                AIntervalSerializerDeserializer.parseDate(admLexer.getLastTokenImage(), out);
+
+                                if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                } catch (AdmLexerException ex) {
+                    throw new AsterixException(ex);
+                }
+                throw new AsterixException("Wrong interval data parsing for date interval.");
+            }
+            case AdmLexer.TOKEN_INTERVAL_TIME_CONS: {
+                try {
+                    if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+                        if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+                            if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+                                AIntervalSerializerDeserializer.parseTime(admLexer.getLastTokenImage(), out);
+
+                                if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                } catch (AdmLexerException ex) {
+                    throw new AsterixException(ex);
+                }
+                throw new AsterixException("Wrong interval data parsing for time interval.");
+            }
+            case AdmLexer.TOKEN_INTERVAL_DATETIME_CONS: {
+                try {
+                    if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+                        if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+                            if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+                                AIntervalSerializerDeserializer.parseDatetime(admLexer.getLastTokenImage(), out);
+
+                                if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                } catch (AdmLexerException ex) {
+                    throw new AsterixException(ex);
+                }
+                throw new AsterixException("Wrong interval data parsing for datetime interval.");
+            }
+            case AdmLexer.TOKEN_DURATION_CONS: {
                 parseConstructor(ATypeTag.DURATION, objectType, out);
                 break;
             }
-            case AdmLexerConstants.POINT_CONS: {
+            case AdmLexer.TOKEN_POINT_CONS: {
                 parseConstructor(ATypeTag.POINT, objectType, out);
                 break;
             }
-            case AdmLexerConstants.POINT3D_CONS: {
+            case AdmLexer.TOKEN_POINT3D_CONS: {
                 parseConstructor(ATypeTag.POINT3D, objectType, out);
                 break;
             }
-            case AdmLexerConstants.CIRCLE_CONS: {
+            case AdmLexer.TOKEN_CIRCLE_CONS: {
                 parseConstructor(ATypeTag.CIRCLE, objectType, out);
                 break;
             }
-            case AdmLexerConstants.RECTANGLE_CONS: {
+            case AdmLexer.TOKEN_RECTANGLE_CONS: {
                 parseConstructor(ATypeTag.RECTANGLE, objectType, out);
                 break;
             }
-            case AdmLexerConstants.LINE_CONS: {
+            case AdmLexer.TOKEN_LINE_CONS: {
                 parseConstructor(ATypeTag.LINE, objectType, out);
                 break;
             }
-            case AdmLexerConstants.POLYGON_CONS: {
+            case AdmLexer.TOKEN_POLYGON_CONS: {
                 parseConstructor(ATypeTag.POLYGON, objectType, out);
                 break;
             }
-            case AdmLexerConstants.START_UNORDERED_LIST: {
+            case AdmLexer.TOKEN_START_UNORDERED_LIST: {
                 if (checkType(ATypeTag.UNORDEREDLIST, objectType, out)) {
                     objectType = getComplexType(objectType, ATypeTag.UNORDEREDLIST);
                     parseUnorderedList((AUnorderedListType) objectType, out);
@@ -263,7 +321,7 @@
                 break;
             }
 
-            case AdmLexerConstants.START_ORDERED_LIST: {
+            case AdmLexer.TOKEN_START_ORDERED_LIST: {
                 if (checkType(ATypeTag.ORDEREDLIST, objectType, out)) {
                     objectType = getComplexType(objectType, ATypeTag.ORDEREDLIST);
                     parseOrderedList((AOrderedListType) objectType, out);
@@ -271,7 +329,7 @@
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeTag());
                 break;
             }
-            case AdmLexerConstants.START_RECORD: {
+            case AdmLexer.TOKEN_START_RECORD: {
                 if (checkType(ATypeTag.RECORD, objectType, out)) {
                     objectType = getComplexType(objectType, ATypeTag.RECORD);
                     parseRecord((ARecordType) objectType, out, datasetRec);
@@ -279,11 +337,11 @@
                     throw new AsterixException(mismatchErrorMessage + objectType.getTypeTag());
                 break;
             }
-            case AdmLexerConstants.EOF: {
+            case AdmLexer.TOKEN_EOF: {
                 break;
             }
             default: {
-                throw new AsterixException("Unexpected ADM token kind: " + admLexer.tokenKindToString(token.kind) + ".");
+                throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token) + ".");
             }
         }
     }
@@ -365,7 +423,7 @@
             recBuilder.reset(null);
 
         recBuilder.init();
-        Token token = null;
+        int token;
         boolean inRecord = true;
         boolean expectingRecordField = false;
         boolean first = true;
@@ -375,15 +433,15 @@
         IAType fieldType = null;
         do {
             token = nextToken();
-            switch (token.kind) {
-                case AdmLexerConstants.END_RECORD: {
+            switch (token) {
+                case AdmLexer.TOKEN_END_RECORD: {
                     if (expectingRecordField) {
                         throw new AsterixException("Found END_RECORD while expecting a record field.");
                     }
                     inRecord = false;
                     break;
                 }
-                case AdmLexerConstants.STRING_LITERAL: {
+                case AdmLexer.TOKEN_STRING_LITERAL: {
                     // we've read the name of the field
                     // now read the content
                     fieldNameBuffer.reset();
@@ -391,12 +449,14 @@
                     expectingRecordField = false;
 
                     if (recType != null) {
-                        String fldName = token.image.substring(1, token.image.length() - 1);
+                        String fldName = admLexer.getLastTokenImage().substring(1,
+                                admLexer.getLastTokenImage().length() - 1);
                         fieldId = recBuilder.getFieldId(fldName);
                         if (fieldId < 0 && !recType.isOpen()) {
                             throw new AsterixException("This record is closed, you can not add extra fields !!");
                         } else if (fieldId < 0 && recType.isOpen()) {
-                            aStringFieldName.setValue(token.image.substring(1, token.image.length() - 1));
+                            aStringFieldName.setValue(admLexer.getLastTokenImage().substring(1,
+                                    admLexer.getLastTokenImage().length() - 1));
                             stringSerde.serialize(aStringFieldName, fieldNameBuffer.getDataOutput());
                             openRecordField = true;
                             fieldType = null;
@@ -407,16 +467,17 @@
                             openRecordField = false;
                         }
                     } else {
-                        aStringFieldName.setValue(token.image.substring(1, token.image.length() - 1));
+                        aStringFieldName.setValue(admLexer.getLastTokenImage().substring(1,
+                                admLexer.getLastTokenImage().length() - 1));
                         stringSerde.serialize(aStringFieldName, fieldNameBuffer.getDataOutput());
                         openRecordField = true;
                         fieldType = null;
                     }
 
                     token = nextToken();
-                    if (token.kind != AdmLexerConstants.COLON) {
-                        throw new AsterixException("Unexpected ADM token kind: "
-                                + admLexer.tokenKindToString(token.kind) + " while expecting \":\".");
+                    if (token != AdmLexer.TOKEN_COLON) {
+                        throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
+                                + " while expecting \":\".");
                     }
 
                     token = nextToken();
@@ -436,7 +497,7 @@
 
                     break;
                 }
-                case AdmLexerConstants.COMMA: {
+                case AdmLexer.TOKEN_COMMA: {
                     if (first) {
                         throw new AsterixException("Found COMMA before any record field.");
                     }
@@ -447,7 +508,7 @@
                     break;
                 }
                 default: {
-                    throw new AsterixException("Unexpected ADM token kind: " + admLexer.tokenKindToString(token.kind)
+                    throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
                             + " while parsing record fields.");
                 }
             }
@@ -498,18 +559,18 @@
             itemType = oltype.getItemType();
         orderedListBuilder.reset(oltype);
 
-        Token token = null;
+        int token;
         boolean inList = true;
         boolean expectingListItem = false;
         boolean first = true;
         do {
             token = nextToken();
-            if (token.kind == AdmLexerConstants.END_ORDERED_LIST) {
+            if (token == AdmLexer.TOKEN_END_ORDERED_LIST) {
                 if (expectingListItem) {
                     throw new AsterixException("Found END_COLLECTION while expecting a list item.");
                 }
                 inList = false;
-            } else if (token.kind == AdmLexerConstants.COMMA) {
+            } else if (token == AdmLexer.TOKEN_COMMA) {
                 if (first) {
                     throw new AsterixException("Found COMMA before any list item.");
                 }
@@ -542,18 +603,18 @@
             itemType = uoltype.getItemType();
         unorderedListBuilder.reset(uoltype);
 
-        Token token = null;
+        int token;
         boolean inList = true;
         boolean expectingListItem = false;
         boolean first = true;
         do {
             token = nextToken();
-            if (token.kind == AdmLexerConstants.END_UNORDERED_LIST) {
+            if (token == AdmLexer.TOKEN_END_UNORDERED_LIST) {
                 if (expectingListItem) {
                     throw new AsterixException("Found END_COLLECTION while expecting a list item.");
                 }
                 inList = false;
-            } else if (token.kind == AdmLexerConstants.COMMA) {
+            } else if (token == AdmLexer.TOKEN_COMMA) {
                 if (first) {
                     throw new AsterixException("Found COMMA before any list item.");
                 }
@@ -574,11 +635,13 @@
         returnTempBuffer(itemBuffer);
     }
 
-    private Token nextToken() throws AsterixException {
+    private int nextToken() throws AsterixException {
         try {
             return admLexer.next();
-        } catch (ParseException pe) {
-            throw new AsterixException(pe);
+        } catch (AdmLexerException e) {
+            throw new AsterixException(e);
+        } catch (IOException e) {
+            throw new AsterixException(e);
         }
     }
 
@@ -633,73 +696,109 @@
 
     private void parseConstructor(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException {
         try {
-            Token token = admLexer.next();
-            if (token.kind == AdmLexerConstants.CONSTRUCTOR_OPEN) {
+            int token = admLexer.next();
+            if (token == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
                 if (checkType(typeTag, objectType, out)) {
                     token = admLexer.next();
-                    if (token.kind == AdmLexerConstants.STRING_LITERAL) {
+                    if (token == AdmLexer.TOKEN_STRING_LITERAL) {
                         switch (typeTag) {
                             case BOOLEAN:
-                                parseBoolean(token.image.substring(1, token.image.length() - 1), out);
+                                parseBoolean(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case INT8:
-                                parseInt8(token.image.substring(1, token.image.length() - 1), out);
+                                parseInt8(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case INT16:
-                                parseInt16(token.image.substring(1, token.image.length() - 1), out);
+                                parseInt16(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case INT32:
-                                parseInt32(token.image.substring(1, token.image.length() - 1), out);
+                                parseInt32(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case INT64:
-                                parseInt64(token.image.substring(1, token.image.length() - 1), out);
+                                parseInt64(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case FLOAT:
-                                aFloat.setValue(Float.parseFloat(token.image.substring(1, token.image.length() - 1)));
+                                aFloat.setValue(Float.parseFloat(admLexer.getLastTokenImage().substring(1,
+                                        admLexer.getLastTokenImage().length() - 1)));
                                 floatSerde.serialize(aFloat, out);
                                 break;
                             case DOUBLE:
-                                aDouble.setValue(Double.parseDouble(token.image.substring(1, token.image.length() - 1)));
+                                aDouble.setValue(Double.parseDouble(admLexer.getLastTokenImage().substring(1,
+                                        admLexer.getLastTokenImage().length() - 1)));
                                 doubleSerde.serialize(aDouble, out);
                                 break;
                             case STRING:
-                                aString.setValue(token.image.substring(1, token.image.length() - 1));
+                                aString.setValue(admLexer.getLastTokenImage().substring(1,
+                                        admLexer.getLastTokenImage().length() - 1));
                                 stringSerde.serialize(aString, out);
                                 break;
                             case TIME:
-                                parseTime(token.image.substring(1, token.image.length() - 1), out);
+                                parseTime(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case DATE:
-                                parseDate(token.image.substring(1, token.image.length() - 1), out);
+                                parseDate(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case DATETIME:
-                                parseDatetime(token.image.substring(1, token.image.length() - 1), out);
+                                parseDatetime(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case DURATION:
-                                parseDuration(token.image.substring(1, token.image.length() - 1), out);
+                                parseDuration(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case POINT:
-                                parsePoint(token.image.substring(1, token.image.length() - 1), out);
+                                parsePoint(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case POINT3D:
-                                parsePoint3d(token.image.substring(1, token.image.length() - 1), out);
+                                parsePoint3d(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case CIRCLE:
-                                parseCircle(token.image.substring(1, token.image.length() - 1), out);
+                                parseCircle(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case RECTANGLE:
-                                parseRectangle(token.image.substring(1, token.image.length() - 1), out);
+                                parseRectangle(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case LINE:
-                                parseLine(token.image.substring(1, token.image.length() - 1), out);
+                                parseLine(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
                             case POLYGON:
-                                parsePolygon(token.image.substring(1, token.image.length() - 1), out);
+                                parsePolygon(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
                                 break;
+                            default:
+                                throw new AsterixException("Missing deserializer method for constructor: "
+                                        + AdmLexer.tokenKindToString(token) + ".");
 
                         }
                         token = admLexer.next();
-                        if (token.kind == AdmLexerConstants.CONSTRUCTOR_CLOSE)
+                        if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE)
                             return;
                     }
                 }
diff --git a/asterix-runtime/src/main/javacc/AdmLexer.jj b/asterix-runtime/src/main/javacc/AdmLexer.jj
deleted file mode 100644
index fbab62f..0000000
--- a/asterix-runtime/src/main/javacc/AdmLexer.jj
+++ /dev/null
@@ -1,150 +0,0 @@
-options {
-
-	  
-       STATIC = false;
-	
-}
-
-PARSER_BEGIN(AdmLexer)
-
-package edu.uci.ics.asterix.adm.parser;
-
-import java.io.*;
-
-public class AdmLexer {
-
-	public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException {
-	   	File file = new File(args[0]);
-		Reader freader =  new BufferedReader(new InputStreamReader 
-		         (new FileInputStream(file), "UTF-8"));		
-		AdmLexer flexer = new AdmLexer(freader);
-		Token t = null;
-		do {
-		   t = flexer.next();		   
-		   System.out.println(AdmLexerConstants.tokenImage[t.kind]);
-		} while (t.kind != EOF);
-	    freader.close();
-	}
-	
-	public Token next() throws ParseException {
-	   return getNextToken();
-	}
-	
-	public String tokenKindToString(int tokenKind) {
-	   return AdmLexerConstants.tokenImage[tokenKind];
-	}
-}
-
-PARSER_END(AdmLexer)
-
-<DEFAULT>
-TOKEN :
-{
-	<NULL_LITERAL : "null">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<TRUE_LITERAL : "true">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<FALSE_LITERAL : "false">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<INTEGER_LITERAL : ("-")? (<DIGIT>)+ >
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<#DIGIT : ["0" - "9"]>
-}
-
-
-TOKEN:
-{
-  < DOUBLE_LITERAL: 
-	      ("-")? <INTEGER> ( "." <INTEGER> )? (<EXPONENT>)? 
-	    | ("-")? "." <INTEGER>
-  >
-  | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
-	| <INTEGER : (<DIGIT>)+ >
-	| <FLOAT_LITERAL: <DOUBLE_LITERAL>("f"|"F")>
- }
-
-<DEFAULT>
-TOKEN :
-{
-	<STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") >
-	|
-	< #EscapeQuot: "\\\"" >
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<START_RECORD : "{">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_RECORD : "}">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<COMMA : ",">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<COLON : ":">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<START_ORDERED_LIST : "[">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_ORDERED_LIST : "]">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<START_UNORDERED_LIST : "{{">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_UNORDERED_LIST : "}}">
-}
-
-
-
-
-SKIP:
-{
-    " "
-|   "\t"
-|   "\r"
-|   "\n"
-}
diff --git a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj b/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
deleted file mode 100644
index d94033d..0000000
--- a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
+++ /dev/null
@@ -1,385 +0,0 @@
-options {
-
-	  
-       STATIC = false;
-	
-}
-
-PARSER_BEGIN(AdmLexer)
-
-package edu.uci.ics.asterix.adm.parser.nontagged;
-
-import java.io.*;
-
-public class AdmLexer {
-
-	public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException {
-	   	File file = new File(args[0]);
-	   	Reader freader = new BufferedReader(new InputStreamReader
-                      (new FileInputStream(file), "UTF-8"));
-		AdmLexer flexer = new AdmLexer(freader);
-		Token t = null;
-		do {
-		   t = flexer.next();		   
-		   System.out.println(AdmLexerConstants.tokenImage[t.kind]);
-		} while (t.kind != EOF);
-	    freader.close();
-	}
-	
-	public Token next() throws ParseException {
-	   return getNextToken();
-	}
-	
-	public String tokenKindToString(int tokenKind) {
-	   return AdmLexerConstants.tokenImage[tokenKind];
-	}
-}
-
-PARSER_END(AdmLexer)
-
-<DEFAULT>
-TOKEN :
-{
-	<NULL_LITERAL : "null">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<TRUE_LITERAL : "true">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<FALSE_LITERAL : "false">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<BOOLEAN_CONS : ("boolean") >	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<CONSTRUCTOR_OPEN : ("(")>	
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<CONSTRUCTOR_CLOSE : (")")>	
-}
-
-<DEFAULT>
-TOKEN:
-{
-	<INT8_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i8")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<INT8_CONS : ("int8") >	
-}
-
-<DEFAULT>
-TOKEN:
-{
-	<INT16_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i16")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<INT16_CONS : ("int16") >	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<INT32_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i32")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<INT32_CONS : ("int32")>	
-}
-
-<DEFAULT>
-TOKEN:
-{
-	<INT64_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i64")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<INT64_CONS : ("int64") >	
-}
-
-<DEFAULT>
-TOKEN:
-{
-	<INT_LITERAL : ("-" | "+")? (<DIGIT>)+>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<CIRCLE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("R") <DOUBLE_LITERAL> >	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<CIRCLE_CONS : ("circle") >	
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<TIMEZONE_LITERAL : (("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | (("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z") >
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATE_LITERAL : (("-")?<DIGIT><DIGIT><DIGIT><DIGIT>("-")<DIGIT><DIGIT>("-")<DIGIT><DIGIT>) | (("-")?<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT>) >
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATE_CONS : ("date")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<TIME_LITERAL : (<DIGIT><DIGIT>(":")<DIGIT><DIGIT>(":")<DIGIT><DIGIT> ( (".")<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | ("Z"))?) | (<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT> (<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z"))?) >
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<TIME_CONS : ("time")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATETIME_LITERAL : (("-")?<DIGIT><DIGIT><DIGIT><DIGIT>("-")<DIGIT><DIGIT>("-")<DIGIT><DIGIT>("T")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>(":")<DIGIT><DIGIT> ( (".")<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | ("Z"))?) | (("-")?<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT>("T")<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT> (<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z"))?)>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATETIME_CONS : ("datetime")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DURATION_LITERAL : ("-")? ("P")(<INTEGER>("Y"))?(<INTEGER>("M"))?(<INTEGER>("D"))?(("T")(((<INTEGER>("H"))(<INTEGER>("M"))?(<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S"))?) | ((<INTEGER>("M"))(<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S"))?) | ((<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S")))))?>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DURATION_CONS : ("duration")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
	<INTERVAL_CONS : ("interval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<TIME_INTERVAL_CONS : ("tinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATE_INTERVAL_CONS : ("dinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DATETIME_INTERVAL_CONS : ("dtinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<#DIGIT : ["0" - "9"]>
-}
-
-TOKEN:
-{
-  < DOUBLE_LITERAL: 
-	      ("-" | "+")? <INTEGER> ( "." <INTEGER> )? (<EXPONENT>)? 
-	    | ("-" | "+")? "." <INTEGER>
-  >
-  | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
-	| <INTEGER : (<DIGIT>)+ >
-	| <FLOAT_LITERAL: <DOUBLE_LITERAL>("f"|"F")>
- }
-
-
-<DEFAULT>
-TOKEN :
-{
-	<FLOAT_CONS : ("float")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<DOUBLE_CONS : ("double")>	
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") >
-	|
-	< #EscapeQuot: "\\\"" >
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<STRING_CONS : ("string")>	
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<POINT_LITERAL : "P"<DOUBLE_LITERAL>(",")<DOUBLE_LITERAL>>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<POINT_CONS : ("point")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<POINT3D_LITERAL : "P" <DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<POINT3D_CONS : ("point3d")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<LINE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<LINE_CONS : ("line")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<POLYGON_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL> (("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>)+>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<POLYGON_CONS : ("polygon")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<RECTANGLE_CONS : ("rectangle")>	
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<RECTANGLE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>		
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<START_RECORD : "{">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_RECORD : "}">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<COMMA : ",">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<COLON : ":">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
-	<START_ORDERED_LIST : "[">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_ORDERED_LIST : "]">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<START_UNORDERED_LIST : "{{">
-}
-
-<DEFAULT>
-TOKEN :
-{
-	<END_UNORDERED_LIST : "}}">
-}
-
-
-
-
-SKIP:
-{
-    " "
-|   "\t"
-|   "\r"
-|   "\n"
-}
diff --git a/asterix-runtime/src/main/resources/adm.grammar b/asterix-runtime/src/main/resources/adm.grammar
new file mode 100644
index 0000000..56c7212
--- /dev/null
+++ b/asterix-runtime/src/main/resources/adm.grammar
@@ -0,0 +1,63 @@
+# LEXER GENERATOR configuration file
+# ---------------------------------------
+# Place *first* the generic configuration
+# then list your grammar.
+
+PACKAGE:          edu.uci.ics.asterix.runtime.operators.file.adm
+LEXER_NAME:       AdmLexer
+
+TOKENS:
+
+BOOLEAN_CONS   = string(boolean)
+INT8_CONS      = string(int8)
+INT16_CONS     = string(int16)
+INT32_CONS     = string(int32)
+INT64_CONS     = string(int64)
+FLOAT_CONS     = string(float)
+DOUBLE_CONS    = string(double)
+DATE_CONS      = string(date)
+DATETIME_CONS  = string(datetime)
+DURATION_CONS  = string(duration)
+STRING_CONS    = string(string)
+POINT_CONS     = string(point)
+POINT3D_CONS   = string(point3d)
+LINE_CONS      = string(line)
+POLYGON_CONS   = string(polygon)
+RECTANGLE_CONS = string(rectangle)
+CIRCLE_CONS    = string(circle)
+TIME_CONS      = string(time)
+INTERVAL_TIME_CONS      = string(interval_time)
+INTERVAL_DATE_CONS      = string(interval_date)
+INTERVAL_DATETIME_CONS  = string(interval_datetime)
+
+NULL_LITERAL   = string(null)
+TRUE_LITERAL   = string(true)
+FALSE_LITERAL  = string(false)
+
+CONSTRUCTOR_OPEN     = char(()
+CONSTRUCTOR_CLOSE    = char())
+START_RECORD         = char({)
+END_RECORD           = char(})
+COMMA                = char(\,)
+COLON                = char(:)
+START_ORDERED_LIST   = char([)
+END_ORDERED_LIST     = char(])
+START_UNORDERED_LIST = string({{)
+END_UNORDERED_LIST   = string(}})
+
+STRING_LITERAL       = char("), anythingUntil(")
+
+INT_LITERAL          = signOrNothing(), digitSequence()
+INT8_LITERAL         = token(INT_LITERAL), string(i8)
+INT16_LITERAL        = token(INT_LITERAL), string(i16)
+INT32_LITERAL        = token(INT_LITERAL), string(i32)
+INT64_LITERAL        = token(INT_LITERAL), string(i64)
+
+@EXPONENT            = caseInsensitiveChar(e), signOrNothing(), digitSequence()
+
+DOUBLE_LITERAL		 = signOrNothing(), char(.), digitSequence()
+DOUBLE_LITERAL		 = signOrNothing(), digitSequence(), char(.), digitSequence()
+DOUBLE_LITERAL		 = signOrNothing(), digitSequence(), char(.), digitSequence(), token(@EXPONENT)
+DOUBLE_LITERAL		 = signOrNothing(), digitSequence(), token(@EXPONENT)
+
+FLOAT_LITERAL		 = token(DOUBLE_LITERAL), caseInsensitiveChar(f)
diff --git a/asterix-test-framework/pom.xml b/asterix-test-framework/pom.xml
index 2f0142e..9462b5d 100755
--- a/asterix-test-framework/pom.xml
+++ b/asterix-test-framework/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -13,21 +14,21 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
-            <plugin>
-                <groupId>org.jvnet.jaxb2.maven2</groupId>
-                <artifactId>maven-jaxb2-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>generate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
+			<plugin>
+				<groupId>org.jvnet.jaxb2.maven2</groupId>
+				<artifactId>maven-jaxb2-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
 		</plugins>
 	</build>
 
diff --git a/asterix-tools/pom.xml b/asterix-tools/pom.xml
index 62176d9..0440618 100644
--- a/asterix-tools/pom.xml
+++ b/asterix-tools/pom.xml
@@ -15,8 +15,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 			<plugin>
diff --git a/asterix-transactions/pom.xml b/asterix-transactions/pom.xml
index 7db5cd9..a402077 100644
--- a/asterix-transactions/pom.xml
+++ b/asterix-transactions/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
@@ -16,8 +17,8 @@
 				<artifactId>maven-compiler-plugin</artifactId>
 				<version>2.0.2</version>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
 		</plugins>
@@ -25,9 +26,9 @@
 	</build>
 
 	<dependencies>
-	    <dependency>
-  		<groupId>edu.uci.ics.hyracks</groupId>
-  		<artifactId>hyracks-storage-am-common</artifactId>
-  	</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.hyracks</groupId>
+			<artifactId>hyracks-storage-am-common</artifactId>
+		</dependency>
 	</dependencies>
 </project>
diff --git a/pom.xml b/pom.xml
index fadaa0b..8999ad9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,7 @@
                 <module>asterix-metadata</module>
                 <module>asterix-dist</module>
                 <module>asterix-test-framework</module>
+        <module>asterix-maven-plugins</module>
         </modules>
 
 	<repositories>