merged issue branch(kisskys/log_cursor_stackoverflow_issue) to master and removed an unnecessary file
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/InvertedIndexPOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/InvertedIndexPOperator.java
index 6bdd9df..23f1d56 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/InvertedIndexPOperator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/InvertedIndexPOperator.java
@@ -89,9 +89,9 @@
     @Override
     public PhysicalOperatorTag getOperatorTag() {
         if (isPartitioned) {
-            return PhysicalOperatorTag.FUZZY_INVERTED_INDEX_SEARCH;
+            return PhysicalOperatorTag.LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH;
         } else {
-            return PhysicalOperatorTag.INVERTED_INDEX_SEARCH;
+            return PhysicalOperatorTag.SINGLE_PARTITION_INVERTED_INDEX_SEARCH;
         }
     }
 
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
index d6a188a..dc8d741 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
@@ -172,10 +172,10 @@
             project.getInputs().add(new MutableObject<ILogicalOperator>(currentTop));
             context.computeAndSetTypeEnvironmentForOperator(project);
             context.computeAndSetTypeEnvironmentForOperator(assign);
-            if (index.getIndexType() == IndexType.BTREE || index.getIndexType() == IndexType.WORD_INVIX
-                    || index.getIndexType() == IndexType.NGRAM_INVIX
-                    || index.getIndexType() == IndexType.FUZZY_WORD_INVIX
-                    || index.getIndexType() == IndexType.FUZZY_NGRAM_INVIX) {
+            if (index.getIndexType() == IndexType.BTREE || index.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX
+                    || index.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX
+                    || index.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
+                    || index.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX) {
                 for (LogicalVariable secondaryKeyVar : secondaryKeyVars) {
                     secondaryExpressions.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(
                             secondaryKeyVar)));
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetAsterixPhysicalOperatorsRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetAsterixPhysicalOperatorsRule.java
index c05f4f7..500f581 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetAsterixPhysicalOperatorsRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetAsterixPhysicalOperatorsRule.java
@@ -187,13 +187,13 @@
                                 op.setPhysicalOperator(new RTreeSearchPOperator(dsi, requiresBroadcast));
                                 break;
                             }
-                            case WORD_INVIX:
-                            case NGRAM_INVIX: {
+                            case SINGLE_PARTITION_WORD_INVIX:
+                            case SINGLE_PARTITION_NGRAM_INVIX: {
                                 op.setPhysicalOperator(new InvertedIndexPOperator(dsi, requiresBroadcast, false));
                                 break;
                             }
-                            case FUZZY_WORD_INVIX:
-                            case FUZZY_NGRAM_INVIX: {
+                            case LENGTH_PARTITIONED_WORD_INVIX:
+                            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                                 op.setPhysicalOperator(new InvertedIndexPOperator(dsi, requiresBroadcast, true));
                                 break;
                             }
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 7084cd7..ab0fd79 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
@@ -148,10 +148,10 @@
     public static int getNumSecondaryKeys(Index index, ARecordType recordType) throws AlgebricksException {
         switch (index.getIndexType()) {
             case BTREE:
-            case WORD_INVIX:
-            case NGRAM_INVIX: 
-            case FUZZY_WORD_INVIX:
-            case FUZZY_NGRAM_INVIX: {
+            case SINGLE_PARTITION_WORD_INVIX:
+            case SINGLE_PARTITION_NGRAM_INVIX: 
+            case LENGTH_PARTITIONED_WORD_INVIX:
+            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                 return index.getKeyFieldNames().size();
             }
             case RTREE: {
@@ -175,8 +175,8 @@
         if (!primaryKeysOnly) {
             switch (index.getIndexType()) {
                 case BTREE:
-                case WORD_INVIX:
-                case NGRAM_INVIX: {
+                case SINGLE_PARTITION_WORD_INVIX:
+                case SINGLE_PARTITION_NGRAM_INVIX: {
                     for (String sk : index.getKeyFieldNames()) {
                         Pair<IAType, Boolean> keyPairType = Index.getNonNullableKeyFieldType(sk, recordType);
                         dest.add(keyPairType.first);
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
index a894098..fb8becc 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
@@ -729,8 +729,8 @@
             IAObject obj = constVal.getObject();
             type = obj.getType();
             typeTag = type.getTypeTag();
-            if (typeTag != ATypeTag.ORDEREDLIST && typeTag != ATypeTag.STRING) {
-                throw new AlgebricksException("Only ordered lists and string types supported.");
+            if (typeTag != ATypeTag.ORDEREDLIST && typeTag != ATypeTag.STRING && typeTag != ATypeTag.UNORDEREDLIST) {
+                throw new AlgebricksException("Only ordered lists, string, and unordered lists types supported.");
             }
         }
         jobGenParams.setSearchKeyType(typeTag);
@@ -781,7 +781,7 @@
             int mergeThreshold = 0;
             // We can only optimize edit distance on strings using an ngram index.
             if (listOrStrObj.getType().getTypeTag() == ATypeTag.STRING
-                    && (index.getIndexType() == IndexType.NGRAM_INVIX || index.getIndexType() == IndexType.FUZZY_NGRAM_INVIX)) {
+                    && (index.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX || index.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX)) {
                 AString astr = (AString) listOrStrObj;
                 // Compute merge threshold.
                 mergeThreshold = (astr.getStringValue().length() + index.getGramLength() - 1)
@@ -789,7 +789,7 @@
             }
             // We can only optimize edit distance on lists using a word index.
             if ((listOrStrObj.getType().getTypeTag() == ATypeTag.ORDEREDLIST || listOrStrObj.getType().getTypeTag() == ATypeTag.UNORDEREDLIST)
-                    && (index.getIndexType() == IndexType.WORD_INVIX || index.getIndexType() == IndexType.FUZZY_WORD_INVIX)) {
+                    && (index.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX || index.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX)) {
                 IACollection alist = (IACollection) listOrStrObj;
                 // Compute merge threshold.
                 mergeThreshold = alist.size() - edThresh.getIntegerValue();
@@ -815,11 +815,11 @@
                 AbstractFunctionCallExpression nonConstfuncExpr = (AbstractFunctionCallExpression) nonConstArg;
                 // We can use this index if the tokenization function matches the index type.
                 if (nonConstfuncExpr.getFunctionIdentifier() == AsterixBuiltinFunctions.WORD_TOKENS
-                        && (index.getIndexType() == IndexType.WORD_INVIX || index.getIndexType() == IndexType.FUZZY_WORD_INVIX)) {
+                        && (index.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX || index.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX)) {
                     return true;
                 }
                 if (nonConstfuncExpr.getFunctionIdentifier() == AsterixBuiltinFunctions.GRAM_TOKENS
-                        && (index.getIndexType() == IndexType.NGRAM_INVIX || index.getIndexType() == IndexType.FUZZY_NGRAM_INVIX)) {
+                        && (index.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX || index.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX)) {
                     return true;
                 }
             }
@@ -832,7 +832,7 @@
         }
         // We can only optimize contains with ngram indexes.
         if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == AsterixBuiltinFunctions.CONTAINS
-                && (index.getIndexType() == IndexType.NGRAM_INVIX || index.getIndexType() == IndexType.FUZZY_NGRAM_INVIX)) {
+                && (index.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX || index.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX)) {
             // Check that the constant search string has at least gramLength characters.
             AsterixConstantValue strConstVal = (AsterixConstantValue) optFuncExpr.getConstantVal(0);
             IAObject strObj = strConstVal.getObject();
@@ -849,12 +849,12 @@
     public static IBinaryTokenizerFactory getBinaryTokenizerFactory(SearchModifierType searchModifierType,
             ATypeTag searchKeyType, Index index) throws AlgebricksException {
         switch (index.getIndexType()) {
-            case WORD_INVIX:
-            case FUZZY_WORD_INVIX: {
+            case SINGLE_PARTITION_WORD_INVIX:
+            case LENGTH_PARTITIONED_WORD_INVIX: {
                 return AqlBinaryTokenizerFactoryProvider.INSTANCE.getWordTokenizerFactory(searchKeyType, false);
             }
-            case NGRAM_INVIX:
-            case FUZZY_NGRAM_INVIX: {
+            case SINGLE_PARTITION_NGRAM_INVIX:
+            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                 // Make sure not to use pre- and postfixing for conjunctive searches.
                 boolean prePost = (searchModifierType == SearchModifierType.CONJUNCTIVE) ? false : true;
                 return AqlBinaryTokenizerFactoryProvider.INSTANCE.getNGramTokenizerFactory(searchKeyType,
@@ -879,13 +879,13 @@
             case EDIT_DISTANCE: {
                 int edThresh = ((AInt32) simThresh).getIntegerValue();
                 switch (index.getIndexType()) {
-                    case NGRAM_INVIX:
-                    case FUZZY_NGRAM_INVIX: {
+                    case SINGLE_PARTITION_NGRAM_INVIX:
+                    case LENGTH_PARTITIONED_NGRAM_INVIX: {
                         // Edit distance on strings, filtered with overlapping grams.
                         return new EditDistanceSearchModifierFactory(index.getGramLength(), edThresh);
                     }
-                    case WORD_INVIX:
-                    case FUZZY_WORD_INVIX: {
+                    case SINGLE_PARTITION_WORD_INVIX:
+                    case LENGTH_PARTITIONED_WORD_INVIX: {
                         // Edit distance on two lists. The list-elements are non-overlapping.
                         return new ListEditDistanceSearchModifierFactory(edThresh);
                     }
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index 42a8695..6f92d3a 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -81,7 +81,6 @@
 import edu.uci.ics.asterix.aql.expression.UpdateStatement;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
@@ -258,11 +257,6 @@
             ILogicalOperator leafOperator = null;
 
             switch (stmt.getKind()) {
-                case WRITE_FROM_QUERY_RESULT: {
-                    leafOperator = new WriteResultOperator(targetDatasource, varRef, varRefsForLoading);
-                    leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(assign));
-                    break;
-                }
                 case INSERT: {
                     ILogicalOperator insertOp = new InsertDeleteOperator(targetDatasource, varRef, varRefsForLoading,
                             InsertDeleteOperator.Kind.INSERT);
@@ -1268,13 +1262,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(DropStatement del, Mutable<ILogicalOperator> arg)
             throws AsterixException {
         // TODO Auto-generated method stub
@@ -1389,13 +1376,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(CreateDataverseStatement del,
             Mutable<ILogicalOperator> arg) throws AsterixException {
         // TODO Auto-generated method stub
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
index 866ad49..d1f8053 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
@@ -85,7 +85,6 @@
 import edu.uci.ics.asterix.aql.expression.UpdateStatement;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlPlusExpressionVisitor;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
@@ -1214,13 +1213,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(DropStatement del, Mutable<ILogicalOperator> arg)
             throws AsterixException {
         // TODO Auto-generated method stub
@@ -1395,13 +1387,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(CreateDataverseStatement del,
             Mutable<ILogicalOperator> arg) throws AsterixException {
         // TODO Auto-generated method stub
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
index e40a163..36f0824 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
@@ -55,44 +55,6 @@
         public Kind getKind();
     }
 
-    public static class CompiledWriteFromQueryResultStatement implements ICompiledDmlStatement {
-
-        private String dataverseName;
-        private String datasetName;
-        private Query query;
-        private int varCounter;
-
-        public CompiledWriteFromQueryResultStatement(String dataverseName, String datasetName, Query query,
-                int varCounter) {
-            this.dataverseName = dataverseName;
-            this.datasetName = datasetName;
-            this.query = query;
-            this.varCounter = varCounter;
-        }
-
-        public String getDataverseName() {
-            return dataverseName;
-        }
-
-        public String getDatasetName() {
-            return datasetName;
-        }
-
-        public int getVarCounter() {
-            return varCounter;
-        }
-
-        public Query getQuery() {
-            return query;
-        }
-
-        @Override
-        public Kind getKind() {
-            return Kind.WRITE_FROM_QUERY_RESULT;
-        }
-
-    }
-
     public static class CompiledDatasetDropStatement implements ICompiledStatement {
         private final String dataverseName;
         private final String datasetName;
diff --git a/asterix-algebra/src/main/javacc/AQLPlus.jj b/asterix-algebra/src/main/javacc/AQLPlus.jj
index 5b97d04..75179b1 100644
--- a/asterix-algebra/src/main/javacc/AQLPlus.jj
+++ b/asterix-algebra/src/main/javacc/AQLPlus.jj
@@ -168,21 +168,13 @@
   Query query;
 }
 {
-  (( "output" "to" 
+  ( "output" "to" 
     <IDENTIFIER> { nodeName = new Identifier(token.image); } 
     ":" <STRING_LITERAL> { 
              fileName = removeQuotesAndEscapes(token.image);
              stmt = new WriteStatement(nodeName, fileName, null);         
-         } )
-    |
-   ( "into" 
-     <DATASET> <IDENTIFIER> { datasetName = new Identifier(token.image); }
-     <LEFTPAREN> query = Query() <RIGHTPAREN>
-     {
-        stmt = new WriteFromQueryResultStatement(null, datasetName, query, getVarCounter());
-     } ))  
-        
-    ";"
+         }
+  ) ";"
     {
       return stmt;
     }
diff --git a/asterix-app/data/duplicateKeys.adm b/asterix-app/data/duplicateKeys.adm
new file mode 100644
index 0000000..2df08e0
--- /dev/null
+++ b/asterix-app/data/duplicateKeys.adm
@@ -0,0 +1,2 @@
+{"id":1}
+{"id":1}
\ No newline at end of file
diff --git a/asterix-app/data/nontagged/orderData.json b/asterix-app/data/nontagged/orderData.json
index 5779b72..989e3dd 100644
--- a/asterix-app/data/nontagged/orderData.json
+++ b/asterix-app/data/nontagged/orderData.json
@@ -1,4 +1,4 @@
 {  "oid": 1000,  "cid": 775,  "orderstatus": "ORDER_DELIVERED",  "orderpriority": "LOW",  "clerk": "Kathryne", "total": 97.20656f, "items": [1,2, 4, 5, 6], "heList": ["1.0f" ,"yassser"], "openlist": [11, 14, "yasir", 1.6f], "loc": point("10.1,11.1") ,  "line" : line("10.1,11.1 10.2,11.2") , "poly" : polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8") , "DOB" : "1989-10-12", "favnumbers" : [10.0,20.0,30.0,40.0]}
-{  "oid": 10,  "cid": 5,  "orderstatus": "ORDER_DELIVERED",  "orderpriority": "HIGH",  "clerk": "ALEX",  "total": 7.206f, "items": [13,52, 24, 15, 60], "heList": [1.0f ,"5.2f", "60"], "openlist": [13231, "foo", null, 13.25, 13.2f], "loc": point("10.1,11.1") ,  "line" : line("10.1,11.1 10.2,11.2") , "poly" : polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8") , "DOB" : "1989-10-12", "favnumbers" : [10.0,20.0,30.0,40.0,50.0,60.0,70.0]}
+{  "oid": 1,  "cid": 5,  "orderstatus": "ORDER_DELIVERED",  "orderpriority": "HIGH",  "clerk": "ALEX",  "total": 7.206f, "items": [13,52, 24, 15, 60], "heList": [1.0f ,"5.2f", "60"], "openlist": [13231, "foo", null, 13.25, 13.2f], "loc": point("10.1,11.1") ,  "line" : line("10.1,11.1 10.2,11.2") , "poly" : polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8") , "DOB" : "1989-10-12", "favnumbers" : [10.0,20.0,30.0,40.0,50.0,60.0,70.0]}
 {  "oid": 100,  "cid": 12, "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH",  "clerk": "YASSER", "total": 124.26f, "items": [13,52, 60], "heList": [1.3f , 5.2f, "60", 12.32f], "openlist": [10, 2.0f, 3.0, 40], "loc": point("10.1,11.1") ,  "line" : line("10.1,11.1 10.2,11.2"), "poly" : polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "DOB" : "1989-10-12" , "favnumbers" : [10.0,50.0,60.0,70.0]}
 {  "oid": 10,  "cid": 775,  "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH",  "clerk": "MIKE",  "total": 14.2326f,  "items": [24, 15],   "heList": [2.4f, "15"], "openlist": [110], "loc": point("10.1,11.1"),  "line" : line("10.1,11.1 10.2,11.2"), "poly" : polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8") , "lastorder": { "oid": 75,  "total": 87.618626f } }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
index 8ecd00f..659a224 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
@@ -21,18 +21,20 @@
     private final boolean printLogicalPlanParam;
     private final boolean printOptimizedLogicalPlanParam;
     private final boolean printPhysicalOpsOnly;
+    private final boolean executeQuery;
     private final boolean generateJobSpec;
     private final boolean printJob;
 
     public SessionConfig(boolean optimize, boolean printExprParam, boolean printRewrittenExprParam,
             boolean printLogicalPlanParam, boolean printOptimizedLogicalPlanParam, boolean printPhysicalOpsOnly,
-            boolean generateJobSpec, boolean printJob) {
+            boolean executeQuery, boolean generateJobSpec, boolean printJob) {
         this.optimize = optimize;
         this.printExprParam = printExprParam;
         this.printRewrittenExprParam = printRewrittenExprParam;
         this.printLogicalPlanParam = printLogicalPlanParam;
         this.printOptimizedLogicalPlanParam = printOptimizedLogicalPlanParam;
         this.printPhysicalOpsOnly = printPhysicalOpsOnly;
+        this.executeQuery = executeQuery;
         this.generateJobSpec = generateJobSpec;
         this.printJob = printJob;
     }
@@ -61,6 +63,10 @@
         return printPhysicalOpsOnly;
     }
 
+    public boolean isExecuteQuery() {
+        return executeQuery;
+    }
+
     public boolean isOptimize() {
         return optimize;
     }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index 6b17cc9..55bf4c9 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -67,6 +67,7 @@
         String printLogicalPlanParam = request.getParameter("print-logical-plan");
         String printOptimizedLogicalPlanParam = request.getParameter("print-optimized-logical-plan");
         String printJob = request.getParameter("print-job");
+        String executeQuery = request.getParameter("execute-query");
         response.setCharacterEncoding("utf-8");
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
@@ -88,7 +89,7 @@
             List<Statement> aqlStatements = parser.Statement();
             SessionConfig sessionConfig = new SessionConfig(true, isSet(printExprParam),
                     isSet(printRewrittenExprParam), isSet(printLogicalPlanParam),
-                    isSet(printOptimizedLogicalPlanParam), false, true, isSet(printJob));
+                    isSet(printOptimizedLogicalPlanParam), false, isSet(executeQuery), true, isSet(printJob));
             MetadataManager.INSTANCE.init();
             AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, out, sessionConfig, format);
             double duration = 0;
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
index 6086bc1..9f6b7eb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
@@ -89,7 +89,7 @@
             if (checkForbiddenStatements(aqlStatements, out)) {
                 return;
             }
-            SessionConfig sessionConfig = new SessionConfig(true, false, false, false, false, false, true, false);
+            SessionConfig sessionConfig = new SessionConfig(true, false, false, false, false, false, true, true, false);
 
             MetadataManager.INSTANCE.init();
 
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java
index fed1238..cb1e9ad 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java
@@ -31,7 +31,7 @@
 
     protected List<Statement.Kind> getAllowedStatements() {
         Kind[] statementsArray = { Kind.DATAVERSE_DECL, Kind.DELETE, Kind.INSERT, Kind.UPDATE,
-                Kind.DML_CMD_LIST, Kind.LOAD_FROM_FILE, Kind.WRITE_FROM_QUERY_RESULT, Kind.BEGIN_FEED,
+                Kind.DML_CMD_LIST, Kind.LOAD_FROM_FILE, Kind.BEGIN_FEED,
                 Kind.CONTROL_FEED };
         return Arrays.asList(statementsArray);
     }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
index b6a262e..d550689 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
@@ -30,11 +30,6 @@
 import edu.uci.ics.hyracks.api.job.JobSpecification;
 import edu.uci.ics.asterix.aql.parser.AQLParser;
 import edu.uci.ics.asterix.aql.parser.ParseException;
-import edu.uci.ics.asterix.aql.translator.AqlTranslator;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.metadata.MetadataManager;
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-import edu.uci.ics.hyracks.api.job.JobSpecification;
 
 public class AsterixJavaClient {
     private IHyracksClientConnection hcc;
@@ -82,7 +77,7 @@
         MetadataManager.INSTANCE.init();
 
         SessionConfig pc = new SessionConfig(optimize, false, printRewrittenExpressions, printLogicalPlan,
-                printOptimizedPlan, printPhysicalOpsOnly, generateBinaryRuntime, printJob);
+                printOptimizedPlan, printPhysicalOpsOnly, true, generateBinaryRuntime, printJob);
 
         AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, writer, pc, DisplayFormat.TEXT);
         aqlTranslator.compileAndExecute(hcc, null, false);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 655d249..1ec0937 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -57,7 +57,6 @@
 import edu.uci.ics.asterix.aql.expression.SetStatement;
 import edu.uci.ics.asterix.aql.expression.TypeDecl;
 import edu.uci.ics.asterix.aql.expression.TypeDropStatement;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
@@ -101,7 +100,6 @@
 import edu.uci.ics.asterix.translator.CompiledStatements.CompiledIndexDropStatement;
 import edu.uci.ics.asterix.translator.CompiledStatements.CompiledInsertStatement;
 import edu.uci.ics.asterix.translator.CompiledStatements.CompiledLoadFromFileStatement;
-import edu.uci.ics.asterix.translator.CompiledStatements.CompiledWriteFromQueryResultStatement;
 import edu.uci.ics.asterix.translator.CompiledStatements.ICompiledDmlStatement;
 import edu.uci.ics.asterix.translator.TypeTranslator;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -250,10 +248,6 @@
                     handleLoadFromFileStatement(metadataProvider, stmt, hcc);
                     break;
                 }
-                case WRITE_FROM_QUERY_RESULT: {
-                    handleWriteFromQueryResultStatement(metadataProvider, stmt, hcc);
-                    break;
-                }
                 case INSERT: {
                     handleInsertStatement(metadataProvider, stmt, hcc);
                     break;
@@ -1183,36 +1177,6 @@
         }
     }
 
-    private void handleWriteFromQueryResultStatement(AqlMetadataProvider metadataProvider, Statement stmt,
-            IHyracksClientConnection hcc) throws Exception {
-        MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-        boolean bActiveTxn = true;
-        metadataProvider.setMetadataTxnContext(mdTxnCtx);
-        acquireReadLatch();
-
-        try {
-            metadataProvider.setWriteTransaction(true);
-            WriteFromQueryResultStatement st1 = (WriteFromQueryResultStatement) stmt;
-            String dataverseName = getActiveDataverseName(st1.getDataverseName());
-            CompiledWriteFromQueryResultStatement clfrqs = new CompiledWriteFromQueryResultStatement(dataverseName, st1
-                    .getDatasetName().getValue(), st1.getQuery(), st1.getVarCounter());
-
-            JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
-            MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            bActiveTxn = false;
-            if (compiled != null) {
-                runJob(hcc, compiled, true);
-            }
-        } catch (Exception e) {
-            if (bActiveTxn) {
-                abort(e, e, mdTxnCtx);
-            }
-            throw e;
-        } finally {
-            releaseReadLatch();
-        }
-    }
-
     private void handleInsertStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws Exception {
 
@@ -1390,7 +1354,7 @@
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
             bActiveTxn = false;
 
-            if (compiled != null) {
+            if (sessionConfig.isExecuteQuery() && compiled != null) {
                 GlobalConfig.ASTERIX_LOGGER.info(compiled.toJSON().toString(1));
                 JobId jobId = runJob(hcc, compiled, false);
 
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 fde3165..a0872d2 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
@@ -33,7 +33,6 @@
 import edu.uci.ics.asterix.formats.base.IDataFormat;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
-import edu.uci.ics.asterix.metadata.dataset.hints.DatasetHints.DatasetCardinalityHint;
 import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
 import edu.uci.ics.asterix.metadata.entities.Dataverse;
@@ -171,7 +170,7 @@
         AsterixStorageProperties storageProperties = AsterixAppContextInfo.getInstance().getStorageProperties();
         //prepare a LocalResourceMetadata which will be stored in NC's local resource repository
         ILocalResourceMetadata localResourceMetadata = new LSMBTreeLocalResourceMetadata(typeTraits,
-                comparatorFactories, blooFilterKeyFields, true, fs, dataset.getDatasetId());
+                comparatorFactories, blooFilterKeyFields, true, dataset.getDatasetId());
         ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
                 localResourceMetadata, LocalResource.LSMBTreeResource);
 
@@ -256,31 +255,26 @@
         }
         LOGGER.info("LOAD into File Splits: " + sb.toString());
 
-        String numElementsHintString = dataset.getHints().get("CARDINALITY");
-        long numElementsHint;
-        if (numElementsHintString == null) {
-            numElementsHint = DatasetCardinalityHint.DEFAULT;
-        } else {
-            numElementsHint = Long.parseLong(dataset.getHints().get("CARDINALITY"));
-        }
-
+        long numElementsHint = metadataProvider.getCardinalityPerPartitionHint(dataset);
         AsterixStorageProperties storageProperties = AsterixAppContextInfo.getInstance().getStorageProperties();
-        TreeIndexBulkLoadOperatorDescriptor btreeBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
-                AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER,
-                splitsAndConstraint.first, typeTraits, comparatorFactories, blooFilterKeyFields, fieldPermutation,
-                GlobalConfig.DEFAULT_BTREE_FILL_FACTOR, false, numElementsHint, new LSMBTreeDataflowHelperFactory(
-                        new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()),
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
-                        new PrimaryIndexOperationTrackerProvider(dataset.getDatasetId()),
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
-                        storageProperties.getBloomFilterFalsePositiveRate()), NoOpOperationCallbackFactory.INSTANCE);
-        AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, btreeBulkLoad,
-                splitsAndConstraint.second);
-
-        spec.connect(new OneToOneConnectorDescriptor(spec), scanner, 0, asterixOp, 0);
-
+        TreeIndexBulkLoadOperatorDescriptor btreeBulkLoad;
         if (!loadStmt.alreadySorted()) {
+            btreeBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
+                    AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER,
+                    AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, splitsAndConstraint.first, typeTraits,
+                    comparatorFactories, blooFilterKeyFields, fieldPermutation, GlobalConfig.DEFAULT_BTREE_FILL_FACTOR,
+                    true, numElementsHint, true, new LSMBTreeDataflowHelperFactory(
+                            new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()),
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            new PrimaryIndexOperationTrackerProvider(dataset.getDatasetId()),
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            storageProperties.getBloomFilterFalsePositiveRate()), NoOpOperationCallbackFactory.INSTANCE);
+            AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, btreeBulkLoad,
+                    splitsAndConstraint.second);
+
+            spec.connect(new OneToOneConnectorDescriptor(spec), scanner, 0, asterixOp, 0);
+
             int framesLimit = physicalOptimizationConfig.getMaxFramesExternalSort();
             ExternalSortOperatorDescriptor sorter = new ExternalSortOperatorDescriptor(spec, framesLimit, keys,
                     comparatorFactories, recDesc);
@@ -291,6 +285,22 @@
             spec.connect(hashConn, asterixOp, 0, sorter, 0);
             spec.connect(new OneToOneConnectorDescriptor(spec), sorter, 0, btreeBulkLoad, 0);
         } else {
+            btreeBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
+                    AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER,
+                    AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, splitsAndConstraint.first, typeTraits,
+                    comparatorFactories, blooFilterKeyFields, fieldPermutation, GlobalConfig.DEFAULT_BTREE_FILL_FACTOR,
+                    false, numElementsHint, true, new LSMBTreeDataflowHelperFactory(
+                            new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()),
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            new PrimaryIndexOperationTrackerProvider(dataset.getDatasetId()),
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
+                            storageProperties.getBloomFilterFalsePositiveRate()), NoOpOperationCallbackFactory.INSTANCE);
+            AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, btreeBulkLoad,
+                    splitsAndConstraint.second);
+
+            spec.connect(new OneToOneConnectorDescriptor(spec), scanner, 0, asterixOp, 0);
+
             IConnectorDescriptor sortMergeConn = new MToNPartitioningMergingConnectorDescriptor(spec,
                     new FieldHashPartitionComputerFactory(keys, hashFactories), keys, comparatorFactories);
             spec.connect(sortMergeConn, asterixOp, 0, btreeBulkLoad, 0);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryBTreeCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryBTreeCreator.java
index 94f831c..052368a 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryBTreeCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryBTreeCreator.java
@@ -55,7 +55,7 @@
         //prepare a LocalResourceMetadata which will be stored in NC's local resource repository
         ILocalResourceMetadata localResourceMetadata = new LSMBTreeLocalResourceMetadata(
                 secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories, secondaryBloomFilterKeyFields, true,
-                secondaryFileSplitProvider.getFileSplits(), dataset.getDatasetId());
+                dataset.getDatasetId());
         ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
                 localResourceMetadata, LocalResource.LSMBTreeResource);
 
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 46f5b1a..6717b4d 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
@@ -29,7 +29,6 @@
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlTypeTraitProvider;
 import edu.uci.ics.asterix.metadata.MetadataException;
-import edu.uci.ics.asterix.metadata.dataset.hints.DatasetHints.DatasetCardinalityHint;
 import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
 import edu.uci.ics.asterix.metadata.entities.Index;
@@ -131,10 +130,10 @@
                 indexCreator = new SecondaryRTreeCreator(physOptConf, asterixPropertiesProvider);
                 break;
             }
-            case WORD_INVIX:
-            case NGRAM_INVIX:
-            case FUZZY_WORD_INVIX:
-            case FUZZY_NGRAM_INVIX: {
+            case SINGLE_PARTITION_WORD_INVIX:
+            case SINGLE_PARTITION_NGRAM_INVIX:
+            case LENGTH_PARTITIONED_WORD_INVIX:
+            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                 indexCreator = new SecondaryInvertedIndexCreator(physOptConf, asterixPropertiesProvider);
                 break;
             }
@@ -180,13 +179,7 @@
         // Must be called in this order.
         setPrimaryRecDescAndComparators();
         setSecondaryRecDescAndComparators(createIndexStmt, metadataProvider);
-
-        String numElementsHintString = dataset.getHints().get("CARDINALITY");
-        if (numElementsHintString == null) {
-            numElementsHint = DatasetCardinalityHint.DEFAULT;
-        } else {
-            numElementsHint = Long.parseLong(dataset.getHints().get("CARDINALITY"));
-        }
+        numElementsHint = metadataProvider.getCardinalityPerPartitionHint(dataset);
     }
 
     protected void setPrimaryRecDescAndComparators() throws AlgebricksException {
@@ -343,7 +336,7 @@
                 AsterixRuntimeComponentsProvider.LSMBTREE_SECONDARY_PROVIDER,
                 AsterixRuntimeComponentsProvider.LSMBTREE_SECONDARY_PROVIDER, secondaryFileSplitProvider,
                 secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories, secondaryBloomFilterKeyFields,
-                fieldPermutation, fillFactor, false, numElementsHint, dataflowHelperFactory,
+                fieldPermutation, fillFactor, false, numElementsHint, false, dataflowHelperFactory,
                 NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, treeIndexBulkLoadOp,
                 secondaryPartitionConstraint);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
index 9a54847..17590c5 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
@@ -92,8 +92,8 @@
         if (numSecondaryKeys > 1) {
             throw new AsterixException("Cannot create composite inverted index on multiple fields.");
         }
-        if (createIndexStmt.getIndexType() == IndexType.FUZZY_WORD_INVIX
-                || createIndexStmt.getIndexType() == IndexType.FUZZY_NGRAM_INVIX) {
+        if (createIndexStmt.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
+                || createIndexStmt.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX) {
             isPartitioned = true;
         } else {
             isPartitioned = false;
@@ -170,7 +170,7 @@
         //prepare a LocalResourceMetadata which will be stored in NC's local resource repository
         ILocalResourceMetadata localResourceMetadata = new LSMInvertedIndexLocalResourceMetadata(invListsTypeTraits,
                 primaryComparatorFactories, tokenTypeTraits, tokenComparatorFactories, tokenizerFactory, isPartitioned,
-                secondaryFileSplitProvider.getFileSplits(), dataset.getDatasetId());
+                dataset.getDatasetId());
         ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
                 localResourceMetadata, LocalResource.LSMInvertedIndexResource);
 
@@ -266,10 +266,11 @@
         }
         IIndexDataflowHelperFactory dataflowHelperFactory = createDataflowHelperFactory();
         LSMInvertedIndexBulkLoadOperatorDescriptor invIndexBulkLoadOp = new LSMInvertedIndexBulkLoadOperatorDescriptor(
-                spec, fieldPermutation, false, numElementsHint, AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER,
-                secondaryFileSplitProvider, AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, tokenTypeTraits,
-                tokenComparatorFactories, invListsTypeTraits, primaryComparatorFactories, tokenizerFactory,
-                dataflowHelperFactory, NoOpOperationCallbackFactory.INSTANCE);
+                spec, fieldPermutation, false, numElementsHint, false,
+                AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, secondaryFileSplitProvider,
+                AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, tokenTypeTraits, tokenComparatorFactories,
+                invListsTypeTraits, primaryComparatorFactories, tokenizerFactory, dataflowHelperFactory,
+                NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, invIndexBulkLoadOp,
                 secondaryPartitionConstraint);
         return invIndexBulkLoadOp;
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryRTreeCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryRTreeCreator.java
index 3332763..17632aa 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryRTreeCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryRTreeCreator.java
@@ -79,8 +79,7 @@
         ILocalResourceMetadata localResourceMetadata = new LSMRTreeLocalResourceMetadata(
                 secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories, primaryComparatorFactories,
                 valueProviderFactories, RTreePolicyType.RTREE, AqlMetadataProvider.proposeLinearizer(keyType,
-                        secondaryComparatorFactories.length), secondaryFileSplitProvider.getFileSplits(),
-                dataset.getDatasetId());
+                        secondaryComparatorFactories.length), dataset.getDatasetId());
         ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
                 localResourceMetadata, LocalResource.LSMRTreeResource);
 
diff --git a/asterix-app/src/main/resources/webui/querytemplate.html b/asterix-app/src/main/resources/webui/querytemplate.html
index 2085f22..0adb518 100644
--- a/asterix-app/src/main/resources/webui/querytemplate.html
+++ b/asterix-app/src/main/resources/webui/querytemplate.html
@@ -200,6 +200,7 @@
               <label class="checkbox optlabel"><input type="checkbox" name="print-logical-plan" value="true" /> Print logical plan</label>
               <label class="checkbox optlabel"><input type="checkbox" name="print-optimized-logical-plan" value="true" /> Print optimized logical plan</label>
               <label class="checkbox optlabel"><input type="checkbox" name="print-job" value="true" /> Print Hyracks job</label>
+              <label class="checkbox optlabel"><input type="checkbox" name="execute-query" value="true" checked/> Execute query</label>
             </div>
           </form>
        </div>
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql
index 938f137..4d8c488 100644
--- a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql
@@ -1,5 +1,5 @@
 /*
- * Description  : create a fuzzy keyword index on unallowed key type.
+ * Description  : create a keyword index on unallowed key type.
  * Expected Res : Failure
  * Date         : 23 April 2013
  * Issue        : 384
@@ -16,5 +16,5 @@
 }
 
 create dataset testds(opentype) primary key id;
-create index loc_index on testds(loc) type fuzzy keyword;
+create index loc_index on testds(loc) type keyword;
 
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql
index dee287d..4ce2d2c 100644
--- a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql
@@ -1,5 +1,5 @@
 /*
- * Description  : create a fuzzy ngram index on unallowed key type.
+ * Description  : create a ngram index on unallowed key type.
  * Expected Res : Failure
  * Date         : 23 April 2013
  * Issue        : 384
@@ -16,5 +16,5 @@
 }
 
 create dataset testds(opentype) primary key id;
-create index loc_index on testds(loc) type fuzzy ngram(2);
+create index loc_index on testds(loc) type ngram(2);
 
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 4ac02c8..6939226 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
@@ -33,5 +33,5 @@
 set simthreshold '0.8f';
 
 for $c in dataset('Customers')
-where $c.interests ~= ["databases", "computers", "wine"]
+where $c.interests ~= {{"computers", "wine", "databases"}}
 return $c
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 80e8aef..364704a 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
@@ -30,5 +30,5 @@
 write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm";
 
 for $c in dataset('Customers')
-where similarity-jaccard-check($c.interests, ["databases", "computers", "wine"], 0.7f)[0]
+where similarity-jaccard-check($c.interests, {{"computers", "wine", "databases"}}, 0.7f)[0]
 return $c
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 588ca14..ca2cfa8 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
@@ -30,5 +30,5 @@
 write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm";
 
 for $c in dataset('Customers')
-where similarity-jaccard($c.interests, ["databases", "computers", "wine"]) >= 0.7f
+where similarity-jaccard($c.interests, {{"computers", "databases", "wine"}}) >= 0.7f
 return $c
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql b/asterix-app/src/test/resources/optimizerts/queries/q01_pricing_summary_report_nt.aql
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
rename to asterix-app/src/test/resources/optimizerts/queries/q01_pricing_summary_report_nt.aql
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql b/asterix-app/src/test/resources/optimizerts/queries/q03_shipping_priority.aql
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/queries/q3_shipping_priority.aql
rename to asterix-app/src/test/resources/optimizerts/queries/q03_shipping_priority.aql
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql b/asterix-app/src/test/resources/optimizerts/queries/q05_local_supplier_volume.aql
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/queries/q5_local_supplier_volume.aql
rename to asterix-app/src/test/resources/optimizerts/queries/q05_local_supplier_volume.aql
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-contains.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-contains.plan
index d7c4c08..ab613e0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-contains.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-contains.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance-check.plan
index 1f53ded..72e494a 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance-check.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance.plan
index 1f53ded..72e494a 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-edit-distance.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-edit-distance.plan
index 8a40be1..fb581db 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-edit-distance.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-jaccard.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-fuzzyeq-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard-check.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard-check.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ngram-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance-check.plan
index 7fcefa6..567720b 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance-check.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance.plan
index 7fcefa6..567720b 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-edit-distance.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-edit-distance.plan
index dca0403..ec1ceb2 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-edit-distance.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-jaccard.plan
index 1f53ded..72e494a 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-fuzzyeq-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard-check.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard-check.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/olist-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-fuzzyeq-jaccard.plan
index 1f53ded..72e494a 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-fuzzyeq-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard-check.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard-check.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/ulist-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-fuzzyeq-jaccard.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-fuzzyeq-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard-check.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard-check.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard-check.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard-check.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-basic/word-jaccard.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.plan
index a59363b..a42ddca 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.plan
index a59363b..a42ddca 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let.plan
index f26c81d..7d4fba5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-edit-distance-check-let.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-let.plan
index e4516f1..0613c77 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-let.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-multi-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-multi-let.plan
index 6900fe8..afdf34e 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-multi-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ngram-jaccard-check-multi-let.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STREAM_PROJECT  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
                                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-edit-distance-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-edit-distance-check-let.plan
index e62367e..30e9fcf 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-edit-distance-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-edit-distance-check-let.plan
@@ -11,7 +11,7 @@
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                          -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- ASSIGN  |PARTITIONED|
                                 -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-jaccard-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-jaccard-check-let.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-jaccard-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/olist-jaccard-check-let.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ulist-jaccard-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ulist-jaccard-check-let.plan
index 7ad0078..ded641f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ulist-jaccard-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/ulist-jaccard-check-let.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-let.plan
index e4516f1..0613c77 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-let.plan
@@ -9,7 +9,7 @@
                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                   -- STREAM_PROJECT  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                      -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- ASSIGN  |PARTITIONED|
                             -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-multi-let.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-multi-let.plan
index 6900fe8..afdf34e 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-multi-let.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-complex/word-jaccard-check-multi-let.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STREAM_PROJECT  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
                                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance-inline.plan
index c683c43..19ceed6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance-inline.plan
@@ -15,7 +15,7 @@
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                  -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                  -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                     -- BROADCAST_EXCHANGE  |PARTITIONED|
                                       -- STREAM_SELECT  |PARTITIONED|
                                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance.plan
index 0aaa618..f9895f2 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-edit-distance.plan
@@ -14,7 +14,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_SELECT  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.plan
index fc5a042..3d2a2f0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.plan
@@ -14,7 +14,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$27(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_SELECT  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.plan
index 7629035..e3fed65 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard-inline.plan
index 4972d0f..e151aa9 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard-inline.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- BROADCAST_EXCHANGE  |PARTITIONED|
                                   -- STREAM_PROJECT  |PARTITIONED|
                                     -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard.plan
index a8c2925..c0802b5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ngram-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$27(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance-inline.plan
index c683c43..19ceed6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance-inline.plan
@@ -15,7 +15,7 @@
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                               -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                  -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                  -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                     -- BROADCAST_EXCHANGE  |PARTITIONED|
                                       -- STREAM_SELECT  |PARTITIONED|
                                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance.plan
index 0aaa618..f9895f2 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-edit-distance.plan
@@ -14,7 +14,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_SELECT  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.plan
index fc5a042..3d2a2f0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.plan
@@ -14,7 +14,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$27(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_SELECT  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.plan
index a2236b0..85320e5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard-inline.plan
index ebebe4d..5133569 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard-inline.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- BROADCAST_EXCHANGE  |PARTITIONED|
                                   -- STREAM_PROJECT  |PARTITIONED|
                                     -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard.plan
index 0ee49d0..cbc411e 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/olist-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.plan
index a2236b0..85320e5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard-inline.plan
index ebebe4d..5133569 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard-inline.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- BROADCAST_EXCHANGE  |PARTITIONED|
                                   -- STREAM_PROJECT  |PARTITIONED|
                                     -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard.plan
index 0ee49d0..cbc411e 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/ulist-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.plan
index 7629035..e3fed65 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard-inline.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard-inline.plan
index 4972d0f..e151aa9 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard-inline.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard-inline.plan
@@ -13,7 +13,7 @@
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                           -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                              -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                 -- BROADCAST_EXCHANGE  |PARTITIONED|
                                   -- STREAM_PROJECT  |PARTITIONED|
                                     -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard.plan
index a8c2925..c0802b5 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join-noeqjoin/word-jaccard.plan
@@ -12,7 +12,7 @@
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                         -- STABLE_SORT [$$27(ASC)]  |PARTITIONED|
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                            -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- STREAM_PROJECT  |PARTITIONED|
                                   -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_01.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_02.plan
index 9fe499b..ed62b15 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_03.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_04.plan
index dbeabdd..4c8419d 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance-check_04.plan
@@ -22,7 +22,7 @@
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                     -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                        -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                        -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                           -- BROADCAST_EXCHANGE  |PARTITIONED|
                                             -- STREAM_SELECT  |PARTITIONED|
                                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_01.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_02.plan
index 9fe499b..ed62b15 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_03.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_04.plan
index 7a789d2..c827d8f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-edit-distance_04.plan
@@ -22,7 +22,7 @@
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                     -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                        -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                        -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                           -- BROADCAST_EXCHANGE  |PARTITIONED|
                                             -- STREAM_SELECT  |PARTITIONED|
                                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_01.plan
index 16f2bfd..57b9a51 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_02.plan
index 595587e..b506ee6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_03.plan
index 595587e..b506ee6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-edit-distance_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_01.plan
index b7fe0db..04e7c27 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_02.plan
index 7160d6f..81b8ffc 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_03.plan
index b7fe0db..04e7c27 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-fuzzyeq-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_01.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_02.plan
index c3bf90e..fb367ed 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_03.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_04.plan
index 5ed5498..0125b0c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard-check_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_01.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_02.plan
index c3bf90e..fb367ed 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_03.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_04.plan
index c995dafa..5526dbc 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ngram-jaccard_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_01.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_02.plan
index 9fe499b..ed62b15 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_03.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_04.plan
index dbeabdd..4c8419d 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance-check_04.plan
@@ -22,7 +22,7 @@
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                     -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                        -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                        -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                           -- BROADCAST_EXCHANGE  |PARTITIONED|
                                             -- STREAM_SELECT  |PARTITIONED|
                                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_01.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_02.plan
index 9fe499b..ed62b15 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_03.plan
index b274dfc..56b5df4 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$26(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_04.plan
index 7a789d2..c827d8f 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-edit-distance_04.plan
@@ -22,7 +22,7 @@
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                     -- STABLE_SORT [$$31(ASC)]  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                        -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                        -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                           -- BROADCAST_EXCHANGE  |PARTITIONED|
                                             -- STREAM_SELECT  |PARTITIONED|
                                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_01.plan
index 595587e..b506ee6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_01.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_02.plan
index 16f2bfd..57b9a51 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_02.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_03.plan
index 595587e..b506ee6 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-edit-distance_03.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_SELECT  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_01.plan
index 74bdea2..5204ee0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_02.plan
index be387f0..80b2a89 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_03.plan
index 74bdea2..5204ee0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-fuzzyeq-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_01.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_02.plan
index 8a7e71b..f6e6db1 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_03.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_04.plan
index 4934b82..e40c034 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard-check_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_01.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_02.plan
index 8a7e71b..f6e6db1 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_03.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_04.plan
index 710ba98..d667093 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/olist-jaccard_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_01.plan
index 74bdea2..5204ee0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_02.plan
index be387f0..80b2a89 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_03.plan
index 74bdea2..5204ee0 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-fuzzyeq-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$22(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_01.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_02.plan
index 8a7e71b..f6e6db1 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_03.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_04.plan
index 4934b82..e40c034 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard-check_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_01.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_02.plan
index 8a7e71b..f6e6db1 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_03.plan
index dc2073c..e0b345c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$23(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_04.plan
index 710ba98..d667093 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/ulist-jaccard_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_01.plan
index b7fe0db..04e7c27 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_02.plan
index 7160d6f..81b8ffc 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_03.plan
index b7fe0db..04e7c27 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-fuzzyeq-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$24(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_01.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_02.plan
index e58089b..4051e3e 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_03.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_04.plan
index 5ed5498..0125b0c 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard-check_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_01.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_01.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_01.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_01.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_02.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_02.plan
index c3bf90e..fb367ed 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_02.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_02.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_03.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_03.plan
index 2710b67..13016ab 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_03.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_03.plan
@@ -18,7 +18,7 @@
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                             -- STABLE_SORT [$$25(ASC)]  |PARTITIONED|
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                   -- BROADCAST_EXCHANGE  |PARTITIONED|
                                     -- STREAM_PROJECT  |PARTITIONED|
                                       -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_04.plan b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_04.plan
index c995dafa..5526dbc 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inverted-index-join/word-jaccard_04.plan
@@ -20,7 +20,7 @@
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                 -- STABLE_SORT [$$30(ASC)]  |PARTITIONED|
                                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                    -- FUZZY_INVERTED_INDEX_SEARCH  |PARTITIONED|
+                                    -- LENGTH_PARTITIONED_INVERTED_INDEX_SEARCH  |PARTITIONED|
                                       -- BROADCAST_EXCHANGE  |PARTITIONED|
                                         -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/q1_pricing_summary_report_nt.plan b/asterix-app/src/test/resources/optimizerts/results/q01_pricing_summary_report_nt.plan
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/results/q1_pricing_summary_report_nt.plan
rename to asterix-app/src/test/resources/optimizerts/results/q01_pricing_summary_report_nt.plan
diff --git a/asterix-app/src/test/resources/optimizerts/results/q3_shipping_priority.plan b/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/results/q3_shipping_priority.plan
rename to asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
diff --git a/asterix-app/src/test/resources/optimizerts/results/q5_local_supplier_volume.plan b/asterix-app/src/test/resources/optimizerts/results/q05_local_supplier_volume.plan
similarity index 100%
rename from asterix-app/src/test/resources/optimizerts/results/q5_local_supplier_volume.plan
rename to asterix-app/src/test/resources/optimizerts/results/q05_local_supplier_volume.plan
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.aql
index 6dfff7a..63f040f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.aql
@@ -1,6 +1,6 @@
 use dataverse test;
 
-write into dataset CustomerOrders1 (
+insert into dataset CustomerOrders1 (
 
 for $c in dataset('Customers1')
 for $o in dataset('Orders1')
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.aql
index fdbfa62..8faaa98 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.aql
@@ -8,7 +8,7 @@
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted;
 
-write into dataset CustomerOrders2 (
+insert into dataset CustomerOrders2 (
 
 for $c in dataset('Customers2')
 let $orders := 
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.aql b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.aql
index 6ddccc4..701119b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.aql
@@ -1,6 +1,6 @@
 use dataverse test;
 
-write into dataset CustomerOrders3 (
+insert into dataset CustomerOrders3 (
 
 for $c in dataset('Customers3')
 let $orders := 
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/load-test/load-test.3.update.aql b/asterix-app/src/test/resources/runtimets/queries/custord/load-test/load-test.3.update.aql
index 11761d6..0cf11bb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/load-test/load-test.3.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/load-test/load-test.3.update.aql
@@ -1,10 +1,9 @@
 use dataverse test;
 
-write into dataset c2 (
+insert into dataset c2 (
 
   for $c in dataset('c1')
   return $c 
 
 );
 
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.1.ddl.aql
index 356aafb..177d74f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.1.ddl.aql
@@ -1,6 +1,6 @@
 /* 
  * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on secondary index 
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
  * Expected Result : Success
  * Date            : May 2 2012
  */
@@ -33,4 +33,3 @@
   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-with-index/empty-load-with-index.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.2.update.aql
index 821c6a3..ce46ab2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.2.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.2.update.aql
@@ -1,6 +1,6 @@
 /* 
  * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on secondary index 
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
  * Expected Result : Success
  * Date            : May 2 2012
  */
@@ -14,4 +14,3 @@
 load dataset LineItem 
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.3.query.aql
index 5111256..2348e27 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load-with-index/empty-load-with-index.3.query.aql
@@ -1,6 +1,6 @@
 /* 
  * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on secondary index 
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
  * Expected Result : Success
  * Date            : May 2 2012
  */
@@ -10,4 +10,4 @@
 for $c in dataset('LineItem')
 order by $c.l_orderkey, $c.l_linenumber
 limit 1
-return $c
+return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.1.ddl.aql
deleted file mode 100644
index 54da1a2..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.1.ddl.aql
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 
- * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on primary index 
- * Expected Result : Success
- * Date            : May 2 2012
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use dataverse test;
-
-create type LineItemType as closed {
-  l_orderkey: int32, 
-  l_partkey: int32, 
-  l_suppkey: int32, 
-  l_linenumber: int32, 
-  l_quantity: double, 
-  l_extendedprice: double,
-  l_discount: double, 
-  l_tax: double,
-  l_returnflag: string, 
-  l_linestatus: string, 
-  l_shipdate: string,
-  l_commitdate: string, 
-  l_receiptdate: string, 
-  l_shipinstruct: string, 
-  l_shipmode: string, 
-  l_comment: string
-}
-
-create dataset LineItem(LineItemType)
-  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/empty-load.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.2.update.aql
deleted file mode 100644
index e9072d1..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.2.update.aql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 
- * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on primary index 
- * Expected Result : Success
- * Date            : May 2 2012
- */
-
-use dataverse test;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/empty.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.3.query.aql
deleted file mode 100644
index bb4cac6..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/dml/empty-load/empty-load.3.query.aql
+++ /dev/null
@@ -1,13 +0,0 @@
-/* 
- * Test case Name  : empty-load-with-index.aql
- * Description     : Check that an empty load doesn't preclude a future non-empty load on primary index 
- * Expected Result : Success
- * Date            : May 2 2012
- */
-
-use dataverse test;
-
-for $c in dataset('LineItem')
-order by $c.l_orderkey, $c.l_linenumber
-limit 1
-return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.3.query.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.3.query.aql
rename to asterix-app/src/test/resources/runtimets/queries/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.3.query.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.aql
index d68b466e..5af25b2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.aql
@@ -12,9 +12,4 @@
   misc: string
 }
 
-create dataset DBLP(DBLPType) primary key id;
-
-load dataset DBLP 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
-
+create dataset DBLP(DBLPType) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.aql
index b2dc701..dfc0f4e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.aql
@@ -1,3 +1,5 @@
+drop dataverse test if exists;
+create dataverse test;
 use dataverse test;
 
 create type AddressType as closed {
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.aql
index 27a838ba..b382619 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.aql
@@ -1,6 +1,6 @@
 use dataverse test;
 
 for $c in dataset('Customers')
-let $jacc := similarity-jaccard-check($c.interests, ["databases", "computers", "wine"], 0.7f)
+let $jacc := similarity-jaccard-check($c.interests, {{"computers", "wine", "databases"}}, 0.7f)
 where $jacc[0]
 return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.1.ddl.aql
new file mode 100644
index 0000000..82ac15f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : Create and load a dataset that has duplicate keys.
+ * Expected Res : Failure
+ * Date         : 04 July 2013
+ */
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+id: int32
+}
+
+create dataset mydataset(Schema)
+primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.2.update.aql
new file mode 100644
index 0000000..8dbb67b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/duplicate-key-error/duplicate-key-error.2.update.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Create and load a dataset that has duplicate keys.
+ * Expected Res : Failure
+ * Date         : 04 July 2013
+ */
+use dataverse test;
+
+load dataset mydataset 
+using localfs(("path"="nc1://data/duplicateKeys.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.aql
similarity index 89%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.3.query.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.aql
index c27be0a..599f51e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.aql
@@ -4,7 +4,8 @@
 for $l in dataset('LineItem')
 where $l.l_shipdate <= '1998-09-02'
 /*+ hash*/
-group by $l_returnflag := $l.l_returnflag, $l_linestatus := $l.l_linestatus  
+group by $l_returnflag := $l.l_returnflag,
+         $l_linestatus := $l.l_linestatus  
   with $l
 order by $l_returnflag, $l_linestatus
 return {
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.aql
new file mode 100644
index 0000000..16cf8b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.aql
@@ -0,0 +1,117 @@
+use dataverse tpch;
+
+declare function tmp1() {
+  for $p in dataset('Part')
+  for $pssrn in (
+    for $ps in dataset('Partsupp')
+    for $srn in (
+      for $s in dataset('Supplier')
+      for $rn in (
+        for $r in dataset('Region')
+        for $n in dataset('Nation')
+        where $n.n_regionkey = $r.r_regionkey and $r.r_name = 'EUROPE' 
+        return {
+          "n_nationkey": $n.n_nationkey,
+          "n_name": $n.n_name
+        }
+      )
+      where $s.s_nationkey = $rn.n_nationkey
+      return {
+        "s_suppkey": $s.s_suppkey,
+        "n_name": $rn.n_name,
+        "s_name": $s.s_name,
+        "s_acctbal": $s.s_acctbal,
+        "s_address": $s.s_address, 
+        "s_phone": $s.s_phone, 
+        "s_comment": $s.s_comment
+      }
+    )
+    where $srn.s_suppkey = $ps.ps_suppkey
+    return {
+      "n_name": $srn.n_name,
+      "p_partkey": $ps.ps_partkey,
+      "ps_supplycost": $ps.ps_supplycost,
+      "s_name": $srn.s_name,
+      "s_acctbal": $srn.s_acctbal,
+      "s_address":  $srn.s_address, 
+      "s_phone":  $srn.s_phone, 
+      "s_comment":  $srn.s_comment
+    }
+  ) 
+  where $p.p_partkey = $pssrn.p_partkey and like($p.p_type, '%BRASS') 
+  return {
+    "s_acctbal": $pssrn.s_acctbal,
+    "s_name": $pssrn.s_name, 
+    "n_name": $pssrn.n_name, 
+    "p_partkey": $p.p_partkey, 
+    "ps_supplycost": $pssrn.ps_supplycost, 
+    "p_mfgr": $p.p_mfgr, 
+    "s_address":  $pssrn.s_address, 
+    "s_phone":  $pssrn.s_phone, 
+    "s_comment":  $pssrn.s_comment
+  }
+}
+
+declare function tmp2(){
+  for $p in dataset('Part')
+  for $pssrn in (
+    for $ps in dataset('Partsupp')
+    for $srn in (
+      for $s in dataset('Supplier')
+      for $rn in (
+        for $r in dataset('Region')
+        for $n in dataset('Nation')
+        where $n.n_regionkey = $r.r_regionkey and $r.r_name = 'EUROPE' 
+        return {
+          "n_nationkey": $n.n_nationkey,
+          "n_name": $n.n_name
+        }
+      )
+      where $s.s_nationkey = $rn.n_nationkey
+      return {
+        "s_suppkey": $s.s_suppkey,
+        "n_name": $rn.n_name,
+        "s_name": $s.s_name,
+        "s_acctbal": $s.s_acctbal,
+        "s_address": $s.s_address, 
+        "s_phone": $s.s_phone, 
+        "s_comment": $s.s_comment
+      }
+    )
+    where $srn.s_suppkey = $ps.ps_suppkey
+    return {
+      "n_name": $srn.n_name,
+      "p_partkey": $ps.ps_partkey,
+      "ps_supplycost": $ps.ps_supplycost,
+      "s_name": $srn.s_name,
+      "s_acctbal": $srn.s_acctbal,
+      "s_address":  $srn.s_address, 
+      "s_phone":  $srn.s_phone, 
+      "s_comment":  $srn.s_comment
+    }
+  )
+  where $p.p_partkey = $pssrn.p_partkey and like($p.p_type, '%BRASS') 
+  /*+ hash*/
+  group by $p_partkey := $pssrn.p_partkey with $pssrn
+  return {
+    "p_partkey": $p_partkey, 
+    "ps_min_supplycost": min(for $i in $pssrn return $i.ps_supplycost)
+  }
+}
+
+for $t2 in tmp2()
+for $t1 in tmp1()
+where $t1.p_partkey = $t2.p_partkey and $t1.ps_supplycost = $t2.ps_min_supplycost
+order by $t1.s_acctbal desc, $t1.n_name, $t1.s_name, $t1.p_partkey
+limit 100
+return 
+{
+  "s_acctbal": $t1.s_acctbal, 
+  "s_name": $t1.s_name, 
+  "n_name": $t1.n_name, 
+  "p_partkey": $t1.p_partkey, 
+  "p_mfgr": $t1.p_mfgr, 
+  "s_address": $t1.s_address, 
+  "s_phone": $t1.s_phone, 
+  "s_comment": $t1.s_comment
+} 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.3.query.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.3.query.aql
new file mode 100644
index 0000000..9912c85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q04_order_priority/q04_order_priority.3.query.aql
@@ -0,0 +1,21 @@
+use dataverse tpch;
+
+declare function tmp()
+{
+  for $l in dataset('LineItem')
+  where $l.l_commitdate < $l.l_receiptdate
+  distinct by $l.l_orderkey
+  return { "o_orderkey": $l.l_orderkey }
+}
+
+for $o in dataset('Orders')
+for $t in tmp()
+where $o.o_orderkey = $t.o_orderkey and 
+  $o.o_orderdate >= '1993-07-01' and $o.o_orderdate < '1993-10-01' 
+group by $o_orderpriority := $o.o_orderpriority with $o
+order by $o_orderpriority
+return {
+  "order_priority": $o_orderpriority,
+  "count": count($o)
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.aql
new file mode 100644
index 0000000..e0e0563
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.aql
@@ -0,0 +1,56 @@
+use dataverse tpch;
+
+for $c in dataset('Customer')
+for $o1 in (
+  for $o in dataset('Orders')
+  for $l1 in (
+    for $l in dataset('LineItem')
+    for $s1 in (
+      for $s in dataset('Supplier')
+      for $n1 in (
+        for $n in dataset('Nation')
+        for $r in dataset('Region')
+        where $n.n_regionkey = $r.r_regionkey
+        return {
+          "n_name": $n.n_name,
+          "n_nationkey": $n.n_nationkey
+        }
+      )
+      where $s.s_nationkey = $n1.n_nationkey
+      return {
+        "n_name": $n1.n_name,
+        "s_suppkey": $s.s_suppkey,
+        "s_nationkey": $s.s_nationkey
+      }
+    )
+    where $l.l_suppkey = $s1.s_suppkey      
+    return {
+      "n_name": $s1.n_name, 
+      "l_extendedprice": $l.l_extendedprice,
+      "l_discount": $l.l_discount,
+      "l_orderkey": $l.l_orderkey,
+      "s_nationkey": $s1.s_nationkey
+    }
+  )
+  where $l1.l_orderkey = $o.o_orderkey and $o.o_orderdate >= '1990-01-01' and $o.o_orderdate < '1995-01-01'
+  return {
+    "n_name": $l1.n_name,
+    "l_extendedprice": $l1.l_extendedprice,
+    "l_discount": $l1.l_discount,
+    "s_nationkey": $l1.s_nationkey,
+    "o_custkey": $o.o_custkey
+  }
+)
+where $c.c_nationkey = $o1.s_nationkey and $c.c_custkey = $o1.o_custkey
+/*+ hash*/     
+group by $n_name := $o1.n_name with $o1
+let $revenue := sum (
+  for $i in $o1 
+  return 
+    $i.l_extendedprice * (1 - $i.l_discount)
+)
+order by $revenue desc
+return {
+  "n_name": $n_name,
+  "revenue": $revenue
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.aql
new file mode 100644
index 0000000..213b41d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.aql
@@ -0,0 +1,13 @@
+use dataverse tpch;
+
+let $revenue := sum(
+  for $l in dataset('LineItem')
+  where $l.l_shipdate >= '1994-01-01'
+    and $l.l_shipdate < '1995-01-01'
+    and $l.l_discount >= 0.05 and $l.l_discount <= 0.07
+    and $l.l_quantity < 24
+  return $l.l_extendedprice * $l.l_discount
+)
+return {
+  "revenue": $revenue
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.3.query.aql
new file mode 100644
index 0000000..7b9e2b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q07_volume_shipping/q07_volume_shipping.3.query.aql
@@ -0,0 +1,63 @@
+use dataverse tpch;
+
+declare function q7_volume_shipping_tmp() {
+  for $n1 in dataset('Nation') 
+  for $n2 in dataset('Nation')
+  where $n2.n_name='GERMANY' or $n1.n_name='GERMANY' 
+  return {
+    "supp_nation": $n1.n_name, 
+    "cust_nation": $n2.n_name, 
+    "s_nationkey": $n1.n_nationkey,      
+    "c_nationkey": $n2.n_nationkey
+  }
+}
+
+for $locs in (
+  for $loc in (
+    for $lo in (
+      for $l in dataset('LineItem')
+      for $o in dataset('Orders')
+      where $o.o_orderkey = $l.l_orderkey and $l.l_shipdate >= '1992-01-01' 
+        and $l.l_shipdate <= '1996-12-31'
+      return {
+        "l_shipdate": $l.l_shipdate, 
+        "l_extendedprice": $l.l_extendedprice, 
+        "l_discount": $l.l_discount, 
+        "l_suppkey": $l.l_suppkey, 
+        "o_custkey": $o.o_custkey 
+      }
+    )
+    for $c in dataset('Customer')
+    where $c.c_custkey = $lo.o_custkey
+    return {
+      "l_shipdate": $lo.l_shipdate, 
+      "l_extendedprice": $lo.l_extendedprice, 
+      "l_discount": $lo.l_discount, 
+      "l_suppkey": $lo.l_suppkey, 
+      "c_nationkey": $c.c_nationkey 
+    }
+  )
+  for $s in dataset('Supplier')
+  where $s.s_suppkey = $loc.l_suppkey
+  return {
+    "l_shipdate": $loc.l_shipdate, 
+    "l_extendedprice": $loc.l_extendedprice, 
+    "l_discount": $loc.l_discount, 
+    "c_nationkey": $loc.c_nationkey, 
+    "s_nationkey": $s.s_nationkey
+  }
+)
+for $t in q7_volume_shipping_tmp()
+where $locs.c_nationkey = $t.c_nationkey
+  and $locs.s_nationkey = $t.s_nationkey
+let $l_year0 := get-year($locs.l_shipdate)
+group by $supp_nation := $t.supp_nation, $cust_nation := $t.cust_nation, $l_year := $l_year0
+with $locs
+let $revenue := sum(for $i in $locs return $i.l_extendedprice * (1 - $i.l_discount))
+order by $supp_nation, $cust_nation, $l_year
+return {
+  "supp_nation": $supp_nation, 
+  "cust_nation": $cust_nation, 
+  "l_year": $l_year,
+  "revenue": $revenue
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.1.ddl.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.1.ddl.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.3.query.aql
new file mode 100644
index 0000000..3b28d11
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q08_national_market_share/q08_national_market_share.3.query.aql
@@ -0,0 +1,73 @@
+use dataverse tpch;
+
+for $t in (
+  for $slnrcop in (
+    for $s in dataset("Supplier")
+    for $lnrcop in (
+      for $lnrco in (
+        for $l in dataset('LineItem')
+        for $nrco in (
+          for $o in dataset('Orders')
+          for $nrc in (
+            for $c in dataset('Customer')
+            for $nr in (
+              for $n1 in dataset('Nation')
+              for $r1 in dataset('Region')
+              where $n1.n_regionkey = $r1.r_regionkey and $r1.r_name = 'AMERICA'
+              return { "n_nationkey": $n1.n_nationkey }
+            )
+            where $c.c_nationkey = $nr.n_nationkey
+            return { "c_custkey": $c.c_custkey }
+          )
+          where $nrc.c_custkey = $o.o_custkey
+          return {
+            "o_orderdate" : $o.o_orderdate, 
+            "o_orderkey": $o.o_orderkey 
+          }
+        )
+        where $l.l_orderkey = $nrco.o_orderkey
+          and $nrco.o_orderdate >= '1995-01-01' 
+          and $nrco.o_orderdate < '1996-12-31'
+        return {
+          "o_orderdate": $nrco.o_orderdate, 
+          "l_partkey": $l.l_partkey, 
+          "l_discount": $l.l_discount, 
+          "l_extendedprice": $l.l_extendedprice, 
+          "l_suppkey": $l.l_suppkey
+        }
+      )
+      for $p in dataset("Part")
+      where $p.p_partkey = $lnrco.l_partkey and $p.p_type = 'ECONOMY ANODIZED STEEL'
+      return {
+        "o_orderdate": $lnrco.o_orderdate, 
+        "l_discount": $lnrco.l_discount, 
+        "l_extendedprice": $lnrco.l_extendedprice, 
+        "l_suppkey": $lnrco.l_suppkey 
+      }
+    )
+    where $s.s_suppkey = $lnrcop.l_suppkey
+    return {
+      "o_orderdate": $lnrcop.o_orderdate, 
+      "l_discount": $lnrcop.l_discount, 
+      "l_extendedprice": $lnrcop.l_extendedprice, 
+      "l_suppkey": $lnrcop.l_suppkey, 
+      "s_nationkey": $s.s_nationkey
+    }
+  )
+  for $n2 in dataset('Nation')
+  where $slnrcop.s_nationkey = $n2.n_nationkey
+  let $o_year := get-year($slnrcop.o_orderdate)
+  return {
+    "year": $o_year,
+    "revenue": $slnrcop.l_extendedprice *(1-$slnrcop.l_discount),
+    "s_name": $n2.n_name
+  }
+)
+group by $year := $t.year with $t
+order by $year
+return {
+  "year": $year,
+  "mkt_share": sum(for $i in $t return switch-case($i.s_name='BRAZIL', true, $i.revenue, false, 0.0))/ 
+        sum(for $i in $t return $i.revenue)
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.aql
similarity index 100%
copy from asterix-app/src/test/resources/runtimets/queries/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.ddl.aql
copy to asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.aql
similarity index 100%
copy from asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.2.update.aql
copy to asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.aql
new file mode 100644
index 0000000..11191d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.aql
@@ -0,0 +1,67 @@
+use dataverse tpch;
+
+for $profit in (
+  for $o in dataset('Orders')
+  for $l3 in (
+    for $p in dataset('Part')
+    for $l2 in (
+      for $ps in dataset('Partsupp')
+      for $l1 in (
+        for $s1 in (
+          for $s in dataset('Supplier')
+          for $n in dataset('Nation')
+          where $n.n_nationkey = $s.s_nationkey
+          return {
+            "s_suppkey": $s.s_suppkey,
+            "n_name": $n.n_name
+          }
+        )
+        for $l in dataset('LineItem')
+        where $s1.s_suppkey = $l.l_suppkey       
+        return  {
+          "l_suppkey": $l.l_suppkey,
+          "l_extendedprice": $l.l_extendedprice,
+          "l_discount": $l.l_discount,
+          "l_quantity": $l.l_quantity,
+          "l_partkey": $l.l_partkey,
+          "l_orderkey": $l.l_orderkey,
+          "n_name": $s1.n_name
+        }
+      )
+      where $ps.ps_suppkey = $l1.l_suppkey and $ps.ps_partkey = $l1.l_partkey       
+      return {
+        "l_extendedprice": $l1.l_extendedprice,
+        "l_discount": $l1.l_discount,
+        "l_quantity": $l1.l_quantity,
+        "l_partkey": $l1.l_partkey,
+        "l_orderkey": $l1.l_orderkey,
+        "n_name": $l1.n_name,
+        "ps_supplycost": $ps.ps_supplycost
+      }
+    )
+    where contains($p.p_name, 'green') and $p.p_partkey = $l2.l_partkey    
+    return {
+      "l_extendedprice": $l2.l_extendedprice,
+      "l_discount": $l2.l_discount,
+      "l_quantity": $l2.l_quantity,
+      "l_orderkey": $l2.l_orderkey,
+      "n_name": $l2.n_name,
+      "ps_supplycost": $l2.ps_supplycost
+    }
+  )
+  where $o.o_orderkey = $l3.l_orderkey
+  let $amount := $l3.l_extendedprice * (1 - $l3.l_discount) -  $l3.ps_supplycost * $l3.l_quantity 
+  let $o_year := get-year($o.o_orderdate)
+  return {
+    "nation": $l3.n_name,
+    "o_year": $o_year,
+    "amount": $amount
+  }
+)
+group by $nation := $profit.nation, $o_year := $profit.o_year with $profit
+order by $nation, $o_year desc
+return {
+  "nation": $nation, 
+  "o_year": $o_year, 
+  "sum_profit": sum( for $pr in $profit return $pr.amount )
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item/q10_returned_item.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item/q10_returned_item.3.query.aql
index c867b31..19a2b44 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item/q10_returned_item.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item/q10_returned_item.3.query.aql
@@ -1,55 +1,55 @@
 use dataverse tpch;
 
 for $locn in (
-for $l in dataset('LineItem')
-for $ocn in (
-	for $o in dataset('Orders')
-	for $c in dataset('Customer')
-		where $c.c_custkey = $o.o_custkey and $o.o_orderdate >= '1993-10-01' and $o.o_orderdate < '1994-01-01'
-	for $n in dataset('Nation')
-		where $c.c_nationkey = $n.n_nationkey
-	return {
-		"c_custkey": $c.c_custkey, 
-		"c_name": $c.c_name,
-  		"c_acctbal": $c.c_acctbal, 
-  		"n_name": $n.n_name, 
-  		"c_address": $c.c_address, 
-  		"c_phone": $c.c_phone, 
-  		"c_comment": $c.c_comment,
-  		"o_orderkey": $o.o_orderkey
-	}
-)
-where
-   $l.l_orderkey = $ocn.o_orderkey and $l.l_returnflag = 'R'
-   return {
-		"c_custkey": $ocn.c_custkey, 
-		"c_name": $ocn.c_name,
-  		"c_acctbal": $ocn.c_acctbal, 
-  		"n_name": $ocn.n_name, 
-  		"c_address": $ocn.c_address, 
-  		"c_phone": $ocn.c_phone, 
-  		"c_comment": $ocn.c_comment,
-  		"l_extendedprice": $l.l_extendedprice,
-  		"l_discount": $l.l_discount
-	}	
+  for $l in dataset('LineItem')
+  for $ocn in (
+    for $o in dataset('Orders')
+    for $c in dataset('Customer')
+    where $c.c_custkey = $o.o_custkey and $o.o_orderdate >= '1993-10-01'
+      and $o.o_orderdate < '1994-01-01'
+    for $n in dataset('Nation')
+    where $c.c_nationkey = $n.n_nationkey
+    return {
+      "c_custkey": $c.c_custkey, 
+      "c_name": $c.c_name,
+      "c_acctbal": $c.c_acctbal, 
+      "n_name": $n.n_name, 
+      "c_address": $c.c_address, 
+      "c_phone": $c.c_phone, 
+      "c_comment": $c.c_comment,
+      "o_orderkey": $o.o_orderkey
+    }
+  )
+  where $l.l_orderkey = $ocn.o_orderkey and $l.l_returnflag = 'R'
+  return {
+    "c_custkey": $ocn.c_custkey, 
+    "c_name": $ocn.c_name,
+    "c_acctbal": $ocn.c_acctbal, 
+    "n_name": $ocn.n_name, 
+    "c_address": $ocn.c_address, 
+    "c_phone": $ocn.c_phone, 
+    "c_comment": $ocn.c_comment,
+    "l_extendedprice": $l.l_extendedprice,
+    "l_discount": $l.l_discount
+  }
 )
 group by $c_custkey:=$locn.c_custkey, 
-		$c_name:=$locn.c_name, 
-		$c_acctbal:=$locn.c_acctbal, $c_phone:=$locn.c_phone, 
-		$n_name:=$locn.n_name, $c_address:=$locn.c_address, $c_comment:=$locn.c_comment
-		with $locn
+    $c_name:=$locn.c_name, 
+    $c_acctbal:=$locn.c_acctbal, $c_phone:=$locn.c_phone, 
+    $n_name:=$locn.n_name, $c_address:=$locn.c_address, $c_comment:=$locn.c_comment
+    with $locn
 let $revenue := sum(for $i in $locn return $i.l_extendedprice * (1 - $i.l_discount))
 order by $revenue desc
 limit 20
 return {
-		"c_custkey": $c_custkey, 
-		"c_name": $c_name,
-		"revenue": $revenue,
-  		"c_acctbal": $c_acctbal, 
-  		"n_name": $n_name, 
-  		"c_address": $c_address, 
-  		"c_phone": $c_phone, 
-  		"c_comment": $c_comment
+  "c_custkey": $c_custkey, 
+  "c_name": $c_name,
+  "revenue": $revenue,
+  "c_acctbal": $c_acctbal, 
+  "n_name": $n_name, 
+  "c_address": $c_address, 
+  "c_phone": $c_phone, 
+  "c_comment": $c_comment
 }
-		
-		
+    
+    
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.aql
index c867b31..19a2b44 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.aql
@@ -1,55 +1,55 @@
 use dataverse tpch;
 
 for $locn in (
-for $l in dataset('LineItem')
-for $ocn in (
-	for $o in dataset('Orders')
-	for $c in dataset('Customer')
-		where $c.c_custkey = $o.o_custkey and $o.o_orderdate >= '1993-10-01' and $o.o_orderdate < '1994-01-01'
-	for $n in dataset('Nation')
-		where $c.c_nationkey = $n.n_nationkey
-	return {
-		"c_custkey": $c.c_custkey, 
-		"c_name": $c.c_name,
-  		"c_acctbal": $c.c_acctbal, 
-  		"n_name": $n.n_name, 
-  		"c_address": $c.c_address, 
-  		"c_phone": $c.c_phone, 
-  		"c_comment": $c.c_comment,
-  		"o_orderkey": $o.o_orderkey
-	}
-)
-where
-   $l.l_orderkey = $ocn.o_orderkey and $l.l_returnflag = 'R'
-   return {
-		"c_custkey": $ocn.c_custkey, 
-		"c_name": $ocn.c_name,
-  		"c_acctbal": $ocn.c_acctbal, 
-  		"n_name": $ocn.n_name, 
-  		"c_address": $ocn.c_address, 
-  		"c_phone": $ocn.c_phone, 
-  		"c_comment": $ocn.c_comment,
-  		"l_extendedprice": $l.l_extendedprice,
-  		"l_discount": $l.l_discount
-	}	
+  for $l in dataset('LineItem')
+  for $ocn in (
+    for $o in dataset('Orders')
+    for $c in dataset('Customer')
+    where $c.c_custkey = $o.o_custkey and $o.o_orderdate >= '1993-10-01'
+      and $o.o_orderdate < '1994-01-01'
+    for $n in dataset('Nation')
+    where $c.c_nationkey = $n.n_nationkey
+    return {
+      "c_custkey": $c.c_custkey, 
+      "c_name": $c.c_name,
+      "c_acctbal": $c.c_acctbal, 
+      "n_name": $n.n_name, 
+      "c_address": $c.c_address, 
+      "c_phone": $c.c_phone, 
+      "c_comment": $c.c_comment,
+      "o_orderkey": $o.o_orderkey
+    }
+  )
+  where $l.l_orderkey = $ocn.o_orderkey and $l.l_returnflag = 'R'
+  return {
+    "c_custkey": $ocn.c_custkey, 
+    "c_name": $ocn.c_name,
+    "c_acctbal": $ocn.c_acctbal, 
+    "n_name": $ocn.n_name, 
+    "c_address": $ocn.c_address, 
+    "c_phone": $ocn.c_phone, 
+    "c_comment": $ocn.c_comment,
+    "l_extendedprice": $l.l_extendedprice,
+    "l_discount": $l.l_discount
+  }
 )
 group by $c_custkey:=$locn.c_custkey, 
-		$c_name:=$locn.c_name, 
-		$c_acctbal:=$locn.c_acctbal, $c_phone:=$locn.c_phone, 
-		$n_name:=$locn.n_name, $c_address:=$locn.c_address, $c_comment:=$locn.c_comment
-		with $locn
+    $c_name:=$locn.c_name, 
+    $c_acctbal:=$locn.c_acctbal, $c_phone:=$locn.c_phone, 
+    $n_name:=$locn.n_name, $c_address:=$locn.c_address, $c_comment:=$locn.c_comment
+    with $locn
 let $revenue := sum(for $i in $locn return $i.l_extendedprice * (1 - $i.l_discount))
 order by $revenue desc
 limit 20
 return {
-		"c_custkey": $c_custkey, 
-		"c_name": $c_name,
-		"revenue": $revenue,
-  		"c_acctbal": $c_acctbal, 
-  		"n_name": $n_name, 
-  		"c_address": $c_address, 
-  		"c_phone": $c_phone, 
-  		"c_comment": $c_comment
+  "c_custkey": $c_custkey, 
+  "c_name": $c_name,
+  "revenue": $revenue,
+  "c_acctbal": $c_acctbal, 
+  "n_name": $n_name, 
+  "c_address": $c_address, 
+  "c_phone": $c_phone, 
+  "c_comment": $c_comment
 }
-		
-		
+    
+    
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock/q11_important_stock.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock/q11_important_stock.3.query.aql
index 42a86d1..fdb01ca 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock/q11_important_stock.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q11_important_stock/q11_important_stock.3.query.aql
@@ -1,31 +1,34 @@
 use dataverse tpch;
 
 let $sum := sum (
-for $ps in dataset('Partsupp')
-for $sn in (
-	for $s in dataset('Supplier')
-	for $n in dataset('Nation')
-		where $s.s_nationkey = $n.n_nationkey
-	return {"s_suppkey": $s.s_suppkey}
-	)
-where $ps.ps_suppkey = $sn.s_suppkey
-return $ps.ps_supplycost * $ps.ps_availqty)
-
-for $t1 in 
-(
-for $ps in dataset('Partsupp')
-for $sn in (
-	for $s in dataset('Supplier')
-	for $n in dataset('Nation')
-		where $s.s_nationkey = $n.n_nationkey
-	return {"s_suppkey": $s.s_suppkey}
+  for $ps in dataset('Partsupp')
+  for $sn in (
+    for $s in dataset('Supplier')
+    for $n in dataset('Nation')
+    where $s.s_nationkey = $n.n_nationkey
+    return { "s_suppkey": $s.s_suppkey }
+  )
+  where $ps.ps_suppkey = $sn.s_suppkey
+  return $ps.ps_supplycost * $ps.ps_availqty
 )
-where $ps.ps_suppkey = $sn.s_suppkey
-group by $ps_partkey := $ps.ps_partkey with $ps
-return {"ps_partkey": $ps_partkey, 
-"part_value": sum(for $i in $ps return $i.ps_supplycost * $i.ps_availqty)}
+for $t1 in (
+  for $ps in dataset('Partsupp')
+  for $sn in (
+    for $s in dataset('Supplier')
+    for $n in dataset('Nation')
+    where $s.s_nationkey = $n.n_nationkey
+    return { "s_suppkey": $s.s_suppkey }
+  )
+  where $ps.ps_suppkey = $sn.s_suppkey
+  group by $ps_partkey := $ps.ps_partkey with $ps
+  return {
+    "ps_partkey": $ps_partkey, 
+    "part_value": sum(for $i in $ps return $i.ps_supplycost * $i.ps_availqty)
+  }
 )
-
 where $t1.part_value > $sum * 0.00001
 order by $t1.part_value desc
-return {"partkey": $t1.ps_partkey, "part_value":$t1.part_value}
+return {
+  "partkey": $t1.ps_partkey,
+  "part_value": $t1.part_value
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping/q12_shipping.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping/q12_shipping.3.query.aql
index b6d4ab0..c836a48 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping/q12_shipping.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q12_shipping/q12_shipping.3.query.aql
@@ -2,27 +2,26 @@
 
 for $l in dataset('LineItem')
 for $o in dataset('Orders')
-
-where
-$o.o_orderkey = $l.l_orderkey 
-and $l.l_commitdate < $l.l_receiptdate
-and $l.l_shipdate < $l.l_commitdate 
-and $l.l_receiptdate >= '1994-01-01' 
-and $l.l_receiptdate < '1995-01-01'
-and ($l.l_shipmode = 'MAIL' or $l.l_shipmode = 'SHIP')
-
+where $o.o_orderkey = $l.l_orderkey 
+  and $l.l_commitdate < $l.l_receiptdate
+  and $l.l_shipdate < $l.l_commitdate 
+  and $l.l_receiptdate >= '1994-01-01' 
+  and $l.l_receiptdate < '1995-01-01'
+  and ($l.l_shipmode = 'MAIL' or $l.l_shipmode = 'SHIP')
 group by $l_shipmode := $l.l_shipmode with $o
 order by $l_shipmode
 return {
-"l_shipmode": $l_shipmode,
-"high_line_count": sum(for $i in $o 
-        return switch-case( $i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
-		true, 1,
-        false, 0)),
-"low_line_count": sum(for $i in $o 
-		return switch-case( $i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
-		true, 0,
-        false, 1))
+  "l_shipmode": $l_shipmode,
+  "high_line_count": sum(
+    for $i in $o 
+    return
+      switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
+                  true, 1, false, 0)
+  ),
+  "low_line_count": sum(
+    for $i in $o 
+    return switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
+                       true, 0, false, 1)
+  )
 }
 
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution/q13_customer_distribution.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution/q13_customer_distribution.3.query.aql
index dd65443..a7b7b62 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution/q13_customer_distribution.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q13_customer_distribution/q13_customer_distribution.3.query.aql
@@ -2,26 +2,28 @@
 set import-private-functions 'true';
 
 for $gco in (
-	for $co in
-		(
-			for $c in dataset('Customer')
-			return 
-			{
-				"c_custkey": $c.c_custkey, 
-				 "o_orderkey_count": count(
-						for $o in dataset('Orders')
-   							where  $c.c_custkey = $o.o_custkey and not(like($o.o_comment,'%special%requests%'))
-						return $o.o_orderkey)
-			}
-		)
-	group by $c_custkey := $co.c_custkey with $co
-		return{
-			"c_custkey": $c_custkey, "c_count": sum(for $i in $co return $i.o_orderkey_count)
-		}
+  for $co in (
+    for $c in dataset('Customer')
+    return {
+      "c_custkey": $c.c_custkey, 
+      "o_orderkey_count": count(
+        for $o in dataset('Orders')
+        where  $c.c_custkey = $o.o_custkey and not(like($o.o_comment,'%special%requests%'))
+        return $o.o_orderkey
+      )
+    }
+  )
+  group by $c_custkey := $co.c_custkey with $co
+  return {
+    "c_custkey": $c_custkey,
+    "c_count": sum(for $i in $co return $i.o_orderkey_count)
+  }
 )
-
 group by $c_count := $gco.c_count with $gco
 let $custdist := count($gco)
 order by $custdist desc, $c_count desc
-return {"c_count": $c_count, "custdist": $custdist}
+return {
+  "c_count": $c_count,
+  "custdist": $custdist
+}
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect/q14_promotion_effect.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect/q14_promotion_effect.3.query.aql
index 040e4ec..786637d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect/q14_promotion_effect.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q14_promotion_effect/q14_promotion_effect.3.query.aql
@@ -2,10 +2,14 @@
 
 for $l in dataset('LineItem')
 for $p in dataset('Part')
-	where $l.l_partkey = $p.p_partkey and $l.l_shipdate >= '1995-09-01' and $l.l_shipdate < '1995-10-01'
+where $l.l_partkey = $p.p_partkey
+  and $l.l_shipdate >= '1995-09-01'
+  and $l.l_shipdate < '1995-10-01'
 group by $t:=1 with $l, $p
-return 100.00 * sum( for $i in $l
-			   return switch-case(like($i.p_type, 'PROMO%'),
-               true, $i.l_extendedprice*(1-$i.l_discount),
-               false, 0.0)
-  ) / sum( for $i in $l return $i.l_extendedprice * (1 - $i.l_discount))
+return 100.00 * sum(
+  for $i in $l
+  return switch-case(like($i.p_type, 'PROMO%'),
+                     true, $i.l_extendedprice*(1-$i.l_discount),
+                     false, 0.0)
+  ) / sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount)
+)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier/q15_top_supplier.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier/q15_top_supplier.3.query.aql
index 9f1080d..45b0fad 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier/q15_top_supplier.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q15_top_supplier/q15_top_supplier.3.query.aql
@@ -1,27 +1,27 @@
 use dataverse tpch;
 
-declare function revenue(){
-for $l in dataset('LineItem')
-where $l.l_shipdate >= '1996-01-01' and $l.l_shipdate < '1996-04-01'
-group by $l_suppkey := $l.l_suppkey with $l
-return {
-"supplier_no": $l_suppkey, 
-"total_revenue": sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount))
-}
+declare function revenue() {
+  for $l in dataset('LineItem')
+  where $l.l_shipdate >= '1996-01-01' and $l.l_shipdate < '1996-04-01'
+  group by $l_suppkey := $l.l_suppkey with $l
+  return {
+    "supplier_no": $l_suppkey, 
+    "total_revenue": sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount))
+  }
 }
 
 let $m := max(
-	for $r2 in revenue()
-	return $r2.total_revenue
+  for $r2 in revenue()
+  return $r2.total_revenue
 )
 
 for $s in dataset('Supplier')
 for $r in revenue()
-	where $s.s_suppkey = $r.supplier_no and $r.total_revenue<$m+0.000000001 and $r.total_revenue>$m-0.000000001
+where $s.s_suppkey = $r.supplier_no and $r.total_revenue<$m+0.000000001 and $r.total_revenue>$m-0.000000001
 return {
-"s_suppkey": $s.s_suppkey, 
-"s_name": $s.s_name, 
-"s_address": $s.s_address, 
-"s_phone": $s.s_phone, 
-"total_revenue": $r.total_revenue
+  "s_suppkey": $s.s_suppkey, 
+  "s_name": $s.s_name, 
+  "s_address": $s.s_address, 
+  "s_phone": $s.s_phone, 
+  "total_revenue": $r.total_revenue
 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.aql
index e5c928e..014ceff 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.aql
@@ -1,54 +1,48 @@
 use dataverse tpch;
 
 declare function tmp(){
-for $psp in (
-	for $ps in dataset('Partsupp')
-	for $p in dataset('Part')
-		where $p.p_partkey = $ps.ps_partkey and $p.p_brand != 'Brand#45' 
-    	and not(like($p.p_type, 'MEDIUM POLISHED%'))
-	return 
-	{
- 	"p_brand": $p.p_brand, 
- 	"p_type": $p.p_type, 
- 	"p_size": $p.p_size,
- 	"ps_suppkey": $ps.ps_suppkey
-	}
-)
-for $s in dataset('Supplier')
-	where $psp.ps_suppkey = $s.s_suppkey and not(like($s.s_comment, '%Customer%Complaints%'))
-return 
-{
- "p_brand": $psp.p_brand, 
- "p_type": $psp.p_type, 
- "p_size": $psp.p_size, 
- "ps_suppkey": $psp.ps_suppkey
-}
+  for $psp in (
+    for $ps in dataset('Partsupp')
+    for $p in dataset('Part')
+    where $p.p_partkey = $ps.ps_partkey and $p.p_brand != 'Brand#45' 
+      and not(like($p.p_type, 'MEDIUM POLISHED%'))
+    return {
+      "p_brand": $p.p_brand, 
+      "p_type": $p.p_type, 
+      "p_size": $p.p_size,
+      "ps_suppkey": $ps.ps_suppkey
+    }
+  )
+  for $s in dataset('Supplier')
+  where $psp.ps_suppkey = $s.s_suppkey and not(like($s.s_comment, '%Customer%Complaints%'))
+  return {
+   "p_brand": $psp.p_brand, 
+   "p_type": $psp.p_type, 
+   "p_size": $psp.p_size, 
+   "ps_suppkey": $psp.ps_suppkey
+  }
 }
 
-for $t2 in 
-(
-for $t in tmp()   
-	where $t.p_size = 49 or $t.p_size = 14 or $t.p_size = 23 or
-         $t.p_size = 45 or $t.p_size = 19 or $t.p_size = 3 or
-         $t.p_size = 36 or $t.p_size = 9
-group by $p_brand1:= $t.p_brand, $p_type1 := $t.p_type, 
-	  $p_size1:= $t.p_size, $ps_suppkey1:=$t.ps_suppkey with $t
-return 
-{
-"p_brand": $p_brand1, 
- "p_type": $p_type1, 
- "p_size": $p_size1, 
- "ps_suppkey": $ps_suppkey1
-} )
+for $t2 in (
+  for $t in tmp()   
+  where $t.p_size = 49 or $t.p_size = 14 or $t.p_size = 23
+    or $t.p_size = 45 or $t.p_size = 19 or $t.p_size = 3
+    or $t.p_size = 36 or $t.p_size = 9
+  group by $p_brand1:= $t.p_brand, $p_type1 := $t.p_type, 
+    $p_size1:= $t.p_size, $ps_suppkey1:=$t.ps_suppkey with $t
+  return {
+    "p_brand": $p_brand1, 
+    "p_type": $p_type1, 
+    "p_size": $p_size1, 
+    "ps_suppkey": $ps_suppkey1
+  }
+)
 group by $p_brand := $t2.p_brand, $p_type := $t2.p_type, $p_size := $t2.p_size with $t2
 let $supplier_cnt := count(for $i in $t2 return $i.ps_suppkey)
 order by $supplier_cnt desc, $p_brand, $p_type, $p_size
 return {
-"p_brand": $p_brand, 
-"p_type": $p_type, 
-"p_size": $p_size,
-"supplier_cnt": $supplier_cnt
+  "p_brand": $p_brand, 
+  "p_type": $p_type, 
+  "p_size": $p_size,
+  "supplier_cnt": $supplier_cnt
 }
-
-
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.aql
index 67644d9..99f32c6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.aql
@@ -1,21 +1,21 @@
 use dataverse tpch;
 
 declare function tmp(){
-for $l in dataset('LineItem')
-group by $l_partkey := $l.l_partkey with $l
-return {
-"t_partkey": $l_partkey, 
-"t_avg_quantity": 0.2 * avg(for $i in $l return $i.l_quantity)
-}
+  for $l in dataset('LineItem')
+  group by $l_partkey := $l.l_partkey with $l
+  return {
+    "t_partkey": $l_partkey, 
+    "t_avg_quantity": 0.2 * avg(for $i in $l return $i.l_quantity)
+  }
 }
 
 sum(
-for $l in dataset('LineItem')
-for $p in dataset('Part')
-where  $p.p_partkey = $l.l_partkey and $p.p_container = 'MED BOX'
-
-for $t in tmp()
-where $l.l_partkey = $t.t_partkey and $l.l_quantity < $t.t_avg_quantity
-return $l.l_extendedprice
+  for $l in dataset('LineItem')
+  for $p in dataset('Part')
+  where  $p.p_partkey = $l.l_partkey and $p.p_container = 'MED BOX'
+  for $t in tmp()
+  where $l.l_partkey = $t.t_partkey
+    and $l.l_quantity < $t.t_avg_quantity
+  return $l.l_extendedprice
 )/7.0
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.aql
index df6d9f0..289d900 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.aql
@@ -2,21 +2,18 @@
 
 for $c in dataset('Customer')
 for $o in dataset('Orders')
-where
-  $c.c_custkey = $o.o_custkey
-for $t in 
-(
+where $c.c_custkey = $o.o_custkey
+for $t in (
   for $l in dataset('LineItem')
   group by $l_orderkey := $l.l_orderkey with $l
-  return 
-    { "l_orderkey": $l_orderkey, 
-      "t_sum_quantity": sum(for $i in $l return $i.l_quantity) }
+  return {
+    "l_orderkey": $l_orderkey, 
+    "t_sum_quantity": sum(for $i in $l return $i.l_quantity)
+  }
 ) 
-where 
-  $o.o_orderkey = $t.l_orderkey and $t.t_sum_quantity > 30
+where $o.o_orderkey = $t.l_orderkey and $t.t_sum_quantity > 30
 for $l in dataset('LineItem')
-where
-  $l.l_orderkey = $o.o_orderkey 
+where $l.l_orderkey = $o.o_orderkey 
 group by $c_name := $c.c_name, $c_custkey := $c.c_custkey, $o_orderkey := $o.o_orderkey, 
          $o_orderdate := $o.o_orderdate, $o_totalprice := $o.o_totalprice with $l
 order by $o_totalprice desc, $o_orderdate 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.aql
index ec10939..7e26d94 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.aql
@@ -1,37 +1,33 @@
 use dataverse tpch;
+
 set import-private-functions 'true';
 
 sum( 
-for $l in dataset('LineItem')
-for $p in dataset('Part')
-where $p.p_partkey = $l.l_partkey
-and (
- (
-    $p.p_brand = 'Brand#12'
-	and reg-exp($p.p_container,'SM CASE||SM BOX||SM PACK||SM PKG')
-	and $l.l_quantity >= 1 and $l.l_quantity <= 11
-	and $p.p_size >= 1 and $p.p_size <= 5
-	and reg-exp($l.l_shipmode, 'AIR||AIR REG')
-	and $l.l_shipinstruct = 'DELIVER IN PERSON'
-  ) 
-  or 
-  (
-    $p.p_brand = 'Brand#23'
-	and reg-exp($p.p_container, 'MED BAG||MED BOX||MED PKG||MED PACK')
-	and $l.l_quantity >= 10 and $l.l_quantity <= 20
-	and $p.p_size >= 1 and $p.p_size <= 10
-	and reg-exp($l.l_shipmode, 'AIR||AIR REG')
-	and $l.l_shipinstruct = 'DELIVER IN PERSON'
-  )
-  or
-  (
-	$p.p_brand = 'Brand#34'
-	and reg-exp($p.p_container, 'LG CASE||LG BOX||LG PACK||LG PKG')
-	and $l.l_quantity >= 20 and $l.l_quantity <= 30
-	and $p.p_size >= 1 and $p.p_size <= 15
-	and reg-exp($l.l_shipmode, 'AIR||AIR REG')
-	and $l.l_shipinstruct = 'DELIVER IN PERSON'
-  )
- )
-return $l.l_extendedprice * (1 - $l.l_discount)
+  for $l in dataset('LineItem')
+  for $p in dataset('Part')
+  where $p.p_partkey = $l.l_partkey
+    and ( (
+        $p.p_brand = 'Brand#12'
+        and reg-exp($p.p_container,'SM CASE||SM BOX||SM PACK||SM PKG')
+        and $l.l_quantity >= 1 and $l.l_quantity <= 11
+        and $p.p_size >= 1 and $p.p_size <= 5
+        and reg-exp($l.l_shipmode, 'AIR||AIR REG')
+        and $l.l_shipinstruct = 'DELIVER IN PERSON'
+      ) or (
+        $p.p_brand = 'Brand#23'
+        and reg-exp($p.p_container, 'MED BAG||MED BOX||MED PKG||MED PACK')
+        and $l.l_quantity >= 10 and $l.l_quantity <= 20
+        and $p.p_size >= 1 and $p.p_size <= 10
+        and reg-exp($l.l_shipmode, 'AIR||AIR REG')
+        and $l.l_shipinstruct = 'DELIVER IN PERSON'
+      ) or (
+        $p.p_brand = 'Brand#34'
+        and reg-exp($p.p_container, 'LG CASE||LG BOX||LG PACK||LG PKG')
+        and $l.l_quantity >= 20 and $l.l_quantity <= 30
+        and $p.p_size >= 1 and $p.p_size <= 15
+        and reg-exp($l.l_shipmode, 'AIR||AIR REG')
+        and $l.l_shipinstruct = 'DELIVER IN PERSON'
+      )
+    )
+  return $l.l_extendedprice * (1 - $l.l_discount)
 )
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.aql
index a5a5bbe..b023966 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.aql
@@ -1,39 +1,48 @@
 use dataverse tpch;
 
 for $t3 in (
-for $t2 in (
-	for $l in dataset('LineItem')
-		group by $l_partkey:=$l.l_partkey, $l_suppkey:=$l.l_suppkey with $l
-	return {
-	"l_partkey": $l_partkey, 
-	"l_suppkey": $l_suppkey, 
-	"sum_quantity": 0.5 * sum(for $i in $l return $i.l_quantity)
-})
-for $pst1 in (
-	for $ps in dataset('Partsupp')
-	for $t1 in 
-	(
-		for $p in dataset('Part')
-			distinct by $p.p_partkey
-		return {"p_partkey": $p.p_partkey}
-	)
-	where $ps.ps_partkey = $t1.p_partkey
-	return {"ps_suppkey": $ps.ps_suppkey, "ps_partkey": $ps.ps_partkey, "ps_availqty": $ps.ps_availqty}
+  for $t2 in (
+    for $l in dataset('LineItem')
+    group by $l_partkey:=$l.l_partkey, $l_suppkey:=$l.l_suppkey with $l
+    return {
+      "l_partkey": $l_partkey, 
+      "l_suppkey": $l_suppkey, 
+      "sum_quantity": 0.5 * sum(for $i in $l return $i.l_quantity)
+    }
+  )
+  for $pst1 in (
+    for $ps in dataset('Partsupp')
+    for $t1 in (
+      for $p in dataset('Part')
+      distinct by $p.p_partkey
+      return { "p_partkey": $p.p_partkey }
+    )
+    where $ps.ps_partkey = $t1.p_partkey
+    return {
+      "ps_suppkey": $ps.ps_suppkey,
+      "ps_partkey": $ps.ps_partkey,
+      "ps_availqty": $ps.ps_availqty
+    }
+  )
+  where $pst1.ps_partkey = $t2.l_partkey and $pst1.ps_suppkey = $t2.l_suppkey
+    and $pst1.ps_availqty > $t2.sum_quantity
+  distinct by $pst1.ps_suppkey
+  return { "ps_suppkey": $pst1.ps_suppkey }
 )
-where $pst1.ps_partkey = $t2.l_partkey and $pst1.ps_suppkey = $t2.l_suppkey
-		and $pst1.ps_availqty > $t2.sum_quantity
-distinct by $pst1.ps_suppkey
-return {"ps_suppkey": $pst1.ps_suppkey}
-)
-
 for $t4 in (
-	for $n in dataset('Nation')
-	for $s in dataset('Supplier')
-		where  $s.s_nationkey = $n.n_nationkey
-	return {"s_name": $s.s_name, "s_address": $s.s_address, "s_suppkey": $s.s_suppkey}
+  for $n in dataset('Nation')
+  for $s in dataset('Supplier')
+  where  $s.s_nationkey = $n.n_nationkey
+  return {
+    "s_name": $s.s_name,
+    "s_address": $s.s_address,
+    "s_suppkey": $s.s_suppkey
+  }
 )
-
 where $t3.ps_suppkey = $t4.s_suppkey
 order by $t4.s_name
-return {"s_name": $t4.s_name, "s_address": $t4.s_address}
+return {
+  "s_name": $t4.s_name,
+  "s_address": $t4.s_address
+}
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.aql
index eb94678..e99dea2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.aql
@@ -1,78 +1,76 @@
 use dataverse tpch;
 
-declare function tmp1()
-{
-for $l2 in 
-(
-	for $l in dataset('LineItem')
-	group by $l_orderkey1 := $l.l_orderkey, $l_suppkey1 := $l.l_suppkey with $l
-	return {
-		"l_orderkey": $l_orderkey1,
-		"l_suppkey": $l_suppkey1
-		} 
-)
-group by $l_orderkey := $l2.l_orderkey with $l2
-return {
-	"l_orderkey": $l_orderkey, 
-	"count_suppkey": count(for $i in $l2 return $i.l_suppkey), 
-	"max_suppkey": max(for $i in $l2 return $i.l_suppkey)
-}
+declare function tmp1() {
+  for $l2 in (
+    for $l in dataset('LineItem')
+    group by $l_orderkey1 := $l.l_orderkey, $l_suppkey1 := $l.l_suppkey with $l
+    return {
+      "l_orderkey": $l_orderkey1,
+      "l_suppkey": $l_suppkey1
+    } 
+  )
+  group by $l_orderkey := $l2.l_orderkey with $l2
+  return {
+    "l_orderkey": $l_orderkey, 
+    "count_suppkey": count(for $i in $l2 return $i.l_suppkey), 
+    "max_suppkey": max(for $i in $l2 return $i.l_suppkey)
+  }
 }
 
-declare function tmp2()
-{
-for $l2 in 
-(
-	for $l in dataset('LineItem')
-	where $l.l_receiptdate > $l.l_commitdate
-	group by $l_orderkey1 := $l.l_orderkey, $l_suppkey1 := $l.l_suppkey with $l
-	return {
-		"l_orderkey": $l_orderkey1,
-		"l_suppkey": $l_suppkey1
-		} 
-)
-group by $l_orderkey := $l2.l_orderkey with $l2
-return {
-"l_orderkey": $l_orderkey, 
-"count_suppkey": count(for $i in $l2 return $i.l_suppkey), 
-"max_suppkey": max(for $i in $l2 return $i.l_suppkey)
-}
+declare function tmp2() {
+  for $l2 in (
+    for $l in dataset('LineItem')
+    where $l.l_receiptdate > $l.l_commitdate
+    group by $l_orderkey1 := $l.l_orderkey, $l_suppkey1 := $l.l_suppkey with $l
+    return {
+      "l_orderkey": $l_orderkey1,
+      "l_suppkey": $l_suppkey1
+    } 
+  )
+  group by $l_orderkey := $l2.l_orderkey with $l2
+  return {
+    "l_orderkey": $l_orderkey, 
+    "count_suppkey": count(for $i in $l2 return $i.l_suppkey), 
+    "max_suppkey": max(for $i in $l2 return $i.l_suppkey)
+  }
 }
 
 for $t4 in (
-for $t3 in (
-	for $l in dataset('LineItem')
-	for $ns in (
-		for $n in dataset('Nation')
-		for $s in dataset('Supplier')
-			where $s.s_nationkey = $n.n_nationkey
-		return {"s_name": $s.s_name, "s_suppkey": $s.s_suppkey}
-	)
-	where $ns.s_suppkey = $l.l_suppkey and $l.l_receiptdate > $l.l_commitdate
-
-	for $o in dataset('Orders')
-	where $o.o_orderkey = $l.l_orderkey
-
-	for $t1 in tmp1()
-	where $l.l_orderkey = $t1.l_orderkey
-	
-	return {"s_name": $ns.s_name, "l_orderkey": $t1.l_orderkey, "l_suppkey": $l.l_suppkey}
+  for $t3 in (
+    for $l in dataset('LineItem')
+    for $ns in (
+      for $n in dataset('Nation')
+      for $s in dataset('Supplier')
+      where $s.s_nationkey = $n.n_nationkey
+      return {
+        "s_name": $s.s_name,
+        "s_suppkey": $s.s_suppkey
+      }
+    )
+    where $ns.s_suppkey = $l.l_suppkey and $l.l_receiptdate > $l.l_commitdate
+    for $o in dataset('Orders')
+    where $o.o_orderkey = $l.l_orderkey
+    for $t1 in tmp1()
+    where $l.l_orderkey = $t1.l_orderkey
+    return {
+      "s_name": $ns.s_name,
+      "l_orderkey": $t1.l_orderkey,
+      "l_suppkey": $l.l_suppkey}
+  )
+  for $t2 in tmp2() 
+  where $t2.count_suppkey >= 0 and $t3.l_orderkey = $t2.l_orderkey
+  return {
+    "s_name": $t3.s_name,
+    "l_suppkey": $t3.l_suppkey,
+    "l_orderkey": $t2.l_orderkey,
+    "count_suppkey": $t2.count_suppkey, 
+    "max_suppkey": $t2.max_suppkey
+  }
 )
-
-for $t2 in tmp2() 
-			where $t2.count_suppkey >= 0 and $t3.l_orderkey = $t2.l_orderkey
-			
-return {
-"s_name": $t3.s_name,
-"l_suppkey": $t3.l_suppkey,
-"l_orderkey": $t2.l_orderkey,
-"count_suppkey": $t2.count_suppkey, 
-"max_suppkey": $t2.max_suppkey
-} )
 group by $s_name := $t4.s_name with $t4
 let $numwait := count($t4)
 order by $numwait desc, $s_name
 return {
-"s_name": $s_name,
-"numwait": $numwait
+  "s_name": $s_name,
+  "numwait": $numwait
 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.aql
index a07e4ad..8913818 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.aql
@@ -1,30 +1,25 @@
 use dataverse tpch;
 
-declare function q22_customer_tmp(){
-for $c in dataset('Customer')
-return {
-"c_acctbal": $c.c_acctbal,
-"c_custkey": $c.c_custkey,
-"cntrycode": substring($c.c_phone, 1, 2)
-}
+declare function q22_customer_tmp() {
+  for $c in dataset('Customer')
+  return {
+    "c_acctbal": $c.c_acctbal,
+    "c_custkey": $c.c_custkey,
+    "cntrycode": substring($c.c_phone, 1, 2)
+  }
 }
 
-
-let $avg := avg( for $c in dataset('Customer')
-					where $c.c_acctbal > 0.00
-				 return $c.c_acctbal
-				)
+let $avg := avg(
+  for $c in dataset('Customer')
+  where $c.c_acctbal > 0.00
+  return $c.c_acctbal
+)
 for $ct in q22_customer_tmp()
 where $ct.c_acctbal > $avg
-
 group by $cntrycode := $ct.cntrycode with $ct
 order by $cntrycode
-
 return {
-"cntrycode": $cntrycode, 
-"numcust": count($ct), 
-"totacctbal": sum(for $i in $ct return $i.c_acctbal)
+  "cntrycode": $cntrycode, 
+  "numcust": count($ct), 
+  "totacctbal": sum(for $i in $ct return $i.c_acctbal)
 }
-
-
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.3.query.aql
deleted file mode 100644
index c13dbb9..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.3.query.aql
+++ /dev/null
@@ -1,103 +0,0 @@
-use dataverse tpch;
-
-declare function tmp1(){
-for $p in dataset('Part')
-for $pssrn in 
-(
-	for $ps in dataset('Partsupp')
-	for $srn in 
-		(
-		for $s in dataset('Supplier')
-		 for $rn in
-			(
-			for $r in dataset('Region')
-			for $n in dataset('Nation')
-			where $n.n_regionkey = $r.r_regionkey and $r.r_name = 'EUROPE' 
-			return {"n_nationkey": $n.n_nationkey, "n_name": $n.n_name}
-			)
-		 where $s.s_nationkey = $rn.n_nationkey
-		 return {"s_suppkey": $s.s_suppkey, "n_name": $rn.n_name,
-		 		"s_name": $s.s_name,
-		 		"s_acctbal": $s.s_acctbal,
-		 		"s_address": $s.s_address, 
-				"s_phone": $s.s_phone, 
-				"s_comment": $s.s_comment}
-		)
-	where $srn.s_suppkey = $ps.ps_suppkey
-	return {"n_name": $srn.n_name, "p_partkey": $ps.ps_partkey, "ps_supplycost": $ps.ps_supplycost,
-			"s_name": $srn.s_name,
-			"s_acctbal": $srn.s_acctbal,
-		 	"s_address":  $srn.s_address, 
-			"s_phone":  $srn.s_phone, 
-			"s_comment":  $srn.s_comment}
-) 
-where $p.p_partkey = $pssrn.p_partkey and like($p.p_type, '%BRASS') 
-return 
-{"s_acctbal": $pssrn.s_acctbal, 
-"s_name": $pssrn.s_name, 
-"n_name": $pssrn.n_name, 
-"p_partkey": $p.p_partkey, 
-"ps_supplycost": $pssrn.ps_supplycost, 
-"p_mfgr": $p.p_mfgr, 
-"s_address":  $pssrn.s_address, 
-"s_phone":  $pssrn.s_phone, 
-"s_comment":  $pssrn.s_comment
-}
-}
-
-declare function tmp2(){
-for $p in dataset('Part')
-for $pssrn in 
-(
-	for $ps in dataset('Partsupp')
-	for $srn in 
-		(
-		for $s in dataset('Supplier')
-		 for $rn in
-			(
-			for $r in dataset('Region')
-			for $n in dataset('Nation')
-			where $n.n_regionkey = $r.r_regionkey and $r.r_name = 'EUROPE' 
-			return {"n_nationkey": $n.n_nationkey, "n_name": $n.n_name}
-			)
-		 where $s.s_nationkey = $rn.n_nationkey
-		 return {"s_suppkey": $s.s_suppkey, "n_name": $rn.n_name,
-		 		"s_name": $s.s_name,
-		 		"s_acctbal": $s.s_acctbal,
-		 		"s_address": $s.s_address, 
-				"s_phone": $s.s_phone, 
-				"s_comment": $s.s_comment}
-		)
-	where $srn.s_suppkey = $ps.ps_suppkey
-	return {"n_name": $srn.n_name, "p_partkey": $ps.ps_partkey, "ps_supplycost": $ps.ps_supplycost,
-			"s_name": $srn.s_name,
-			"s_acctbal": $srn.s_acctbal,
-		 	"s_address":  $srn.s_address, 
-			"s_phone":  $srn.s_phone, 
-			"s_comment":  $srn.s_comment}
-)
-where $p.p_partkey = $pssrn.p_partkey and like($p.p_type, '%BRASS') 
-/*+ hash*/
-group by $p_partkey := $pssrn.p_partkey
-with $pssrn
-return {"p_partkey": $p_partkey, 
-"ps_min_supplycost": min(for $i in $pssrn return $i.ps_supplycost)
-}
-}
-
-for $t2 in tmp2()
-for $t1 in tmp1()
-where $t1.p_partkey = $t2.p_partkey and $t1.ps_supplycost = $t2.ps_min_supplycost
-order by $t1.s_acctbal desc, $t1.n_name, $t1.s_name, $t1.p_partkey
-limit 100
-return 
-{
-"s_acctbal":$t1.s_acctbal, 
-"s_name":$t1.s_name, 
-"n_name":$t1.n_name, 
-"p_partkey":$t1.p_partkey, 
-"p_mfgr":$t1.p_mfgr, 
-"s_address":$t1.s_address, 
-"s_phone":$t1.s_phone, 
-"s_comment":$t1.s_comment
-} 
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.3.query.aql
deleted file mode 100644
index 4079a25..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q4_order_priority/q4_order_priority.3.query.aql
+++ /dev/null
@@ -1,24 +0,0 @@
-use dataverse tpch;
-
-declare function tmp()
-{
-for $l in dataset('LineItem')
-where $l.l_commitdate<$l.l_receiptdate
-distinct by $l.l_orderkey
-return {"o_orderkey": $l.l_orderkey}
-}
-
-for $o in dataset('Orders')
-for $t in tmp()
-where
-$o.o_orderkey = $t.o_orderkey and 
-$o.o_orderdate >= '1993-07-01' and $o.o_orderdate < '1993-10-01' 
-group by $o_orderpriority := $o.o_orderpriority 
-with $o
-order by $o_orderpriority
-return 
-{
-"order_priority": $o_orderpriority,
-"count": count($o)
-}
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.3.query.aql
deleted file mode 100644
index d654ce1..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q5_local_supplier_volume/q5_local_supplier_volume.3.query.aql
+++ /dev/null
@@ -1,35 +0,0 @@
-use dataverse tpch;
-
-for $c in dataset('Customer')
-for $o1 in 
-(  for $o in dataset('Orders')
-   for $l1 in (
-     for $l in dataset('LineItem')
-     for $s1 in 
-     (  for $s in dataset('Supplier')
-        for $n1 in 
-        (  for $n in dataset('Nation')
-           for $r in dataset('Region')
-             where $n.n_regionkey = $r.r_regionkey
-           return 
-              {"n_name": $n.n_name, "n_nationkey": $n.n_nationkey}  )
-        where $s.s_nationkey = $n1.n_nationkey
-        return 
-           { "n_name": $n1.n_name, "s_suppkey": $s.s_suppkey, "s_nationkey": $s.s_nationkey }  )
-     where $l.l_suppkey = $s1.s_suppkey      
-     return 
-        { "n_name": $s1.n_name, "l_extendedprice": $l.l_extendedprice, "l_discount": $l.l_discount, "l_orderkey": $l.l_orderkey, "s_nationkey": $s1.s_nationkey }  )
-   where $l1.l_orderkey = $o.o_orderkey and $o.o_orderdate >= '1990-01-01' and $o.o_orderdate < '1995-01-01'
-   return 
-     { "n_name": $l1.n_name, "l_extendedprice": $l1.l_extendedprice, "l_discount": $l1.l_discount, "s_nationkey": $l1.s_nationkey, "o_custkey": $o.o_custkey }  )
-where $c.c_nationkey = $o1.s_nationkey and $c.c_custkey = $o1.o_custkey
-/*+ hash*/     
-group by $n_name := $o1.n_name with $o1
-let $revenue := sum (
-  for $i in $o1 
-  return 
-    $i.l_extendedprice * (1 - $i.l_discount)
-)
-order by $revenue desc
-return 
-  { "n_name": $n_name, "revenue": $revenue }
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.3.query.aql
deleted file mode 100644
index 8ac1613..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.3.query.aql
+++ /dev/null
@@ -1,14 +0,0 @@
-use dataverse tpch;
-
-let $revenue := sum(
-for $l in dataset('LineItem')
-where 
-  $l.l_shipdate >= '1994-01-01'
-  and $l.l_shipdate < '1995-01-01'
-  and $l.l_discount >= 0.05 and $l.l_discount <= 0.07
-  and $l.l_quantity < 24
-return $l.l_extendedprice * $l.l_discount
-)
-return {
-"revenue": $revenue
-}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.3.query.aql
deleted file mode 100644
index 843204a..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q7_volume_shipping/q7_volume_shipping.3.query.aql
+++ /dev/null
@@ -1,70 +0,0 @@
-use dataverse tpch;
-
-declare function q7_volume_shipping_tmp(){
-for $n1 in dataset('Nation') 
-for $n2 in dataset('Nation')
-   where $n2.n_name='GERMANY' or $n1.n_name='GERMANY' 
-return 
-{
- 	"supp_nation": $n1.n_name, 
- 	"cust_nation": $n2.n_name, 
- 	"s_nationkey": $n1.n_nationkey,      
-    "c_nationkey": $n2.n_nationkey
-}
-}
-
-for $locs in (
-	for $loc in (
-		for $lo in 
-		(
-			for $l in dataset('LineItem')
-			for $o in dataset('Orders')
-			where 
-				$o.o_orderkey = $l.l_orderkey and $l.l_shipdate >= '1992-01-01' 
-				and $l.l_shipdate <= '1996-12-31'
-			return
-			{
-			"l_shipdate": $l.l_shipdate, 
-			"l_extendedprice": $l.l_extendedprice, 
-			"l_discount": $l.l_discount, 
-			"l_suppkey": $l.l_suppkey, 
-			"o_custkey": $o.o_custkey 
-			}
-		)
-		for $c in dataset('Customer')
-		where
-			$c.c_custkey = $lo.o_custkey
-		return 
-		{
-		"l_shipdate": $lo.l_shipdate, 
-		"l_extendedprice": $lo.l_extendedprice, 
-		"l_discount": $lo.l_discount, 
-		"l_suppkey": $lo.l_suppkey, 
-		"c_nationkey": $c.c_nationkey 
-		}
-	)
-	for $s in dataset('Supplier')
-	where
-		$s.s_suppkey = $loc.l_suppkey
-	return {
-	"l_shipdate": $loc.l_shipdate, 
-	"l_extendedprice": $loc.l_extendedprice, 
-	"l_discount": $loc.l_discount, 
-	"c_nationkey": $loc.c_nationkey, 
-	"s_nationkey": $s.s_nationkey
-	}
-)
-for $t in q7_volume_shipping_tmp()
-where
-	$locs.c_nationkey = $t.c_nationkey and $locs.s_nationkey = $t.s_nationkey
-let $l_year0 := get-year($locs.l_shipdate)
-group by $supp_nation := $t.supp_nation, $cust_nation := $t.cust_nation, $l_year := $l_year0
-with $locs
-let $revenue := sum(for $i in $locs return $i.l_extendedprice * (1 - $i.l_discount))
-order by $supp_nation, $cust_nation, $l_year
-return {
-	"supp_nation": $supp_nation, 
-	"cust_nation": $cust_nation, 
-	"l_year": $l_year,
-	"revenue": $revenue
-}
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.3.query.aql
deleted file mode 100644
index cac1248..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q8_national_market_share/q8_national_market_share.3.query.aql
+++ /dev/null
@@ -1,72 +0,0 @@
-use dataverse tpch;
-
-for $t in (
-for $slnrcop in 
-(for $s in dataset("Supplier")
-for $lnrcop in
-(
-for $lnrco in
-(
-for $l in dataset('LineItem')
-for $nrco in (
-	for $o in dataset('Orders')
-	for $nrc in (
-		for $c in dataset('Customer')
-		for $nr in (
-			for $n1 in dataset('Nation')
-			for $r1 in dataset('Region')
-				where $n1.n_regionkey = $r1.r_regionkey and $r1.r_name = 'AMERICA'
-			return {"n_nationkey": $n1.n_nationkey}
-		)
-		where $c.c_nationkey = $nr.n_nationkey
-		return {"c_custkey": $c.c_custkey}
-	)
-	where $nrc.c_custkey = $o.o_custkey
-	return {
-		"o_orderdate" : $o.o_orderdate, 
-		"o_orderkey": $o.o_orderkey 
-	}
-)
-where $l.l_orderkey = $nrco.o_orderkey and $nrco.o_orderdate >= '1995-01-01' 
-                         and $nrco.o_orderdate < '1996-12-31'
-return {
-  "o_orderdate": $nrco.o_orderdate, 
-  "l_partkey": $l.l_partkey, 
-  "l_discount": $l.l_discount, 
-  "l_extendedprice": $l.l_extendedprice, 
-  "l_suppkey": $l.l_suppkey
-})
-for $p in dataset("Part")
-where $p.p_partkey = $lnrco.l_partkey and $p.p_type = 'ECONOMY ANODIZED STEEL'
-return {
-	"o_orderdate": $lnrco.o_orderdate, 
-	"l_discount": $lnrco.l_discount, 
-	"l_extendedprice": $lnrco.l_extendedprice, 
-	"l_suppkey": $lnrco.l_suppkey 
-}
-)
-where $s.s_suppkey = $lnrcop.l_suppkey
-return {
-	"o_orderdate": $lnrcop.o_orderdate, 
-	"l_discount": $lnrcop.l_discount, 
-	"l_extendedprice": $lnrcop.l_extendedprice, 
-	"l_suppkey": $lnrcop.l_suppkey, 
-	"s_nationkey": $s.s_nationkey
-})
-
-for $n2 in dataset('Nation')
-where $slnrcop.s_nationkey = $n2.n_nationkey
-let $o_year := get-year($slnrcop.o_orderdate)
-return {
-  "year": $o_year,
-  "revenue": $slnrcop.l_extendedprice *(1-$slnrcop.l_discount),
-  "s_name": $n2.n_name
-})
-group by $year := $t.year with $t
-order by $year
-return {
-	"year": $year,
-	"mkt_share":sum(for $i in $t return switch-case($i.s_name='BRAZIL', true, $i.revenue, false, 0.0))/ 
-				sum(for $i in $t return $i.revenue)
-}
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.1.ddl.aql
deleted file mode 100644
index c7fbbc6..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.1.ddl.aql
+++ /dev/null
@@ -1,107 +0,0 @@
-drop dataverse tpch if exists;
-create dataverse tpch;
-
-use dataverse tpch;
-
-create type LineItemType as closed {
-  l_orderkey: int32, 
-  l_partkey: int32, 
-  l_suppkey: int32, 
-  l_linenumber: int32, 
-  l_quantity: int32, 
-  l_extendedprice: double,
-  l_discount: double, 
-  l_tax: double,
-  l_returnflag: string, 
-  l_linestatus: string, 
-  l_shipdate: string,
-  l_commitdate: string, 
-  l_receiptdate: string, 
-  l_shipinstruct: string, 
-  l_shipmode: string, 
-  l_comment: string
-}
-
-create type OrderType as closed {
-  o_orderkey: int32, 
-  o_custkey: int32, 
-  o_orderstatus: string, 
-  o_totalprice: double, 
-  o_orderdate: string, 
-  o_orderpriority: string,
-  o_clerk: string, 
-  o_shippriority: int32, 
-  o_comment: string
-}
-
-create type CustomerType as closed {
-  c_custkey: int32, 
-  c_name: string, 
-  c_address: string, 
-  c_nationkey: int32, 
-  c_phone: string, 
-  c_acctbal: double, 
-  c_mktsegment: string,
-  c_comment: string
-}
-
-create type SupplierType as closed {
-  s_suppkey: int32, 
-  s_name: string,
-  s_address: string,
-  s_nationkey: int32,
-  s_phone: string,
-  s_acctbal: double,
-  s_comment: string
-}
-
-create type NationType as closed {
-  n_nationkey: int32,
-  n_name: string,
-  n_regionkey: int32,
-  n_comment: string
-}
-
-create type RegionType as closed {
-	r_regionkey: int32, 
-	r_name: string, 
-	r_comment: string
-} 
-
-create type PartType as closed {
-  p_partkey: int32, 
-  p_name: string, 
-  p_mfgr: string,
-  p_brand: string,
-  p_type: string,
-  p_size: int32,
-  p_container: string,
-  p_retailprice: double,
-  p_comment: string
-}
-
-create type PartSuppType as closed {
-  ps_partkey: int32, 
-  ps_suppkey: int32,
-  ps_availqty: int32,
-  ps_supplycost: double,
-  ps_comment: string 
-}
-
-create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber;
-create dataset Orders(OrderType)
-  primary key o_orderkey;
-create dataset Supplier(SupplierType)
-  primary key s_suppkey;
-create dataset Region(RegionType) 
-  primary key r_regionkey;
-create dataset Nation(NationType) 
-  primary key n_nationkey;
-create dataset Part(PartType)
-  primary key p_partkey;
-create dataset PartSupp(PartSuppType)
-  primary key ps_partkey, ps_suppkey;  
-create dataset Customer(CustomerType) 
-  primary key c_custkey;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.2.update.aql
deleted file mode 100644
index c68e0af..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.2.update.aql
+++ /dev/null
@@ -1,34 +0,0 @@
-use dataverse tpch;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Orders 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Supplier 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Region 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Nation 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Part 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset PartSupp 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset Customer 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.3.query.aql
deleted file mode 100644
index 2e54083..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.3.query.aql
+++ /dev/null
@@ -1,40 +0,0 @@
-use dataverse tpch;
-                
-for $profit in 
-(  for $o in dataset('Orders')
-   for $l3 in 
-   (  for $p in dataset('Part')
-      for $l2 in 
-      (  for $ps in dataset('PartSupp')
-         for $l1 in 
-        (  for $s1 in
-            (  for $s in dataset('Supplier')
-               for $n in dataset('Nation')
-               where $n.n_nationkey = $s.s_nationkey
-               return 
-                 { "s_suppkey": $s.s_suppkey, "n_name": $n.n_name}  )
-            for $l in dataset('LineItem')
-            where $s1.s_suppkey = $l.l_suppkey       
-            return 
-              { "l_suppkey": $l.l_suppkey, "l_extendedprice": $l.l_extendedprice, "l_discount": $l.l_discount,
-                "l_quantity": $l.l_quantity, "l_partkey": $l.l_partkey, "l_orderkey": $l.l_orderkey, "n_name": $s1.n_name } )
-         where $ps.ps_suppkey = $l1.l_suppkey and $ps.ps_partkey = $l1.l_partkey       
-         return 
-           { "l_extendedprice": $l1.l_extendedprice, "l_discount": $l1.l_discount, "l_quantity": $l1.l_quantity, 
-             "l_partkey": $l1.l_partkey, "l_orderkey": $l1.l_orderkey, "n_name": $l1.n_name, "ps_supplycost": $ps.ps_supplycost }  )
-      where contains($p.p_name, 'green') and $p.p_partkey = $l2.l_partkey    
-      return 
-        { "l_extendedprice": $l2.l_extendedprice, "l_discount": $l2.l_discount, "l_quantity": $l2.l_quantity, 
-          "l_orderkey": $l2.l_orderkey, "n_name": $l2.n_name, "ps_supplycost": $l2.ps_supplycost  }  )
-   where $o.o_orderkey = $l3.l_orderkey
-   let $amount := $l3.l_extendedprice * (1 - $l3.l_discount) -  $l3.ps_supplycost * $l3.l_quantity 
-   let $o_year := get-year($o.o_orderdate)
-   return 
-     { "nation": $l3.n_name, "o_year": $o_year, "amount": $amount }  )
- group by $nation := $profit.nation, $o_year := $profit.o_year with $profit
- order by $nation, $o_year desc
- return 
-   { "nation": $nation, 
-     "o_year": $o_year, 
-      "sum_profit": sum( for $pr in $profit return $pr.amount )  }    
-   
diff --git a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses/join_across_dataverses.1.adm b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses/join_across_dataverses.1.adm
index e78ad8f..0e1edd5 100644
--- a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses/join_across_dataverses.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses/join_across_dataverses.1.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 1, 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/join_q_01.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01/join_q_01.1.adm
index e78ad8f..0e1edd5 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_01/join_q_01.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01/join_q_01.1.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 1, 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_02/join_q_02.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_02/join_q_02.1.adm
index a24c6d7..5c955c3 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_02/join_q_02.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_02/join_q_02.1.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "order_total": 7.206f, "orderedlist": [ 10, 48, 5 ], "unorderedlist": {{ 10, 48, 5 }} }
+{ "cust_name": "Jodi Alex", "order_total": 7.206f, "orderedlist": [ 1, 48, 5 ], "unorderedlist": {{ 1, 48, 5 }} }
 { "cust_name": "Jodi Rotruck", "order_total": 14.2326f, "orderedlist": [ 10, 66, 775 ], "unorderedlist": {{ 10, 66, 775 }} }
 { "cust_name": "Jodi Rotruck", "order_total": 97.20656f, "orderedlist": [ 1000, 66, 775 ], "unorderedlist": {{ 1000, 66, 775 }} }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/join_q_03/join_q_03.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_03/join_q_03.1.adm
index 5583a3f..6bbd9f5 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_03/join_q_03.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_03/join_q_03.1.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "order_total": 7.206f, "orderedlist": [ 10, 48, 5 ], "unorderedlist": {{ 10, 48, 5 }}, "ol_item1": 10, "ol_item2": 48, "ol_item5": null, "ul_item1": 10 }
+{ "cust_name": "Jodi Alex", "order_total": 7.206f, "orderedlist": [ 1, 48, 5 ], "unorderedlist": {{ 1, 48, 5 }}, "ol_item1": 1, "ol_item2": 48, "ol_item5": null, "ul_item1": 1 }
 { "cust_name": "Jodi Rotruck", "order_total": 14.2326f, "orderedlist": [ 10, 66, 775 ], "unorderedlist": {{ 10, 66, 775 }}, "ol_item1": 10, "ol_item2": 66, "ol_item5": null, "ul_item1": 10 }
 { "cust_name": "Jodi Rotruck", "order_total": 97.20656f, "orderedlist": [ 1000, 66, 775 ], "unorderedlist": {{ 1000, 66, 775 }}, "ol_item1": 1000, "ol_item2": 66, "ol_item5": null, "ul_item1": 1000 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/join_q_04/join_q_04.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_04/join_q_04.1.adm
index 51f998a..c5cd404 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_04/join_q_04.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_04/join_q_04.1.adm
@@ -1,4 +1,4 @@
-{ "cust_name": "Jodi Alex", "order_ids": [ 10 ] }
+{ "cust_name": "Jodi Alex", "order_ids": [ 1 ] }
 { "cust_name": "Jodi Rotruck", "order_ids": [ 10, 1000 ] }
 { "cust_name": "Mary Carey", "order_ids": [  ] }
 { "cust_name": "Mike Carey", "order_ids": [  ] }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_01/order_q_01.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_01/order_q_01.1.adm
index 276d94b..d606b89 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_01/order_q_01.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_01/order_q_01.1.adm
@@ -1,4 +1,4 @@
 { "oid": 1000, "cid": 775, "orderstatus": "ORDER_DELIVERED", "orderpriority": "LOW", "clerk": "Kathryne", "total": 97.20656f, "items": [ 1, 2, 4, 5, 6 ], "heList": [ "1.0f", "yassser" ], "openlist": [ 11, 14, "yasir", 1.6f ], "loc": point("10.1,11.1"), "line": line("10.1,11.1 10.2,11.2"), "poly": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "DOB": "1989-10-12", "favnumbers": [ 10.0d, 20.0d, 30.0d, 40.0d ] }
-{ "oid": 10, "cid": 5, "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH", "clerk": "ALEX", "total": 7.206f, "items": [ 13, 52, 24, 15, 60 ], "heList": [ 1.0f, "5.2f", "60" ], "openlist": [ 13231, "foo", null, 13.25d, 13.2f ], "loc": point("10.1,11.1"), "line": line("10.1,11.1 10.2,11.2"), "poly": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "DOB": "1989-10-12", "favnumbers": [ 10.0d, 20.0d, 30.0d, 40.0d, 50.0d, 60.0d, 70.0d ] }
+{ "oid": 1, "cid": 5, "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH", "clerk": "ALEX", "total": 7.206f, "items": [ 13, 52, 24, 15, 60 ], "heList": [ 1.0f, "5.2f", "60" ], "openlist": [ 13231, "foo", null, 13.25d, 13.2f ], "loc": point("10.1,11.1"), "line": line("10.1,11.1 10.2,11.2"), "poly": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "DOB": "1989-10-12", "favnumbers": [ 10.0d, 20.0d, 30.0d, 40.0d, 50.0d, 60.0d, 70.0d ] }
 { "oid": 100, "cid": 12, "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH", "clerk": "YASSER", "total": 124.26f, "items": [ 13, 52, 60 ], "heList": [ 1.3f, 5.2f, "60", 12.32f ], "openlist": [ 10, 2.0f, 3.0d, 40 ], "loc": point("10.1,11.1"), "line": line("10.1,11.1 10.2,11.2"), "poly": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "DOB": "1989-10-12", "favnumbers": [ 10.0d, 50.0d, 60.0d, 70.0d ] }
 { "oid": 10, "cid": 775, "orderstatus": "ORDER_DELIVERED", "orderpriority": "HIGH", "clerk": "MIKE", "total": 14.2326f, "items": [ 24, 15 ], "heList": [ 2.4f, "15" ], "openlist": [ 110 ], "loc": point("10.1,11.1"), "line": line("10.1,11.1 10.2,11.2"), "poly": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "lastorder": { "oid": 75, "total": 87.61863f } }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03/order_q_03.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03/order_q_03.1.adm
index 4e02c4b..b766274 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03/order_q_03.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03/order_q_03.1.adm
@@ -1,4 +1,4 @@
 { "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": 1, "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/order_q_04.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm
index 3992f7d..aa5c557 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.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" ], "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": 1, "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/order_q_05.1.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
index 4d8b37c..4d0e0c0 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
@@ -1,4 +1,4 @@
 { "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": 1, "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/results/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.1.adm b/asterix-app/src/test/resources/runtimets/results/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/failure/q1_pricing_summary_report_failure/q1_pricing_summary_report_failure.1.adm
rename to asterix-app/src/test/resources/runtimets/results/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/index-join/btree-primary-equi-join/btree-primary-equi-join.1.adm b/asterix-app/src/test/resources/runtimets/results/index-join/btree-primary-equi-join/btree-primary-equi-join.1.adm
index bc2a454..10260c7 100644
--- a/asterix-app/src/test/resources/runtimets/results/index-join/btree-primary-equi-join/btree-primary-equi-join.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/index-join/btree-primary-equi-join/btree-primary-equi-join.1.adm
@@ -1,3 +1,3 @@
-{ "cid": 5, "oid": 10 }
+{ "cid": 5, "oid": 1 }
 { "cid": 775, "oid": 10 }
 { "cid": 775, "oid": 1000 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q2_minimum_cost_supplier/q2_minimum_cost_supplier.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q3_shipping_priority_nt/q3_shipping_priority_nt.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q4_order_priority/q4_order_priority.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q04_order_priority/q04_order_priority.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q4_order_priority/q4_order_priority.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q04_order_priority/q04_order_priority.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q5_local_supplier_volume/q5_local_supplier_volume.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q5_local_supplier_volume/q5_local_supplier_volume.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q6_forecast_revenue_change/q6_forecast_revenue_change.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q7_volume_shipping/q7_volume_shipping.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q07_volume_shipping/q07_volume_shipping.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q7_volume_shipping/q7_volume_shipping.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q07_volume_shipping/q07_volume_shipping.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q8_national_market_share/q8_national_market_share.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q08_national_market_share/q08_national_market_share.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q8_national_market_share/q8_national_market_share.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q08_national_market_share/q08_national_market_share.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.1.adm b/asterix-app/src/test/resources/runtimets/results/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/tpch/q9_product_type_profit_nt/q9_product_type_profit_nt.1.adm
rename to asterix-app/src/test/resources/runtimets/results/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 7571664..eadf7fb 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -965,11 +965,6 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
-      <compilation-unit name="empty-load">
-        <output-dir compare="Text">empty-load</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="dml">
       <compilation-unit name="insert-into-empty-dataset-with-index">
         <output-dir compare="Text">insert-into-empty-dataset-with-index</output-dir>
       </compilation-unit>
@@ -3867,8 +3862,8 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q1_pricing_summary_report_nt">
-        <output-dir compare="Text">q1_pricing_summary_report_nt</output-dir>
+      <compilation-unit name="q01_pricing_summary_report_nt">
+        <output-dir compare="Text">q01_pricing_summary_report_nt</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
@@ -3887,43 +3882,43 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q2_minimum_cost_supplier">
-        <output-dir compare="Text">q2_minimum_cost_supplier</output-dir>
+      <compilation-unit name="q02_minimum_cost_supplier">
+        <output-dir compare="Text">q02_minimum_cost_supplier</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q3_shipping_priority_nt">
-        <output-dir compare="Text">q3_shipping_priority_nt</output-dir>
+      <compilation-unit name="q03_shipping_priority_nt">
+        <output-dir compare="Text">q03_shipping_priority_nt</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q4_order_priority">
-        <output-dir compare="Text">q4_order_priority</output-dir>
+      <compilation-unit name="q04_order_priority">
+        <output-dir compare="Text">q04_order_priority</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q5_local_supplier_volume">
-        <output-dir compare="Text">q5_local_supplier_volume</output-dir>
+      <compilation-unit name="q05_local_supplier_volume">
+        <output-dir compare="Text">q05_local_supplier_volume</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q6_forecast_revenue_change">
-        <output-dir compare="Text">q6_forecast_revenue_change</output-dir>
+      <compilation-unit name="q06_forecast_revenue_change">
+        <output-dir compare="Text">q06_forecast_revenue_change</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q7_volume_shipping">
-        <output-dir compare="Text">q7_volume_shipping</output-dir>
+      <compilation-unit name="q07_volume_shipping">
+        <output-dir compare="Text">q07_volume_shipping</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q8_national_market_share">
-        <output-dir compare="Text">q8_national_market_share</output-dir>
+      <compilation-unit name="q08_national_market_share">
+        <output-dir compare="Text">q08_national_market_share</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch">
-      <compilation-unit name="q9_product_type_profit_nt">
-        <output-dir compare="Text">q9_product_type_profit_nt</output-dir>
+      <compilation-unit name="q09_product_type_profit_nt">
+        <output-dir compare="Text">q09_product_type_profit_nt</output-dir>
       </compilation-unit>
     </test-case>
   </test-group>
@@ -4274,6 +4269,12 @@
         <output-dir compare="Text">query-issue244</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="load">
+      <compilation-unit name="duplicate-key-error">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.api.exceptions.HyracksException</expected-error> 
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="hints">
     <test-case FilePath="hints">
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/q01_pricing_summary_report.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/asterix/q1_pricing_summary_report.aql
rename to asterix-app/src/test/resources/tpch/queries/asterix/q01_pricing_summary_report.aql
diff --git a/asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql b/asterix-app/src/test/resources/tpch/queries/asterix/q03_shipping_priority.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/asterix/q3_shipping_priority.aql
rename to asterix-app/src/test/resources/tpch/queries/asterix/q03_shipping_priority.aql
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/q05_local_supplier_volume.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/asterix/q5_local_supplier_volume.aql
rename to asterix-app/src/test/resources/tpch/queries/asterix/q05_local_supplier_volume.aql
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/q09_product_type_profit.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/asterix/q9_product_type_profit.aql
rename to asterix-app/src/test/resources/tpch/queries/asterix/q09_product_type_profit.aql
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/q01_pricing_summary_report.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/local/q1_pricing_summary_report.aql
rename to asterix-app/src/test/resources/tpch/queries/local/q01_pricing_summary_report.aql
diff --git a/asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql b/asterix-app/src/test/resources/tpch/queries/local/q03_shipping_priority.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/local/q3_shipping_priority.aql
rename to asterix-app/src/test/resources/tpch/queries/local/q03_shipping_priority.aql
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/q05_local_supplier_volume.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/local/q5_local_supplier_volume.aql
rename to asterix-app/src/test/resources/tpch/queries/local/q05_local_supplier_volume.aql
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/q09_product_type_profit.aql
similarity index 100%
rename from asterix-app/src/test/resources/tpch/queries/local/q9_product_type_profit.aql
rename to asterix-app/src/test/resources/tpch/queries/local/q09_product_type_profit.aql
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 b767d57..78375e6 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
@@ -58,7 +58,7 @@
 declare dataset CustOrder(CustOrderType)
   primary key co_custkey on group1;
 
-write into dataset CustOrder 
+insert into dataset CustOrder 
 ( for $c in dataset('Customers')
   for $o in dataset('Orders')
   where $c.c_custkey = $o.o_custkey
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Statement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Statement.java
index 2064d47..98f8387 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Statement.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Statement.java
@@ -26,7 +26,6 @@
         DML_CMD_LIST,
         FUNCTION_DECL,
         LOAD_FROM_FILE,
-        WRITE_FROM_QUERY_RESULT,
         NODEGROUP_DECL,
         NODEGROUP_DROP,
         QUERY,
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WriteFromQueryResultStatement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WriteFromQueryResultStatement.java
deleted file mode 100644
index 06e452d..0000000
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WriteFromQueryResultStatement.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.aql.expression;
-
-import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
-import edu.uci.ics.asterix.aql.expression.visitor.IAqlVisitorWithVoidReturn;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-
-public class WriteFromQueryResultStatement implements Statement {
-
-    private Identifier dataverseName;
-    private Identifier datasetName;
-
-    private Query query;
-    private int varCounter;
-
-    public WriteFromQueryResultStatement(Identifier dataverseName, Identifier datasetName, Query query, int varCounter) {
-        this.dataverseName = dataverseName;
-        this.datasetName = datasetName;
-        this.query = query;
-        this.varCounter = varCounter;
-    }
-
-    @Override
-    public Kind getKind() {
-        return Kind.WRITE_FROM_QUERY_RESULT;
-    }
-
-    public Identifier getDataverseName() {
-        return dataverseName;
-    }
-
-    public Identifier getDatasetName() {
-        return datasetName;
-    }
-
-    public Query getQuery() {
-        return query;
-    }
-
-    public int getVarCounter() {
-        return varCounter;
-    }
-
-    @Override
-    public <R, T> R accept(IAqlExpressionVisitor<R, T> visitor, T arg) throws AsterixException {
-        return visitor.visitLoadFromQueryResultStatement(this, arg);
-    }
-
-    @Override
-    public <T> void accept(IAqlVisitorWithVoidReturn<T> visitor, T arg) throws AsterixException {
-        visitor.visit(this, arg);
-    }
-
-}
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
index 652aff5..cdbd86f 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
@@ -76,7 +76,6 @@
 import edu.uci.ics.asterix.aql.expression.UpdateStatement;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -421,12 +420,6 @@
     }
 
     @Override
-    public void visit(WriteFromQueryResultStatement stmtLoad, Integer arg) throws AsterixException {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
     public void visit(DropStatement stmtDel, Integer arg) throws AsterixException {
         // TODO Auto-generated method stub
 
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
index f6b05d8..7fbf342 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
@@ -61,7 +61,6 @@
 import edu.uci.ics.asterix.aql.expression.UpdateStatement;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 
@@ -79,8 +78,6 @@
 
     R visitLoadFromFileStatement(LoadFromFileStatement stmtLoad, T arg) throws AsterixException;
 
-    R visitLoadFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, T arg) throws AsterixException;
-
     R visitDropStatement(DropStatement del, T arg) throws AsterixException;
 
     R visitInsertStatement(InsertStatement insert, T arg) throws AsterixException;
@@ -161,8 +158,6 @@
 
     R visitDataverseDecl(DataverseDecl dv, T arg) throws AsterixException;
 
-    R visitWriteFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, T arg) throws AsterixException;
-
     R visit(CreateFunctionStatement cfs, T arg) throws AsterixException;
 
     R visitFunctionDropStatement(FunctionDropStatement del, T arg) throws AsterixException;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
index fe85851..b936c63 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
@@ -61,7 +61,6 @@
 import edu.uci.ics.asterix.aql.expression.UpdateStatement;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 
@@ -87,8 +86,6 @@
 
     void visit(UpdateClause updateClause, T arg) throws AsterixException;
 
-    void visit(WriteFromQueryResultStatement stmtLoad, T arg) throws AsterixException;
-
     void visit(DatasetDecl dd, T arg) throws AsterixException;
 
     void visit(LiteralExpr l, T arg) throws AsterixException;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
index cf6020e..a9d8585 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
@@ -75,7 +75,6 @@
 import edu.uci.ics.asterix.aql.expression.VarIdentifier;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
@@ -485,13 +484,6 @@
         }
 
         @Override
-        public Void visitWriteFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, Void arg)
-                throws AsterixException {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
         public Void visitWriteStatement(WriteStatement ws, Void arg) throws AsterixException {
             // TODO Auto-generated method stub
             return null;
@@ -502,13 +494,6 @@
         }
 
         @Override
-        public Void visitLoadFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, Void arg)
-                throws AsterixException {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
         public Void visitCreateDataverseStatement(CreateDataverseStatement del, Void arg) throws AsterixException {
             // TODO Auto-generated method stub
             return null;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
index 4f2f796..dcb4a66 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
@@ -72,7 +72,6 @@
 import edu.uci.ics.asterix.aql.expression.VarIdentifier;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -436,13 +435,6 @@
     }
 
     @Override
-    public Pair<IAqlExpression, List<VariableSubstitution>> visitWriteFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, List<VariableSubstitution> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<IAqlExpression, List<VariableSubstitution>> visitCreateIndexStatement(CreateIndexStatement cis,
             List<VariableSubstitution> arg) throws AsterixException {
         // TODO Auto-generated method stub
@@ -536,13 +528,6 @@
     }
 
     @Override
-    public Pair<IAqlExpression, List<VariableSubstitution>> visitLoadFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, List<VariableSubstitution> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Pair<IAqlExpression, List<VariableSubstitution>> visitCreateDataverseStatement(CreateDataverseStatement del,
             List<VariableSubstitution> arg) throws AsterixException {
         // TODO Auto-generated method stub
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
index 4858789..ae5d7d9 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
@@ -73,7 +73,6 @@
 import edu.uci.ics.asterix.aql.expression.VarIdentifier;
 import edu.uci.ics.asterix.aql.expression.VariableExpr;
 import edu.uci.ics.asterix.aql.expression.WhereClause;
-import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -461,26 +460,12 @@
     }
 
     @Override
-    public Boolean visitWriteFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, List<FunctionDecl> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Boolean visitWriteStatement(WriteStatement ws, List<FunctionDecl> arg) throws AsterixException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public Boolean visitLoadFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, List<FunctionDecl> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public Boolean visitCreateDataverseStatement(CreateDataverseStatement del, List<FunctionDecl> arg)
             throws AsterixException {
         // TODO Auto-generated method stub
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index bd21581..84d46f5 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -376,11 +376,11 @@
     }
   | "keyword"
     {
-      type = IndexType.FUZZY_WORD_INVIX;
+      type = IndexType.LENGTH_PARTITIONED_WORD_INVIX;
     }
   | "ngram" <LEFTPAREN> <INTEGER_LITERAL>
     {
-      type = IndexType.FUZZY_NGRAM_INVIX;
+      type = IndexType.LENGTH_PARTITIONED_NGRAM_INVIX;
       gramLength = Integer.valueOf(token.image);
     }
   <RIGHTPAREN>)
@@ -678,30 +678,15 @@
 {
   String nodeName = null;
   String fileName = null;
-  Statement stmt = null;
   Query query;
   String writerClass = null;
   Pair<Identifier,Identifier> nameComponents = null;
 }
 {
-  "write" ((
-    "output" "to" nodeName = Identifier() ":" fileName = StringLiteral()
+  "write" "output" "to" nodeName = Identifier() ":" fileName = StringLiteral()
     ( "using" writerClass = StringLiteral() )?
-      {                  
-        stmt = new WriteStatement(new Identifier(nodeName), fileName, writerClass);         
-      }
-  ) | (
-    "into" <DATASET> 
-      {
-        nameComponents = QualifiedName();
-      }
-    <LEFTPAREN> query = Query() <RIGHTPAREN>
-      {
-        stmt = new WriteFromQueryResultStatement(nameComponents.first, nameComponents.second, query, getVarCounter());
-      }
-  ))
-    {
-      return stmt;
+    {                  
+      return new WriteStatement(new Identifier(nodeName), fileName, writerClass);         
     }
 }
 
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/DatasetConfig.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/DatasetConfig.java
index 9e2388c..60cf6e5 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/DatasetConfig.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/DatasetConfig.java
@@ -40,10 +40,10 @@
     public enum IndexType {
         BTREE,        
         RTREE,
-        WORD_INVIX,
-        NGRAM_INVIX,
-        FUZZY_WORD_INVIX,
-        FUZZY_NGRAM_INVIX
+        SINGLE_PARTITION_WORD_INVIX,
+        SINGLE_PARTITION_NGRAM_INVIX,
+        LENGTH_PARTITIONED_WORD_INVIX,
+        LENGTH_PARTITIONED_NGRAM_INVIX
     }
 
 }
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
index 1931188..7232f01 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
@@ -165,7 +165,8 @@
         List<DatasetInfo> datasetInfosList = new ArrayList<DatasetInfo>(datasetInfos.values());
         Collections.sort(datasetInfosList);
         for (DatasetInfo dsInfo : datasetInfosList) {
-            if (((PrimaryIndexOperationTracker) datasetOpTrackers.get(dsInfo.datasetID)).getNumActiveOperations() == 0
+            ILSMOperationTracker opTracker = datasetOpTrackers.get(dsInfo.datasetID);
+            if (opTracker != null && ((PrimaryIndexOperationTracker) opTracker).getNumActiveOperations() == 0
                     && dsInfo.referenceCount == 0 && dsInfo.isOpen) {
                 for (IndexInfo iInfo : dsInfo.indexes.values()) {
                     if (iInfo.isOpen) {
diff --git a/asterix-doc/src/site/markdown/install.md b/asterix-doc/src/site/markdown/install.md
index 65aebdf..4d53f75 100644
--- a/asterix-doc/src/site/markdown/install.md
+++ b/asterix-doc/src/site/markdown/install.md
@@ -96,21 +96,35 @@
         RSA key fingerprint is aa:7b:51:90:74:39:c4:f6:28:a2:9d:47:c2:8d:33:31.
         Are you sure you want to continue connecting (yes/no)?
 
-If you are not prompted for a password, that is if you get an output similar to one shown below, skip to the next section [Configuring Managix](#Configuring_Managix).
+If you are not prompted for a password, that is if you get an output similar to one shown below, it signifies that you already 
+have password-less SSH configured. 
 
 
         $ ssh 127.0.0.1
         Last login: Sat Mar 23 22:52:49 2013
 
-You are here because you were prompted for a password.  You need to configure password less SSH.   Follow the instructions below.
+
+[Important: Password-less SSH requires the use of a (public,private) key-pair. The key-pair is located as a pair of files under
+ $HOME/.ssh directory. It is required that the (public,private) key-pair files have default names (id_rsa.pub, id_rsa) respectively. 
+ If you are using different names, please rename the files to use the default names]
+
+Skip to the next section [Configuring Managix](#Configuring_Managix).
+
+
+You are here because you were prompted for a password.  You need to configure password-less SSH.   
+We shall generate a (public,private) key-pair as id_rsa.pub and id_rsa respectively. If $HOME/.ssh already
+contains a (public,private) key-pair, please ensure the files are renamed before proceeding.
+Follow the instructions below.
 
 
          $ ssh-keygen -t rsa -P ""
         Generating public/private rsa key pair.
-        Enter file in which to save the key (/home/joe/.ssh/id_rsa):   [We shall use the default value, so simply press enter]
+        Enter file in which to save the key (/home/joe/.ssh/id_rsa):   
+        [Important: Please ensure that we use the default value, so simply press enter]
+
 
 If a key already exists, you should get an output similar to what is shown below.  Press 'y' to overwrite the existing key.
-
+It is required to use the default name. If you wish to not overwrite a pre-existing key, ensure that the pre-existing key is saved with a different name.
 
         /home/joe/.ssh/id_rsa already exists.
         Overwrite (y/n)?
@@ -137,6 +151,7 @@
 
 
           $ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
+          $ chmod 700  $HOME/.ssh/authorized_keys
 
 We shall now retry SSH without password.
 
@@ -261,39 +276,39 @@
         <cluster xmlns="cluster">
             <name>local</name>
             <java_home>/usr/lib/jvm/jdk1.7.0</java_home>
-            <java_opts>-Xmx1048m</java_opts>
-            <logdir>/home/joe/asterix-mgmt/clusters/local/working_dir/logs</logdir>
+            <log_dir>/home/joe/asterix-mgmt/clusters/local/working_dir/logs</logdir>
+            <txn_log_dir>/home/joe/asterix-mgmt/clusters/local/working_dir/logs</txn_log_dir>
             <iodevices>/home/joe/asterix-mgmt/clusters/local/working_dir</iodevices>
             <store>storage</store>
-            <workingDir>
+            <working_dir>
                 <dir>/home/joe/asterix-mgmt/clusters/local/working_dir</dir>
                 <NFS>true</NFS>
-            </workingDir>
-            <master-node>
+            </working_dir>
+            <master_node>
                 <id>master</id>
-                <client-ip>127.0.0.1</client-ip>
-                <cluster-ip>127.0.0.1</cluster-ip>
-            </master-node>
+                <client_ip>127.0.0.1</client_ip>
+                <cluster_ip>127.0.0.1</cluster_ip>
+            </master_node>
             <node>
                 <id>node1</id>
-                <cluster-ip>127.0.0.1</cluster-ip>
+                <cluster_ip>127.0.0.1</cluster_ip>
             </node>
         </cluster>
 
 We shall next explain the components of the cluster configuration XML file.
 
 #### (1) Defining nodes in ASTERIX runtime ####
-The single-machine ASTERIX instance configuration that is auto-generated by Managix (using the "configure" command) involves a master node (CC) and a worker node (NC).  Each node is assigned a unique id and provided with an ip address (called ''cluster-ip'') that maps a node to a physical machine. The following snippet from the above XML file captures the master/worker nodes in our ASTERIX installation.
+The single-machine ASTERIX instance configuration that is auto-generated by Managix (using the "configure" command) involves a master node (CC) and a worker node (NC).  Each node is assigned a unique id and provided with an ip address (called ''cluster_ip'') that maps a node to a physical machine. The following snippet from the above XML file captures the master/worker nodes in our ASTERIX installation.
 
 
-            <master-node>
+            <master_node>
                 <id>master</id>
-                <client-ip>127.0.0.1</client-ip>
-                <cluster-ip>127.0.0.1</cluster-ip>
-            </master-node>
+                <client_ip>127.0.0.1</client_ip>
+                <cluster_ip>127.0.0.1</cluster_ip>
+            </master_node>
             <node>
                 <id>node1</id>
-                <cluster-ip>127.0.0.1</cluster-ip>
+                <cluster_ip>127.0.0.1</cluster_ip>
             </node>
 
 
@@ -309,11 +324,11 @@
   <td>A unique id for a node.</td>
 </tr>
 <tr>
-  <td>cluster-ip</td>
+  <td>cluster_ip</td>
   <td>IP address of the machine to which a node maps to. This address is used for all internal communication between the nodes.</td>
 </tr>
 <tr>
-  <td>client-ip</td>
+  <td>client_ip</td>
   <td>Provided for the master node. This IP should be reachable from clients that want to connect with ASTERIX via its web interface.</td>
 </tr>
 </table>
@@ -331,20 +346,20 @@
   <td>Java installation directory at each node.</td>
 </tr>
 <tr>
-  <td>java_opts</td>
-  <td>JVM arguments passed on to the JVM that represents a node.</td>
-</tr>
-<tr>
-  <td>logdir</td>
+  <td>log_dir</td>
   <td>A directory where worker node may write logs.</td>
 </tr>
 <tr>
-  <td>io_devices</td>
+  <td>txn_log_dir</td>
+  <td>A directory where worker node may write transaction logs.</td>
+</tr>
+<tr>
+  <td>iodevices</td>
   <td>Comma separated list of IO Device mount points.</td>
 </tr>
 <tr>
   <td>store</td>
-  <td>A data directory that ASTERIX uses to store data belonging to dataset(s).</td>
+  <td>A data directory (under each iodevice) that ASTERIX uses to store data belonging to dataset(s).</td>
 </tr>
 </table>
 
@@ -354,10 +369,10 @@
 
 Next we explain the following setting in the file $MANAGIX_HOME/clusters/local/local.xml.
 
-            <workingDir>
+            <working_dir>
                 <dir>/Users/joe/asterix-mgmt/clusters/local/working_dir</dir>
                 <NFS>true</NFS>
-            </workingDir>
+            </working_dir>
 
 
 Managix associates a working directory with an ASTERIX instance and uses this directory for transferring binaries to each node. If there exists a directory that is readable by each node, Managix can use it to place binaries that can be accessed and used by all the nodes in the ASTERIX set up. A network file system (NFS) provides such a functionality for a cluster of physical machines such that a path on NFS is accessible from each machine in the cluster.  In the single-machine set up described above, all nodes correspond to a single physical machine. Each path on the local file system is accessible to all the nodes in the ASTERIX setup and the boolean value for NFS above is thus set to `true`.
@@ -384,13 +399,13 @@
 
 ![AsterixCluster](https://asterixdb.googlecode.com/files/AsterixCluster.png)
 
-Notice that each machine has a ''cluster-ip'' address, which is used by these machines for their intra-cluster communication. Meanwhile, the master machine also has a ''client-ip'' address, using which an end-user outside the cluster can communicate with this machine.  The reason we differentiate between these two types of IP addresses is that we can have a cluster of machines using a private network. In this case they have internal ip addresses that cannot be used outside the network.  In the case all the machines are on a public network, the "client-ip" and "cluster-ip" of the master machine can share the same address.
+Notice that each machine has a ''cluster_ip'' address, which is used by these machines for their intra-cluster communication. Meanwhile, the master machine also has a ''client_ip'' address, using which an end-user outside the cluster can communicate with this machine.  The reason we differentiate between these two types of IP addresses is that we can have a cluster of machines using a private network. In this case they have internal ip addresses that cannot be used outside the network.  In the case all the machines are on a public network, the "client_ip" and "cluster_ip" of the master machine can share the same address.
 
 Next we describe how to set up ASTERIX in this cluster, assuming no Managix has been installed on these machines.
 
 ### Step (1): Define the ASTERIX cluster ###
 
-We first log into the master machine as the user "joe". On this machine, download Managix from [here](https://asterixdb.googlecode.com/files/asterix-installer-0.0.5-binary-assembly.zip) (save as above), then do the following steps similar to the single-machine case described above:
+We first log into the master machine as the user "joe". On this machine, download Managix from [here](https://asterixdb.googlecode.com/files/asterix-installer-0.0.5-binary-assembly.zip) (same as above), then do the following steps similar to the single-machine case described above:
 
 
         machineA> cd ~
@@ -418,42 +433,49 @@
           <username>joe</username>
         
           <!-- The working directory of Managix. It should be on a network file system (NFS) that
-            can accessed by all the machine. Need to create it before running Managix. -->
-          <workingDir>
+            can accessed by all the machine. -->
+          <working_dir>
             <dir>/home/joe/managix-workingDir</dir>
             <NFS>true</NFS>
-          </workingDir>
+          </working_dir>
         
-          <!-- Directory for Asterix to store log information for each machine. Needs
-           to be a local file system. Needs to create it before running Managix. -->
-          <logdir>/mnt/joe/logs</logdir>
+          <!-- Directory for Asterix to store log information for each node. Needs
+           to be on the local file system.  -->
+          <log_dir>/mnt/joe/logs</log_dir>
         
-          <!-- Directory used by each worker node to store data files. Needs
-           to be a local file system. Needs to create it before running Managix. -->
+          <!-- Directory for Asterix to store transaction logs information for each node. Needs
+           to be on the local file system.  -->
+          <txn_log_dir>/mnt/joe/txn-logs</txn_log_dir>
+        
           <iodevices>/mnt/joe</iodevices>
+          
+          <!-- Directory named (under each iodevice) that used by each worker node to store data files. Needs
+           to be on the local file system. -->
           <store>storage</store>
         
-          <!-- Java home for each machine with its JVM options -->
+          <!-- Java home for each node. Can be overriden at node level. -->
           <java_home>/usr/lib/jvm/jdk1.7.0</java_home>
-          <java_opts>-Xmx1024m</java_opts>
         
            <!-- IP addresses of the master machine A -->
-          <master-node>
+          <master_node>
             <id>master</id>
-            <client-ip>128.195.52.177</client-ip>
-            <cluster-ip>192.168.100.0</cluster-ip>
-          </master-node>
+            <client_ip>128.195.52.177</client_ip>
+            <cluster_ip>192.168.100.0</cluster_ip>
+            <client_port>1098</client_port>
+            <cluster_port>1099</cluster_port>
+            <http_port>8888</http_port>
+          </master_node>
         
            <!-- IP address(es) of machine B -->
           <node>
             <id>nodeB</id>
-            <cluster-ip>192.168.100.1</cluster-ip>
+            <cluster_ip>192.168.100.1</cluster_ip>
           </node>
         
            <!-- IP address(es) of machine C -->
           <node>
             <id>nodeC</id>
-            <cluster-ip>192.168.100.2</cluster-ip>
+            <cluster_ip>192.168.100.2</cluster_ip>
           </node>
         </cluster>
 
@@ -474,14 +496,35 @@
 On the master machine, do the following:
 
 
-        machineA> ssh localhost
+        machineA> ssh 127.0.0.1
 
 
+If you get an output similar to one shown below, type "yes" and press enter.
+
+
+        The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
+        RSA key fingerprint is aa:7b:51:90:74:39:c4:f6:28:a2:9d:47:c2:8d:33:31.
+        Are you sure you want to continue connecting (yes/no)?
+
+If you are not prompted for a password, that is if you get an output similar to one shown below, it signifies that you already 
+have password-less SSH configured. 
+
+
+        $ ssh 127.0.0.1
+        Last login: Sat Mar 23 22:52:49 2013
+
+
+[Important: Password-less SSH requires the use of a (public,private) key-pair. The key-pair is located as a pair of files under
+ $HOME/.ssh directory. It is required that the (public,private) key-pair files have default names (id_rsa.pub, id_rsa) respectively. 
+ If you are using different names, please rename the files to use the default names]
+
 If you are prompted for a password, execute the following
 
 
         machineA> ssh-keygen -t rsa -P ""
         machineA> cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
+        machineA> chmod 700  $HOME/.ssh/authorized_keys
+        
 
 
 If $HOME is not on the NFS, copy the id_rsa.pub to the directory ~/.ssh (login with the same account) on each machine, and then do the following on each machine. (Notice that this step is not needed if the folder ".ssh" is on the NFS and can be accessed by all the nodes.)
@@ -489,12 +532,13 @@
 
         cd ~/.ssh
         cat id_rsa.pub >> authorized_keys
+        chmod 700  $HOME/.ssh/authorized_keys
+         
+
+Then run the following step again and type "yes" if prompted:
 
 
-Then run the following step again and type "Yes" if promoted:
-
-
-        machineA> ssh localhost
+        machineA> ssh 127.0.0.1
 
 ### Step (3): Configuring Managix ###
 
@@ -530,7 +574,7 @@
 We shall now use the `create` command to create an ASTERIX instance called "rainbow_asterix". In doing so, we shall use the cluster configuration file that was auto-generated by Managix.
 
 
-        machineA> managix create -n rainbow_asterix -c $MANAGIX_HOME/clusters/rainbow/rainbow.xml
+        machineA> managix create -n rainbow_asterix -c $MANAGIX_HOME/clusters/rainbow.xml
 
 
 If the response message does not have warning, then Congratulations! You have successfully installed Asterix on this cluster of machines!
@@ -554,6 +598,7 @@
 <tr><td><a href="#Delete_Command"              >delete</a></td>   <td>Deletes an Asterix instance.</td></tr>
 <tr><td><a href="#Configuring_Managix"         >validate</a></td> <td>Validates the installer/cluster configuration.</td></tr>
 <tr><td><a href="#Configuring_Managix"         >configure</a></td><td>Auto generate configuration for an Asterix instance.</td></tr>
+<tr><td><a href="#Log_Command"                 >log</a></td><td>Produces a zip archive containing log files from each node in an AsterixDB instance.</td></tr>
 <tr><td><a href="#Shutdown_Command"            >shutdown</a></td> <td>Shutdown the installer service.</td></tr>
 </table>
 
@@ -735,6 +780,25 @@
 
 You can start the ASTERIX instance by using the start command.
 
+##### Log Command #####
+
+The `log` command allows you to collect the log files coresponding to each node of an AsterixDB instance into a zip archive. 
+The zip archive is produced on the local file system of the machine running managix. 
+
+          $ managix help -cmd log
+        
+          Creates a zip archive containing log files corresponding to each worker node (NC) and the master (CC)  for an AsterixDB instance
+
+          Available arguments/options
+          -n name of the AsterixDB instance. 
+          -d destination directory for producing the zip archive. Defaults to $MANAGIX_HOME/logdump.
+         
+The following is an example showing the use of the log command. 
+
+         $ managix log -n my_asterix -d  /Users/joe/logdump
+         INFO: Log zip archive created at /Users/joe/logdump/log_Thu_Jun_06_00:53:51_PDT_2013.zip
+
+
 ##### Delete Command #####
 As the name suggests, the `delete` command permanently removes an ASTERIX instance by cleaning up all associated data/artifacts. The usage can be looked up by executing the following:
 
@@ -775,34 +839,44 @@
 ## Section 5: Frequently Asked Questions ##
 
 
-*Question*
-What is meant by the "UNUSABLE" state in the lifecycle of  an ASTERIX instance ?
+##### Question #####
+What happens if a machine acting as a node in the Asterix cluster becomes unreachable for some reason (network partition/machine failure) ?
 
+##### Answer #####
+When a node leaves the Asterix cluster, the AsterixDB instance transits to an 'UNUSABLE' state, indicating that it is no longer
+available for serving queries. To know which set of node(s) left the cluster, run the describe command with -admin flag. 
 
-*Answer*
-When Managix fails to start a required process (CC/NC), the instance transits to an UNUSABLE state.
-The reason for the failure needs to be looked up in the logs.
-Before we attempt to start the instance again, any processes that got launched
-as part of failed attempt must be stopped. No other operation except "stop" is supported in the UNUSABLE state.
+        $ $MANAGIX_HOME/bin/managix describe -n <name of the AsterixDB instance>-admin
+        
+Above command will show the state of AsterixDB instance and list the set of nodes that have left the cluster.           
 
-Get rid of the started processes:-
+The failed node must be brought back to re-join the cluster. Once done, you may bring back the 
+instance to an 'ACTIVE' state by executing the following sequence. 
+
+1) Get rid of the Asterix processes running on the nodes in the cluster:-
 
         $MANAGIX_HOME/bin/managix stop -n my_asterix
 
 
-Any processes associated with the instance are killed and the instance moves to the INACTIVE state.
-You may now delete the instance by executing the following
+The processes associated with the instance are terminated and the instance moves to the INACTIVE state.
+
+2) Start the AsterixDB instance using the start command.
+
+        $MANAGIX_HOME/bin/managix start -n <name of your AsterixDB instance>
 
 
-        $MANAGIX_HOME/bin/managix delete -n <name of your ASTERIX instance>
+##### Question #####
+Do I need to create all the directories/paths I put into the cluster configuration XML ?
+
+##### Answer ##### 
+Managix will create a path if it is not existing. It does so using the user account mentioned in the cluster configuration xml. 
+Please ensure that the user account has appropriate permissions for creating the missing paths. 
 
 
-Note that above would remove all traces of the instance including the logs and thus the reason for the failed attempt.
+##### Question ##### 
 
-OR
+Should MANAGIX_HOME be on the network file system (NFS) ?
 
-make a subsequent attempt to start the instance if you realized a mistake in the cluster configuration XML and have corrected it. To start the instance, we execute the following.
-
-
-        $MANAGIX_HOME/bin/managix start -n <name of your ASTERIX instance>
-
+##### Answer #####
+It is recommended that MANAGIX_HOME is not on the NFS. Managix produces artifacts/logs on disk which are not required to be shared. 
+As such an overhead in creating the artifacts/logs on the NFS should be avoided.
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index 715448d..aa976f8 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -328,9 +328,10 @@
     }
 
     private static void enlistMetadataDataset(IMetadataIndex index, boolean create) throws Exception {
-        String filePath = IndexFileNameUtil.prepareFileName(
-                metadataStore + File.separator + index.getFileNameRelativePath(),
-                runtimeContext.getMetaDataIODeviceId());
+        String filePath = ioManager.getIODevices().get(runtimeContext.getMetaDataIODeviceId()).getPath()
+                + File.separator
+                + IndexFileNameUtil.prepareFileName(metadataStore + File.separator + index.getFileNameRelativePath(),
+                        runtimeContext.getMetaDataIODeviceId());
         FileReference file = new FileReference(new File(filePath));
         IVirtualBufferCache virtualBufferCache = runtimeContext.getVirtualBufferCache(index.getDatasetId().getId());
         ITypeTraits[] typeTraits = index.getTypeTraits();
@@ -343,32 +344,28 @@
         ILSMOperationTracker opTracker = index.isPrimaryIndex() ? runtimeContext.getLSMBTreeOperationTracker(index
                 .getDatasetId().getId()) : new BaseOperationTracker(LSMBTreeIOOperationCallbackFactory.INSTANCE);
         if (create) {
-            lsmBtree = LSMBTreeUtils.createLSMTree(virtualBufferCache, ioManager, file, bufferCache, fileMapProvider,
-                    typeTraits, comparatorFactories, bloomFilterKeyFields,
-                    runtimeContext.getBloomFilterFalsePositiveRate(), runtimeContext.getLSMMergePolicy(), opTracker,
-                    runtimeContext.getLSMIOScheduler(), rtcProvider, runtimeContext.getMetaDataIODeviceId());
+            lsmBtree = LSMBTreeUtils.createLSMTree(virtualBufferCache, file, bufferCache, fileMapProvider, typeTraits,
+                    comparatorFactories, bloomFilterKeyFields, runtimeContext.getBloomFilterFalsePositiveRate(),
+                    runtimeContext.getLSMMergePolicy(), opTracker, runtimeContext.getLSMIOScheduler(), rtcProvider);
             lsmBtree.create();
             resourceID = runtimeContext.getResourceIdFactory().createId();
             ILocalResourceMetadata localResourceMetadata = new LSMBTreeLocalResourceMetadata(typeTraits,
-                    comparatorFactories, bloomFilterKeyFields, index.isPrimaryIndex(),
-                    runtimeContext.getMetaDataIODeviceId(), index.getDatasetId().getId());
+                    comparatorFactories, bloomFilterKeyFields, index.isPrimaryIndex(), index.getDatasetId().getId());
             ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
                     localResourceMetadata, LocalResource.LSMBTreeResource);
             ILocalResourceFactory localResourceFactory = localResourceFactoryProvider.getLocalResourceFactory();
-            localResourceRepository.insert(
-                    localResourceFactory.createLocalResource(resourceID, file.getFile().getPath(), 0),
-                    runtimeContext.getMetaDataIODeviceId());
+            localResourceRepository.insert(localResourceFactory.createLocalResource(resourceID, file.getFile()
+                    .getPath(), 0));
             indexLifecycleManager.register(resourceID, lsmBtree);
         } else {
             resourceID = localResourceRepository.getResourceByName(file.getFile().getPath()).getResourceId();
             lsmBtree = (LSMBTree) indexLifecycleManager.getIndex(resourceID);
             if (lsmBtree == null) {
-                lsmBtree = LSMBTreeUtils.createLSMTree(virtualBufferCache, ioManager, file, bufferCache,
-                        fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
+                lsmBtree = LSMBTreeUtils.createLSMTree(virtualBufferCache, file, bufferCache, fileMapProvider,
+                        typeTraits, comparatorFactories, bloomFilterKeyFields,
                         runtimeContext.getBloomFilterFalsePositiveRate(), runtimeContext.getLSMMergePolicy(),
                         opTracker, runtimeContext.getLSMIOScheduler(),
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
-                        runtimeContext.getMetaDataIODeviceId());
+                        AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER);
                 indexLifecycleManager.register(resourceID, lsmBtree);
             }
         }
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 51ab213..1ade7ef 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
@@ -575,9 +575,11 @@
                     appContext.getStorageManagerInterface(), appContext.getIndexLifecycleManagerProvider(), spPc.first,
                     typeTraits, comparatorFactories, bloomFilterKeyFields, lowKeyFields, highKeyFields,
                     lowKeyInclusive, highKeyInclusive, new LSMBTreeDataflowHelperFactory(
-                            new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()), rtcProvider, rtcProvider,
-                            rtcProvider, rtcProvider, storageProperties.getBloomFilterFalsePositiveRate()),
-                    retainInput, searchCallbackFactory);
+                            new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()), rtcProvider,
+                            isSecondary ? AsterixRuntimeComponentsProvider.LSMBTREE_SECONDARY_PROVIDER
+                                    : new PrimaryIndexOperationTrackerProvider(dataset.getDatasetId()), rtcProvider,
+                            rtcProvider, storageProperties.getBloomFilterFalsePositiveRate()), retainInput,
+                    searchCallbackFactory);
 
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeSearchOp, spPc.second);
 
@@ -788,13 +790,7 @@
                     dataSource.getId().getDataverseName(), datasetName, indexName);
             IAsterixApplicationContextInfo appContext = (IAsterixApplicationContextInfo) context.getAppContext();
 
-            String numElementsHintString = dataset.getHints().get("CARDINALITY");
-            long numElementsHint;
-            if (numElementsHintString == null) {
-                numElementsHint = DatasetCardinalityHint.DEFAULT;
-            } else {
-                numElementsHint = Long.parseLong(dataset.getHints().get("CARDINALITY"));
-            }
+            long numElementsHint = getCardinalityPerPartitionHint(dataset);
 
             // TODO
             // figure out the right behavior of the bulkload and then give the
@@ -804,8 +800,8 @@
             TreeIndexBulkLoadOperatorDescriptor btreeBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
                     appContext.getStorageManagerInterface(), appContext.getIndexLifecycleManagerProvider(),
                     splitsAndConstraint.first, typeTraits, comparatorFactories, bloomFilterKeyFields, fieldPermutation,
-                    GlobalConfig.DEFAULT_BTREE_FILL_FACTOR, false, numElementsHint, new LSMBTreeDataflowHelperFactory(
-                            new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()),
+                    GlobalConfig.DEFAULT_BTREE_FILL_FACTOR, false, numElementsHint, true,
+                    new LSMBTreeDataflowHelperFactory(new AsterixVirtualBufferCacheProvider(dataset.getDatasetId()),
                             AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
                             new PrimaryIndexOperationTrackerProvider(dataset.getDatasetId()),
                             AsterixRuntimeComponentsProvider.LSMBTREE_PRIMARY_PROVIDER,
@@ -936,10 +932,10 @@
                 return getRTreeDmlRuntime(dataverseName, datasetName, indexName, propagatedSchema, typeEnv,
                         primaryKeys, secondaryKeys, filterFactory, recordDesc, context, spec, indexOp);
             }
-            case WORD_INVIX:
-            case NGRAM_INVIX:
-            case FUZZY_WORD_INVIX:
-            case FUZZY_NGRAM_INVIX: {
+            case SINGLE_PARTITION_WORD_INVIX:
+            case SINGLE_PARTITION_NGRAM_INVIX:
+            case LENGTH_PARTITIONED_WORD_INVIX:
+            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                 return getInvertedIndexDmlRuntime(dataverseName, datasetName, indexName, propagatedSchema, typeEnv,
                         primaryKeys, secondaryKeys, filterFactory, recordDesc, context, spec, indexOp,
                         secondaryIndex.getIndexType());
@@ -1115,7 +1111,8 @@
         }
 
         boolean isPartitioned;
-        if (indexType == IndexType.FUZZY_WORD_INVIX || indexType == IndexType.FUZZY_NGRAM_INVIX) {
+        if (indexType == IndexType.LENGTH_PARTITIONED_WORD_INVIX
+                || indexType == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX) {
             isPartitioned = true;
         } else {
             isPartitioned = false;
@@ -1326,6 +1323,34 @@
         }
     }
 
+    /**
+     * Calculate an estimate size of the bloom filter. Note that this is an estimation which assumes that the data
+     * is going to be uniformly distributed across all partitions.
+     * 
+     * @param dataset
+     * @return Number of elements that will be used to create a bloom filter per dataset per partition
+     * @throws MetadataException
+     * @throws AlgebricksException
+     */
+    public long getCardinalityPerPartitionHint(Dataset dataset) throws MetadataException, AlgebricksException {
+        String numElementsHintString = dataset.getHints().get(DatasetCardinalityHint.NAME);
+        long numElementsHint;
+        if (numElementsHintString == null) {
+            numElementsHint = DatasetCardinalityHint.DEFAULT;
+        } else {
+            numElementsHint = Long.parseLong(numElementsHintString);
+        }
+
+        int numPartitions = 0;
+        InternalDatasetDetails datasetDetails = (InternalDatasetDetails) dataset.getDatasetDetails();
+        List<String> nodeGroup = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, datasetDetails.getNodeGroupName())
+                .getNodeNames();
+        for (String nd : nodeGroup) {
+            numPartitions += AsterixClusterProperties.INSTANCE.getNumberOfIODevices(nd);
+        }
+        return numElementsHint /= numPartitions;
+    }
+
     @Override
     public IFunctionInfo lookupFunction(FunctionIdentifier fid) {
         return AsterixBuiltinFunctions.lookupFunction(fid);
@@ -1365,9 +1390,10 @@
             }
             for (int i = 0; i < nodeStores.length; i++) {
                 int numIODevices = AsterixClusterProperties.INSTANCE.getNumberOfIODevices(node);
+                String[] ioDevices = AsterixClusterProperties.INSTANCE.getIODevices(node);
                 for (int j = 0; j < nodeStores.length; j++) {
                     for (int k = 0; k < numIODevices; k++) {
-                        File f = new File(nodeStores[j] + File.separator + relPathFile);
+                        File f = new File(ioDevices[k] + File.separator + nodeStores[j] + File.separator + relPathFile);
                         splits.add(new FileSplit(node, new FileReference(f), k));
                     }
                 }
@@ -1405,9 +1431,11 @@
                     } else {
                         numIODevices = AsterixClusterProperties.INSTANCE.getNumberOfIODevices(nd);
                     }
+                    String[] ioDevices = AsterixClusterProperties.INSTANCE.getIODevices(nd);
                     for (int j = 0; j < nodeStores.length; j++) {
                         for (int k = 0; k < numIODevices; k++) {
-                            File f = new File(nodeStores[j] + File.separator + relPathFile);
+                            File f = new File(ioDevices[k] + File.separator + nodeStores[j] + File.separator
+                                    + relPathFile);
                             splitArray.add(new FileSplit(nd, new FileReference(f), k));
                         }
                     }
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 7d20886..0319c7c 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
@@ -329,17 +329,17 @@
                                     + fieldType.getTypeTag() + " cannot be indexed using the RTree index.");
                     }
                     break;
-                case FUZZY_NGRAM_INVIX:
+                case LENGTH_PARTITIONED_NGRAM_INVIX:
                     switch (fieldType.getTypeTag()) {
                         case STRING:
                         case UNION:
                             break;
                         default:
                             throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
-                                    + fieldType.getTypeTag() + " cannot be indexed using the Fuzzy N-Gram index.");
+                                    + fieldType.getTypeTag() + " cannot be indexed using the Length Partitioned N-Gram index.");
                     }
                     break;
-                case FUZZY_WORD_INVIX:
+                case LENGTH_PARTITIONED_WORD_INVIX:
                     switch (fieldType.getTypeTag()) {
                         case STRING:
                         case UNORDEREDLIST:
@@ -348,10 +348,10 @@
                             break;
                         default:
                             throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
-                                    + fieldType.getTypeTag() + " cannot be indexed using the Fuzzy Keyword index.");
+                                    + fieldType.getTypeTag() + " cannot be indexed using the Length Partitioned Keyword index.");
                     }
                     break;
-                case NGRAM_INVIX:
+                case SINGLE_PARTITION_NGRAM_INVIX:
                     switch (fieldType.getTypeTag()) {
                         case STRING:
                         case UNION:
@@ -361,7 +361,7 @@
                                     + fieldType.getTypeTag() + " cannot be indexed using the N-Gram index.");
                     }
                     break;
-                case WORD_INVIX:
+                case SINGLE_PARTITION_WORD_INVIX:
                     switch (fieldType.getTypeTag()) {
                         case STRING:
                         case UNORDEREDLIST:
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/AsterixClusterProperties.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/AsterixClusterProperties.java
index b9282b3..6e6e09a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/AsterixClusterProperties.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/AsterixClusterProperties.java
@@ -78,6 +78,26 @@
         }
         return ncConfig.get(IO_DEVICES).split(",").length;
     }
+    
+    /**
+     * Returns the IO devices configured for a Node Controller
+     * 
+     * @param nodeId
+     *            unique identifier of the Node Controller
+     * @return a list of IO devices. null if node id is not valid. A node id is not valid
+     *         if it does not correspond to the set of registered Node Controllers.
+     */
+    public String[] getIODevices(String nodeId) {
+        Map<String, String> ncConfig = ncConfiguration.get(nodeId);
+        if (ncConfig == null) {
+            if (LOGGER.isLoggable(Level.WARNING)) {
+                LOGGER.warning("Configuration parameters for nodeId" + nodeId
+                        + " not found. The node has not joined yet or has left.");
+            }
+            return null;
+        }
+        return ncConfig.get(IO_DEVICES).split(",");
+    }
 
     public State getState() {
         return state;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/NonTaggedFormatUtil.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/NonTaggedFormatUtil.java
index 86c1346..c12d8b8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/NonTaggedFormatUtil.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/util/NonTaggedFormatUtil.java
@@ -191,12 +191,12 @@
     public static IBinaryTokenizerFactory getBinaryTokenizerFactory(ATypeTag keyType, IndexType indexType,
             int gramLength) throws AlgebricksException {
         switch (indexType) {
-            case WORD_INVIX:
-            case FUZZY_WORD_INVIX: {
+            case SINGLE_PARTITION_WORD_INVIX:
+            case LENGTH_PARTITIONED_WORD_INVIX: {
                 return AqlBinaryTokenizerFactoryProvider.INSTANCE.getWordTokenizerFactory(keyType, false);
             }
-            case NGRAM_INVIX:
-            case FUZZY_NGRAM_INVIX: {
+            case SINGLE_PARTITION_NGRAM_INVIX:
+            case LENGTH_PARTITIONED_NGRAM_INVIX: {
                 return AqlBinaryTokenizerFactoryProvider.INSTANCE.getNGramTokenizerFactory(keyType, gramLength, true,
                         false);
             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AbstractTupleParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AbstractTupleParser.java
index f2d9384..2322338 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AbstractTupleParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AbstractTupleParser.java
@@ -43,7 +43,7 @@
     protected final ARecordType recType;
     protected final IHyracksTaskContext ctx;
 
-    public AbstractTupleParser(IHyracksTaskContext ctx, ARecordType recType) {
+    public AbstractTupleParser(IHyracksTaskContext ctx, ARecordType recType) throws HyracksDataException {
         appender = new FrameTupleAppender(ctx.getFrameSize());
         frame = ctx.allocateFrame();
         this.recType = recType;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
index b4ca5fe..5c84fe4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
@@ -16,6 +16,7 @@
 
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParser;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParserFactory;
 
@@ -34,7 +35,7 @@
     }
 
     @Override
-    public ITupleParser createTupleParser(final IHyracksTaskContext ctx) {
+    public ITupleParser createTupleParser(final IHyracksTaskContext ctx) throws HyracksDataException {
         return new AdmTupleParser(ctx, recType);
     }
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmTupleParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmTupleParser.java
index a91f142..7cb9bb0 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmTupleParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmTupleParser.java
@@ -16,6 +16,7 @@
 
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * An extension of AbstractTupleParser that provides functionality for
@@ -23,7 +24,7 @@
  */
 public class AdmTupleParser extends AbstractTupleParser {
 
-    public AdmTupleParser(IHyracksTaskContext ctx, ARecordType recType) {
+    public AdmTupleParser(IHyracksTaskContext ctx, ARecordType recType) throws HyracksDataException {
         super(ctx, recType);
     }
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataTupleParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataTupleParser.java
index 96adb5a..9f5e6e9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataTupleParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataTupleParser.java
@@ -16,6 +16,7 @@
 
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.dataflow.common.data.parsers.IValueParserFactory;
 
 /**
@@ -27,7 +28,7 @@
     private final DelimitedDataParser dataParser;
 
     public DelimitedDataTupleParser(IHyracksTaskContext ctx, ARecordType recType,
-            IValueParserFactory[] valueParserFactories, char fieldDelimter) {
+            IValueParserFactory[] valueParserFactories, char fieldDelimter) throws HyracksDataException {
         super(ctx, recType);
         dataParser = new DelimitedDataParser(recType, valueParserFactories, fieldDelimter);
     }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
index 167ff8a..6c56094 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
@@ -16,6 +16,7 @@
 
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.dataflow.common.data.parsers.IValueParserFactory;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParser;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParserFactory;
@@ -38,7 +39,7 @@
     }
 
     @Override
-    public ITupleParser createTupleParser(final IHyracksTaskContext ctx) {
+    public ITupleParser createTupleParser(final IHyracksTaskContext ctx) throws HyracksDataException {
         return new DelimitedDataTupleParser(ctx, recordType, valueParserFactories, fieldDelimiter);
     }
 
diff --git a/asterix-tools/src/main/java/edu/uci/ics/asterix/tools/external/data/RateControlledFileSystemBasedAdapter.java b/asterix-tools/src/main/java/edu/uci/ics/asterix/tools/external/data/RateControlledFileSystemBasedAdapter.java
index 49098a4..e037ec6 100644
--- a/asterix-tools/src/main/java/edu/uci/ics/asterix/tools/external/data/RateControlledFileSystemBasedAdapter.java
+++ b/asterix-tools/src/main/java/edu/uci/ics/asterix/tools/external/data/RateControlledFileSystemBasedAdapter.java
@@ -92,7 +92,8 @@
 
     }
 
-    protected ITupleParser getRateControlledDelimitedDataTupleParser(ARecordType recordType) throws AsterixException {
+    protected ITupleParser getRateControlledDelimitedDataTupleParser(ARecordType recordType) throws AsterixException,
+            HyracksDataException {
         ITupleParser parser;
         int n = recordType.getFieldTypes().length;
         IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];
@@ -171,7 +172,7 @@
     }
 
     @Override
-    public ITupleParser createTupleParser(IHyracksTaskContext ctx) {
+    public ITupleParser createTupleParser(IHyracksTaskContext ctx) throws HyracksDataException {
         return new RateControlledTupleParser(ctx, recordType, dataParser, configuration);
     }
 
@@ -187,7 +188,7 @@
     public static final String INTER_TUPLE_INTERVAL = "tuple-interval";
 
     public RateControlledTupleParser(IHyracksTaskContext ctx, ARecordType recType, IDataParser dataParser,
-            Map<String, Object> configuration) {
+            Map<String, Object> configuration) throws HyracksDataException {
         super(ctx, recType);
         this.dataParser = dataParser;
         String propValue = (String) configuration.get(INTER_TUPLE_INTERVAL);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMBTreeLocalResourceMetadata.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMBTreeLocalResourceMetadata.java
index d42c6a0..8ce0174 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMBTreeLocalResourceMetadata.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMBTreeLocalResourceMetadata.java
@@ -22,7 +22,6 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.api.io.FileReference;
-import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;
 import edu.uci.ics.hyracks.storage.am.lsm.btree.impls.LSMBTree;
 import edu.uci.ics.hyracks.storage.am.lsm.btree.util.LSMBTreeUtils;
 import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMIndex;
@@ -36,27 +35,14 @@
     private final IBinaryComparatorFactory[] cmpFactories;
     private final int[] bloomFilterKeyFields;
     private final boolean isPrimary;
-    private FileSplit[] fileSplits;
-    private int ioDeviceID;
 
     public LSMBTreeLocalResourceMetadata(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
-            int[] bloomFilterKeyFields, boolean isPrimary, FileSplit[] fileSplits, int datasetID) {
+            int[] bloomFilterKeyFields, boolean isPrimary, int datasetID) {
         super(datasetID);
         this.typeTraits = typeTraits;
         this.cmpFactories = cmpFactories;
         this.bloomFilterKeyFields = bloomFilterKeyFields;
         this.isPrimary = isPrimary;
-        this.fileSplits = fileSplits;
-    }
-
-    public LSMBTreeLocalResourceMetadata(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
-            int[] bloomFilterKeyFields, boolean isPrimary, int ioDeviceID, int datasetID) {
-        super(datasetID);
-        this.typeTraits = typeTraits;
-        this.cmpFactories = cmpFactories;
-        this.bloomFilterKeyFields = bloomFilterKeyFields;
-        this.isPrimary = isPrimary;
-        this.ioDeviceID = ioDeviceID;
     }
 
     @Override
@@ -64,14 +50,12 @@
             int partition) {
         FileReference file = new FileReference(new File(filePath));
         IVirtualBufferCache virtualBufferCache = runtimeContextProvider.getVirtualBufferCache(datasetID);
-        LSMBTree lsmBTree = LSMBTreeUtils.createLSMTree(virtualBufferCache, runtimeContextProvider.getIOManager(),
-                file, runtimeContextProvider.getBufferCache(), runtimeContextProvider.getFileMapManager(), typeTraits,
-                cmpFactories, bloomFilterKeyFields, runtimeContextProvider.getBloomFilterFalsePositiveRate(),
-                runtimeContextProvider.getLSMMergePolicy(),
-                isPrimary ? runtimeContextProvider.getLSMBTreeOperationTracker(datasetID) : new BaseOperationTracker(
-                        LSMBTreeIOOperationCallbackFactory.INSTANCE), runtimeContextProvider.getLSMIOScheduler(),
-                runtimeContextProvider.getLSMBTreeIOOperationCallbackProvider(isPrimary),
-                fileSplits == null ? ioDeviceID : fileSplits[partition].getIODeviceId());
+        LSMBTree lsmBTree = LSMBTreeUtils.createLSMTree(virtualBufferCache, file, runtimeContextProvider
+                .getBufferCache(), runtimeContextProvider.getFileMapManager(), typeTraits, cmpFactories,
+                bloomFilterKeyFields, runtimeContextProvider.getBloomFilterFalsePositiveRate(), runtimeContextProvider
+                        .getLSMMergePolicy(), isPrimary ? runtimeContextProvider.getLSMBTreeOperationTracker(datasetID)
+                        : new BaseOperationTracker(LSMBTreeIOOperationCallbackFactory.INSTANCE), runtimeContextProvider
+                        .getLSMIOScheduler(), runtimeContextProvider.getLSMBTreeIOOperationCallbackProvider(isPrimary));
         return lsmBTree;
     }
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
index 0357a57..b3da3ee 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
@@ -20,7 +20,6 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;
 import edu.uci.ics.hyracks.storage.am.common.api.IndexException;
 import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMIndex;
 import edu.uci.ics.hyracks.storage.am.lsm.common.api.IVirtualBufferCache;
@@ -37,12 +36,11 @@
     private final IBinaryComparatorFactory[] tokenCmpFactories;
     private final IBinaryTokenizerFactory tokenizerFactory;
     private final boolean isPartitioned;
-    private final FileSplit[] fileSplits;
 
     public LSMInvertedIndexLocalResourceMetadata(ITypeTraits[] invListTypeTraits,
             IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits,
             IBinaryComparatorFactory[] tokenCmpFactories, IBinaryTokenizerFactory tokenizerFactory,
-            boolean isPartitioned, FileSplit[] fileSplits, int datasetID) {
+            boolean isPartitioned, int datasetID) {
         super(datasetID);
         this.invListTypeTraits = invListTypeTraits;
         this.invListCmpFactories = invListCmpFactories;
@@ -50,7 +48,6 @@
         this.tokenCmpFactories = tokenCmpFactories;
         this.tokenizerFactory = tokenizerFactory;
         this.isPartitioned = isPartitioned;
-        this.fileSplits = fileSplits;
     }
 
     @Override
@@ -61,23 +58,21 @@
             if (isPartitioned) {
                 return InvertedIndexUtils.createPartitionedLSMInvertedIndex(virtualBufferCache, runtimeContextProvider
                         .getFileMapManager(), invListTypeTraits, invListCmpFactories, tokenTypeTraits,
-                        tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
-                        runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider
-                                .getBloomFilterFalsePositiveRate(), runtimeContextProvider.getLSMMergePolicy(),
-                        new BaseOperationTracker(LSMInvertedIndexIOOperationCallbackFactory.INSTANCE),
-                        runtimeContextProvider.getLSMIOScheduler(), runtimeContextProvider
-                                .getLSMInvertedIndexIOOperationCallbackProvider(), fileSplits[partition]
-                                .getIODeviceId());
+                        tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(), filePath,
+                        runtimeContextProvider.getBloomFilterFalsePositiveRate(), runtimeContextProvider
+                                .getLSMMergePolicy(), new BaseOperationTracker(
+                                LSMInvertedIndexIOOperationCallbackFactory.INSTANCE), runtimeContextProvider
+                                .getLSMIOScheduler(), runtimeContextProvider
+                                .getLSMInvertedIndexIOOperationCallbackProvider());
             } else {
                 return InvertedIndexUtils.createLSMInvertedIndex(virtualBufferCache, runtimeContextProvider
                         .getFileMapManager(), invListTypeTraits, invListCmpFactories, tokenTypeTraits,
-                        tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
-                        runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider
-                                .getBloomFilterFalsePositiveRate(), runtimeContextProvider.getLSMMergePolicy(),
-                        new BaseOperationTracker(LSMInvertedIndexIOOperationCallbackFactory.INSTANCE),
-                        runtimeContextProvider.getLSMIOScheduler(), runtimeContextProvider
-                                .getLSMInvertedIndexIOOperationCallbackProvider(), fileSplits[partition]
-                                .getIODeviceId());
+                        tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(), filePath,
+                        runtimeContextProvider.getBloomFilterFalsePositiveRate(), runtimeContextProvider
+                                .getLSMMergePolicy(), new BaseOperationTracker(
+                                LSMInvertedIndexIOOperationCallbackFactory.INSTANCE), runtimeContextProvider
+                                .getLSMIOScheduler(), runtimeContextProvider
+                                .getLSMInvertedIndexIOOperationCallbackProvider());
             }
         } catch (IndexException e) {
             throw new HyracksDataException(e);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
index 86fa4af..9b9faef 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
@@ -24,7 +24,6 @@
 import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.api.io.FileReference;
-import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;
 import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
 import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
 import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMIndex;
@@ -42,12 +41,10 @@
     private final IPrimitiveValueProviderFactory[] valueProviderFactories;
     private final RTreePolicyType rtreePolicyType;
     private final ILinearizeComparatorFactory linearizeCmpFactory;
-    private final FileSplit[] fileSplits;
 
     public LSMRTreeLocalResourceMetadata(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] rtreeCmpFactories,
             IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories,
-            RTreePolicyType rtreePolicyType, ILinearizeComparatorFactory linearizeCmpFactory, FileSplit[] fileSplits,
-            int datasetID) {
+            RTreePolicyType rtreePolicyType, ILinearizeComparatorFactory linearizeCmpFactory, int datasetID) {
         super(datasetID);
         this.typeTraits = typeTraits;
         this.rtreeCmpFactories = rtreeCmpFactories;
@@ -55,7 +52,6 @@
         this.valueProviderFactories = valueProviderFactories;
         this.rtreePolicyType = rtreePolicyType;
         this.linearizeCmpFactory = linearizeCmpFactory;
-        this.fileSplits = fileSplits;
     }
 
     @Override
@@ -64,14 +60,12 @@
         FileReference file = new FileReference(new File(filePath));
         IVirtualBufferCache virtualBufferCache = runtimeContextProvider.getVirtualBufferCache(datasetID);
         try {
-            return LSMRTreeUtils.createLSMTree(virtualBufferCache, runtimeContextProvider.getIOManager(), file,
-                    runtimeContextProvider.getBufferCache(), runtimeContextProvider.getFileMapManager(), typeTraits,
-                    rtreeCmpFactories, btreeCmpFactories, valueProviderFactories, rtreePolicyType,
-                    runtimeContextProvider.getBloomFilterFalsePositiveRate(), runtimeContextProvider
-                            .getLSMMergePolicy(),
-                    new BaseOperationTracker(LSMRTreeIOOperationCallbackFactory.INSTANCE), runtimeContextProvider
-                            .getLSMIOScheduler(), runtimeContextProvider.getLSMRTreeIOOperationCallbackProvider(),
-                    linearizeCmpFactory, fileSplits[partition].getIODeviceId());
+            return LSMRTreeUtils.createLSMTree(virtualBufferCache, file, runtimeContextProvider.getBufferCache(),
+                    runtimeContextProvider.getFileMapManager(), typeTraits, rtreeCmpFactories, btreeCmpFactories,
+                    valueProviderFactories, rtreePolicyType, runtimeContextProvider.getBloomFilterFalsePositiveRate(),
+                    runtimeContextProvider.getLSMMergePolicy(), new BaseOperationTracker(
+                            LSMRTreeIOOperationCallbackFactory.INSTANCE), runtimeContextProvider.getLSMIOScheduler(),
+                    runtimeContextProvider.getLSMRTreeIOOperationCallbackProvider(), linearizeCmpFactory);
         } catch (TreeIndexException e) {
             throw new HyracksDataException(e);
         }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
index ace47a2..c11766a 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
@@ -104,7 +104,7 @@
                 }
                 LocalResource rootLocalResource = new LocalResource(ROOT_LOCAL_RESOURCE_ID, rootMetadataFileName, 0, 0,
                         mountedRootDir);
-                insert(rootLocalResource, i);
+                insert(rootLocalResource);
                 if (LOGGER.isLoggable(Level.INFO)) {
                     LOGGER.info("created the root-metadata-file: " + rootMetadataFileName);
                 }
@@ -206,7 +206,7 @@
     }
 
     @Override
-    public synchronized void insert(LocalResource resource, int ioDeviceId) throws HyracksDataException {
+    public synchronized void insert(LocalResource resource) throws HyracksDataException {
         long id = resource.getResourceId();
 
         if (id2ResourceMap.containsKey(id)) {
@@ -222,8 +222,7 @@
         ObjectOutputStream oosToFos = null;
 
         try {
-            fos = new FileOutputStream(getFileName(mountPoints[ioDeviceId], resource.getResourceName(),
-                    resource.getResourceId()));
+            fos = new FileOutputStream(getFileName(resource.getResourceName(), resource.getResourceId()));
             oosToFos = new ObjectOutputStream(fos);
             oosToFos.writeObject(resource);
             oosToFos.flush();
@@ -248,26 +247,26 @@
     }
 
     @Override
-    public synchronized void deleteResourceById(long id, int ioDeviceId) throws HyracksDataException {
+    public synchronized void deleteResourceById(long id) throws HyracksDataException {
         LocalResource resource = id2ResourceMap.get(id);
         if (resource == null) {
             throw new HyracksDataException("Resource doesn't exist");
         }
         id2ResourceMap.remove(id);
         name2ResourceMap.remove(resource.getResourceName());
-        File file = new File(getFileName(mountPoints[ioDeviceId], resource.getResourceName(), resource.getResourceId()));
+        File file = new File(getFileName(resource.getResourceName(), resource.getResourceId()));
         file.delete();
     }
 
     @Override
-    public synchronized void deleteResourceByName(String name, int ioDeviceId) throws HyracksDataException {
+    public synchronized void deleteResourceByName(String name) throws HyracksDataException {
         LocalResource resource = name2ResourceMap.get(name);
         if (resource == null) {
             throw new HyracksDataException("Resource doesn't exist");
         }
         id2ResourceMap.remove(resource.getResourceId());
         name2ResourceMap.remove(name);
-        File file = new File(getFileName(mountPoints[ioDeviceId], resource.getResourceName(), resource.getResourceId()));
+        File file = new File(getFileName(resource.getResourceName(), resource.getResourceId()));
         file.delete();
     }
 
@@ -280,16 +279,15 @@
         return resources;
     }
 
-    private String getFileName(String mountPoint, String baseDir, long resourceId) {
+    private String getFileName(String baseDir, long resourceId) {
 
         if (resourceId == ROOT_LOCAL_RESOURCE_ID) {
             return baseDir;
         } else {
-            String fileName = new String(mountPoint);
             if (!baseDir.endsWith(System.getProperty("file.separator"))) {
                 baseDir += System.getProperty("file.separator");
             }
-            fileName += baseDir + METADATA_FILE_NAME;
+            String fileName = new String(baseDir + METADATA_FILE_NAME);
             return fileName;
         }
     }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
index 021d9f4..16ffa69 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
@@ -73,10 +73,9 @@
         newTuple.resetByTupleOffset(logLocator.getBuffer().getByteBuffer(), offset);
         offset += newValueSize;
 
-        ILSMIndexAccessor indexAccessor = (ILSMIndexAccessor) index.createAccessor(NoOpOperationCallback.INSTANCE,
-                NoOpOperationCallback.INSTANCE);
-
         try {
+            ILSMIndexAccessor indexAccessor = (ILSMIndexAccessor) index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
+
             if (resourceType == ResourceType.LSM_BTREE) {
 
                 /* old operation */
@@ -145,10 +144,9 @@
         newTuple.resetByTupleOffset(logLocator.getBuffer().getByteBuffer(), offset);
         offset += newValueSize;
 
-        ILSMIndexAccessor indexAccessor = (ILSMIndexAccessor) index.createAccessor(NoOpOperationCallback.INSTANCE,
-                NoOpOperationCallback.INSTANCE);
-
         try {
+            ILSMIndexAccessor indexAccessor = (ILSMIndexAccessor) index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
+
             if (newOperation == IndexOperation.INSERT.ordinal()) {
                 indexAccessor.insert(newTuple);
             } else if (newOperation == IndexOperation.DELETE.ordinal()) {
diff --git a/pom.xml b/pom.xml
index 808f075..121b736 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,8 +21,8 @@
 	<packaging>pom</packaging>
 
     <properties>
-    	<algebricks.version>0.2.7-SNAPSHOT</algebricks.version>
-    	<hyracks.version>0.2.7-SNAPSHOT</hyracks.version>
+    	<algebricks.version>0.2.9-SNAPSHOT</algebricks.version>
+    	<hyracks.version>0.2.9-SNAPSHOT</hyracks.version>
     </properties>
 
 	<build>