Merge branch 'master' into westmann/docs
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 48f9e36..6edcc39 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
@@ -205,14 +205,16 @@
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
-                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages());
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate());
             } else {
                 dataflowHelperFactory = new PartitionedLSMInvertedIndexDataflowHelperFactory(
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
-                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages());
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate());
             }
             LSMInvertedIndexSearchOperatorDescriptor invIndexSearchOp = new LSMInvertedIndexSearchOperatorDescriptor(
                     jobSpec, queryField, appContext.getStorageManagerInterface(), secondarySplitsAndConstraint.first,
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
index 3dad464..dc86722 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
@@ -186,6 +186,8 @@
                 case DATE:
                 case TIME:
                 case DURATION:
+                case YEARMONTHDURATION:
+                case DAYTIMEDURATION:
                 case INTERVAL:
                 case POINT:
                 case POINT3D:
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 f769db3..e07c1d0 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
@@ -92,6 +92,7 @@
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions.FunctionNamespace;
 import edu.uci.ics.asterix.om.functions.AsterixFunctionInfo;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -506,10 +507,14 @@
         if (builtinAquafi != null) {
             fi = builtinAquafi;
         } else {
-            fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, functionName, arity);
+            fi = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(), functionName, arity);
             afi = AsterixBuiltinFunctions.lookupFunction(fi);
             if (afi == null) {
-                return null;
+                fi = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(), functionName, arity);
+                afi = AsterixBuiltinFunctions.lookupFunction(fi);
+                if (afi == null) {
+                    return null;
+                }
             }
         }
         if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
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 9f28113..92add99 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
@@ -89,6 +89,7 @@
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions.FunctionNamespace;
 import edu.uci.ics.asterix.om.functions.AsterixFunctionInfo;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -464,10 +465,14 @@
         if (builtinAquafi != null) {
             fi = builtinAquafi;
         } else {
-            fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, signature.getName());
+            fi = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(), signature.getName());
             FunctionIdentifier builtinAsterixFi = AsterixBuiltinFunctions.getBuiltinFunctionIdentifier(fi);
             if (builtinAsterixFi != null) {
                 fi = builtinAsterixFi;
+            } else {
+                fi = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(), signature.getName());
+                builtinAsterixFi = AsterixBuiltinFunctions.getBuiltinFunctionIdentifier(fi);
+                fi = builtinAsterixFi;
             }
         }
         AbstractFunctionCallExpression f;
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 6cf8d28..a91f2eb 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
@@ -35,10 +35,10 @@
 import edu.uci.ics.asterix.aql.expression.WhereClause;
 import edu.uci.ics.asterix.aql.literal.StringLiteral;
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.common.functions.FunctionSignature;
 import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -495,8 +495,8 @@
             LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg));
             arguments.add(argumentLiteral);
 
-            CallExpr callExpression = new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, "dataset", 1),
-                    arguments);
+            CallExpr callExpression = new CallExpr(new FunctionSignature(
+                    AsterixBuiltinFunctions.FunctionNamespace.ASTERIX_PUBLIC.name(), "dataset", 1), arguments);
             List<Clause> clauseList = new ArrayList<Clause>();
             Clause forClause = new ForClause(var, callExpression);
             clauseList.add(forClause);
diff --git a/asterix-app/.gitignore b/asterix-app/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/asterix-app/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/asterix-app/data/temporal/temporalData.json b/asterix-app/data/temporal/temporalData.json
index 5b3a0f5..bedf2c7 100644
--- a/asterix-app/data/temporal/temporalData.json
+++ b/asterix-app/data/temporal/temporalData.json
@@ -1,3 +1,4 @@
 {"id": "001", "dateField": date("-2012-12-12"), "dateFieldPlus": date("0990-01-01"), "timeField": time("23:49:12.39Z"), "timeFieldPlus": time("03:23:12.2"), "datetimeField": datetime("2012-12-12T00:00:00.001"), "datetimeFieldPlus": datetime("-00130810T221015398"), "durationField": duration("P20Y19DT3H74M23.34S"), "durationFieldPlus": duration("-P2MT4M300.68S"), "intervalField": interval-datetime("2012-12-12T00:00:00.001,20130810T221015398") }
 {"id": "002", "timeField": time("12:12:12.219+08:00"), "timeField2": time("13:13:13.321-08:00"), "datetimeField": datetime("19201220T232918478-1200"), "intervalField": interval-time("12:29:30+08:00, 235959999-0800") }
-{"id": "003", "durationField": duration("-P27Y48DT2400H"), "datetimeField": datetime("-0290-03-23T00:59:48.999+07:00"), "intervalField": interval-date("-2012-03-17, 2013-04-01"), "intervalPlus": interval-time("19:23:32.328Z,23:20:20") }
\ No newline at end of file
+{"id": "003", "durationField": duration("-P27Y48DT2400H"), "datetimeField": datetime("-0290-03-23T00:59:48.999+07:00"), "intervalField": interval-date("-2012-03-17, 2013-04-01"), "intervalPlus": interval-time("19:23:32.328Z,23:20:20") }
+{"id": "003", "dayTimeDurationField": day-time-duration("-P48DT2400H"), "yearMonthDurationField": year-month-duration("P27Y50M") }
\ No newline at end of file
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 438bc74..e1114eb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -181,7 +181,7 @@
                 }
             }
         }
-        AqlRewriter rw = new AqlRewriter(declaredFunctions, q, metadataProvider.getMetadataTxnContext());
+        AqlRewriter rw = new AqlRewriter(declaredFunctions, q, metadataProvider);
         rw.rewrite();
         Query rwQ = rw.getExpr();
         return new Pair(rwQ, rw.getVarCounter());
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 66a3980..d4e5e22 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
@@ -59,6 +59,7 @@
 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;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -1358,6 +1359,8 @@
             }
             bfs.initialize(metadataProvider.getMetadataTxnContext(), dataset);
             cbfs.setQuery(bfs.getQuery());
+            metadataProvider.getConfig().put(FunctionUtils.IMPORT_PRIVATE_FUNCTIONS, "" + Boolean.TRUE);
+
             JobSpecification compiled = rewriteCompileQuery(metadataProvider, bfs.getQuery(), cbfs);
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
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 25a2551..3600bea 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
@@ -128,7 +128,8 @@
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
-                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()));
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()));
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(specPrimary, primaryBtreeDrop,
                 splitsAndConstraint.second);
 
@@ -181,8 +182,9 @@
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                localResourceFactoryProvider, NoOpOperationCallbackFactory.INSTANCE);
+                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), localResourceFactoryProvider,
+                NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, indexCreateOp,
                 splitsAndConstraint.second);
         spec.addRoot(indexCreateOp);
@@ -266,13 +268,13 @@
         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(AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                GlobalConfig.DEFAULT_BTREE_FILL_FACTOR, false, numElementsHint, new LSMBTreeDataflowHelperFactory(
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                NoOpOperationCallbackFactory.INSTANCE);
+                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, btreeBulkLoad,
                 splitsAndConstraint.second);
 
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/IndexOperations.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/IndexOperations.java
index cec97ad..67bdabb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/IndexOperations.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/IndexOperations.java
@@ -57,7 +57,8 @@
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
-                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()));
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()));
         AlgebricksPartitionConstraintHelper
                 .setPartitionConstraintInJobSpec(spec, btreeDrop, splitsAndConstraint.second);
         spec.addRoot(btreeDrop);
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 958f8d1..c3a2c01 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
@@ -47,13 +47,14 @@
         TreeIndexCreateOperatorDescriptor secondaryIndexCreateOp = new TreeIndexCreateOperatorDescriptor(spec,
                 AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER, AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER,
                 secondaryFileSplitProvider, secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories,
-                secondaryBloomFilterKeyFields,
-                new LSMBTreeDataflowHelperFactory(AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                secondaryBloomFilterKeyFields, new LSMBTreeDataflowHelperFactory(
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
-                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                localResourceFactoryProvider, NoOpOperationCallbackFactory.INSTANCE);
+                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                        AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
+                        storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), localResourceFactoryProvider,
+                NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, secondaryIndexCreateOp,
                 secondaryPartitionConstraint);
         spec.addRoot(secondaryIndexCreateOp);
@@ -92,8 +93,8 @@
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                BTree.DEFAULT_FILL_FACTOR);
+                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), BTree.DEFAULT_FILL_FACTOR);
 
         // Connect the operators.
         spec.connect(new OneToOneConnectorDescriptor(spec), keyProviderOp, 0, primaryScanOp, 0);
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 83c9393..253df4b 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
@@ -282,7 +282,8 @@
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()), false,
+                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), false,
                 NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, primarySearchOp,
                 primaryPartitionConstraint);
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 7b53a28..366e247 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
@@ -270,14 +270,16 @@
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
-                    storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages());
+                    storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                    storageProperties.getBloomFilterFalsePositiveRate());
         } else {
             return new PartitionedLSMInvertedIndexDataflowHelperFactory(
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                     AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
-                    storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages());
+                    storageProperties.getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                    storageProperties.getBloomFilterFalsePositiveRate());
         }
     }
 }
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 1a5e0da..89a59e8 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
@@ -78,8 +78,9 @@
                         AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER, AqlMetadataProvider.proposeLinearizer(
                                 keyType, secondaryComparatorFactories.length), storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                localResourceFactoryProvider, NoOpOperationCallbackFactory.INSTANCE);
+                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), localResourceFactoryProvider,
+                NoOpOperationCallbackFactory.INSTANCE);
         AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, secondaryIndexCreateOp,
                 secondaryPartitionConstraint);
         spec.addRoot(secondaryIndexCreateOp);
@@ -163,8 +164,8 @@
                         AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER,
                         AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER, AqlMetadataProvider.proposeLinearizer(
                                 keyType, secondaryComparatorFactories.length), storageProperties
-                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                BTree.DEFAULT_FILL_FACTOR);
+                                .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                        storageProperties.getBloomFilterFalsePositiveRate()), BTree.DEFAULT_FILL_FACTOR);
 
         // Connect the operators.
         spec.connect(new OneToOneConnectorDescriptor(spec), keyProviderOp, 0, primaryScanOp, 0);
diff --git a/asterix-app/src/main/resources/asterix-build-configuration.xml b/asterix-app/src/main/resources/asterix-build-configuration.xml
index 20ffb37..3e1b4b2 100644
--- a/asterix-app/src/main/resources/asterix-build-configuration.xml
+++ b/asterix-app/src/main/resources/asterix-build-configuration.xml
@@ -11,6 +11,6 @@
   <property>
      <name>log.level</name>
      <value>WARNING</value>
-     <description></description>
+     <description>Log level for running tests/build</description>
   </property>
 </asterixConfiguration>
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.1.ddl.aql
new file mode 100644
index 0000000..c04af59
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.1.ddl.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : create a dataset using year-month-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as open {
+id:year-month-duration,
+name:string
+}
+
+create dataset Employee(Emp) primary key id;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.2.update.aql
new file mode 100644
index 0000000..d07ed34
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.2.update.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using year-month-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+insert into dataset Employee({"id":year-month-duration("P16Y"), "name": "John"})
+insert into dataset Employee({"id":year-month-duration("-P37M"), "name": "Alex"})
+insert into dataset Employee({"id":year-month-duration("P2013Y"), "name": "Bob"})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.3.query.aql
new file mode 100644
index 0000000..a25bfb8
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_0/issue_363_temporal_key_0.3.query.aql
@@ -0,0 +1,13 @@
+/*
+ * Description  : create a dataset using year-month-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+for $x in dataset('Employee')
+where $x.id > year-month-duration("P350M")
+return $x
+
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.1.ddl.aql
new file mode 100644
index 0000000..1f59a51
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.1.ddl.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : create a dataset using datetime as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as open {
+id:datetime,
+name:string
+}
+
+create dataset Employee(Emp) primary key id;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.2.update.aql
new file mode 100644
index 0000000..0640b52
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.2.update.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using datetime as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+insert into dataset Employee({"id":datetime("1900-01-01T00:00:00"), "name": "John"})
+insert into dataset Employee({"id":datetime("2000-01-01T00:00:00"), "name": "Alex"})
+insert into dataset Employee({"id":datetime("2013-01-01T00:00:00"), "name": "Bob"})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.3.query.aql
new file mode 100644
index 0000000..2b82717
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_1/issue_363_temporal_key_1.3.query.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using datetime as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+for $x in dataset('Employee')
+where $x.id > datetime("2007-07-07T07:07:07.777Z")
+return $x
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.1.ddl.aql
new file mode 100644
index 0000000..97c62cf
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.1.ddl.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : create a dataset using time as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as open {
+id:time,
+name:string
+}
+
+create dataset Employee(Emp) primary key id;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.2.update.aql
new file mode 100644
index 0000000..f98a754
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.2.update.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using time as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+insert into dataset Employee({"id":time("03:10:00.493Z"), "name": "John"})
+insert into dataset Employee({"id":time("20:37:19+08:00"), "name": "Alex"})
+insert into dataset Employee({"id":time("21:39:17.948-04:00"), "name": "Bob"})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.3.query.aql
new file mode 100644
index 0000000..197b461
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_2/issue_363_temporal_key_2.3.query.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using time as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+for $x in dataset('Employee')
+where $x.id > time("07:07:07.777Z")
+return $x
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.1.ddl.aql
new file mode 100644
index 0000000..5e4ae49
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.1.ddl.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : create a dataset using date as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as open {
+id:date,
+name:string
+}
+
+create dataset Employee(Emp) primary key id;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.2.update.aql
new file mode 100644
index 0000000..624cdc8
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.2.update.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using date as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+insert into dataset Employee({"id":date("2010-01-01"), "name": "John"})
+insert into dataset Employee({"id":date("-1912-10-11"), "name": "Alex"})
+insert into dataset Employee({"id":date("0732-02-02"), "name": "Bob"})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.3.query.aql
new file mode 100644
index 0000000..3f9960e
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_3/issue_363_temporal_key_3.3.query.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using date as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+for $x in dataset('Employee')
+where $x.id > date("2007-07-07")
+return $x
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.1.ddl.aql
new file mode 100644
index 0000000..9a3da89
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.1.ddl.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : create a dataset using day-time-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as open {
+id:day-time-duration,
+name:string
+}
+
+create dataset Employee(Emp) primary key id;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.2.update.aql
new file mode 100644
index 0000000..04a35de
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.2.update.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using day-time-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+
+use dataverse test;
+
+insert into dataset Employee({"id":day-time-duration("P380DT983M"), "name": "John"})
+insert into dataset Employee({"id":day-time-duration("-P3829H849.392S"), "name": "Alex"})
+insert into dataset Employee({"id":day-time-duration("PT93847M0.392S"), "name": "Bob"})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.3.query.aql
new file mode 100644
index 0000000..e45250b
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/issue_363_temporal_key_4/issue_363_temporal_key_4.3.query.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a dataset using day-time-duration as the primary key 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * Issue        : 363
+ */
+ 
+use dataverse test;
+
+for $x in dataset('Employee')
+where $x.id > day-time-duration("P350D")
+return $x
diff --git a/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_0/issue363_temporal_key_0.1.adm b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_0/issue363_temporal_key_0.1.adm
new file mode 100644
index 0000000..be11d3c
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_0/issue363_temporal_key_0.1.adm
@@ -0,0 +1 @@
+{ "id": year-month-duration("P2013Y"), "name": "Bob" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_1/issue363_temporal_key_1.1.adm b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_1/issue363_temporal_key_1.1.adm
new file mode 100644
index 0000000..f4a131a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_1/issue363_temporal_key_1.1.adm
@@ -0,0 +1 @@
+{ "id": datetime("2013-01-01T00:00:00.000Z"), "name": "Bob" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_2/issue363_temporal_key_2.1.adm b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_2/issue363_temporal_key_2.1.adm
new file mode 100644
index 0000000..e9829f4
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_2/issue363_temporal_key_2.1.adm
@@ -0,0 +1,2 @@
+{ "id": time("12:37:19.000Z"), "name": "Alex" }
+{ "id": time("01:39:17.948Z"), "name": "Bob" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_3/issue363_temporal_key_3.1.adm b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_3/issue363_temporal_key_3.1.adm
new file mode 100644
index 0000000..125c38a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_3/issue363_temporal_key_3.1.adm
@@ -0,0 +1 @@
+{ "id": date("2010-01-01"), "name": "John" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_4/issue363_temporal_key_4.1.adm b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_4/issue363_temporal_key_4.1.adm
new file mode 100644
index 0000000..43bda78
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/results/basic/issue_363_temporal_key_4/issue363_temporal_key_4.1.adm
@@ -0,0 +1 @@
+{ "id": day-time-duration("P380DT16H23M"), "name": "John" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/results/basic/meta17/meta17.1.adm b/asterix-app/src/test/resources/metadata/results/basic/meta17/meta17.1.adm
index 2de89a6..d193dd1 100644
--- a/asterix-app/src/test/resources/metadata/results/basic/meta17/meta17.1.adm
+++ b/asterix-app/src/test/resources/metadata/results/basic/meta17/meta17.1.adm
@@ -42,6 +42,7 @@
 { "DataverseName": "Metadata", "DatatypeName": "circle", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "date", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "datetime", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
+{ "DataverseName": "Metadata", "DatatypeName": "day-time-duration", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "double", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "duration", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "float", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
@@ -58,3 +59,4 @@
 { "DataverseName": "Metadata", "DatatypeName": "rectangle", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "string", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "time", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
+{ "DataverseName": "Metadata", "DatatypeName": "year-month-duration", "Derived": null, "Timestamp": "Fri Feb 08 15:49:29 PST 2013" }
diff --git a/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm b/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
index 84e2ca8..cecdb85 100644
--- a/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
+++ b/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
@@ -42,6 +42,7 @@
 { "DataverseName": "Metadata", "DatatypeName": "circle", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "date", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "datetime", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
+{ "DataverseName": "Metadata", "DatatypeName": "day-time-duration", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "double", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "duration", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "float", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
@@ -58,3 +59,4 @@
 { "DataverseName": "Metadata", "DatatypeName": "rectangle", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "string", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
 { "DataverseName": "Metadata", "DatatypeName": "time", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
+{ "DataverseName": "Metadata", "DatatypeName": "year-month-duration", "Derived": null, "Timestamp": "Fri Mar 29 11:19:47 PDT 2013" }
diff --git a/asterix-app/src/test/resources/metadata/testsuite.xml b/asterix-app/src/test/resources/metadata/testsuite.xml
index 47bcafa..63487d4 100644
--- a/asterix-app/src/test/resources/metadata/testsuite.xml
+++ b/asterix-app/src/test/resources/metadata/testsuite.xml
@@ -150,6 +150,31 @@
         <output-dir compare="Text">issue_251_dataset_hint_4</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="basic">
+      <compilation-unit name="issue_363_temporal_key_0">
+        <output-dir compare="Text">issue_363_temporal_key_0</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="basic">
+      <compilation-unit name="issue_363_temporal_key_1">
+        <output-dir compare="Text">issue_363_temporal_key_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="basic">
+      <compilation-unit name="issue_363_temporal_key_2">
+        <output-dir compare="Text">issue_363_temporal_key_2</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="basic">
+      <compilation-unit name="issue_363_temporal_key_3">
+        <output-dir compare="Text">issue_363_temporal_key_3</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="basic">
+      <compilation-unit name="issue_363_temporal_key_4">
+        <output-dir compare="Text">issue_363_temporal_key_4</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="exception">
     <test-case FilePath="exception">
diff --git a/asterix-app/src/test/resources/optimizerts/ignore.txt b/asterix-app/src/test/resources/optimizerts/ignore.txt
index babe741..34d7259 100644
--- a/asterix-app/src/test/resources/optimizerts/ignore.txt
+++ b/asterix-app/src/test/resources/optimizerts/ignore.txt
@@ -1 +1,4 @@
-distinct_aggregate.aql
\ No newline at end of file
+distinct_aggregate.aql
+unnest_list_in_subplan.aql
+fj-phase2-with-hints.aql
+fj-dblp-csx.aql
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
index 5e9ac0e..911b63f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
index dbb9c71..a42fc6b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard-check.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -24,4 +25,4 @@
 
 for $o in dataset('DBLP')
 where similarity-jaccard-check(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)[0]
-return $o
\ No newline at end of file
+return $o
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
index f25fb8b..b11629f 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/ngram-jaccard.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
index fb59040..486fe66 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-let.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -26,4 +27,4 @@
 for $o in dataset('DBLP')
 let $jacc := similarity-jaccard-check(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)
 where $jacc[0]
-return $o
\ No newline at end of file
+return $o
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
index b86c6b2..7dfc9f6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-complex/ngram-jaccard-check-multi-let.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -29,4 +30,4 @@
 let $query_tokens := gram-tokens("Transactions for Cooperative Environments", 3, false)
 let $jacc := similarity-jaccard-check($paper_tokens, $query_tokens, 0.5f)
 where $jacc[0]
-return {"Paper": $paper_tokens, "Query": $query_tokens }
\ No newline at end of file
+return {"Paper": $paper_tokens, "Query": $query_tokens }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
index 1a97936..5b2be0c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -39,4 +40,4 @@
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where gram-tokens($a.title, 3, false) ~= gram-tokens($b.title, 3, false) and $a.id < $b.id
-return {"atitle": $a.title, "btitle": $b.title}
\ No newline at end of file
+return {"atitle": $a.title, "btitle": $b.title}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
index bf6bb82..d4ec177 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
@@ -9,6 +9,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -28,4 +29,4 @@
 for $b in dataset('DBLP')
 let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
 where $jacc >= 0.5f and $a.id < $b.id
-return {"atitle": $a.title, "btitle": $b.title, "jacc": $jacc}
\ No newline at end of file
+return {"atitle": $a.title, "btitle": $b.title, "jacc": $jacc}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
index dae2a78..1e7df4b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -37,4 +38,4 @@
 for $b in dataset('CSX')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f
       and $a.id < $b.id
-return {"atitle": $a.title, "btitle": $b.title}
\ No newline at end of file
+return {"atitle": $a.title, "btitle": $b.title}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
index 84fb8f3..931734c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_01.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -38,4 +39,4 @@
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where gram-tokens($a.title, 3, false) ~= gram-tokens($b.title, 3, false) and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
index d0c3c6f..ecbeea7 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_02.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -38,4 +39,4 @@
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where gram-tokens($a.title, 3, false) ~= gram-tokens($b.title, 3, false) and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
index a725edc..b437183 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-fuzzyeq-jaccard_03.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -28,4 +29,4 @@
 for $a in dataset('DBLP')
 for $b in dataset('DBLP')
 where gram-tokens($a.title, 3, false) ~= gram-tokens($b.title, 3, false) and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
index c25e2e3..d554d76 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_01.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -36,4 +37,4 @@
 for $b in dataset('CSX')
 where similarity-jaccard-check(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false), 0.5f)[0]
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
index 0e9f4d5..d60baad 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_02.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -36,4 +37,4 @@
 for $b in dataset('CSX')
 where similarity-jaccard-check(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false), 0.5f)[0]
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
index bbd0f51..cc7dded 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_03.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -26,4 +27,4 @@
 for $b in dataset('DBLP')
 where similarity-jaccard-check(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false), 0.5f)[0]
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
index 956f712..e51adbd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard-check_04.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -27,4 +28,4 @@
 for $b in dataset('DBLP')
 let $jacc := similarity-jaccard-check(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false), 0.5f)
 where $jacc[0] and $a.id < $b.id
-return {"arec": $a, "brec": $b, "jacc": $jacc[1] }
\ No newline at end of file
+return {"arec": $a, "brec": $b, "jacc": $jacc[1] }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
index 742cb69..3893857 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_01.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -36,4 +37,4 @@
 for $b in dataset('CSX')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
index a620399..372d622 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_02.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -36,4 +37,4 @@
 for $b in dataset('CSX')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
index d12bf98..568bcfa 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_03.aql
@@ -7,6 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -26,4 +27,4 @@
 for $b in dataset('DBLP')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f
       and $a.id < $b.id
-return {"arec": $a, "brec": $b }
\ No newline at end of file
+return {"arec": $a, "brec": $b }
diff --git a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
index 6b308c8..c1a08b9 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/inverted-index-join/ngram-jaccard_04.aql
@@ -8,6 +8,7 @@
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
+set import-private-functions 'true';
 
 create type DBLPType as closed {
   id: int32, 
@@ -27,4 +28,4 @@
 for $b in dataset('DBLP')
 let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
 where $jacc >= 0.5f and $a.id < $b.id
-return {"arec": $a, "brec": $b, "jacc": $jacc }
\ No newline at end of file
+return {"arec": $a, "brec": $b, "jacc": $jacc }
diff --git a/asterix-app/src/test/resources/optimizerts/results/scan-delete-rtree-secondary-index.plan b/asterix-app/src/test/resources/optimizerts/results/scan-delete-rtree-secondary-index.plan
index bf8978b..4f0d931 100644
--- a/asterix-app/src/test/resources/optimizerts/results/scan-delete-rtree-secondary-index.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/scan-delete-rtree-secondary-index.plan
@@ -3,23 +3,21 @@
     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
       -- INDEX_INSERT_DELETE  |PARTITIONED|
         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-          -- STABLE_SORT [$$29(ASC), $$30(ASC), $$31(ASC), $$32(ASC)]  |PARTITIONED|
-            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          -- STREAM_PROJECT  |PARTITIONED|
+            -- ASSIGN  |PARTITIONED|
               -- STREAM_PROJECT  |PARTITIONED|
                 -- ASSIGN  |PARTITIONED|
-                  -- STREAM_PROJECT  |PARTITIONED|
-                    -- ASSIGN  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- INSERT_DELETE  |PARTITIONED|
                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                        -- INSERT_DELETE  |PARTITIONED|
-                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            -- STABLE_SORT [$$14(ASC)]  |PARTITIONED|
-                              -- HASH_PARTITION_EXCHANGE [$$14]  |PARTITIONED|
+                        -- STABLE_SORT [$$14(ASC)]  |PARTITIONED|
+                          -- HASH_PARTITION_EXCHANGE [$$14]  |PARTITIONED|
+                            -- ASSIGN  |PARTITIONED|
+                              -- STREAM_PROJECT  |PARTITIONED|
                                 -- ASSIGN  |PARTITIONED|
                                   -- STREAM_PROJECT  |PARTITIONED|
-                                    -- ASSIGN  |PARTITIONED|
-                                      -- STREAM_PROJECT  |PARTITIONED|
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      -- BTREE_SEARCH  |PARTITIONED|
                                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                          -- BTREE_SEARCH  |PARTITIONED|
-                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                              -- ASSIGN  |PARTITIONED|
-                                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
+                                          -- ASSIGN  |PARTITIONED|
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/results/scan-insert-secondary-index.plan b/asterix-app/src/test/resources/optimizerts/results/scan-insert-secondary-index.plan
index e6cf237..1458c66 100644
--- a/asterix-app/src/test/resources/optimizerts/results/scan-insert-secondary-index.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/scan-insert-secondary-index.plan
@@ -3,28 +3,24 @@
     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
       -- INDEX_INSERT_DELETE  |PARTITIONED|
         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-          -- STABLE_SORT [$$11(ASC)]  |PARTITIONED|
-            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          -- STREAM_PROJECT  |PARTITIONED|
+            -- ASSIGN  |PARTITIONED|
               -- STREAM_PROJECT  |PARTITIONED|
-                -- ASSIGN  |PARTITIONED|
-                  -- STREAM_PROJECT  |PARTITIONED|
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  -- INDEX_INSERT_DELETE  |PARTITIONED|
                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                      -- INDEX_INSERT_DELETE  |PARTITIONED|
+                      -- ASSIGN  |PARTITIONED|
                         -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                          -- STABLE_SORT [$$10(ASC)]  |PARTITIONED|
+                          -- INSERT_DELETE  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                              -- ASSIGN  |PARTITIONED|
-                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                  -- INSERT_DELETE  |PARTITIONED|
-                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                      -- STABLE_SORT [$$6(ASC)]  |PARTITIONED|
-                                        -- HASH_PARTITION_EXCHANGE [$$6]  |PARTITIONED|
+                              -- STABLE_SORT [$$6(ASC)]  |PARTITIONED|
+                                -- HASH_PARTITION_EXCHANGE [$$6]  |PARTITIONED|
+                                  -- ASSIGN  |PARTITIONED|
+                                    -- STREAM_PROJECT  |PARTITIONED|
+                                      -- ASSIGN  |PARTITIONED|
+                                        -- STREAM_PROJECT  |PARTITIONED|
                                           -- ASSIGN  |PARTITIONED|
-                                            -- STREAM_PROJECT  |PARTITIONED|
-                                              -- ASSIGN  |PARTITIONED|
-                                                -- STREAM_PROJECT  |PARTITIONED|
-                                                  -- ASSIGN  |PARTITIONED|
-                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                                      -- DATASOURCE_SCAN  |PARTITIONED|
-                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.aql
index 432866f..144f427 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 sum(for $l in dataset('tdst')
 where not(is-null($l.sal))
diff --git a/asterix-app/src/test/resources/runtimets/queries/boolean/not_01/not_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/boolean/not_01/not_01.3.query.aql
index af1a6bc..059da38 100644
--- a/asterix-app/src/test/resources/runtimets/queries/boolean/not_01/not_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/boolean/not_01/not_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $x := true
 let $y := false
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.1.ddl.aql
new file mode 100644
index 0000000..0e39a04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.1.ddl.aql
@@ -0,0 +1,8 @@
+/*
+ * Description      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+drop dataverse test if exists;
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.2.update.aql
new file mode 100644
index 0000000..335a24a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.2.update.aql
@@ -0,0 +1,5 @@
+/*
+ * Description      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.3.query.aql
new file mode 100644
index 0000000..69a8b28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/day_time_duration_order/day_time_duration_order.3.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+use dataverse test;
+
+let $dr1 := day-time-duration("P439D")
+let $dr2 := day-time-duration("-PT328M")
+let $dr3 := day-time-duration("-P48DT12M43.932S")
+let $dr4 := day-time-duration("P12H")
+
+for $dr in [$dr1, $dr2, $dr3, $dr4]
+order by $dr
+return $dr
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.1.ddl.aql
new file mode 100644
index 0000000..ba511f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.2.update.aql
new file mode 100644
index 0000000..dd5635c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.3.query.aql
new file mode 100644
index 0000000..7e898a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_equality/issue363_equality.3.query.aql
@@ -0,0 +1,54 @@
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+let $v1 := duration("P3Y6M3DT9H5M2.348S")
+let $v2 := year-month-duration("P3Y6M")
+let $v3 := day-time-duration("P3DT9H5M2.348S")
+let $v4 := point("47.44,80.65")
+let $v5 := line("10.1234,11.1e-1 +10.2E-2,-11.22")
+let $v6 := polygon("-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75")
+let $v7 := circle("0.1234,-1.00e-10 +10.5E-2")
+let $v8 := rectangle("0.1234,-1.00e-10 5.5487,0.48765")
+let $v9 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+let $dv1 := duration("P3Y6M3DT9H5M2.348S")
+let $dv2 := year-month-duration("P3Y6M")
+let $dv3 := day-time-duration("P3DT9H5M2.348S")
+let $dv4 := point("47.44,80.65")
+let $dv5 := line("10.1234,11.1e-1 +10.2E-2,-11.22")
+let $dv6 := polygon("-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75")
+let $dv7 := circle("0.1234,-1.00e-10 +10.5E-2")
+let $dv8 := rectangle("0.1234,-1.00e-10 5.5487,0.48765")
+let $dv9 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+let $ndv1 := duration("P4Y6M3DT9H5M2.348S")
+let $ndv2 := year-month-duration("P3Y7M")
+let $ndv3 := day-time-duration("P3DT1H5M2.348S")
+let $ndv4 := point("47.4444,80.65")
+let $ndv5 := line("10.5678,11.1e-1 +10.2E-2,-11.22")
+let $ndv6 := polygon("-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75")
+let $ndv7 := circle("0.5678,-1.00e-10 +10.5E-2")
+let $ndv8 := rectangle("0.5678,-1.00e-10 5.5487,0.48765")
+let $ndv9 := interval-from-datetime(datetime("-1983-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+
+return { "duration":  $v1 = $dv1, 
+"year-month-duration":  $v2 = $dv2, 
+"day-time-duration":  $v3 = $dv3, 
+"point": $v4 = $dv4, 
+"line": $v5 = $dv5, 
+"polygon": $v6 = $dv6,
+"circle": $v7 = $dv7,
+"rectangle": $v8 = $dv8,
+"interval": $v9 = $dv9,
+"duration2":  $v1 != $ndv1, 
+"year-month-duration2": $v2 != $ndv2, 
+"day-time-duration2":  $v3 != $ndv3, 
+"point2": $v4 != $ndv4, 
+"line2": $v5 != $ndv5, 
+"polygon2": $v6 != $ndv6,
+"circle2": $v7 != $ndv7,
+"rectangle2": $v8 != $ndv8,
+"interval2": $v9 != $ndv9
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.aql
new file mode 100644
index 0000000..b05c7fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.aql
new file mode 100644
index 0000000..b05c7fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.aql
new file mode 100644
index 0000000..dc9aeb5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := circle("0.1234,-1.00e-10 +10.5E-2")
+let $dv1 := circle("0.5678,-1.00e-10 +10.5E-2")
+
+return { "circle0":  $v1 > $dv1, "circle1": $dv1 < $v1, "circle2":  $v1 >= $dv1, "circle3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.aql
new file mode 100644
index 0000000..6533b0d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.aql
new file mode 100644
index 0000000..6533b0d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.aql
new file mode 100644
index 0000000..a365aba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := duration("P300Y6M3DT9H5M2.348S")
+let $dv1 := duration("P3Y6M3DT9H5M2.348S")
+
+return { "duration0":  $v1 > $dv1, "duration1": $dv1 < $v1, "duration2":  $v1 >= $dv1, "duration3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.aql
new file mode 100644
index 0000000..ac47f3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.aql
new file mode 100644
index 0000000..ac47f3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.aql
new file mode 100644
index 0000000..36ac511
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+let $dv1 := interval-from-datetime(datetime("-1983-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+
+return { "interval0":  $v1 > $dv1, "interval1": $dv1 < $v1, "interval2":  $v1 >= $dv1, "interval3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.aql
new file mode 100644
index 0000000..3618d18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.2.update.aql
new file mode 100644
index 0000000..3618d18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.3.query.aql
new file mode 100644
index 0000000..d887233
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_line/issue363_inequality_line.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := line("10.1234,11.1e-1 +10.2E-2,-11.22")
+let $dv1 := line("10.1234,11.1e-1 +10.2E-2,-11.22")
+
+return { "line0":  $v1 > $dv1, "line1": $dv1 < $v1, "line2":  $v1 >= $dv1, "line3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.aql
new file mode 100644
index 0000000..434dd0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.2.update.aql
new file mode 100644
index 0000000..434dd0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.3.query.aql
new file mode 100644
index 0000000..2199d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_point/issue363_inequality_point.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := point("47.44,80.65")
+let $dv1 := point("47.4444,80.65")
+
+return { "point0":  $v1 > $dv1, "point1": $dv1 < $v1, "point2":  $v1 >= $dv1, "point3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.aql
new file mode 100644
index 0000000..12e3ca6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.aql
new file mode 100644
index 0000000..12e3ca6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.aql
new file mode 100644
index 0000000..04af82a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := polygon("-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75")
+let $dv1 := polygon("-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75")
+
+return { "polygon0":  $v1 > $dv1, "polygon1": $dv1 < $v1, "polygon2":  $v1 >= $dv1, "polygon3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.aql
new file mode 100644
index 0000000..c62c7a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.aql
new file mode 100644
index 0000000..c62c7a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.aql
new file mode 100644
index 0000000..ed6770e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+ 
+let $v1 := rectangle("0.1234,-1.00e-10 5.5487,0.48765")
+let $dv1 := rectangle("0.5678,-1.00e-10 5.5487,0.48765")
+
+return { "rectangle0":  $v1 > $dv1, "rectangle1": $dv1 < $v1, "rectangle2":  $v1 >= $dv1, "rectangle3": $dv1 <= $v1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.1.ddl.aql
new file mode 100644
index 0000000..356810c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.1.ddl.aql
@@ -0,0 +1,8 @@
+/*
+ * Description      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+drop dataverse test if exists;
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.2.update.aql
new file mode 100644
index 0000000..65105d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.2.update.aql
@@ -0,0 +1,5 @@
+/*
+ * Description      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.3.query.aql
new file mode 100644
index 0000000..3fbfafe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/year_month_duration_order/year_month_duration_order.3.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+use dataverse test;
+
+let $dr1 := year-month-duration("P439Y")
+let $dr2 := year-month-duration("-P328M")
+let $dr3 := year-month-duration("-P48Y12M")
+let $dr4 := year-month-duration("P12M")
+
+for $dr in [$dr1, $dr2, $dr3, $dr4]
+order by $dr
+return $dr
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.1.ddl.aql
index 754ea81..84fe314 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.1.ddl.aql
@@ -1,3 +1,9 @@
+/*
+ * Description  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
+
 drop dataverse test if exists;
 create dataverse test;
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.2.update.aql
index e69de29..0c32771 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.2.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.2.update.aql
@@ -0,0 +1,5 @@
+/*
+ * Description  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.3.query.aql
index 6db5228..898ab18 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_01/duration_01.3.query.aql
@@ -1,3 +1,9 @@
+/*
+ * Description  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
+
 use dataverse test;
 
 let $c1 := duration("P30Y10M25DT13H12M50S")
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.1.ddl.aql
new file mode 100644
index 0000000..f3978bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.1.ddl.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.2.update.aql
new file mode 100644
index 0000000..73d2817
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.2.update.aql
@@ -0,0 +1,6 @@
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.3.query.aql
new file mode 100644
index 0000000..f526bc4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/duration_02/duration_02.3.query.aql
@@ -0,0 +1,22 @@
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
+
+use dataverse test;
+
+let $c1 := year-month-duration("P30Y10M")
+let $c2 := day-time-duration("P25DT13H12M50S")
+let $c3 := day-time-duration("PT13H12M50S")
+let $c4 := year-month-duration("P30Y")
+let $c5 := day-time-duration("PT13H")
+let $c6 := year-month-duration("-P30Y10M")
+let $c7 := day-time-duration("-P25DT13H12M50S")
+let $c8 := day-time-duration("-PT13H50S")
+let $c9 := day-time-duration("P120D")
+let $c10 := year-month-duration("-P28M")
+let $c11 := day-time-duration("PT29M90.937S")
+let $c12 := year-month-duration("P300Y15M")
+return {"duration1": $c1, "duration2": $c2, "duration3": $c3, "duration4": $c4, "duration5": $c5, "duration6": $c6, "duration7": $c7, "duration8": $c8, "duration9": $c9, "duration10": $c10, "duration11": $c11, "duration12": $c12}
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.aql
index bc6490d..c3b22f0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.aql
@@ -1,5 +1,6 @@
 use dataverse fuzzyjoin;
 
+set import-private-functions 'true';
             //
             // -- - Stage 1 - --
             //
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.aql
index e6a2e36..5f0ede9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
             //
             // -- - Stage 1 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.aql
index e6a2e36..dd0f1ba 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.aql
@@ -1,5 +1,5 @@
 use dataverse fuzzyjoin;
-
+set import-private-functions 'true';
             //
             // -- - Stage 1 - --
             //
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.aql
index aa6a746..6d3d69b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.aql
@@ -1,5 +1,5 @@
 use dataverse fuzzyjoin;
-
+set import-private-functions 'true';
             //
             // -- - Stage 1 - --
             //
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.aql
index 70de806..adcb9c7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.aql
@@ -1,5 +1,5 @@
 use dataverse fuzzyjoin;
-
+set import-private-functions 'true';
     //
     // -- - Stage 2 - --
     //
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.aql
index 03add70..b7a71e9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.aql
index 977a2a9..621f40e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.aql
@@ -1,5 +1,5 @@
 use dataverse fuzzyjoin;
-
+set import-private-functions 'true';
     //
     // -- - Stage 2 - --
     //
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.aql
index 275a4cf..ddcded7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.aql
index 8f75103..cfa6079 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.aql
index abb7736..a1eca39 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.aql
index 1950989..1bf3ea3 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.aql
index f6b4832..ad5fbad 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.aql
index 6ea3207..666e91b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.aql
index 6ea3207..666e91b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.aql
index 81013bb..b14940f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.aql
index 039ed1b..c6260c2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.aql
index 2c2d349..cac9513 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.aql
index 0d1976b..9763760 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.aql
index 2d3a1f2..51266cd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.aql
index 8847306..1482237 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.aql
index 4438e50..07846e7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.aql
index e2fc8d1..6a6826a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.aql
index d6e7183..b92449f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.aql
index f379cf4..cab57b4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.aql
index de3c8e8..5ef887e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.aql
index 803db8f..65b86d6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.aql
index 60ea2ee..c562ba9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
     //
     // -- - Stage 2 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.aql
index 8757f02..a8e5821 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.aql
index 7d40888..e643523 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.aql
index 85ace1c..2dae3af 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.aql
index 3574534..3f5a623 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.aql
index 6a6dc0c..832ec5c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.aql
index 5359b9f..e17ad08 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.aql
index f0dbf23..52456d7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.aql
index 40aba87..ba532b9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.aql
index 103af68..f68ef0e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.aql
index 2199203..ecc30bc 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.aql
index 44807b2..9b80d4d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse fuzzyjoin;
+set import-private-functions 'true';
 
 //
 // -- - Stage 3 - --
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/fuzzy-inverted-index-ngram-jaccard/fuzzy-inverted-index-ngram-jaccard.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/fuzzy-inverted-index-ngram-jaccard/fuzzy-inverted-index-ngram-jaccard.3.query.aql
index 79b65bb..dc18182 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/fuzzy-inverted-index-ngram-jaccard/fuzzy-inverted-index-ngram-jaccard.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/fuzzy-inverted-index-ngram-jaccard/fuzzy-inverted-index-ngram-jaccard.3.query.aql
@@ -1,6 +1,7 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $o in dataset('DBLP')
 let $jacc := similarity-jaccard-check(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)
 where $jacc[0]
-return $o
\ No newline at end of file
+return $o
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
index dcd5245..1851f7c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
@@ -7,6 +7,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.aql
index 4364545..8bd1d9c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.aql
index d904c09..1a4be9b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.aql
@@ -7,6 +7,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.aql
index b9221da..545db4a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.aql
index 8dda04e..159b30e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.aql
@@ -7,6 +7,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.aql
index 0af3efe..dd4f610 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.aql
index b7b056e..260a871 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.aql
@@ -7,6 +7,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.aql
index 57fd37c..2fe6e28 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.aql
index 6faa6a7..8debbfd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.aql
@@ -7,6 +7,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.aql
index 3db8b5f..a8684e0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
index e7fc13e..4068296 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
@@ -6,6 +6,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.aql
index b237130..b64e7e1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.aql
@@ -5,6 +5,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
diff --git a/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01/is-null_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01/is-null_01.3.query.aql
index 7725698..61220f7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01/is-null_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01/is-null_01.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 [is-null(null), is-null(10)]
diff --git a/asterix-app/src/test/resources/runtimets/queries/misc/range_01/range_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/misc/range_01/range_01.3.query.aql
index 439c244..a2bcb99 100644
--- a/asterix-app/src/test/resources/runtimets/queries/misc/range_01/range_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/range_01/range_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $x in range(20,30)
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04/everysat_04.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04/everysat_04.3.query.aql
index 7742254..e5e425f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04/everysat_04.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04/everysat_04.3.query.aql
@@ -4,6 +4,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 let $x := [
 every $x in [false,false] satisfies $x,
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06/somesat_06.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06/somesat_06.3.query.aql
index e406cda..4d75664 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06/somesat_06.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06/somesat_06.3.query.aql
@@ -4,6 +4,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 let $x := [
 some $x in [false,false] satisfies $x,
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_01/closed-record-constructor_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_01/closed-record-constructor_01.3.query.aql
index 4ef8508..b4f18bf 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_01/closed-record-constructor_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_01/closed-record-constructor_01.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 closed-record-constructor("foo1", 10, "bar1", 20, "foo2", 30, "bar2", 40)
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_02/closed-record-constructor_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_02/closed-record-constructor_02.3.query.aql
index c6e3756..040a7fb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_02/closed-record-constructor_02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_02/closed-record-constructor_02.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 closed-record-constructor("foo1", 10, "bar1", closed-record-constructor("bar1.1", 10, "bar1.2", 20, "bar1.3", 30, "bar1.4", closed-record-constructor("bar1.4.1", 10, "bar1.4.2", 20, "bar1.4.3", 30, "bar1.4.4", 40), "foo2", 30, "bar2", 40), "foo2", 30, "bar2", 40)
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_03/closed-record-constructor_03.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_03/closed-record-constructor_03.3.query.aql
index 7285a75..416d22e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_03/closed-record-constructor_03.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/closed-record-constructor_03/closed-record-constructor_03.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 {"foo1": 10, "bar1": {"bar1.1": 10, "bar1.2": 20, "bar1.3": 30, "bar1.4": {"bar1.4.1": 10, "bar1.4.2": 20 } }, "foo2": 30, "bar2": 40}
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/field-access-by-index_01/field-access-by-index_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/field-access-by-index_01/field-access-by-index_01.3.query.aql
index d25edc6..b5ff5ed 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/field-access-by-index_01/field-access-by-index_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/field-access-by-index_01/field-access-by-index_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $x := { "foo1": 10, "bar1": 20, "foo2": 30, "bar2": 40 }
 return field-access-by-index($x,2)
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_01/open-record-constructor_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_01/open-record-constructor_01.3.query.aql
index d6c8701..43a8e19 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_01/open-record-constructor_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_01/open-record-constructor_01.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 open-record-constructor("foo1", 10, "bar1", 20, "foo2", 30, "bar2", 40)
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_02/open-record-constructor_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_02/open-record-constructor_02.3.query.aql
index 972ecb2..9b1ea45 100644
--- a/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_02/open-record-constructor_02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-record-constructor_02/open-record-constructor_02.3.query.aql
@@ -1,3 +1,4 @@
 use dataverse test;
+set import-private-functions 'true';
 
 open-record-constructor("foo1", 10, "bar1", closed-record-constructor("bar1.1", 10, "bar1.2", 20, "bar1.3", 30, "bar1.4", closed-record-constructor("bar1.4.1", 10, "bar1.4.2", 20, "bar1.4.3", 30, "bar1.4.4", 40), "foo2", 30, "bar2", 40), "foo2", 30, "bar2", 40)
diff --git a/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
index 4247586..53e4ace 100644
--- a/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $o in dataset('Orders')
 where not(is-null($o.param1))
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.aql
index 97fbd61..d2dd7e8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := []
 let $b := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.aql
index 9d55ce7..e78037f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := ""
 let $b := "abcdefghij"
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.aql
index 1f61b15..693f83d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in [1]
 return [
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.aql
index 46c0389..6863929 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in [1]
 return [
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.aql
index 10db026..18de7bf 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in [1]
 return [
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.aql
index 31c8b1b..2e29289 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := [1, 2, 3, 4, 5]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.aql
index a8089ec..69a9a31 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $paper in dataset('DBLP')
 let $paper_tokens := word-tokens($paper.title)
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.aql
index 326b626..9f2bf71 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := ["abc", "bcd", "cde", "def", "efg"]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.aql
index 0915bd6..61d4372 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := [1, 2, 3, 4, 5]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.aql
index 6d6e2c8..9f1aa77 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $paper in dataset('DBLP')
 let $paper_tokens := word-tokens($paper.title)
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.aql
index 2271db0..907538f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := ["abc", "bcd", "cde", "def", "efg"]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.aql
index a76a82a..8bfb1e0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := [1, 2, 3, 4, 5]
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.aql
index 86cc50f..a731d94 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $paper in dataset('DBLP')
 let $paper_tokens := word-tokens($paper.title)
diff --git a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.aql
index b7c627e..3db4369 100644
--- a/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $a := [ ]
 let $b := ["abc", "bcd", "cde", "def", "efg"]
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/string-equal1/string-equal1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/string-equal1/string-equal1.3.query.aql
index 954ac57..3e3e57a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/string-equal1/string-equal1.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/string-equal1/string-equal1.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $c1 := string-equal("test","tess")
 return {"result1": $c1}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/string-equal2/string-equal2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/string-equal2/string-equal2.3.query.aql
index 66af45d..77b837a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/string-equal2/string-equal2.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/string-equal2/string-equal2.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $c1 := string-equal("test","test")
 return {"result1": $c1}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/string-equal3/string-equal3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/string-equal3/string-equal3.3.query.aql
index fe3b341..87c0123 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/string-equal3/string-equal3.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/string-equal3/string-equal3.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $c1 := string-equal("test11","test")
 return {"result1": $c1}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/string-equal4/string-equal4.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/string-equal4/string-equal4.3.query.aql
index 2b5166c..1128cc5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/string-equal4/string-equal4.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/string-equal4/string-equal4.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $c1 := string-equal("","")
 let $c3 := string-equal(null,"")
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/01/01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/01/01.3.query.aql
index 05612a3..4341d92 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/01/01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/01/01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection([1], 0, 1)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/02/02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/02/02.3.query.aql
index 14b3e4e..666eb76 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/02/02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/02/02.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection([1, 2, 3, 4], 1, 2)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/03/03.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/03/03.3.query.aql
index 248bff3..aaaf487 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/03/03.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/03/03.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection([1, 2, 3, 4], 0, 0)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/04/04.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/04/04.3.query.aql
index 0fde28a..1b41033 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/04/04.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/04/04.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in [1]
 return subset-collection([1, 2, 3, 4], 1, 2)
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/05/05.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/05/05.3.query.aql
index 2403754..7d369ef 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/05/05.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/05/05.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection(['a', 'b', 'c', 'd'], 1, 2)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/06/06.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/06/06.3.query.aql
index c8e78af..e4dd90d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/06/06.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/06/06.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection([1, 2, 3, 4], 2, 2)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/subset-collection/07/07.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/subset-collection/07/07.3.query.aql
index 5166adf..d651d3c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/subset-collection/07/07.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/subset-collection/07/07.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 for $l in subset-collection([1, 2, 3, 4], 2, 10)
 return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
index 291d296..016f3b3 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $t1 := datetime("1987-11-19T23:49:23.938")
 let $t2 := date("-1328-10-23")
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
index b748429..143a02b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $d1 := date-from-unix-time-in-days(15600)
 let $null1 := date-from-unix-time-in-days(null)
@@ -20,4 +21,4 @@
 let $null5 := subtract-date(null, $d2)
 let $null6 := subtract-date($d5, null)
 
-return { "date1": $d1, "date2": $d2, "date3": $d3, "date4": $d4, "date5": $d5, "duration1": $dr3, "duration2": $dr4, "c1": $c1, "c2": $c2, "null1": $null1, "null2": $null2, "null3": $null3, "null4": $null4, "null5": $null5, "null6": $null6 }
\ No newline at end of file
+return { "date1": $d1, "date2": $d2, "date3": $d3, "date4": $d4, "date5": $d5, "duration1": $dr3, "duration2": $dr4, "c1": $c1, "c2": $c2, "null1": $null1, "null2": $null2, "null3": $null3, "null4": $null4, "null5": $null5, "null6": $null6 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
index ea6c2a8..3d24549 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $dt1 := datetime-from-unix-time-in-ms(956007429)
 let $null1 := datetime-from-unix-time-in-ms(null)
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql
index 77fcc4f..456c3cc 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql
@@ -1,11 +1,12 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $dr1 := duration("-P3D")
 let $dr2 := duration("P1D")
 let $dr3 := duration("P1Y")
 let $dr4 := duration("P13M")
 let $dr5 := duration("PT24H")
-let $dr6 := duration-from-months(months-of-year-month-duration($dr3))
-let $dr7 := duration-from-ms(ms-of-day-time-duration($dr1))
+let $dr6 := duration-from-months(months-from-year-month-duration(get-year-month-duration($dr3)))
+let $dr7 := duration-from-ms(ms-from-day-time-duration(get-day-time-duration($dr1)))
 
-return { "yearMonthGreaterComp" : year-month-duration-greater-than($dr4, $dr3), "dayTimeGreaterComp" : day-time-duration-greater-than($dr2, $dr1), "yearMonthLessComp" : year-month-duration-less-than($dr4, $dr3), "dayTimeLessComp" : day-time-duration-less-than($dr2, $dr1), "equal1": duration-equal($dr2, $dr5), "equal2": duration-equal($dr1, $dr5), "equal3": duration-equal($dr6, $dr3), "equal4": duration-equal($dr7, $dr1) }
\ No newline at end of file
+return { "yearMonthGreaterComp" : year-month-duration-greater-than($dr4, $dr3), "dayTimeGreaterComp" : day-time-duration-greater-than($dr2, $dr1), "yearMonthLessComp" : year-month-duration-less-than($dr4, $dr3), "dayTimeLessComp" : day-time-duration-less-than($dr2, $dr1), "equal1": duration-equal($dr2, $dr5), "equal2": duration-equal($dr1, $dr5), "equal3": duration-equal($dr6, $dr3), "equal4": duration-equal($dr7, $dr1) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.aql
index 0338aef..07825c7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.aql
@@ -14,7 +14,9 @@
   timeField: time?,
   datetimeField: datetime?,
   durationField: duration?,
-  intervalField: interval?
+  intervalField: interval?,
+  yearMonthDurationField: year-month-duration?,
+  dayTimeDurationField: day-time-duration?
 }
 
 create external dataset testds(testtype)
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.aql
index 2defafc..de39156 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.aql
@@ -1,4 +1,4 @@
 use dataverse testdvt;
 
 for $r in dataset("testds") 
-return {"date": $r.dateField, "time": $r.timeField, "datetime": $r.datetimeField, "duration": $r.durationField, "interval": $r.intervalField }
\ No newline at end of file
+return {"date": $r.dateField, "time": $r.timeField, "datetime": $r.datetimeField, "duration": $r.durationField, "interval": $r.intervalField, "ymduration": $r.yearMonthDurationField, "dtduration": $r.dayTimeDurationField }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
index c042df0..86a4a72 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $t1 := time-from-unix-time-in-ms(1560074)
 let $null1 := time-from-unix-time-in-ms(null)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.aql
index 7b2148c..59937c7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := counthashed-gram-tokens($txt, 3, false)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.aql
index f871047..1b86c69 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := counthashed-gram-tokens($txt, 3, true)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.aql
index 3d44cfb..f124c3c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen."
 let $tokens := counthashed-word-tokens($txt)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_01/gram-tokens_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_01/gram-tokens_01.3.query.aql
index ae3a339..e25dc2a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_01/gram-tokens_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_01/gram-tokens_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := gram-tokens($txt, 3, false)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_02/gram-tokens_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_02/gram-tokens_02.3.query.aql
index 1fa90ca..4dbcf94 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_02/gram-tokens_02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/gram-tokens_02/gram-tokens_02.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := gram-tokens($txt, 3, true)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.aql
index 694ef83..66ebdc6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := hashed-gram-tokens($txt, 3, false)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.aql
index 8e46d4a..4fdba79 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Jürgen S. Generic's Car"
 let $tokens := hashed-gram-tokens($txt, 3, true)
diff --git a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.aql
index 62d8387..c87362e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse test;
+set import-private-functions 'true';
 
 let $txt := "Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen."
 let $tokens := hashed-word-tokens($txt)
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 a75b9c9..dd65443 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
@@ -1,4 +1,5 @@
 use dataverse tpch;
+set import-private-functions 'true';
 
 for $gco in (
 	for $co in
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 3fd46d5..ec10939 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,4 +1,5 @@
 use dataverse tpch;
+set import-private-functions 'true';
 
 sum( 
 for $l in dataset('LineItem')
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/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.3.query.aql
index b6d6c48..c27be0a 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/q1_pricing_summary_report_nt/q1_pricing_summary_report_nt.3.query.aql
@@ -1,4 +1,5 @@
 use dataverse tpch;
+set import-private-functions 'true';
  
 for $l in dataset('LineItem')
 where $l.l_shipdate <= '1998-09-02'
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.aql
new file mode 100644
index 0000000..13b7b58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.aql
@@ -0,0 +1,9 @@
+/*
+ * Description  : Invoke a private function (internal to Asterix) without setting the 'import-private-functions' flag as true
+ * Expected Res : Failure (Unknown Function)
+ * Date         : 18th May 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.3.query.aql
new file mode 100644
index 0000000..b7c627e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/invoke-private-function/invoke-private-function.3.query.aql
@@ -0,0 +1,23 @@
+use dataverse test;
+
+let $a := [ ]
+let $b := ["abc", "bcd", "cde", "def", "efg"]
+let $c := ["abc", "bcd", "cde", "def", "efg", "hij", "ijk"]
+let $d := ["abc", "bcd", "cde", "def", "efg", "fgh", "ghi", "hij", "ijk", "jkl"]
+let $e := ["efg", "abc", "cde", "def", "hij", "ijk", "bcd"]
+let $f := ["abc", "ijk", "bcd", "efg", "fgh", "ghi", "def", "hij", "jkl", "cde"]
+let $g := ["Efg", "aBc", "cdE", "DEf", "hIJ", "IjK", "BCD"]
+let $h := ["abc", "ijk", "bcd", "efg", "fgh", "ghi", "def", "hij", "jkl", "cde"]
+let $results :=
+[
+  similarity-jaccard($a, $b),
+  similarity-jaccard($b, $a),
+  similarity-jaccard($c, $d),
+  similarity-jaccard($d, $c),
+  similarity-jaccard($e, $f),
+  similarity-jaccard($f, $e),
+  similarity-jaccard($g, $h),
+  similarity-jaccard($h, $g)
+]
+for $i in $results
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201/query-issue201.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201/query-issue201.3.query.aql
index 6dc27e2..ac37c1a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201/query-issue201.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201/query-issue201.3.query.aql
@@ -5,6 +5,7 @@
  * Date         : 26th November 2012
  */
 
+set import-private-functions 'true';
 
 let $x:=range(1,100)
 for $i in $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.1.ddl.aql
new file mode 100644
index 0000000..062c4c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.1.ddl.aql
@@ -0,0 +1,15 @@
+/*
+ * Description  : This test case is to verify the fix for issue 455
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=455
+ * Expected Res : Failure
+ * Date         : 19th May November 2013
+ */
+ 
+
+drop dataverse test if exists;
+create dataverse test;
+
+create function printName()
+{
+"AsterixDB Shared nothing parallel BDMS"
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.2.update.aql
new file mode 100644
index 0000000..3b2310e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.2.update.aql
@@ -0,0 +1,7 @@
+/*
+ * Description  : This test case is to verify the fix for issue 455
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=455
+ * Expected Res : Failure
+ * Date         : 19th May 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.3.query.aql
new file mode 100644
index 0000000..deea3ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.3.query.aql
@@ -0,0 +1,8 @@
+/*
+ * Description  : This test case is to verify the fix for issue 455
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=455
+ * Expected Res : Failure
+ * Date         : 19th May 2013
+ */
+
+printName();
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.4.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.4.ddl.aql
new file mode 100644
index 0000000..c2986d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.4.ddl.aql
@@ -0,0 +1,8 @@
+/*
+ * Description  : This test case is to verify the fix for issue 455
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=455
+ * Expected Res : Failure
+ * Date         : 19th May 2013
+ */
+
+drop function test.printName@0;
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.5.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.5.query.aql
new file mode 100644
index 0000000..d8207e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue455/query-issue455.5.query.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : This test case is to verify the fix for issue 455
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=455
+ * Expected Res : Failure
+ * Date         : 19th May 2013
+ */
+
+for $l in dataset Metadata.Function
+return $l
+
+printName();
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18/udf18.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18/udf18.3.query.aql
index 0bdf0e4..c2af48d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18/udf18.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18/udf18.3.query.aql
@@ -5,6 +5,7 @@
  */
 
 use dataverse test;
+set import-private-functions 'true';
 
 let $val := not(test.fn06())
 return $val
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/day_time_duration_order/day_time_duration_order.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/day_time_duration_order/day_time_duration_order.1.adm
new file mode 100644
index 0000000..4c0aea9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/day_time_duration_order/day_time_duration_order.1.adm
@@ -0,0 +1,4 @@
+day-time-duration("-P48DT12M43.932S")
+day-time-duration("-PT5H28M")
+day-time-duration("P12H")
+day-time-duration("P439D")
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_equality/issue363_equality.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_equality/issue363_equality.1.adm
new file mode 100644
index 0000000..ac3caa3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_equality/issue363_equality.1.adm
@@ -0,0 +1 @@
+{ "duration": true, "year-month-duration": true, "day-time-duration": true, "point": true, "line": true, "polygon": true, "circle": true, "rectangle": true, "interval": true, "duration2": true, "year-month-duration2": true, "day-time-duration2": true, "point2": true, "line2": true, "polygon2": true, "circle2": true, "rectangle2": true, "interval2": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_circle/issue363_inequality_circle.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_circle/issue363_inequality_circle.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_circle/issue363_inequality_circle.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_duration/issue363_inequality_duration.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_duration/issue363_inequality_duration.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_duration/issue363_inequality_duration.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_interval/issue363_inequality_interval.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_interval/issue363_inequality_interval.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_interval/issue363_inequality_interval.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_line/issue363_inequality_line.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_line/issue363_inequality_line.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_line/issue363_inequality_line.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_point/issue363_inequality_point.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_point/issue363_inequality_point.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_point/issue363_inequality_point.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/year_month_duration_order/year_month_duration_order.1.adm b/asterix-app/src/test/resources/runtimets/results/comparison/year_month_duration_order/year_month_duration_order.1.adm
new file mode 100644
index 0000000..c0159ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/year_month_duration_order/year_month_duration_order.1.adm
@@ -0,0 +1,4 @@
+year-month-duration("-P49Y")
+year-month-duration("-P27Y4M")
+year-month-duration("P1Y")
+year-month-duration("P439Y")
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/duration_02/duration_02.1.adm b/asterix-app/src/test/resources/runtimets/results/constructor/duration_02/duration_02.1.adm
new file mode 100644
index 0000000..108af42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/duration_02/duration_02.1.adm
@@ -0,0 +1 @@
+{ "duration1": year-month-duration("P30Y10M"), "duration2": day-time-duration("P25DT13H12M50S"), "duration3": day-time-duration("PT13H12M50S"), "duration4": year-month-duration("P30Y"), "duration5": day-time-duration("PT13H"), "duration6": year-month-duration("-P30Y10M"), "duration7": day-time-duration("-P25DT13H12M50S"), "duration8": day-time-duration("-PT13H50S"), "duration9": day-time-duration("P120D"), "duration10": year-month-duration("-P2Y4M"), "duration11": day-time-duration("PT30M30.937S"), "duration12": year-month-duration("P301Y3M") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds/insert_from_ext_ds.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds/insert_from_ext_ds.1.adm
index b087496..9573677 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds/insert_from_ext_ds.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds/insert_from_ext_ds.1.adm
@@ -1,3 +1,4 @@
-{ "date": date("-2012-12-12"), "time": time("23:49:12.390Z"), "datetime": datetime("2012-12-12T00:00:00.001Z"), "duration": duration("P20Y19DT4H14M23.34S"), "interval": interval-datetime("2012-12-12T00:00:00.001Z, 2013-08-10T22:10:15.398Z") }
-{ "date": null, "time": time("04:12:12.219Z"), "datetime": datetime("1920-12-21T11:29:18.478Z"), "duration": null, "interval": interval-time("04:29:30.000Z, 07:59:59.999Z") }
-{ "date": null, "time": null, "datetime": datetime("-0290-03-22T17:59:48.999Z"), "duration": duration("-P27Y148D"), "interval": interval-date("-2012-03-17, 2013-04-01") }
\ No newline at end of file
+{ "date": date("-2012-12-12"), "time": time("23:49:12.390Z"), "datetime": datetime("2012-12-12T00:00:00.001Z"), "duration": duration("P20Y19DT4H14M23.34S"), "interval": interval-datetime("2012-12-12T00:00:00.001Z, 2013-08-10T22:10:15.398Z"), "ymduration": null, "dtduration": null }
+{ "date": null, "time": time("04:12:12.219Z"), "datetime": datetime("1920-12-21T11:29:18.478Z"), "duration": null, "interval": interval-time("04:29:30.000Z, 07:59:59.999Z"), "ymduration": null, "dtduration": null }
+{ "date": null, "time": null, "datetime": datetime("-0290-03-22T17:59:48.999Z"), "duration": duration("-P27Y148D"), "interval": interval-date("-2012-03-17, 2013-04-01"), "ymduration": null, "dtduration": null }
+{ "date": null, "time": null, "datetime": null, "duration": null, "interval": null, "ymduration": year-month-duration("P31Y2M"), "dtduration": day-time-duration("-P148D") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 976f071..18ec161 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -391,6 +391,11 @@
   </test-group>
   <test-group name="comparison">
     <test-case FilePath="comparison">
+      <compilation-unit name="year_month_duration_order">
+        <output-dir compare="Text">year_month_duration_order</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="datetime_order">
         <output-dir compare="Text">datetime_order</output-dir>
       </compilation-unit>
@@ -517,6 +522,53 @@
         <output-dir compare="Text">string_null</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_equality">
+        <output-dir compare="Text">issue363_equality</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_duration">
+        <output-dir compare="Text">issue363_inequality_duration</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_interval">
+        <output-dir compare="Text">issue363_inequality_interval</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_point">
+        <output-dir compare="Text">issue363_inequality_point</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_line">
+        <output-dir compare="Text">issue363_inequality_line</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_polygon">
+        <output-dir compare="Text">issue363_inequality_polygon</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_rectangle">
+        <output-dir compare="Text">issue363_inequality_rectangle</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
+      <compilation-unit name="issue363_inequality_circle">
+        <output-dir compare="Text">issue363_inequality_circle</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="constructor">
     <test-case FilePath="constructor">
@@ -555,6 +607,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="constructor">
+      <compilation-unit name="duration_02">
+        <output-dir compare="Text">duration_02</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="constructor">
       <compilation-unit name="float_01">
         <output-dir compare="Text">float_01</output-dir>
       </compilation-unit>
@@ -1499,6 +1556,7 @@
   </test-group>
   -->
   <test-group name="fuzzyjoin">
+    <!-- internal function
     <test-case FilePath="fuzzyjoin">
       <compilation-unit name="dblp-1_1">
         <output-dir compare="Text">dblp-1_1</output-dir>
@@ -1519,6 +1577,8 @@
         <output-dir compare="Text">dblp-1_2</output-dir>
       </compilation-unit>
     </test-case>
+   -->
+    <!-- internal function
     <test-case FilePath="fuzzyjoin">
       <compilation-unit name="dblp-2.1_5.3.1">
         <output-dir compare="Text">dblp-2.1_5.3.1</output-dir>
@@ -1589,6 +1649,7 @@
         <output-dir compare="Text">dblp-3_1</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="fuzzyjoin">
       <compilation-unit name="dblp-aqlplus_1">
         <output-dir compare="Text">dblp-aqlplus_1</output-dir>
@@ -1600,6 +1661,7 @@
         <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
       </compilation-unit>
     </test-case>
+   <!-- internal function
     <test-case FilePath="fuzzyjoin">
       <compilation-unit name="dblp-csx-2_1">
         <output-dir compare="Text">dblp-csx-2_1</output-dir>
@@ -1700,6 +1762,7 @@
         <output-dir compare="Text">dblp-csx-3_5</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="fuzzyjoin">
       <compilation-unit name="dblp-csx-aqlplus_1">
         <output-dir compare="Text">dblp-csx-aqlplus_1</output-dir>
@@ -1786,11 +1849,13 @@
         <output-dir compare="Text">fuzzy-inverted-index-ngram-edit-distance</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="index-selection">
       <compilation-unit name="fuzzy-inverted-index-ngram-jaccard">
         <output-dir compare="Text">fuzzy-inverted-index-ngram-jaccard</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="index-selection">
       <compilation-unit name="fuzzy-inverted-index-olist-edit-distance-panic">
         <output-dir compare="Text">fuzzy-inverted-index-olist-edit-distance-panic</output-dir>
@@ -1836,11 +1901,13 @@
         <output-dir compare="Text">inverted-index-ngram-edit-distance</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="index-selection">
       <compilation-unit name="inverted-index-ngram-jaccard">
         <output-dir compare="Text">inverted-index-ngram-jaccard</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="index-selection">
       <compilation-unit name="inverted-index-olist-edit-distance-panic">
         <output-dir compare="Text">inverted-index-olist-edit-distance-panic</output-dir>
@@ -1928,16 +1995,20 @@
         <output-dir compare="Text">ngram-edit-distance-inline</output-dir>
       </compilation-unit>
     </test-case>
+   <!-- internal function
     <test-case FilePath="inverted-index-join">
       <compilation-unit name="ngram-jaccard">
         <output-dir compare="Text">ngram-jaccard</output-dir>
       </compilation-unit>
     </test-case>
+   -->
+   <!-- internal function
     <test-case FilePath="inverted-index-join">
       <compilation-unit name="ngram-jaccard-inline">
         <output-dir compare="Text">ngram-jaccard-inline</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="inverted-index-join">
       <compilation-unit name="olist-edit-distance">
         <output-dir compare="Text">olist-edit-distance</output-dir>
@@ -1990,6 +2061,7 @@
         <output-dir compare="Text">ngram-edit-distance-inline</output-dir>
       </compilation-unit>
     </test-case>
+   <!-- internal function
     <test-case FilePath="inverted-index-join-noeqjoin">
       <compilation-unit name="ngram-jaccard">
         <output-dir compare="Text">ngram-jaccard</output-dir>
@@ -2000,6 +2072,7 @@
         <output-dir compare="Text">ngram-jaccard-inline</output-dir>
       </compilation-unit>
     </test-case>
+   -->
     <test-case FilePath="inverted-index-join-noeqjoin">
       <compilation-unit name="olist-edit-distance">
         <output-dir compare="Text">olist-edit-distance</output-dir>
@@ -2160,11 +2233,13 @@
         <output-dir compare="Text">nested-loop-join_01</output-dir>
       </compilation-unit>
     </test-case>
+   <!--
     <test-case FilePath="misc">
       <compilation-unit name="range_01">
         <output-dir compare="Text">range_01</output-dir>
       </compilation-unit>
     </test-case>
+   -->
     <test-case FilePath="misc">
       <compilation-unit name="tid_01">
         <output-dir compare="Text">tid_01</output-dir>
@@ -2794,6 +2869,7 @@
     </test-case>
   </test-group>
   <test-group name="records">
+    <!-- internal function
     <test-case FilePath="records">
       <compilation-unit name="closed-record-constructor_01">
         <output-dir compare="Text">closed-record-constructor_01</output-dir>
@@ -2809,21 +2885,25 @@
         <output-dir compare="Text">closed-record-constructor_03</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="records">
       <compilation-unit name="expFieldName">
         <output-dir compare="Text">expFieldName</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="records">
       <compilation-unit name="field-access-by-index_01">
         <output-dir compare="Text">field-access-by-index_01</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="records">
       <compilation-unit name="field-access-on-open-field">
         <output-dir compare="Text">field-access-on-open-field</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="records">
       <compilation-unit name="open-record-constructor_01">
         <output-dir compare="Text">open-record-constructor_01</output-dir>
@@ -2834,6 +2914,7 @@
         <output-dir compare="Text">open-record-constructor_02</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="records">
       <compilation-unit name="closed-closed-fieldname-conflict_issue173">
         <output-dir compare="Text">closed-closed-fieldname-conflict_issue173</output-dir>
@@ -2953,6 +3034,7 @@
         <output-dir compare="Text">edit-distance-check_strings</output-dir>
       </compilation-unit>
     </test-case>
+   <!-- internal function
     <test-case FilePath="similarity">
       <compilation-unit name="edit-distance-list-is-filterable">
         <output-dir compare="Text">edit-distance-list-is-filterable</output-dir>
@@ -2963,6 +3045,7 @@
         <output-dir compare="Text">edit-distance-string-is-filterable</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="similarity">
       <compilation-unit name="edit-distance_ints">
         <output-dir compare="Text">edit-distance_ints</output-dir>
@@ -2983,11 +3066,13 @@
         <output-dir compare="Text">fuzzyeq-similarity-jaccard</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="similarity">
       <compilation-unit name="prefix-len-jaccard">
         <output-dir compare="Text">prefix-len-jaccard</output-dir>
       </compilation-unit>
     </test-case>
+    -->
     <test-case FilePath="similarity">
       <compilation-unit name="similarity-jaccard-check_ints">
         <output-dir compare="Text">similarity-jaccard-check_ints</output-dir>
@@ -3003,6 +3088,7 @@
         <output-dir compare="Text">similarity-jaccard-check_strings</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="similarity">
       <compilation-unit name="similarity-jaccard-prefix-check">
         <output-dir compare="Text">similarity-jaccard-prefix-check</output-dir>
@@ -3028,6 +3114,8 @@
         <output-dir compare="Text">similarity-jaccard-sorted-check_strings</output-dir>
       </compilation-unit>
     </test-case>
+    -->
+   <!-- internal functions
     <test-case FilePath="similarity">
       <compilation-unit name="similarity-jaccard-sorted_ints">
         <output-dir compare="Text">similarity-jaccard-sorted_ints</output-dir>
@@ -3058,6 +3146,7 @@
         <output-dir compare="Text">similarity-jaccard_strings</output-dir>
       </compilation-unit>
     </test-case>
+   -->
   </test-group>
   <test-group name="spatial">
     <test-case FilePath="spatial">
@@ -3439,6 +3528,7 @@
         <output-dir compare="Text">string-concat1</output-dir>
       </compilation-unit>
     </test-case>
+   <!-- internal function
     <test-case FilePath="string">
       <compilation-unit name="string-equal1">
         <output-dir compare="Text">string-equal1</output-dir>
@@ -3459,6 +3549,7 @@
         <output-dir compare="Text">string-equal4</output-dir>
       </compilation-unit>
     </test-case>
+   -->
     <test-case FilePath="string">
       <compilation-unit name="string-join1">
         <output-dir compare="Text">string-join1</output-dir>
@@ -3597,6 +3688,7 @@
       </compilation-unit>
     </test-case>
   </test-group>
+  <!-- internal function
   <test-group name="subset-collection">
     <test-case FilePath="subset-collection">
       <compilation-unit name="01">
@@ -3613,13 +3705,11 @@
         <output-dir compare="Text">03</output-dir>
       </compilation-unit>
     </test-case>
-    <!--
     <test-case FilePath="subset-collection">
       <compilation-unit name="04">
         <output-dir compare="Text">04</output-dir>
       </compilation-unit>
     </test-case>
-    -->
     <test-case FilePath="subset-collection">
       <compilation-unit name="05">
         <output-dir compare="Text">05</output-dir>
@@ -3636,7 +3726,9 @@
       </compilation-unit>
     </test-case>
   </test-group>
+  -->
   <test-group name="tokenizers">
+   <!-- internal function
     <test-case FilePath="tokenizers">
       <compilation-unit name="counthashed-gram-tokens_01">
         <output-dir compare="Text">counthashed-gram-tokens_01</output-dir>
@@ -3652,6 +3744,8 @@
         <output-dir compare="Text">counthashed-word-tokens_01</output-dir>
       </compilation-unit>
     </test-case>
+    -->
+   <!-- internal function
     <test-case FilePath="tokenizers">
       <compilation-unit name="gram-tokens_01">
         <output-dir compare="Text">gram-tokens_01</output-dir>
@@ -3662,6 +3756,8 @@
         <output-dir compare="Text">gram-tokens_02</output-dir>
       </compilation-unit>
     </test-case>
+   -->
+   <!-- internal function
     <test-case FilePath="tokenizers">
       <compilation-unit name="hashed-gram-tokens_01">
         <output-dir compare="Text">hashed-gram-tokens_01</output-dir>
@@ -3677,6 +3773,7 @@
         <output-dir compare="Text">hashed-word-tokens_01</output-dir>
       </compilation-unit>
     </test-case>
+   -->
     <test-case FilePath="tokenizers">
       <compilation-unit name="word-tokens_01">
         <output-dir compare="Text">word-tokens_01</output-dir>
@@ -3749,11 +3846,13 @@
         <output-dir compare="Text">q18_large_volume_customer</output-dir>
       </compilation-unit>
     </test-case>
+    <!-- internal function
     <test-case FilePath="tpch">
       <compilation-unit name="q19_discounted_revenue">
         <output-dir compare="Text">q19_discounted_revenue</output-dir>
       </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>
@@ -3935,11 +4034,19 @@
     </test-case>
   </test-group>
   <test-group name="user-defined-functions">
+   <!-- internal function
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="query-issue201">
         <output-dir compare="Text">query-issue201</output-dir>
       </compilation-unit>
     </test-case>
+   -->
+    <test-case FilePath="user-defined-functions">
+      <compilation-unit name="query-issue455">
+        <output-dir compare="Text">query-issue455</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="udf01">
         <output-dir compare="Text">udf01</output-dir>
@@ -4100,6 +4207,12 @@
         <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error> 
       </compilation-unit>
     </test-case>
+    <test-case FilePath="user-defined-functions">
+      <compilation-unit name="invoke-private-function">
+        <output-dir compare="Text">invoke-private-function</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error> 
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="load">
     <test-case FilePath="load">
@@ -4202,6 +4315,7 @@
         <output-dir compare="Text">adjust_timezone</output-dir>
       </compilation-unit>
   	</test-case>
+       <!-- internal function
   	<test-case FilePath="temporal">
   		<compilation-unit name="calendar_duration">
         <output-dir compare="Text">calendar_duration</output-dir>
@@ -4217,11 +4331,14 @@
         <output-dir compare="Text">datetime_functions</output-dir>
       </compilation-unit>
   	</test-case>
-<!--   	<test-case FilePath="temporal">
-  		<compilation-unit name="insert_from_delimited_ds">
-        <output-dir compare="Text">insert_from_delimited_ds</output-dir>
-      </compilation-unit>
-  	</test-case> -->
+       -->
+        <!--
+   	<test-case FilePath="temporal">
+           <compilation-unit name="insert_from_delimited_ds">
+              <output-dir compare="Text">insert_from_delimited_ds</output-dir>
+           </compilation-unit>
+  	</test-case> 
+        -->
   	<test-case FilePath="temporal">
   		<compilation-unit name="insert_from_ext_ds">
         <output-dir compare="Text">insert_from_ext_ds</output-dir>
@@ -4232,21 +4349,25 @@
         <output-dir compare="Text">interval_functions</output-dir>
       </compilation-unit>
   	</test-case>
+        <!-- internal functions
   	<test-case FilePath="temporal">
   		<compilation-unit name="time_functions">
         <output-dir compare="Text">time_functions</output-dir>
       </compilation-unit>
   	</test-case>
+       -->
   	<test-case FilePath="constructor">
   		<compilation-unit name="interval">
         <output-dir compare="Text">interval</output-dir>
       </compilation-unit>
   	</test-case>
+        <!-- internal function
   	<test-case FilePath="temporal">
   		<compilation-unit name="duration_comps">
         <output-dir compare="Text">duration_comps</output-dir>
       </compilation-unit>
   	</test-case>
+       -->
   </test-group>
   <test-group name="leftouterjoin">
     <test-case FilePath="leftouterjoin">
diff --git a/asterix-aql/pom.xml b/asterix-aql/pom.xml
index 038ec62..249299c 100644
--- a/asterix-aql/pom.xml
+++ b/asterix-aql/pom.xml
@@ -41,6 +41,24 @@
 					</execution>
 				</executions>
 			</plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/javacc/</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
 		</plugins>
 		<pluginManagement>
 			<plugins>
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/BeginFeedStatement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/BeginFeedStatement.java
index 422ca79..d7de106 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/BeginFeedStatement.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/BeginFeedStatement.java
@@ -8,7 +8,9 @@
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlVisitorWithVoidReturn;
 import edu.uci.ics.asterix.aql.parser.AQLParser;
 import edu.uci.ics.asterix.aql.parser.ParseException;
+import edu.uci.ics.asterix.aql.util.FunctionUtils;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.common.functions.FunctionSignature;
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataManager;
@@ -35,6 +37,7 @@
         FeedDatasetDetails feedDetails = (FeedDatasetDetails) dataset.getDatasetDetails();
         String functionName = feedDetails.getFunction() == null ? null : feedDetails.getFunction().getName();
         StringBuilder builder = new StringBuilder();
+        builder.append("set" + " " + FunctionUtils.IMPORT_PRIVATE_FUNCTIONS + " " + "'" + Boolean.TRUE + "'" + ";\n");
         builder.append("insert into dataset " + datasetName + " ");
 
         if (functionName == null) {
@@ -65,7 +68,7 @@
         List<Statement> statements;
         try {
             statements = parser.Statement();
-            query = ((InsertStatement) statements.get(0)).getQuery();
+            query = ((InsertStatement) statements.get(1)).getQuery();
         } catch (ParseException pe) {
             throw new MetadataException(pe);
         }
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 84d8321..7969941 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
@@ -66,10 +66,10 @@
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.common.functions.FunctionSignature;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
+import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.entities.Function;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.AsterixFunction;
@@ -82,6 +82,7 @@
     private final List<FunctionDecl> declaredFunctions;
     private final AqlRewritingContext context;
     private final MetadataTransactionContext mdTxnCtx;
+    private final AqlMetadataProvider metadataProvider;
 
     private enum DfsColor {
         WHITE,
@@ -89,11 +90,12 @@
         BLACK
     }
 
-    public AqlRewriter(List<FunctionDecl> declaredFunctions, Query topExpr, MetadataTransactionContext mdTxnCtx) {
+    public AqlRewriter(List<FunctionDecl> declaredFunctions, Query topExpr, AqlMetadataProvider metadataProvider) {
         this.topExpr = topExpr;
         context = new AqlRewritingContext(topExpr.getVarCounter());
         this.declaredFunctions = declaredFunctions;
-        this.mdTxnCtx = mdTxnCtx;
+        this.mdTxnCtx = metadataProvider.getMetadataTxnContext();
+        this.metadataProvider = metadataProvider;
     }
 
     public Query getExpr() {
@@ -145,6 +147,7 @@
                 // loop until no more changes
             }
         }
+        declaredFunctions.removeAll(otherFDecls);
     }
 
     private void buildOtherUdfs(Expression expression, List<FunctionDecl> functionDecls,
@@ -169,7 +172,9 @@
                     buildOtherUdfs(functionDecl.getFuncBody(), functionDecls, declaredFunctions);
                 }
             } else {
-                if (isBuiltinFunction(signature)) {
+                String value = metadataProvider.getConfig().get(FunctionUtils.IMPORT_PRIVATE_FUNCTIONS);
+                boolean includePrivateFunctions = (value != null) ? Boolean.valueOf(value.toLowerCase()) : false;
+                if (isBuiltinFunction(signature, includePrivateFunctions)) {
                     continue;
                 } else {
                     throw new AsterixException(" unknown function " + signature);
@@ -190,15 +195,25 @@
 
     }
 
-    private boolean isBuiltinFunction(FunctionSignature functionSignature) {
-        if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-                functionSignature.getName(), functionSignature.getArity()))) {
+    private boolean isBuiltinFunction(FunctionSignature signature, boolean includePrivateFunctions) {
+        signature.setNamespace(AsterixBuiltinFunctions.FunctionNamespace.ASTERIX_PUBLIC.name());
+        if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(signature.getNamespace(),
+                signature.getName(), signature.getArity()))) {
             return true;
         }
 
-        if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(
-                AlgebricksBuiltinFunctions.ALGEBRICKS_NS, functionSignature.getName(), functionSignature.getArity()))) {
-            return true;
+        if (includePrivateFunctions) {
+            signature.setNamespace(AlgebricksBuiltinFunctions.ALGEBRICKS_NS);
+            if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(signature.getNamespace(),
+                    signature.getName(), signature.getArity()))) {
+                return true;
+            }
+
+            signature.setNamespace(AsterixBuiltinFunctions.FunctionNamespace.ASTERIX_PRIVATE.name());
+            if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(signature.getNamespace(),
+                    signature.getName(), signature.getArity()))) {
+                return true;
+            }
         }
 
         return false;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/util/FunctionUtils.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/util/FunctionUtils.java
index e3f3641..87525c9 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/util/FunctionUtils.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/util/FunctionUtils.java
@@ -32,6 +32,8 @@
 
 public class FunctionUtils {
 
+    public static final String IMPORT_PRIVATE_FUNCTIONS = "import-private-functions";
+
     public static FunctionDecl getFunctionDecl(Function function) throws AsterixException {
         String functionBody = function.getFunctionBody();
         List<String> params = function.getParams();
diff --git a/asterix-common/.gitignore b/asterix-common/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/asterix-common/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
index 03e84ef..8fe3341 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
@@ -149,6 +149,10 @@
         return mergePolicy;
     }
 
+    public double getBloomFilterFalsePositiveRate() {
+        return storageProperties.getBloomFilterFalsePositiveRate();
+    }
+
     public ILSMOperationTrackerFactory getLSMBTreeOperationTrackerFactory() {
         return lsmBTreeOpTrackerFactory;
     }
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContextProviderForRecovery.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContextProviderForRecovery.java
index 8f2b96f..10660cc 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContextProviderForRecovery.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContextProviderForRecovery.java
@@ -42,6 +42,11 @@
     }
 
     @Override
+    public double getBloomFilterFalsePositiveRate() {
+        return asterixAppRuntimeContext.getBloomFilterFalsePositiveRate();
+    }
+
+    @Override
     public ILSMMergePolicy getLSMMergePolicy() {
         return asterixAppRuntimeContext.getLSMMergePolicy();
     }
@@ -100,5 +105,4 @@
     public ILSMIOOperationCallbackProvider getNoOpIOOperationCallbackProvider() {
         return asterixAppRuntimeContext.getNoOpIOOperationCallbackProvider();
     }
-
 }
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/functions/FunctionSignature.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/functions/FunctionSignature.java
index 188593c..563b2cf 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/functions/FunctionSignature.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/functions/FunctionSignature.java
@@ -5,10 +5,10 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 public class FunctionSignature implements Serializable {
-    private final String namespace;
-    private final String name;
-    private final int arity;
-    private final String rep;
+    private  String namespace;
+    private  String name;
+    private  int arity;
+    private  String rep;
 
     public FunctionSignature(String namespace, String name, int arity) {
         this.namespace = namespace;
@@ -50,4 +50,16 @@
         return arity;
     }
 
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setArity(int arity) {
+        this.arity = arity;
+    }
+
 }
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
index 9f75973..e702ef3 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
@@ -32,95 +32,84 @@
 
 public class EventExecutor {
 
-	public static final String EVENTS_DIR = "events";
-	private static final String EXECUTE_SCRIPT = "execute.sh";
-	private static final String IP_LOCATION = "IP_LOCATION";
-	private static final String CLUSTER_ENV = "ENV";
-	private static final String SCRIPT = "SCRIPT";
-	private static final String ARGS = "ARGS";
-	private static final String DAEMON = "DAEMON";
+    public static final String EVENTS_DIR = "events";
+    private static final String EXECUTE_SCRIPT = "execute.sh";
+    private static final String IP_LOCATION = "IP_LOCATION";
+    private static final String CLUSTER_ENV = "ENV";
+    private static final String SCRIPT = "SCRIPT";
+    private static final String ARGS = "ARGS";
+    private static final String DAEMON = "DAEMON";
 
-	public void executeEvent(Node node, String script, List<String> args,
-			boolean isDaemon, Cluster cluster, Pattern pattern,
-			IOutputHandler outputHandler, EventrixClient client)
-			throws IOException {
-		List<String> pargs = new ArrayList<String>();
-		pargs.add("/bin/bash");
-		pargs.add(client.getEventsDir() + File.separator + "scripts"
-				+ File.separator + EXECUTE_SCRIPT);
-		StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "="
-				+ node.getClusterIp() + " ");
-		boolean isMasterNode = node.getId().equals(
-				cluster.getMasterNode().getId());
+    public void executeEvent(Node node, String script, List<String> args, boolean isDaemon, Cluster cluster,
+            Pattern pattern, IOutputHandler outputHandler, EventrixClient client) throws IOException {
+        List<String> pargs = new ArrayList<String>();
+        pargs.add("/bin/bash");
+        pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
+        StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getClusterIp() + " ");
+        boolean isMasterNode = node.getId().equals(cluster.getMasterNode().getId());
 
-		if (!node.getId().equals(EventDriver.CLIENT_NODE_ID)
-				&& cluster.getEnv() != null) {
-			for (Property p : cluster.getEnv().getProperty()) {
-				if (p.getKey().equals("JAVA_HOME")) {
-					String val = node.getJavaHome() == null ? p.getValue()
-							: node.getJavaHome();
-					envBuffer.append(p.getKey() + "=" + val + " ");
-				} else if (p.getKey().equals(EventUtil.NC_JAVA_OPTS)) {
-					if (!isMasterNode) {
-						StringBuilder builder = new StringBuilder();
-						builder.append("\"");
-						String javaOpts = p.getValue();
-						if (javaOpts != null) {
-							builder.append(javaOpts);
-						}
-						builder.append("\"");
-						envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
-					}
-				} else if (p.getKey().equals(EventUtil.CC_JAVA_OPTS)) {
-					if (isMasterNode) {
-						StringBuilder builder = new StringBuilder();
-						builder.append("\"");
-						String javaOpts = p.getValue();
-						if (javaOpts != null) {
-							builder.append(javaOpts);
-						}
-						builder.append("\"");
-						envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
-					}
-				} else if (p.getKey().equals("LOG_DIR")) {
-					String val = node.getLogDir() == null ? p.getValue() : node
-							.getLogDir();
-					envBuffer.append(p.getKey() + "=" + val + " ");
-				} else {
-					envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
-				}
+        if (!node.getId().equals(EventDriver.CLIENT_NODE_ID) && cluster.getEnv() != null) {
+            for (Property p : cluster.getEnv().getProperty()) {
+                if (p.getKey().equals("JAVA_HOME")) {
+                    String val = node.getJavaHome() == null ? p.getValue() : node.getJavaHome();
+                    envBuffer.append(p.getKey() + "=" + val + " ");
+                } else if (p.getKey().equals(EventUtil.NC_JAVA_OPTS)) {
+                    if (!isMasterNode) {
+                        StringBuilder builder = new StringBuilder();
+                        builder.append("\"");
+                        String javaOpts = p.getValue();
+                        if (javaOpts != null) {
+                            builder.append(javaOpts);
+                        }
+                        builder.append("\"");
+                        envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
+                    }
+                } else if (p.getKey().equals(EventUtil.CC_JAVA_OPTS)) {
+                    if (isMasterNode) {
+                        StringBuilder builder = new StringBuilder();
+                        builder.append("\"");
+                        String javaOpts = p.getValue();
+                        if (javaOpts != null) {
+                            builder.append(javaOpts);
+                        }
+                        builder.append("\"");
+                        envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
+                    }
+                } else if (p.getKey().equals("LOG_DIR")) {
+                    String val = node.getLogDir() == null ? p.getValue() : node.getLogDir();
+                    envBuffer.append(p.getKey() + "=" + val + " ");
+                } else {
+                    envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
+                }
 
-			}
-			pargs.add(cluster.getUsername() == null ? System
-					.getProperty("user.name") : cluster.getUsername());
-		}
+            }
+            pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
+        }
 
-		StringBuffer argBuffer = new StringBuffer();
-		if (args != null && args.size() > 0) {
-			for (String arg : args) {
-				argBuffer.append(arg + " ");
-			}
-		}
+        StringBuffer argBuffer = new StringBuffer();
+        if (args != null && args.size() > 0) {
+            for (String arg : args) {
+                argBuffer.append(arg + " ");
+            }
+        }
 
-		ProcessBuilder pb = new ProcessBuilder(pargs);
-		pb.environment().put(IP_LOCATION, node.getClusterIp());
-		pb.environment().put(CLUSTER_ENV, envBuffer.toString());
-		pb.environment().put(SCRIPT, script);
-		pb.environment().put(ARGS, argBuffer.toString());
-		pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+        ProcessBuilder pb = new ProcessBuilder(pargs);
+        pb.environment().put(IP_LOCATION, node.getClusterIp());
+        pb.environment().put(CLUSTER_ENV, envBuffer.toString());
+        pb.environment().put(SCRIPT, script);
+        pb.environment().put(ARGS, argBuffer.toString());
+        pb.environment().put(DAEMON, isDaemon ? "true" : "false");
 
-		Process p = pb.start();
-		if (!isDaemon) {
-			BufferedInputStream bis = new BufferedInputStream(p
-					.getInputStream());
-			StringWriter writer = new StringWriter();
-			IOUtils.copy(bis, writer, "UTF-8");
-			String result = writer.getBuffer().toString();
-			OutputAnalysis analysis = outputHandler.reportEventOutput(pattern
-					.getEvent(), result);
-			if (!analysis.isExpected()) {
-				throw new IOException(analysis.getErrorMessage() + result);
-			}
-		}
-	}
+        Process p = pb.start();
+        if (!isDaemon) {
+            BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
+            StringWriter writer = new StringWriter();
+            IOUtils.copy(bis, writer, "UTF-8");
+            String result = writer.getBuffer().toString();
+            OutputAnalysis analysis = outputHandler.reportEventOutput(pattern.getEvent(), result);
+            if (!analysis.isExpected()) {
+                throw new IOException(analysis.getErrorMessage() + result);
+            }
+        }
+    }
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
index 4216978..0f382f9 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
@@ -315,14 +315,11 @@
         List<Pattern> patternList = new ArrayList<Pattern>();
         Cluster cluster = instance.getCluster();
         Nodeid nodeid = null;
-        String pargs = null;
         Event event = null;
         for (Node node : cluster.getNode()) {
-            String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
-            String primaryIODevice = iodevices.split(",")[0].trim();
-            pargs = primaryIODevice + File.separator + InstallerUtil.TXN_LOG_DIR;
+            String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
             nodeid = new Nodeid(new Value(null, node.getId()));
-            event = new Event("file_delete", nodeid, pargs);
+            event = new Event("file_delete", nodeid, txnLogDir);
             patternList.add(new Pattern(null, 1, null, event));
         }
 
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
index 1eba89f..9839b90 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
@@ -28,9 +28,7 @@
 
     private static final long serialVersionUID = 2874439550187520449L;
 
-    public static final String CC_JAVA_OPTS = "cc_java_opts";
-    public static final String NC_JAVA_OPTS = "nc_java_opts";
-
+  
     public enum State {
         ACTIVE,
         INACTIVE,
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 8d5d13b..f3ccc9c 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
@@ -348,8 +348,9 @@
         if (create) {
             lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file, bufferCache,
                     fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
-                    runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
-                    runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
+                    runtimeContext.getBloomFilterFalsePositiveRate(), runtimeContext.getLSMMergePolicy(),
+                    runtimeContext.getLSMBTreeOperationTrackerFactory(), runtimeContext.getLSMIOScheduler(),
+                    AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
             lsmBtree.create();
             resourceID = runtimeContext.getResourceIdFactory().createId();
             indexLifecycleManager.register(resourceID, lsmBtree);
@@ -369,8 +370,9 @@
             if (lsmBtree == null) {
                 lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
                         bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
-                        runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
-                        runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
+                        runtimeContext.getBloomFilterFalsePositiveRate(), runtimeContext.getLSMMergePolicy(),
+                        runtimeContext.getLSMBTreeOperationTrackerFactory(), runtimeContext.getLSMIOScheduler(),
+                        AsterixRuntimeComponentsProvider.LSMBTREE_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 4773ed0..2e45802 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
@@ -548,7 +548,8 @@
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             storageProperties.getMemoryComponentPageSize(),
-                            storageProperties.getMemoryComponentNumPages()), retainInput, searchCallbackFactory);
+                            storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), retainInput, searchCallbackFactory);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeSearchOp, spPc.second);
 
         } catch (MetadataException me) {
@@ -617,7 +618,8 @@
                             AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER, proposeLinearizer(
                                     nestedKeyType.getTypeTag(), comparatorFactories.length),
                             storageProperties.getMemoryComponentPageSize(),
-                            storageProperties.getMemoryComponentNumPages()), retainInput, searchCallbackFactory);
+                            storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), retainInput, searchCallbackFactory);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(rtreeSearchOp, spPc.second);
 
         } catch (MetadataException me) {
@@ -777,7 +779,8 @@
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             storageProperties.getMemoryComponentPageSize(),
-                            storageProperties.getMemoryComponentNumPages()), NoOpOperationCallbackFactory.INSTANCE);
+                            storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), NoOpOperationCallbackFactory.INSTANCE);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeBulkLoad,
                     splitsAndConstraint.second);
         } catch (MetadataException me) {
@@ -844,8 +847,8 @@
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                    null, modificationCallbackFactory);
+                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), null, modificationCallbackFactory);
 
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeBulkLoad,
                     splitsAndConstraint.second);
@@ -1040,8 +1043,9 @@
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER, storageProperties
-                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                    filterFactory, modificationCallbackFactory);
+                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), filterFactory,
+                    modificationCallbackFactory);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeBulkLoad,
                     splitsAndConstraint.second);
         } catch (MetadataException e) {
@@ -1166,8 +1170,9 @@
                             AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER,
                             AsterixRuntimeComponentsProvider.LSMINVERTEDINDEX_PROVIDER, storageProperties
-                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages()),
-                    filterFactory, modificationCallbackFactory);
+                                    .getMemoryComponentPageSize(), storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), filterFactory,
+                    modificationCallbackFactory);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(insertDeleteOp,
                     splitsAndConstraint.second);
         } catch (MetadataException e) {
@@ -1262,7 +1267,9 @@
                             AsterixRuntimeComponentsProvider.LSMRTREE_PROVIDER, proposeLinearizer(
                                     nestedKeyType.getTypeTag(), comparatorFactories.length),
                             storageProperties.getMemoryComponentPageSize(),
-                            storageProperties.getMemoryComponentNumPages()), filterFactory, modificationCallbackFactory);
+                            storageProperties.getMemoryComponentNumPages(),
+                            storageProperties.getBloomFilterFalsePositiveRate()), filterFactory,
+                    modificationCallbackFactory);
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(rtreeUpdate, splitsAndConstraint.second);
         } catch (MetadataException | IOException e) {
             throw new AlgebricksException(e);
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/AsterixBuiltinTypeMap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/AsterixBuiltinTypeMap.java
index 27cf542..aa8f452 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/AsterixBuiltinTypeMap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/AsterixBuiltinTypeMap.java
@@ -40,6 +40,8 @@
         _builtinTypeMap.put("time", BuiltinType.ATIME);
         _builtinTypeMap.put("datetime", BuiltinType.ADATETIME);
         _builtinTypeMap.put("duration", BuiltinType.ADURATION);
+        _builtinTypeMap.put("year-month-duration", BuiltinType.AYEARMONTHDURATION);
+        _builtinTypeMap.put("day-time-duration", BuiltinType.ADAYTIMEDURATION);
         _builtinTypeMap.put("interval", BuiltinType.AINTERVAL);
         _builtinTypeMap.put("point", BuiltinType.APOINT);
         _builtinTypeMap.put("point3d", BuiltinType.APOINT3D);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..0c54ea1
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
@@ -0,0 +1,82 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class ACirclePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final ACirclePartialBinaryComparatorFactory INSTANCE = new ACirclePartialBinaryComparatorFactory();
+
+    private ACirclePartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                try {
+                    // center.x
+                    int c = Double
+                            .compare(
+                                    ADoubleSerializerDeserializer.getDouble(
+                                            b1,
+                                            s1
+                                                    + ACircleSerializerDeserializer
+                                                            .getCenterPointCoordinateOffset(Coordinate.X) - 1),
+                                    ADoubleSerializerDeserializer.getDouble(
+                                            b2,
+                                            s2
+                                                    + ACircleSerializerDeserializer
+                                                            .getCenterPointCoordinateOffset(Coordinate.X) - 1));
+                    if (c == 0) {
+                        // center.y
+                        c = Double.compare(
+                                ADoubleSerializerDeserializer.getDouble(b1,
+                                        s1 + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.Y)
+                                                - 1),
+                                ADoubleSerializerDeserializer.getDouble(b2,
+                                        s2 + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.Y)
+                                                - 1));
+                        if (c == 0) {
+                            // radius
+                            return Double.compare(
+                                    ADoubleSerializerDeserializer.getDouble(b1,
+                                            s1 + ACircleSerializerDeserializer.getRadiusOffset() - 1),
+                                    ADoubleSerializerDeserializer.getDouble(b2,
+                                            s2 + ACircleSerializerDeserializer.getRadiusOffset() - 1));
+                        }
+                    }
+                    return c;
+                } catch (HyracksDataException hex) {
+                    throw new IllegalStateException(hex);
+                }
+            }
+        };
+    }
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateOrTimeAscBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateOrTimeAscBinaryComparatorFactory.java
deleted file mode 100644
index 464a03c..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateOrTimeAscBinaryComparatorFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2009-2011 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.dataflow.data.nontagged.comparators;
-
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-
-public class ADateOrTimeAscBinaryComparatorFactory implements IBinaryComparatorFactory {
-
-    private static final long serialVersionUID = 1L;
-
-    public static final ADateOrTimeAscBinaryComparatorFactory INSTANCE = new ADateOrTimeAscBinaryComparatorFactory();
-
-    private ADateOrTimeAscBinaryComparatorFactory() {
-    }
-
-    /* (non-Javadoc)
-     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
-     */
-    @Override
-    public IBinaryComparator createBinaryComparator() {
-        return new IBinaryComparator() {
-
-            @Override
-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
-                int chrononTime1 = getInt(b1, s1);
-                int chrononTime2 = getInt(b2, s2);
-
-                if (chrononTime1 > chrononTime2) {
-                    return 1;
-                } else if (chrononTime1 < chrononTime2) {
-                    return -1;
-                } else {
-                    return 0;
-                }
-            }
-
-            private int getInt(byte[] bytes, int start) {
-                return ((bytes[start] & 0xff) << 24) + ((bytes[start + 1] & 0xff) << 16)
-                        + ((bytes[start + 2] & 0xff) << 8) + ((bytes[start + 3] & 0xff) << 0);
-            }
-        };
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateTimeAscBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateTimeAscBinaryComparatorFactory.java
deleted file mode 100644
index 2dd8785..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADateTimeAscBinaryComparatorFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.comparators;
-
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-
-public class ADateTimeAscBinaryComparatorFactory implements IBinaryComparatorFactory {
-    private static final long serialVersionUID = 1L;
-
-    public static final ADateTimeAscBinaryComparatorFactory INSTANCE = new ADateTimeAscBinaryComparatorFactory();
-
-    private ADateTimeAscBinaryComparatorFactory() {
-    }
-
-    @Override
-    public IBinaryComparator createBinaryComparator() {
-        return new IBinaryComparator() {
-
-            @Override
-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
-
-                long chrononTime1 = getLong(b1, s1);
-                long chrononTime2 = getLong(b2, s2);
-
-                if (chrononTime1 > chrononTime2) {
-                    return 1;
-                } else if (chrononTime1 < chrononTime2) {
-                    return -1;
-                } else {
-                    return 0;
-                }
-            }
-
-            private long getLong(byte[] bytes, int start) {
-                return (((long) (bytes[start] & 0xff)) << 56) + (((long) (bytes[start + 1] & 0xff)) << 48)
-                        + (((long) (bytes[start + 2] & 0xff)) << 40) + (((long) (bytes[start + 3] & 0xff)) << 32)
-                        + (((long) (bytes[start + 4] & 0xff)) << 24) + (((long) (bytes[start + 5] & 0xff)) << 16)
-                        + (((long) (bytes[start + 6] & 0xff)) << 8) + (((long) (bytes[start + 7] & 0xff)) << 0);
-            }
-
-        };
-    }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..877426d
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class ADurationPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final ADurationPartialBinaryComparatorFactory INSTANCE = new ADurationPartialBinaryComparatorFactory();
+
+    private ADurationPartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                int c = Integer.compare(
+                        AInt32SerializerDeserializer.getInt(b1,
+                                s1 + ADurationSerializerDeserializer.getYearMonthOffset()),
+                        AInt32SerializerDeserializer.getInt(b2,
+                                s2 + ADurationSerializerDeserializer.getYearMonthOffset()));
+                if (c == 0) {
+                    return Double.compare(
+                            ADoubleSerializerDeserializer.getDouble(b1,
+                                    s1 + ADurationSerializerDeserializer.getDayTimeOffset()),
+                            ADoubleSerializerDeserializer.getDouble(b2,
+                                    s2 + ADurationSerializerDeserializer.getDayTimeOffset()));
+                }
+                return c;
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..69f5051
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
@@ -0,0 +1,61 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class AIntervalPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final AIntervalPartialBinaryComparatorFactory INSTANCE = new AIntervalPartialBinaryComparatorFactory();
+
+    private AIntervalPartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                int c = Double.compare(
+                        AInt64SerializerDeserializer.getLong(b1,
+                                s1 + AIntervalSerializerDeserializer.getIntervalStartOffset()),
+                        AInt64SerializerDeserializer.getLong(b2,
+                                s2 + AIntervalSerializerDeserializer.getIntervalStartOffset()));
+                if (c == 0) {
+                    c = Double.compare(
+                            AInt64SerializerDeserializer.getLong(b1,
+                                    s1 + AIntervalSerializerDeserializer.getIntervalEndOffset()),
+                            AInt64SerializerDeserializer.getLong(b2,
+                                    s2 + AIntervalSerializerDeserializer.getIntervalEndOffset()));
+                    if (c == 0) {
+                        c = Byte.compare(b1[s1 + 16], b2[s2 + 16]);
+                    }
+                }
+                return c;
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..9f0fb57
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
@@ -0,0 +1,88 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ALineSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class ALinePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final ALinePartialBinaryComparatorFactory INSTANCE = new ALinePartialBinaryComparatorFactory();
+
+    private ALinePartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                try {
+                    int c = Double.compare(
+                            ADoubleSerializerDeserializer.getDouble(b1,
+                                    s1 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X) - 1),
+                            ADoubleSerializerDeserializer.getDouble(b2,
+                                    s2 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X) - 1));
+                    if (c == 0) {
+                        c = Double.compare(
+                                ADoubleSerializerDeserializer.getDouble(b1,
+                                        s1 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.Y)
+                                                - 1),
+                                ADoubleSerializerDeserializer.getDouble(b2,
+                                        s2 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.Y)
+                                                - 1));
+                        if (c == 0) {
+                            c = Double.compare(
+                                    ADoubleSerializerDeserializer.getDouble(b1,
+                                            s1 + ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X)
+                                                    - 1),
+                                    ADoubleSerializerDeserializer.getDouble(b2,
+                                            s2 + ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X)
+                                                    - 1));
+                            if (c == 0) {
+                                return Double.compare(
+                                        ADoubleSerializerDeserializer.getDouble(
+                                                b1,
+                                                s1
+                                                        + ALineSerializerDeserializer
+                                                                .getEndPointCoordinateOffset(Coordinate.Y) - 1),
+                                        ADoubleSerializerDeserializer.getDouble(
+                                                b2,
+                                                s2
+                                                        + ALineSerializerDeserializer
+                                                                .getEndPointCoordinateOffset(Coordinate.Y) - 1));
+                            }
+                        }
+                    }
+                    return c;
+                } catch (HyracksDataException hex) {
+                    throw new IllegalStateException(hex);
+                }
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
index ca926e4..865ab94 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
@@ -32,11 +32,20 @@
                     .createBinaryComparator();
             final IBinaryComparator ascDoubleComp = new PointableBinaryComparatorFactory(DoublePointable.FACTORY)
                     .createBinaryComparator();
-            final IBinaryComparator ascRectangleComp = RectangleBinaryComparatorFactory.INSTANCE
+            final IBinaryComparator ascRectangleComp = ARectanglePartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
-            final IBinaryComparator ascDateTimeComp = ADateTimeAscBinaryComparatorFactory.INSTANCE
+            final IBinaryComparator ascCircleComp = ACirclePartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
-            final IBinaryComparator ascDateOrTimeComp = ADateOrTimeAscBinaryComparatorFactory.INSTANCE
+            final IBinaryComparator ascDurationComp = ADurationPartialBinaryComparatorFactory.INSTANCE
+                    .createBinaryComparator();
+            final IBinaryComparator ascIntervalComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+                    .createBinaryComparator();
+            final IBinaryComparator ascLineComp = ALinePartialBinaryComparatorFactory.INSTANCE.createBinaryComparator();
+            final IBinaryComparator ascPointComp = APointPartialBinaryComparatorFactory.INSTANCE
+                    .createBinaryComparator();
+            final IBinaryComparator ascPoint3DComp = APoint3DPartialBinaryComparatorFactory.INSTANCE
+                    .createBinaryComparator();
+            final IBinaryComparator ascPolygonComp = APolygonPartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
             final IBinaryComparator rawComp = RawBinaryComparatorFactory.INSTANCE.createBinaryComparator();
 
@@ -58,9 +67,14 @@
                     case BOOLEAN: {
                         return ascBoolComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
+                    case TIME:
+                    case DATE:
+                    case YEARMONTHDURATION:
                     case INT32: {
                         return ascIntComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
+                    case DATETIME:
+                    case DAYTIMEDURATION:
                     case INT64: {
                         return ascLongComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
@@ -76,12 +90,26 @@
                     case RECTANGLE: {
                         return ascRectangleComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
-                    case DATETIME: {
-                        return ascDateTimeComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    case CIRCLE: {
+                        return ascCircleComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
-                    case TIME:
-                    case DATE: {
-                        return ascDateOrTimeComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    case POINT: {
+                        return ascPointComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    }
+                    case POINT3D: {
+                        return ascPoint3DComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    }
+                    case LINE: {
+                        return ascLineComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    }
+                    case POLYGON: {
+                        return ascPolygonComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    }
+                    case DURATION: {
+                        return ascDurationComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                    }
+                    case INTERVAL: {
+                        return ascIntervalComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
                     }
                     default: {
                         return rawComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..caf855a
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APoint3DSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksException;
+
+public class APoint3DPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final APoint3DPartialBinaryComparatorFactory INSTANCE = new APoint3DPartialBinaryComparatorFactory();
+
+    private APoint3DPartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                try {
+                    int c = Double.compare(
+                            ADoubleSerializerDeserializer.getDouble(b1,
+                                    s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1),
+                            ADoubleSerializerDeserializer.getDouble(b2,
+                                    s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
+                    if (c == 0) {
+                        c = Double.compare(
+                                ADoubleSerializerDeserializer.getDouble(b1,
+                                        s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1),
+                                ADoubleSerializerDeserializer.getDouble(b2,
+                                        s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1));
+                        if (c == 0) {
+                            return Double.compare(
+                                    ADoubleSerializerDeserializer.getDouble(b1,
+                                            s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Z) - 1),
+                                    ADoubleSerializerDeserializer.getDouble(b2,
+                                            s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Z) - 1));
+                        }
+                    }
+                    return c;
+                } catch (HyracksException hex) {
+                    throw new IllegalStateException(hex);
+                }
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..24d47eb
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
@@ -0,0 +1,61 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class APointPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static APointPartialBinaryComparatorFactory INSTANCE = new APointPartialBinaryComparatorFactory();
+
+    private APointPartialBinaryComparatorFactory() {
+
+    }
+
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                try {
+                    int c = Double.compare(
+                            ADoubleSerializerDeserializer.getDouble(b1,
+                                    s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1),
+                            ADoubleSerializerDeserializer.getDouble(b2,
+                                    s2 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
+                    if (c == 0) {
+                        return Double.compare(
+                                ADoubleSerializerDeserializer.getDouble(b1,
+                                        s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1),
+                                ADoubleSerializerDeserializer.getDouble(b2,
+                                        s2 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1));
+                    }
+                    return c;
+                } catch (HyracksDataException hex) {
+                    throw new IllegalStateException(hex);
+                }
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..fec245f
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
@@ -0,0 +1,90 @@
+/*
+ * 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.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APolygonSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.DoubleSerializerDeserializer;
+
+public class APolygonPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static APolygonPartialBinaryComparatorFactory INSTANCE = new APolygonPartialBinaryComparatorFactory();
+
+    private APolygonPartialBinaryComparatorFactory() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+     */
+    @Override
+    public IBinaryComparator createBinaryComparator() {
+        return new IBinaryComparator() {
+
+            @Override
+            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+                try {
+                    short pointCount1 = AInt16SerializerDeserializer.getShort(b1,
+                            s1 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1);
+                    int c = Short.compare(
+                            pointCount1,
+                            AInt16SerializerDeserializer.getShort(b2,
+                                    s2 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1));
+
+                    if (c == 0) {
+                        int ci = 0;
+                        for (int i = 0; i < pointCount1; i++) {
+                            ci = Double.compare(
+                                    DoubleSerializerDeserializer.getDouble(b1,
+                                            s1 + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.X)
+                                                    - 1),
+                                    DoubleSerializerDeserializer.getDouble(b2,
+                                            s1 + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.X)
+                                                    - 1));
+                            if (ci == 0) {
+                                ci = Double.compare(
+                                        DoubleSerializerDeserializer.getDouble(
+                                                b1,
+                                                s1
+                                                        + APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                                                Coordinate.Y) - 1),
+                                        DoubleSerializerDeserializer.getDouble(
+                                                b2,
+                                                s1
+                                                        + APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                                                Coordinate.Y) - 1));
+                                if (ci == 0) {
+                                    continue;
+                                }
+                            }
+                            return ci;
+                        }
+                    }
+
+                    return c;
+                } catch (HyracksDataException hex) {
+                    throw new IllegalStateException(hex);
+                }
+            }
+        };
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/RectangleBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
similarity index 86%
rename from asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/RectangleBinaryComparatorFactory.java
rename to asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
index bdc8409..63d0d24 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/RectangleBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
@@ -4,12 +4,12 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 
-public class RectangleBinaryComparatorFactory implements IBinaryComparatorFactory {
+public class ARectanglePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
     private static final long serialVersionUID = 1L;
 
-    public final static RectangleBinaryComparatorFactory INSTANCE = new RectangleBinaryComparatorFactory();
+    public final static ARectanglePartialBinaryComparatorFactory INSTANCE = new ARectanglePartialBinaryComparatorFactory();
 
-    private RectangleBinaryComparatorFactory() {
+    private ARectanglePartialBinaryComparatorFactory() {
     }
 
     @Override
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/AObjectBinaryHashFunctionFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/AObjectBinaryHashFunctionFactory.java
index 2d19320..495b41f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/AObjectBinaryHashFunctionFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/AObjectBinaryHashFunctionFactory.java
@@ -4,6 +4,7 @@
 import edu.uci.ics.asterix.om.types.EnumDeserializer;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
+import edu.uci.ics.hyracks.data.std.accessors.MurmurHash3BinaryHashFunctionFamily;
 import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
 import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
@@ -33,9 +34,9 @@
 
             private IBinaryHashFunction doubleHash = DoubleBinaryHashFunctionFactory.INSTANCE
                     .createBinaryHashFunction();
-            private IBinaryHashFunction rectangleHash = RectangleBinaryHashFunctionFactory.INSTANCE
-                    .createBinaryHashFunction();
-            private IBinaryHashFunction rawHash = RawBinaryHashFunctionFactory.INSTANCE.createBinaryHashFunction();
+
+            private IBinaryHashFunction genericBinaryHash = MurmurHash3BinaryHashFunctionFamily.INSTANCE
+                    .createBinaryHashFunction(0);
 
             @Override
             public int hash(byte[] bytes, int offset, int length) {
@@ -44,9 +45,14 @@
                     case BOOLEAN: {
                         return boolHash.hash(bytes, offset + 1, length - 1);
                     }
+                    case TIME:
+                    case DATE:
+                    case YEARMONTHDURATION:
                     case INT32: {
                         return intHash.hash(bytes, offset + 1, length - 1);
                     }
+                    case DATETIME:
+                    case DAYTIMEDURATION:
                     case INT64: {
                         return longHash.hash(bytes, offset + 1, length - 1);
                     }
@@ -59,14 +65,11 @@
                     case STRING: {
                         return stringHash.hash(bytes, offset + 1, length - 1);
                     }
-                    case RECTANGLE: {
-                        return rectangleHash.hash(bytes, offset + 1, length - 1);
-                    }
                     case NULL: {
                         return 0;
                     }
                     default: {
-                        return rawHash.hash(bytes, offset + 1, length - 1);
+                        return genericBinaryHash.hash(bytes, offset + 1, length - 1);
                     }
                 }
             }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/MurmurHash3BinaryHashFunctionFamily.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/MurmurHash3BinaryHashFunctionFamily.java
deleted file mode 100644
index 83b165b..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/MurmurHash3BinaryHashFunctionFamily.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2009-2010 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.dataflow.data.nontagged.hash;
-
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
-
-/**
- * An implementation of the Murmur3 hash family. The code is implemented based
- * on the original <a
- * href=http://code.google.com/p/guava-libraries/source/browse
- * /guava/src/com/google/common/hash/Murmur3_32HashFunction.java>guava
- * implementation</a> from Google Guava library.
- */
-public class MurmurHash3BinaryHashFunctionFamily implements
-		IBinaryHashFunctionFamily {
-
-	public static final IBinaryHashFunctionFamily INSTANCE = new MurmurHash3BinaryHashFunctionFamily();
-
-	private static final long serialVersionUID = 1L;
-
-	private MurmurHash3BinaryHashFunctionFamily() {
-	}
-
-	private static final int C1 = 0xcc9e2d51;
-	private static final int C2 = 0x1b873593;
-	private static final int C3 = 5;
-	private static final int C4 = 0xe6546b64;
-	private static final int C5 = 0x85ebca6b;
-	private static final int C6 = 0xc2b2ae35;
-
-	@Override
-	public IBinaryHashFunction createBinaryHashFunction(final int seed) {
-		return new IBinaryHashFunction() {
-			@Override
-			public int hash(byte[] bytes, int offset, int length) {
-				int h = seed;
-				int p = offset;
-				int remain = length;
-				while (remain >= 4) {
-					int k = (bytes[p] & 0xff) | ((bytes[p + 1] & 0xff) << 8)
-							| ((bytes[p + 2] & 0xff) << 16)
-							| ((bytes[p + 3] & 0xff) << 24);
-					k *= C1;
-					k = Integer.rotateLeft(k, 15);
-					k *= C2;
-					h ^= k;
-					h = Integer.rotateLeft(h, 13);
-					h = h * C3 + C4;
-					p += 4;
-					remain -= 4;
-				}
-				if (remain > 0) {
-					int k = 0;
-					for (int i = 0; remain > 0; i += 8) {
-						k ^= (bytes[p++] & 0xff) << i;
-						remain--;
-					}
-					k *= C1;
-					k = Integer.rotateLeft(k, 15);
-					k *= C2;
-					h ^= k;
-				}
-				h ^= length;
-				h ^= (h >>> 16);
-				h *= C5;
-				h ^= (h >>> 13);
-				h *= C6;
-				h ^= (h >>> 16);
-				return h;
-			}
-		};
-	}
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RawBinaryHashFunctionFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RawBinaryHashFunctionFactory.java
deleted file mode 100644
index 4aeb00e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RawBinaryHashFunctionFactory.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.hash;
-
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-
-public class RawBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {
-    private static final long serialVersionUID = 1L;
-
-    public static IBinaryHashFunctionFactory INSTANCE = new RawBinaryHashFunctionFactory();
-
-    private RawBinaryHashFunctionFactory() {
-    }
-
-    @Override
-    public IBinaryHashFunction createBinaryHashFunction() {
-
-        return new IBinaryHashFunction() {
-            @Override
-            public int hash(byte[] bytes, int offset, int length) {
-                int value = 1;
-                int end = offset + length;
-                for (int i = offset; i < end; i++)
-                    value = value * 31 + (int) bytes[i];
-                return value;
-            }
-        };
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RectangleBinaryHashFunctionFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RectangleBinaryHashFunctionFactory.java
deleted file mode 100644
index 83bc50e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/hash/RectangleBinaryHashFunctionFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.hash;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-
-public class RectangleBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {
-
-    private static final long serialVersionUID = 1L;
-
-    public static final RectangleBinaryHashFunctionFactory INSTANCE = new RectangleBinaryHashFunctionFactory();
-
-    private RectangleBinaryHashFunctionFactory() {
-    }
-
-    @Override
-    public IBinaryHashFunction createBinaryHashFunction() {
-        return new IBinaryHashFunction() {
-            @Override
-            public int hash(byte[] bytes, int offset, int length) {
-                long xBits = ADoubleSerializerDeserializer.getLongBits(bytes, offset);
-                long yBits = ADoubleSerializerDeserializer.getLongBits(bytes, offset + 8);
-                return (int) ((xBits ^ (xBits >>> 32)) ^ (yBits ^ (yBits >>> 32)));
-            }
-        };
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinter.java
new file mode 100644
index 0000000..c596a8c
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinter.java
@@ -0,0 +1,77 @@
+package edu.uci.ics.asterix.dataflow.data.nontagged.printers;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.utils.WriteValueTools;
+
+public class ADayTimeDurationPrinter implements IPrinter {
+
+    public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
+    private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
+    
+    @Override
+    public void init() throws AlgebricksException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+        boolean positive = true;
+        long milliseconds = AInt64SerializerDeserializer.getLong(b, s + 1);
+
+        // set the negative flag. "||" is necessary in case that months field is not there (so it is 0)
+        if (milliseconds < 0) {
+            milliseconds *= -1;
+            positive = false;
+        }
+
+        int millisecond = gCalInstance.getDurationMillisecond(milliseconds);
+        int second = gCalInstance.getDurationSecond(milliseconds);
+        int minute = gCalInstance.getDurationMinute(milliseconds);
+        int hour = gCalInstance.getDurationHour(milliseconds);
+        int day = gCalInstance.getDurationDay(milliseconds);
+
+        ps.print("day-time-duration(\"");
+        if (!positive) {
+            ps.print("-");
+        }
+        try {
+            ps.print("P");
+            if (day != 0) {
+                WriteValueTools.writeInt(day, ps);
+                ps.print("D");
+            }
+            if (hour != 0 || minute != 0 || second != 0 || millisecond != 0) {
+                ps.print("T");
+            }
+            if (hour != 0) {
+                WriteValueTools.writeInt(hour, ps);
+                ps.print("H");
+            }
+            if (minute != 0) {
+                WriteValueTools.writeInt(minute, ps);
+                ps.print("M");
+            }
+            if (second != 0 || millisecond != 0) {
+                WriteValueTools.writeInt(second, ps);
+            }
+            if (millisecond > 0) {
+                ps.print(".");
+                WriteValueTools.writeInt(millisecond, ps);
+            }
+            if (second != 0 || millisecond != 0) {
+                ps.print("S");
+            }
+            ps.print("\")");
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
+        }
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinterFactory.java
new file mode 100644
index 0000000..4817916
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADayTimeDurationPrinterFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.dataflow.data.nontagged.printers;
+
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+
+public class ADayTimeDurationPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+
+    @Override
+    public IPrinter createPrinter() {
+        return ADayTimeDurationPrinter.INSTANCE;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AObjectPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AObjectPrinter.java
index 478ad2c..41fd904 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AObjectPrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AObjectPrinter.java
@@ -73,6 +73,14 @@
                 ADurationPrinter.INSTANCE.print(b, s, l, ps);
                 break;
             }
+            case YEARMONTHDURATION: {
+                AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
+                break;
+            }
+            case DAYTIMEDURATION: {
+                ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
+                break;
+            }
             case INTERVAL: {
                 AIntervalPrinter.INSTANCE.print(b, s, l, ps);
                 break;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinter.java
new file mode 100644
index 0000000..29e2529
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinter.java
@@ -0,0 +1,75 @@
+/*
+ * 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.dataflow.data.nontagged.printers;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.utils.WriteValueTools;
+
+public class AYearMonthDurationPrinter implements IPrinter {
+
+    public static final AYearMonthDurationPrinter INSTANCE = new AYearMonthDurationPrinter();
+    private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#init()
+     */
+    @Override
+    public void init() throws AlgebricksException {
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#print(byte[], int, int, java.io.PrintStream)
+     */
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+        boolean positive = true;
+        int months = AInt32SerializerDeserializer.getInt(b, s + 1);
+
+        // set the negative flag. "||" is necessary in case that months field is not there (so it is 0)
+        if (months < 0) {
+            months *= -1;
+            positive = false;
+        }
+
+        int month = gCalInstance.getDurationMonth(months);
+        int year = gCalInstance.getDurationYear(months);
+
+        ps.print("year-month-duration(\"");
+        if (!positive) {
+            ps.print("-");
+        }
+        try {
+            ps.print("P");
+            if (year != 0) {
+                WriteValueTools.writeInt(year, ps);
+                ps.print("Y");
+            }
+            if (month != 0) {
+                WriteValueTools.writeInt(month, ps);
+                ps.print("M");
+            }
+            ps.print("\")");
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
+        }
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinterFactory.java
new file mode 100644
index 0000000..7e6111d
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AYearMonthDurationPrinterFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.dataflow.data.nontagged.printers;
+
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+
+public class AYearMonthDurationPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinterFactory#createPrinter()
+     */
+    @Override
+    public IPrinter createPrinter() {
+        return AYearMonthDurationPrinter.INSTANCE;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinter.java
new file mode 100644
index 0000000..552e8d7
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinter.java
@@ -0,0 +1,28 @@
+package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
+
+import java.io.PrintStream;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+
+public class ADayTimeDurationPrinter implements IPrinter {
+
+    public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
+
+    @Override
+    public void init() throws AlgebricksException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+        long milliseconds = AInt64SerializerDeserializer.getLong(b, s + 1);
+
+        ps.print("{ day-time-duration: ");
+        ps.print(milliseconds);
+        ps.print("}");
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinterFactory.java
new file mode 100644
index 0000000..bbf0a70
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADayTimeDurationPrinterFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.dataflow.data.nontagged.printers.json;
+
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+
+public class ADayTimeDurationPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+
+    @Override
+    public IPrinter createPrinter() {
+        return ADayTimeDurationPrinter.INSTANCE;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinter.java
new file mode 100644
index 0000000..c6afb74
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinter.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2009-2011 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.dataflow.data.nontagged.printers.json;
+
+import java.io.PrintStream;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+
+public class AIntervalPrinter implements IPrinter {
+
+    public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#init()
+     */
+    @Override
+    public void init() throws AlgebricksException {
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#print(byte[], int, int, java.io.PrintStream)
+     */
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+        ps.print("{ interval: { start: ");
+
+        short typetag = AInt8SerializerDeserializer.getByte(b, s + 1 + 8 * 2);
+
+        IPrinter timeInstancePrinter;
+
+        if (typetag == ATypeTag.DATE.serialize()) {
+            timeInstancePrinter = ADatePrinter.INSTANCE;
+            ((ADatePrinter) timeInstancePrinter).print(b, s + 4, 4, ps);
+            ps.print(", end: ");
+            ((ADatePrinter) timeInstancePrinter).print(b, s + 12, 4, ps);
+        } else if (typetag == ATypeTag.TIME.serialize()) {
+            timeInstancePrinter = ATimePrinter.INSTANCE;
+            ((ATimePrinter) timeInstancePrinter).print(b, s + 4, 4, ps);
+            ps.print(", end: ");
+            ((ATimePrinter) timeInstancePrinter).print(b, s + 12, 4, ps);
+        } else if (typetag == ATypeTag.DATETIME.serialize()) {
+            timeInstancePrinter = ADateTimePrinter.INSTANCE;
+            ((ADateTimePrinter) timeInstancePrinter).print(b, s, 8, ps);
+            ps.print(", end: ");
+            ((ADateTimePrinter) timeInstancePrinter).print(b, s + 8, 8, ps);
+        } else {
+            throw new AlgebricksException("Unsupport internal time types in interval: " + typetag);
+        }
+
+        ps.print("}}");
+    }
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinterFactory.java
new file mode 100644
index 0000000..7b3c3fe
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AIntervalPrinterFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2011 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.dataflow.data.nontagged.printers.json;
+
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+
+public class AIntervalPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final AIntervalPrinterFactory INSTANCE = new AIntervalPrinterFactory();
+
+    @Override
+    public IPrinter createPrinter() {
+        return AIntervalPrinter.INSTANCE;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java
index 29c4ee1..3cf4ff2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java
@@ -73,6 +73,14 @@
                 ADurationPrinter.INSTANCE.print(b, s, l, ps);
                 break;
             }
+            case YEARMONTHDURATION: {
+                AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
+                break;
+            }
+            case DAYTIMEDURATION: {
+                ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
+                break;
+            }
             case POINT: {
                 APointPrinter.INSTANCE.print(b, s, l, ps);
                 break;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinter.java
new file mode 100644
index 0000000..163dc52
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinter.java
@@ -0,0 +1,47 @@
+/*
+ * 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.dataflow.data.nontagged.printers.json;
+
+import java.io.PrintStream;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+
+public class AYearMonthDurationPrinter implements IPrinter {
+
+    public static final AYearMonthDurationPrinter INSTANCE = new AYearMonthDurationPrinter();
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#init()
+     */
+    @Override
+    public void init() throws AlgebricksException {
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinter#print(byte[], int, int, java.io.PrintStream)
+     */
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+
+        int months = AInt32SerializerDeserializer.getInt(b, s + 1);
+
+        ps.print("{ year-month-duration: ");
+        ps.print(months);
+        ps.print("}");
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinterFactory.java
new file mode 100644
index 0000000..b32d010
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AYearMonthDurationPrinterFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.dataflow.data.nontagged.printers.json;
+
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+
+public class AYearMonthDurationPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.algebricks.data.IPrinterFactory#createPrinter()
+     */
+    @Override
+    public IPrinter createPrinter() {
+        return AYearMonthDurationPrinter.INSTANCE;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADayTimeDurationSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADayTimeDurationSerializerDeserializer.java
new file mode 100644
index 0000000..b016af0
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADayTimeDurationSerializerDeserializer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.dataflow.data.nontagged.serde;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
+import edu.uci.ics.asterix.om.base.AMutableDayTimeDuration;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class ADayTimeDurationSerializerDeserializer implements ISerializerDeserializer<ADayTimeDuration> {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final ADayTimeDurationSerializerDeserializer INSTNACE = new ADayTimeDurationSerializerDeserializer();
+
+    @SuppressWarnings("unchecked")
+    private static final ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
+    private static final AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0);
+
+    @Override
+    public ADayTimeDuration deserialize(DataInput in) throws HyracksDataException {
+        try {
+            return new ADayTimeDuration(in.readLong());
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
+    }
+
+    @Override
+    public void serialize(ADayTimeDuration instance, DataOutput out) throws HyracksDataException {
+        try {
+            out.writeLong(instance.getMilliseconds());
+        } catch (IOException e) {
+            throw new HyracksDataException();
+        }
+    }
+
+    public static void parse(String durationString, DataOutput out) throws HyracksDataException {
+        try {
+            ADurationParserFactory.parseDuration(durationString, 0, durationString.length(), aDayTimeDuration,
+                    ADurationParseOption.All);
+            dayTimeDurationSerde.serialize(aDayTimeDuration, out);
+        } catch (Exception e) {
+            throw new HyracksDataException(e);
+        }
+    }
+
+    public static long getDayTime(byte[] data, int offset) {
+        return AInt64SerializerDeserializer.getLong(data, offset);
+    }
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
index 6930f60..498a5b8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
@@ -8,6 +8,7 @@
 import edu.uci.ics.asterix.om.base.ADuration;
 import edu.uci.ics.asterix.om.base.AMutableDuration;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -46,7 +47,7 @@
 
     public static void parse(String duration, DataOutput out) throws HyracksDataException {
         try {
-            ADurationParserFactory.parseDuration(duration, 0, duration.length(), aDuration);
+            ADurationParserFactory.parseDuration(duration, 0, duration.length(), aDuration, ADurationParseOption.All);
             durationSerde.serialize(aDuration, out);
         } catch (Exception e) {
             throw new HyracksDataException(e);
@@ -61,7 +62,7 @@
      * @return
      */
     public static int getYearMonth(byte[] data, int offset) {
-        return AInt32SerializerDeserializer.getInt(data, offset);
+        return AInt32SerializerDeserializer.getInt(data, offset + getYearMonthOffset());
     }
 
     /**
@@ -72,6 +73,14 @@
      * @return
      */
     public static long getDayTime(byte[] data, int offset) {
-        return AInt64SerializerDeserializer.getLong(data, offset + 4);
+        return AInt64SerializerDeserializer.getLong(data, offset + getDayTimeOffset());
+    }
+
+    public static int getYearMonthOffset() {
+        return 0;
+    }
+
+    public static int getDayTimeOffset() {
+        return 4;
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 8c4def0..318d10e 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -66,11 +66,19 @@
     }
 
     public static long getIntervalStart(byte[] data, int offset) {
-        return AInt64SerializerDeserializer.getLong(data, offset);
+        return AInt64SerializerDeserializer.getLong(data, offset + getIntervalStartOffset());
     }
 
     public static long getIntervalEnd(byte[] data, int offset) {
-        return AInt64SerializerDeserializer.getLong(data, offset + 8);
+        return AInt64SerializerDeserializer.getLong(data, offset + getIntervalEndOffset());
+    }
+
+    public static int getIntervalStartOffset() {
+        return 0;
+    }
+
+    public static int getIntervalEndOffset() {
+        return 8;
     }
 
     public static byte getIntervalTimeType(byte[] data, int offset) {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
index 2e4f72c..88aa7f4 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
@@ -86,6 +86,12 @@
             case DURATION: {
                 return ADurationSerializerDeserializer.INSTANCE.deserialize(in);
             }
+            case YEARMONTHDURATION: {
+                return AYearMonthDurationerializerDeserializer.INSTANCE.deserialize(in);
+            }
+            case DAYTIMEDURATION: {
+                return ADayTimeDurationSerializerDeserializer.INSTNACE.deserialize(in);
+            }
             case INTERVAL: {
                 return AIntervalSerializerDeserializer.INSTANCE.deserialize(in);
             }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java
new file mode 100644
index 0000000..79bf3c0
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java
@@ -0,0 +1,73 @@
+/*
+ * 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.dataflow.data.nontagged.serde;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AMutableYearMonthDuration;
+import edu.uci.ics.asterix.om.base.AYearMonthDuration;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class AYearMonthDurationerializerDeserializer implements ISerializerDeserializer<AYearMonthDuration> {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final AYearMonthDurationerializerDeserializer INSTANCE = new AYearMonthDurationerializerDeserializer();
+
+    @SuppressWarnings("unchecked")
+    private static final ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION);
+    private static final AMutableYearMonthDuration aYearMonthDuration = new AMutableYearMonthDuration(0);
+
+    @Override
+    public AYearMonthDuration deserialize(DataInput in) throws HyracksDataException {
+        try {
+            return new AYearMonthDuration(in.readInt());
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
+    }
+
+    @Override
+    public void serialize(AYearMonthDuration instance, DataOutput out) throws HyracksDataException {
+        try {
+            out.writeInt(instance.getMonths());
+        } catch (IOException e) {
+            throw new HyracksDataException();
+        }
+    }
+
+    public static void parse(String durationString, DataOutput out) throws HyracksDataException {
+        try {
+            ADurationParserFactory.parseDuration(durationString, 0, durationString.length(), aYearMonthDuration,
+                    ADurationParseOption.All);
+            yearMonthDurationSerde.serialize(aYearMonthDuration, out);
+        } catch (Exception e) {
+            throw new HyracksDataException(e);
+        }
+    }
+
+    public static int getYearMonth(byte[] data, int offset) {
+        return AInt32SerializerDeserializer.getInt(data, offset);
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
index 38fddb7..fb9d195 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
@@ -2,13 +2,18 @@
 
 import java.io.Serializable;
 
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateOrTimeAscBinaryComparatorFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateTimeAscBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AObjectAscBinaryComparatorFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AObjectDescBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APoint3DPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APointPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APolygonPartialBinaryComparatorFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.BooleanBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ARectanglePartialBinaryComparatorFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.RawBinaryComparatorFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.RectangleBinaryComparatorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.hyracks.algebricks.data.IBinaryComparatorFactoryProvider;
@@ -102,9 +107,14 @@
             case INT16: {
                 return addOffset(SHORT_POINTABLE_INSTANCE, ascending);
             }
+            case DATE:
+            case TIME:
+            case YEARMONTHDURATION:
             case INT32: {
                 return addOffset(INTEGER_POINTABLE_INSTANCE, ascending);
             }
+            case DATETIME:
+            case DAYTIMEDURATION:
             case INT64: {
                 return addOffset(LONG_POINTABLE_INSTANCE, ascending);
             }
@@ -118,14 +128,28 @@
                 return addOffset(UTF8STRING_POINTABLE_INSTANCE, ascending);
             }
             case RECTANGLE: {
-                return addOffset(RectangleBinaryComparatorFactory.INSTANCE, ascending);
+                return addOffset(ARectanglePartialBinaryComparatorFactory.INSTANCE, ascending);
             }
-            case DATE:
-            case TIME: {
-                return addOffset(ADateOrTimeAscBinaryComparatorFactory.INSTANCE, ascending);
+            case CIRCLE: {
+                return addOffset(ACirclePartialBinaryComparatorFactory.INSTANCE, ascending);
             }
-            case DATETIME: {
-                return addOffset(ADateTimeAscBinaryComparatorFactory.INSTANCE, ascending);
+            case POINT: {
+                return addOffset(APointPartialBinaryComparatorFactory.INSTANCE, ascending);
+            }
+            case POINT3D: {
+                return addOffset(APoint3DPartialBinaryComparatorFactory.INSTANCE, ascending);
+            }
+            case LINE: {
+                return addOffset(ALinePartialBinaryComparatorFactory.INSTANCE, ascending);
+            }
+            case POLYGON: {
+                return addOffset(APolygonPartialBinaryComparatorFactory.INSTANCE, ascending);
+            }
+            case DURATION: {
+                return addOffset(ADurationPartialBinaryComparatorFactory.INSTANCE, ascending);
+            }
+            case INTERVAL: {
+                return addOffset(AIntervalPartialBinaryComparatorFactory.INSTANCE, ascending);
             }
             default: {
                 return addOffset(RawBinaryComparatorFactory.INSTANCE, ascending);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFactoryProvider.java
index 5498374..33698bd 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFactoryProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFactoryProvider.java
@@ -6,12 +6,11 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.hash.BooleanBinaryHashFunctionFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.hash.DoubleBinaryHashFunctionFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.hash.LongBinaryHashFunctionFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.hash.RawBinaryHashFunctionFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.hash.RectangleBinaryHashFunctionFactory;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFactoryProvider;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
+import edu.uci.ics.hyracks.data.std.accessors.MurmurHash3BinaryHashFunctionFamily;
 import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
 import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
 import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
@@ -69,9 +68,14 @@
             case BOOLEAN: {
                 return addOffset(BooleanBinaryHashFunctionFactory.INSTANCE);
             }
+            case DATE:
+            case TIME:
+            case YEARMONTHDURATION:
             case INT32: {
                 return addOffset(new PointableBinaryHashFunctionFactory(IntegerPointable.FACTORY));
             }
+            case DAYTIMEDURATION:
+            case DATETIME:
             case INT64: {
                 return addOffset(LongBinaryHashFunctionFactory.INSTANCE);
             }
@@ -84,11 +88,8 @@
             case STRING: {
                 return addOffset(new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY));
             }
-            case RECTANGLE: {
-                return addOffset(RectangleBinaryHashFunctionFactory.INSTANCE);
-            }
             default: {
-                return addOffset(RawBinaryHashFunctionFactory.INSTANCE);
+                return addOffsetForGenericBinaryHash();
             }
         }
     }
@@ -112,4 +113,16 @@
         };
     }
 
+    private IBinaryHashFunctionFactory addOffsetForGenericBinaryHash() {
+        return new IBinaryHashFunctionFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IBinaryHashFunction createBinaryHashFunction() {
+                return MurmurHash3BinaryHashFunctionFamily.INSTANCE.createBinaryHashFunction(0);
+            }
+        };
+    }
+
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFamilyProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFamilyProvider.java
index bc7ba26..61ac6fa 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFamilyProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryHashFunctionFamilyProvider.java
@@ -17,8 +17,8 @@
 
 import java.io.Serializable;
 
-import edu.uci.ics.asterix.dataflow.data.nontagged.hash.MurmurHash3BinaryHashFunctionFamily;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.data.std.accessors.MurmurHash3BinaryHashFunctionFamily;
 import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFamilyProvider;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
 
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
index b8c6ab0..842a6e8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
@@ -14,11 +14,11 @@
  */
 package edu.uci.ics.asterix.formats.nontagged;
 
-
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ABooleanPrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ACirclePrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADatePrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADateTimePrinterFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADayTimeDurationPrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADoublePrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADurationPrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AFloatPrinterFactory;
@@ -40,6 +40,8 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ATimePrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AUnionPrinterFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AUnorderedlistPrinterFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AYearMonthDurationPrinter;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AYearMonthDurationPrinterFactory;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.AUnionType;
@@ -63,8 +65,8 @@
 
         if (aqlType != null) {
             switch (aqlType.getTypeTag()) {
-                // case ANYTYPE:
-                // return AAnyTypePrinterFactory.INSTANCE;
+            // case ANYTYPE:
+            // return AAnyTypePrinterFactory.INSTANCE;
                 case INT8:
                     return AInt8PrinterFactory.INSTANCE;
                 case INT16:
@@ -89,6 +91,10 @@
                     return ADateTimePrinterFactory.INSTANCE;
                 case DURATION:
                     return ADurationPrinterFactory.INSTANCE;
+                case YEARMONTHDURATION:
+                    return AYearMonthDurationPrinterFactory.INSTANCE;
+                case DAYTIMEDURATION:
+                    return ADayTimeDurationPrinterFactory.INSTANCE;
                 case POINT:
                     return APointPrinterFactory.INSTANCE;
                 case POINT3D:
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlNormalizedKeyComputerFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlNormalizedKeyComputerFactoryProvider.java
index 23306ed..b4a1fd8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlNormalizedKeyComputerFactoryProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlNormalizedKeyComputerFactoryProvider.java
@@ -23,9 +23,14 @@
         IAType aqlType = (IAType) type;
         if (ascending) {
             switch (aqlType.getTypeTag()) {
+                case DATE:
+                case TIME:
+                case YEARMONTHDURATION:
                 case INT32: {
                     return new AWrappedAscNormalizedKeyComputerFactory(new IntegerNormalizedKeyComputerFactory());
                 }
+                case DATETIME:
+                case DAYTIMEDURATION:
                 case INT64: {
                     return new AWrappedAscNormalizedKeyComputerFactory(new Integer64NormalizedKeyComputerFactory());
                 }
@@ -44,9 +49,14 @@
             }
         } else {
             switch (aqlType.getTypeTag()) {
+                case DATE:
+                case TIME:
+                case YEARMONTHDURATION:
                 case INT32: {
                     return new AWrappedDescNormalizedKeyComputerFactory(new IntegerNormalizedKeyComputerFactory());
                 }
+                case DATETIME:
+                case DAYTIMEDURATION:
                 case INT64: {
                     return new AWrappedDescNormalizedKeyComputerFactory(new Integer64NormalizedKeyComputerFactory());
                 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
index 29e33fd..92cfc5b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
@@ -9,6 +9,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
@@ -29,6 +30,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
@@ -112,6 +114,12 @@
             case DURATION: {
                 return ADurationSerializerDeserializer.INSTANCE;
             }
+            case YEARMONTHDURATION: {
+                return AYearMonthDurationerializerDeserializer.INSTANCE;
+            }
+            case DAYTIMEDURATION: {
+                return ADayTimeDurationSerializerDeserializer.INSTNACE;
+            }
             case INTERVAL: {
                 return AIntervalSerializerDeserializer.INSTANCE;
             }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADayTimeDuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADayTimeDuration.java
new file mode 100644
index 0000000..03a9627
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADayTimeDuration.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.base;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.asterix.om.visitors.IOMVisitor;
+
+public class ADayTimeDuration implements IAObject {
+
+    protected long chrononInMillisecond;
+
+    public ADayTimeDuration(long millisecond) {
+        this.chrononInMillisecond = millisecond;
+    }
+
+    public long getMilliseconds() {
+        return chrononInMillisecond;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.JSONSerializable#toJSON()
+     */
+    @Override
+    public JSONObject toJSON() throws JSONException {
+        JSONObject json = new JSONObject();
+
+        JSONObject duration = new JSONObject();
+        duration.put("milliseconds", chrononInMillisecond);
+        json.put("ADuration", duration);
+
+        return json;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#getType()
+     */
+    @Override
+    public IAType getType() {
+        return BuiltinType.ADAYTIMEDURATION;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#accept(edu.uci.ics.asterix.om.visitors.IOMVisitor)
+     */
+    @Override
+    public void accept(IOMVisitor visitor) throws AsterixException {
+        visitor.visitADayTimeDuration(this);
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#deepEqual(edu.uci.ics.asterix.om.base.IAObject)
+     */
+    @Override
+    public boolean deepEqual(IAObject obj) {
+        return equals(obj);
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#hash()
+     */
+    @Override
+    public int hash() {
+        return hashCode();
+    }
+
+    public boolean equals(Object o) {
+        if (o instanceof ADayTimeDuration) {
+            return ((ADayTimeDuration) o).chrononInMillisecond == chrononInMillisecond;
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return (int) (chrononInMillisecond ^ (chrononInMillisecond >>> 32));
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableDayTimeDuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableDayTimeDuration.java
new file mode 100644
index 0000000..ebd0a18
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableDayTimeDuration.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.base;
+
+public class AMutableDayTimeDuration extends ADayTimeDuration {
+
+    public AMutableDayTimeDuration(long milliseconds) {
+        super(milliseconds);
+    }
+
+    public void setMilliseconds(long milliseconds) {
+        this.chrononInMillisecond = milliseconds;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableYearMonthDuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableYearMonthDuration.java
new file mode 100644
index 0000000..3a21144
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableYearMonthDuration.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.base;
+
+public class AMutableYearMonthDuration extends AYearMonthDuration {
+
+    public AMutableYearMonthDuration(int months) {
+        super(months);
+    }
+
+    public void setMonths(int months) {
+        this.chrononInMonth = months;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AYearMonthDuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AYearMonthDuration.java
new file mode 100644
index 0000000..1714bb0
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AYearMonthDuration.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.base;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.asterix.om.visitors.IOMVisitor;
+
+/**
+ * AYearMonthDuration represents the duration in the unit of months.
+ * <p/>
+ * An AYearMonthDuration may contain the following two fields:<br/>
+ * - year;<br/>
+ * - month.
+ * <p/>
+ */
+public class AYearMonthDuration implements IAObject {
+
+    protected int chrononInMonth;
+
+    public AYearMonthDuration(int months) {
+        this.chrononInMonth = months;
+    }
+
+    public int getMonths() {
+        return chrononInMonth;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.hyracks.api.dataflow.value.JSONSerializable#toJSON()
+     */
+    @Override
+    public JSONObject toJSON() throws JSONException {
+        JSONObject json = new JSONObject();
+
+        JSONObject duration = new JSONObject();
+        duration.put("months", chrononInMonth);
+        json.put("ADuration", duration);
+
+        return json;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#getType()
+     */
+    @Override
+    public IAType getType() {
+        return BuiltinType.AYEARMONTHDURATION;
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#accept(edu.uci.ics.asterix.om.visitors.IOMVisitor)
+     */
+    @Override
+    public void accept(IOMVisitor visitor) throws AsterixException {
+        visitor.visitAYearMonthDuration(this);
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#deepEqual(edu.uci.ics.asterix.om.base.IAObject)
+     */
+    @Override
+    public boolean deepEqual(IAObject obj) {
+        return equals(obj);
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.base.IAObject#hash()
+     */
+    @Override
+    public int hash() {
+        return hashCode();
+    }
+
+    public boolean equals(Object o) {
+        if (o instanceof AYearMonthDuration) {
+            return ((AYearMonthDuration) o).chrononInMonth == chrononInMonth;
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return chrononInMonth;
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
index de5a6a1..84e2386 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
@@ -17,7 +17,10 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
+import edu.uci.ics.asterix.om.base.AMutableDayTimeDuration;
 import edu.uci.ics.asterix.om.base.AMutableDuration;
+import edu.uci.ics.asterix.om.base.AMutableYearMonthDuration;
+import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.dataflow.common.data.parsers.IValueParser;
 import edu.uci.ics.hyracks.dataflow.common.data.parsers.IValueParserFactory;
@@ -28,7 +31,11 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final String durationErrorMessage = "Wrong Input Format for a Duration Value";
+    private static final String durationErrorMessage = "Wrong Input Format for a duration/year-month-duration/day-time-duration Value";
+    private static final String onlyYearMonthErrorMessage = "Only year-month fields are allowed";
+    private static final String onlyDayTimeErrorMessage = "Only day-time fields are allowed";
+
+    private static final int DECIMAL_UNIT = 10;
 
     private ADurationParserFactory() {
 
@@ -41,7 +48,7 @@
 
             @Override
             public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
-                parseDuration(buffer, start, length, aMutableDuration);
+                parseDuration(buffer, start, length, aMutableDuration, ADurationParseOption.All);
                 try {
                     out.writeInt(aMutableDuration.getMonths());
                     out.writeLong(aMutableDuration.getMilliseconds());
@@ -64,299 +71,75 @@
         SEC;
     };
 
-    public static void parseDuration(String durationString, int start, int length, AMutableDuration aDuration)
-            throws HyracksDataException {
-
-        boolean positive = true;
-        int offset = 0;
-        int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
-        State state = State.NOTHING_READ;
-
-        if (durationString.charAt(start + offset) == '-') {
-            offset++;
-            positive = false;
-        }
-
-        if (durationString.charAt(start + offset) != 'P') {
-            throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
-        }
-
-        offset++;
-
-        for (; offset < length; offset++) {
-            if (durationString.charAt(start + offset) >= '0' && durationString.charAt(start + offset) <= '9') {
-                // accumulate the digit fields
-                value = value * 10 + durationString.charAt(start + offset) - '0';
-            } else {
-                switch (durationString.charAt(start + offset)) {
-                    case 'Y':
-                        if (state.compareTo(State.YEAR) < 0) {
-                            year = value;
-                            state = State.YEAR;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
-                        }
-                        break;
-                    case 'M':
-                        if (state.compareTo(State.TIME) < 0) {
-                            if (state.compareTo(State.MONTH) < 0) {
-                                month = value;
-                                state = State.MONTH;
-                            } else {
-                                throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
-                            }
-                        } else if (state.compareTo(State.MIN) < 0) {
-                            minute = value;
-                            state = State.MIN;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
-                        }
-                        break;
-                    case 'D':
-                        if (state.compareTo(State.DAY) < 0) {
-                            day = value;
-                            state = State.DAY;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
-                        }
-                        break;
-                    case 'T':
-                        if (state.compareTo(State.TIME) < 0) {
-                            state = State.TIME;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
-                        }
-                        break;
-
-                    case 'H':
-                        if (state.compareTo(State.HOUR) < 0) {
-                            hour = value;
-                            state = State.HOUR;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
-                        }
-                        break;
-                    case '.':
-                        if (state.compareTo(State.MILLISEC) < 0) {
-                            int i = 1;
-                            for (; offset + i < length; i++) {
-                                if (durationString.charAt(start + offset + i) >= '0'
-                                        && durationString.charAt(start + offset + i) <= '9') {
-                                    if (i < 4) {
-                                        millisecond = millisecond * 10
-                                                + (durationString.charAt(start + offset + i) - '0');
-                                    } else {
-                                        throw new HyracksDataException(durationErrorMessage
-                                                + ": wrong MILLISECOND field.");
-                                    }
-                                } else {
-                                    break;
-                                }
-                            }
-                            offset += i;
-                            state = State.MILLISEC;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
-                        }
-                    case 'S':
-                        if (state.compareTo(State.SEC) < 0) {
-                            second = value;
-                            state = State.SEC;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
-                        }
-                        break;
-                    default:
-                        throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
-
-                }
-                value = 0;
-            }
-        }
-
-        if (state.compareTo(State.TIME) == 0) {
-            throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
-        }
-
-        short temp = 1;
-        if (!positive) {
-            temp = -1;
-        }
-
-        aDuration.setValue(temp * (year * 12 + month), temp
-                * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
-
+    public enum ADurationParseOption {
+        YEAR_MONTH,
+        DAY_TIME,
+        All
     }
 
-    /**
-     * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
-     * object creation.
-     * 
-     * @param charAccessor
-     * @param start
-     * @param length
-     * @param aDuration
-     * @throws HyracksDataException
-     */
-    public static void parseDuration(char[] charAccessor, int start, int length, AMutableDuration aDuration)
-            throws HyracksDataException {
-
-        boolean positive = true;
-        int offset = 0;
-        int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
-        State state = State.NOTHING_READ;
-
-        if (charAccessor[start + offset] == '-') {
-            offset++;
-            positive = false;
-        }
-
-        if (charAccessor[start + offset] != 'P') {
-            throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
-        }
-
-        offset++;
-
-        for (; offset < length; offset++) {
-            if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
-                // accumulate the digit fields
-                value = value * 10 + charAccessor[start + offset] - '0';
-            } else {
-                switch (charAccessor[start + offset]) {
-                    case 'Y':
-                        if (state.compareTo(State.YEAR) < 0) {
-                            year = value;
-                            state = State.YEAR;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
-                        }
-                        break;
-                    case 'M':
-                        if (state.compareTo(State.TIME) < 0) {
-                            if (state.compareTo(State.MONTH) < 0) {
-                                month = value;
-                                state = State.MONTH;
-                            } else {
-                                throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
-                            }
-                        } else if (state.compareTo(State.MIN) < 0) {
-                            minute = value;
-                            state = State.MIN;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
-                        }
-                        break;
-                    case 'D':
-                        if (state.compareTo(State.DAY) < 0) {
-                            day = value;
-                            state = State.DAY;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
-                        }
-                        break;
-                    case 'T':
-                        if (state.compareTo(State.TIME) < 0) {
-                            state = State.TIME;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
-                        }
-                        break;
-
-                    case 'H':
-                        if (state.compareTo(State.HOUR) < 0) {
-                            hour = value;
-                            state = State.HOUR;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
-                        }
-                        break;
-                    case '.':
-                        if (state.compareTo(State.MILLISEC) < 0) {
-                            int i = 1;
-                            for (; offset + i < length; i++) {
-                                if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
-                                    if (i < 4) {
-                                        millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
-                                    } else {
-                                        throw new HyracksDataException(durationErrorMessage
-                                                + ": wrong MILLISECOND field.");
-                                    }
-                                } else {
-                                    break;
-                                }
-                            }
-                            offset += i;
-                            state = State.MILLISEC;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
-                        }
-                    case 'S':
-                        if (state.compareTo(State.SEC) < 0) {
-                            second = value;
-                            state = State.SEC;
-                        } else {
-                            throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
-                        }
-                        break;
-                    default:
-                        throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
-
-                }
-                value = 0;
-            }
-        }
-
-        if (state.compareTo(State.TIME) == 0) {
-            throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
-        }
-
-        short temp = 1;
-        if (!positive) {
-            temp = -1;
-        }
-
-        aDuration.setValue(temp * (year * 12 + month), temp
-                * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
-
+    interface IStringAccessor {
+        char getCharAt(int index);
     }
 
-    /**
-     * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
-     * object creation.
-     * 
-     * @param charAccessor
-     * @param start
-     * @param length
-     * @param aDuration
-     * @throws HyracksDataException
-     */
-    public static void parseDuration(byte[] charAccessor, int start, int length, AMutableDuration aDuration)
-            throws HyracksDataException {
+    public static void parseDuration(final Object durationString, final int start, int length, IAObject mutableObject,
+            ADurationParseOption parseOption) throws HyracksDataException {
 
-        boolean positive = true;
         int offset = 0;
         int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
         State state = State.NOTHING_READ;
 
-        if (charAccessor[start + offset] == '-') {
-            offset++;
-            positive = false;
+        IStringAccessor charAccessor;
+
+        if (durationString instanceof char[]) {
+            charAccessor = new IStringAccessor() {
+                @Override
+                public char getCharAt(int index) {
+                    return ((char[]) durationString)[start + index];
+                }
+            };
+        } else if (durationString instanceof byte[]) {
+            charAccessor = new IStringAccessor() {
+
+                @Override
+                public char getCharAt(int index) {
+                    return (char) (((byte[]) durationString)[start + index]);
+                }
+            };
+        } else if (durationString instanceof String) {
+            charAccessor = new IStringAccessor() {
+
+                @Override
+                public char getCharAt(int index) {
+                    return ((String) durationString).charAt(start + index);
+                }
+            };
+        } else {
+            throw new HyracksDataException(durationErrorMessage);
         }
 
-        if (charAccessor[start + offset] != 'P') {
+        short sign = 1;
+        if (charAccessor.getCharAt(offset) == '-') {
+            offset++;
+            sign = -1;
+        }
+
+        if (charAccessor.getCharAt(offset) != 'P') {
             throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
         }
 
         offset++;
 
         for (; offset < length; offset++) {
-            if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+            if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9') {
                 // accumulate the digit fields
-                value = value * 10 + charAccessor[start + offset] - '0';
+                value = value * DECIMAL_UNIT + charAccessor.getCharAt(offset) - '0';
             } else {
-                switch (charAccessor[start + offset]) {
+                switch (charAccessor.getCharAt(offset)) {
                     case 'Y':
                         if (state.compareTo(State.YEAR) < 0) {
+                            if (parseOption == ADurationParseOption.DAY_TIME) {
+                                throw new HyracksDataException(onlyDayTimeErrorMessage);
+                            }
                             year = value;
                             state = State.YEAR;
                         } else {
@@ -366,12 +149,18 @@
                     case 'M':
                         if (state.compareTo(State.TIME) < 0) {
                             if (state.compareTo(State.MONTH) < 0) {
+                                if (parseOption == ADurationParseOption.DAY_TIME) {
+                                    throw new HyracksDataException(onlyDayTimeErrorMessage);
+                                }
                                 month = value;
                                 state = State.MONTH;
                             } else {
                                 throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
                             }
                         } else if (state.compareTo(State.MIN) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             minute = value;
                             state = State.MIN;
                         } else {
@@ -380,6 +169,9 @@
                         break;
                     case 'D':
                         if (state.compareTo(State.DAY) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             day = value;
                             state = State.DAY;
                         } else {
@@ -388,6 +180,9 @@
                         break;
                     case 'T':
                         if (state.compareTo(State.TIME) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             state = State.TIME;
                         } else {
                             throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
@@ -396,6 +191,9 @@
 
                     case 'H':
                         if (state.compareTo(State.HOUR) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             hour = value;
                             state = State.HOUR;
                         } else {
@@ -404,11 +202,16 @@
                         break;
                     case '.':
                         if (state.compareTo(State.MILLISEC) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             int i = 1;
                             for (; offset + i < length; i++) {
-                                if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+                                if (charAccessor.getCharAt(offset + i) >= '0'
+                                        && charAccessor.getCharAt(offset + i) <= '9') {
                                     if (i < 4) {
-                                        millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
+                                        millisecond = millisecond * DECIMAL_UNIT
+                                                + (charAccessor.getCharAt(offset + i) - '0');
                                     } else {
                                         throw new HyracksDataException(durationErrorMessage
                                                 + ": wrong MILLISECOND field.");
@@ -424,6 +227,9 @@
                         }
                     case 'S':
                         if (state.compareTo(State.SEC) < 0) {
+                            if (parseOption == ADurationParseOption.YEAR_MONTH) {
+                                throw new HyracksDataException(onlyYearMonthErrorMessage);
+                            }
                             second = value;
                             state = State.SEC;
                         } else {
@@ -442,13 +248,18 @@
             throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
         }
 
-        short temp = 1;
-        if (!positive) {
-            temp = -1;
+        if (mutableObject instanceof AMutableDuration) {
+            ((AMutableDuration) mutableObject)
+                    .setValue(sign * (year * 12 + month),
+                            sign
+                                    * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second
+                                            * 1000L + millisecond));
+        } else if (mutableObject instanceof AMutableYearMonthDuration) {
+            ((AMutableYearMonthDuration) mutableObject).setMonths(sign * (year * 12 + month));
+        } else if (mutableObject instanceof AMutableDayTimeDuration) {
+            ((AMutableDayTimeDuration) mutableObject)
+                    .setMilliseconds(sign
+                            * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
         }
-
-        aDuration.setValue(temp * (year * 12 + month), temp
-                * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
-
     }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index bea62dc..38af5e1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -8,7 +8,6 @@
 
 import org.apache.commons.lang3.mutable.Mutable;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.ABooleanTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.ACircleTypeComputer;
@@ -48,6 +47,7 @@
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalACircleTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalADateTimeTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalADateTypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.OptionalADayTimeDurationTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalADoubleTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalADurationTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalAFloatTypeComputer;
@@ -64,6 +64,7 @@
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalAStringTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalATemporalInstanceTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OptionalATimeTypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.OptionalAYearMonthDurationTypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListConstructorResultType;
 import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAInt32TypeComputer;
 import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAPointTypeComputer;
@@ -102,7 +103,15 @@
         SI
     }
 
-    private static final FunctionInfoRepository finfoRepo = new FunctionInfoRepository();
+    /*
+     * A function is categorized as public or private depending upon whether it can be used by the end-user in AQL queries.
+     */
+    public enum FunctionNamespace {
+        ASTERIX_PUBLIC,
+        ASTERIX_PRIVATE
+    }
+
+    private static final FunctionInfoRepository registeredFunctions = new FunctionInfoRepository();
 
     // it is supposed to be an identity mapping
     private final static Map<IFunctionInfo, IFunctionInfo> builtinFunctionsSet = new HashMap<IFunctionInfo, IFunctionInfo>();
@@ -117,419 +126,449 @@
     private final static Map<IFunctionInfo, IFunctionInfo> scalarToAggregateFunctionMap = new HashMap<IFunctionInfo, IFunctionInfo>();
     private static final Map<IFunctionInfo, SpatialFilterKind> spatialFilterFunctions = new HashMap<IFunctionInfo, SpatialFilterKind>();
 
-    public final static FunctionIdentifier TYPE_OF = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "type-of", 1);
-    public final static FunctionIdentifier GET_HANDLE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "get-handle", 2);
-    public final static FunctionIdentifier GET_DATA = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-data",
-            2);
-    public final static FunctionIdentifier EMBED_TYPE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "embed-type", 1);
+    public final static FunctionIdentifier TYPE_OF = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "type-of", 1);
+    public final static FunctionIdentifier GET_HANDLE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "get-handle", 2);
+    public final static FunctionIdentifier GET_DATA = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "get-data", 2);
+    public final static FunctionIdentifier EMBED_TYPE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "embed-type", 1);
 
-    public final static FunctionIdentifier GET_ITEM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item",
-            2);
-    public final static FunctionIdentifier ANY_COLLECTION_MEMBER = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "any-collection-member", 1);
-    public final static FunctionIdentifier LISTIFY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1);
+    public final static FunctionIdentifier GET_ITEM = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "get-item", 2);
+    public final static FunctionIdentifier ANY_COLLECTION_MEMBER = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "any-collection-member", 1);
+    public final static FunctionIdentifier LISTIFY = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "listify", 1);
     // public final static FunctionIdentifier BAGIFY = new
     // FunctionIdentifier(ASTERIX_NS, "bagify", 1, true);
-    public final static FunctionIdentifier LEN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "len", 1);
+    public final static FunctionIdentifier LEN = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(), "len",
+            1);
 
-    public final static FunctionIdentifier CONCAT_NON_NULL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "concat-non-null", FunctionIdentifier.VARARGS);
-    public final static FunctionIdentifier EMPTY_STREAM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "empty-stream", 0);
-    public final static FunctionIdentifier NON_EMPTY_STREAM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "non-empty-stream", 0);
+    public final static FunctionIdentifier CONCAT_NON_NULL = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "concat-non-null", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier EMPTY_STREAM = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "empty-stream", 0);
+    public final static FunctionIdentifier NON_EMPTY_STREAM = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "non-empty-stream", 0);
     public final static FunctionIdentifier ORDERED_LIST_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "ordered-list-constructor", FunctionIdentifier.VARARGS);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "ordered-list-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier UNORDERED_LIST_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "unordered-list-constructor", FunctionIdentifier.VARARGS);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "unordered-list-constructor", FunctionIdentifier.VARARGS);
 
     // records
     public final static FunctionIdentifier CLOSED_RECORD_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "closed-record-constructor", FunctionIdentifier.VARARGS);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "closed-record-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier OPEN_RECORD_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "open-record-constructor", FunctionIdentifier.VARARGS);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "open-record-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier RECORD_TYPE_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "record-type-constructor", FunctionIdentifier.VARARGS);
-    public final static FunctionIdentifier FIELD_ACCESS_BY_INDEX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "field-access-by-index", 2);
-    public final static FunctionIdentifier FIELD_ACCESS_BY_NAME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "field-access-by-name", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "record-type-constructor", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier FIELD_ACCESS_BY_INDEX = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "field-access-by-index", 2);
+    public final static FunctionIdentifier FIELD_ACCESS_BY_NAME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "field-access-by-name", 2);
 
-    public final static FunctionIdentifier NUMERIC_UNARY_MINUS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-unary-minus", 1);
+    public final static FunctionIdentifier NUMERIC_UNARY_MINUS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-unary-minus", 1);
 
-    public final static FunctionIdentifier NUMERIC_SUBTRACT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-subtract", 2);
-    public final static FunctionIdentifier NUMERIC_MULTIPLY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-multiply", 2);
-    public final static FunctionIdentifier NUMERIC_DIVIDE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-divide", 2);
-    public final static FunctionIdentifier NUMERIC_MOD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-mod", 2);
-    public final static FunctionIdentifier NUMERIC_IDIV = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-idiv", 2);
-    public final static FunctionIdentifier CARET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "caret", 2);
+    public final static FunctionIdentifier NUMERIC_SUBTRACT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-subtract", 2);
+    public final static FunctionIdentifier NUMERIC_MULTIPLY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-multiply", 2);
+    public final static FunctionIdentifier NUMERIC_DIVIDE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-divide", 2);
+    public final static FunctionIdentifier NUMERIC_MOD = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-mod", 2);
+    public final static FunctionIdentifier NUMERIC_IDIV = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-idiv", 2);
+    public final static FunctionIdentifier CARET = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "caret", 2);
 
-    public final static FunctionIdentifier NUMERIC_ABS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-abs", 1);
-    public final static FunctionIdentifier NUMERIC_CEILING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-ceiling", 1);
-    public final static FunctionIdentifier NUMERIC_FLOOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-floor", 1);
-    public final static FunctionIdentifier NUMERIC_ROUND = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-round", 1);
+    public final static FunctionIdentifier NUMERIC_ABS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-abs", 1);
+    public final static FunctionIdentifier NUMERIC_CEILING = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-ceiling", 1);
+    public final static FunctionIdentifier NUMERIC_FLOOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-floor", 1);
+    public final static FunctionIdentifier NUMERIC_ROUND = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-round", 1);
     public final static FunctionIdentifier NUMERIC_ROUND_HALF_TO_EVEN = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "numeric-round-half-to-even", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-round-half-to-even", 1);
     public final static FunctionIdentifier NUMERIC_ROUND_HALF_TO_EVEN2 = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "numeric-round-half-to-even", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "numeric-round-half-to-even", 2);
     // String funcitons
-    public final static FunctionIdentifier STRING_EQUAL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string-equal", 2);
-    public final static FunctionIdentifier STRING_START_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "start-with", 2);
-    public final static FunctionIdentifier STRING_END_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "end-with", 2);
-    public final static FunctionIdentifier STRING_MATCHES = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "matches", 2);
+    public final static FunctionIdentifier STRING_EQUAL = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "string-equal", 2);
+    public final static FunctionIdentifier STRING_START_WITH = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "start-with", 2);
+    public final static FunctionIdentifier STRING_END_WITH = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "end-with", 2);
+    public final static FunctionIdentifier STRING_MATCHES = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "matches", 2);
     public final static FunctionIdentifier STRING_MATCHES_WITH_FLAG = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "matches", 3);
-    public final static FunctionIdentifier STRING_LOWERCASE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "lowercase", 1);
-    public final static FunctionIdentifier STRING_REPLACE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "replace", 3);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "matches", 3);
+    public final static FunctionIdentifier STRING_LOWERCASE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "lowercase", 1);
+    public final static FunctionIdentifier STRING_REPLACE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "replace", 3);
     public final static FunctionIdentifier STRING_REPLACE_WITH_FLAG = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "replace", 4);
-    public final static FunctionIdentifier STRING_LENGTH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string-length", 1);
-    public final static FunctionIdentifier SUBSTRING2 = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "replace", 4);
+    public final static FunctionIdentifier STRING_LENGTH = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "string-length", 1);
+    public final static FunctionIdentifier SUBSTRING2 = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
             "substring", 2);
-    public final static FunctionIdentifier SUBSTRING_BEFORE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "substring-before", 2);
-    public final static FunctionIdentifier SUBSTRING_AFTER = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "substring-after", 2);
-    public final static FunctionIdentifier STRING_TO_CODEPOINT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string-to-codepoint", 1);
-    public final static FunctionIdentifier CODEPOINT_TO_STRING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "codepoint-to-string", 1);
-    public final static FunctionIdentifier STRING_CONCAT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string-concat", 1);
-    public final static FunctionIdentifier STRING_JOIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string-join", 2);
+    public final static FunctionIdentifier SUBSTRING_BEFORE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "substring-before", 2);
+    public final static FunctionIdentifier SUBSTRING_AFTER = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "substring-after", 2);
+    public final static FunctionIdentifier STRING_TO_CODEPOINT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "string-to-codepoint", 1);
+    public final static FunctionIdentifier CODEPOINT_TO_STRING = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "codepoint-to-string", 1);
+    public final static FunctionIdentifier STRING_CONCAT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "string-concat", 1);
+    public final static FunctionIdentifier STRING_JOIN = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "string-join", 2);
 
-    public final static FunctionIdentifier DATASET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "dataset", 1);
-    public final static FunctionIdentifier FEED_INGEST = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "feed-ingest", 1);
+    public final static FunctionIdentifier DATASET = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "dataset", 1);
+    public final static FunctionIdentifier FEED_INGEST = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "feed-ingest", 1);
 
-    public final static FunctionIdentifier INDEX_SEARCH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "index-search", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier INDEX_SEARCH = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "index-search", FunctionIdentifier.VARARGS);
 
     public final static FunctionIdentifier MAKE_FIELD_INDEX_HANDLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "make-field-index-handle", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "make-field-index-handle", 2);
     public final static FunctionIdentifier MAKE_FIELD_NAME_HANDLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "make-field-name-handle", 1);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "make-field-name-handle", 1);
 
-    public final static FunctionIdentifier SUBSTRING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier SUBSTRING = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
             "substring", 3);
-    public final static FunctionIdentifier LIKE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "like", 2);
-    public final static FunctionIdentifier CONTAINS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "contains",
-            2);
-    public final static FunctionIdentifier STARTS_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "starts-with", 2);
-    public final static FunctionIdentifier ENDS_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier LIKE = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "like", 2);
+    public final static FunctionIdentifier CONTAINS = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "contains", 2);
+    public final static FunctionIdentifier STARTS_WITH = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "starts-with", 2);
+    public final static FunctionIdentifier ENDS_WITH = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
             "ends-with", 2);
 
-    public final static FunctionIdentifier AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-avg", 1);
-    public final static FunctionIdentifier COUNT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-count", 1);
-    public final static FunctionIdentifier SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sum", 1);
-    public final static FunctionIdentifier LOCAL_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier AVG = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "agg-avg", 1);
+    public final static FunctionIdentifier COUNT = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "agg-count", 1);
+    public final static FunctionIdentifier SUM = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "agg-sum", 1);
+    public final static FunctionIdentifier LOCAL_SUM = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
             "agg-local-sum", 1);
-    public final static FunctionIdentifier MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-max", 1);
-    public final static FunctionIdentifier LOCAL_MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier MAX = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "agg-max", 1);
+    public final static FunctionIdentifier LOCAL_MAX = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
             "agg-local-max", 1);
-    public final static FunctionIdentifier MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-min", 1);
-    public final static FunctionIdentifier LOCAL_MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier MIN = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "agg-min", 1);
+    public final static FunctionIdentifier LOCAL_MIN = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
             "agg-local-min", 1);
-    public final static FunctionIdentifier GLOBAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "agg-global-avg", 1);
-    public final static FunctionIdentifier LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier GLOBAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "agg-global-avg", 1);
+    public final static FunctionIdentifier LOCAL_AVG = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
             "agg-local-avg", 1);
 
-    public final static FunctionIdentifier SCALAR_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1);
-    public final static FunctionIdentifier SCALAR_COUNT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "count",
-            1);
-    public final static FunctionIdentifier SCALAR_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sum", 1);
-    public final static FunctionIdentifier SCALAR_MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "max", 1);
-    public final static FunctionIdentifier SCALAR_MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "min", 1);
-    public final static FunctionIdentifier SCALAR_GLOBAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "global-avg", 1);
-    public final static FunctionIdentifier SCALAR_LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-avg", 1);
+    public final static FunctionIdentifier SCALAR_AVG = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "avg", 1);
+    public final static FunctionIdentifier SCALAR_COUNT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "count", 1);
+    public final static FunctionIdentifier SCALAR_SUM = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "sum", 1);
+    public final static FunctionIdentifier SCALAR_MAX = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "max", 1);
+    public final static FunctionIdentifier SCALAR_MIN = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "min", 1);
+    public final static FunctionIdentifier SCALAR_GLOBAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "global-avg", 1);
+    public final static FunctionIdentifier SCALAR_LOCAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "local-avg", 1);
 
     // serializable aggregate functions
-    public final static FunctionIdentifier SERIAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "avg-serial", 1);
-    public final static FunctionIdentifier SERIAL_COUNT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "count-serial", 1);
-    public final static FunctionIdentifier SERIAL_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "sum-serial", 1);
-    public final static FunctionIdentifier SERIAL_LOCAL_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-sum-serial", 1);
-    public final static FunctionIdentifier SERIAL_GLOBAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "global-avg-serial", 1);
-    public final static FunctionIdentifier SERIAL_LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-avg-serial", 1);
+    public final static FunctionIdentifier SERIAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "avg-serial", 1);
+    public final static FunctionIdentifier SERIAL_COUNT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "count-serial", 1);
+    public final static FunctionIdentifier SERIAL_SUM = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "sum-serial", 1);
+    public final static FunctionIdentifier SERIAL_LOCAL_SUM = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "local-sum-serial", 1);
+    public final static FunctionIdentifier SERIAL_GLOBAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "global-avg-serial", 1);
+    public final static FunctionIdentifier SERIAL_LOCAL_AVG = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "local-avg-serial", 1);
 
-    public final static FunctionIdentifier SCAN_COLLECTION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "scan-collection", 1);
-    public final static FunctionIdentifier SUBSET_COLLECTION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subset-collection", 3);
+    public final static FunctionIdentifier SCAN_COLLECTION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "scan-collection", 1);
+    public final static FunctionIdentifier SUBSET_COLLECTION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "subset-collection", 3);
 
-    public final static FunctionIdentifier RANGE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "range", 2);
+    public final static FunctionIdentifier RANGE = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "range", 2);
 
     // fuzzy functions:
-    public final static FunctionIdentifier FUZZY_EQ = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "fuzzy-eq",
-            2);
+    public final static FunctionIdentifier FUZZY_EQ = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "fuzzy-eq", 2);
 
-    public final static FunctionIdentifier PREFIX_LEN_JACCARD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "prefix-len-jaccard", 2);
+    public final static FunctionIdentifier PREFIX_LEN_JACCARD = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "prefix-len-jaccard", 2);
 
-    public final static FunctionIdentifier SIMILARITY_JACCARD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard", 2);
+    public final static FunctionIdentifier SIMILARITY_JACCARD = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "similarity-jaccard", 2);
     public final static FunctionIdentifier SIMILARITY_JACCARD_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-check", 3);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "similarity-jaccard-check", 3);
     public final static FunctionIdentifier SIMILARITY_JACCARD_SORTED = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "similarity-jaccard-sorted", 2);
     public final static FunctionIdentifier SIMILARITY_JACCARD_SORTED_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted-check", 3);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "similarity-jaccard-sorted-check", 3);
     public final static FunctionIdentifier SIMILARITY_JACCARD_PREFIX = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix", 6);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "similarity-jaccard-prefix", 6);
     public final static FunctionIdentifier SIMILARITY_JACCARD_PREFIX_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix-check", 6);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "similarity-jaccard-prefix-check", 6);
 
-    public final static FunctionIdentifier EDIT_DISTANCE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance", 2);
-    public final static FunctionIdentifier EDIT_DISTANCE_CHECK = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance-check", 3);
+    public final static FunctionIdentifier EDIT_DISTANCE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "edit-distance", 2);
+    public final static FunctionIdentifier EDIT_DISTANCE_CHECK = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "edit-distance-check", 3);
     public final static FunctionIdentifier EDIT_DISTANCE_LIST_IS_FILTERABLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "edit-distance-list-is-filterable", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "edit-distance-list-is-filterable", 2);
     public final static FunctionIdentifier EDIT_DISTANCE_STRING_IS_FILTERABLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "edit-distance-string-is-filterable", 4);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "edit-distance-string-is-filterable", 4);
 
     // tokenizers:
-    public final static FunctionIdentifier WORD_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "word-tokens", 1);
-    public final static FunctionIdentifier HASHED_WORD_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-word-tokens", 1);
+    public final static FunctionIdentifier WORD_TOKENS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "word-tokens", 1);
+    public final static FunctionIdentifier HASHED_WORD_TOKENS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "hashed-word-tokens", 1);
     public final static FunctionIdentifier COUNTHASHED_WORD_TOKENS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "counthashed-word-tokens", 1);
-    public final static FunctionIdentifier GRAM_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "gram-tokens", 3);
-    public final static FunctionIdentifier HASHED_GRAM_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-gram-tokens", 3);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "counthashed-word-tokens", 1);
+    public final static FunctionIdentifier GRAM_TOKENS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "gram-tokens", 3);
+    public final static FunctionIdentifier HASHED_GRAM_TOKENS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "hashed-gram-tokens", 3);
     public final static FunctionIdentifier COUNTHASHED_GRAM_TOKENS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "counthashed-gram-tokens", 3);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "counthashed-gram-tokens", 3);
 
-    public final static FunctionIdentifier TID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tid", 0);
+    public final static FunctionIdentifier TID = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "tid", 0);
 
     // constructors:
-    public final static FunctionIdentifier BOOLEAN_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "boolean", 1);
-    public final static FunctionIdentifier NULL_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "null", 1);
-    public final static FunctionIdentifier STRING_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string", 1);
-    public final static FunctionIdentifier INT8_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int8", 1);
-    public final static FunctionIdentifier INT16_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int16", 1);
-    public final static FunctionIdentifier INT32_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int32", 1);
-    public final static FunctionIdentifier INT64_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int64", 1);
-    public final static FunctionIdentifier FLOAT_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "float", 1);
-    public final static FunctionIdentifier DOUBLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "double", 1);
-    public final static FunctionIdentifier POINT_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "point", 1);
-    public final static FunctionIdentifier POINT3D_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "point3d", 1);
-    public final static FunctionIdentifier LINE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "line", 1);
-    public final static FunctionIdentifier CIRCLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "circle", 1);
-    public final static FunctionIdentifier RECTANGLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "rectangle", 1);
-    public final static FunctionIdentifier POLYGON_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "polygon", 1);
-    public final static FunctionIdentifier TIME_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "time", 1);
-    public final static FunctionIdentifier DATE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "date", 1);
-    public final static FunctionIdentifier DATETIME_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "datetime", 1);
-    public final static FunctionIdentifier DURATION_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "duration", 1);
+    public final static FunctionIdentifier BOOLEAN_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "boolean", 1);
+    public final static FunctionIdentifier NULL_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "null", 1);
+    public final static FunctionIdentifier STRING_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "string", 1);
+    public final static FunctionIdentifier INT8_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "int8", 1);
+    public final static FunctionIdentifier INT16_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "int16", 1);
+    public final static FunctionIdentifier INT32_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "int32", 1);
+    public final static FunctionIdentifier INT64_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "int64", 1);
+    public final static FunctionIdentifier FLOAT_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "float", 1);
+    public final static FunctionIdentifier DOUBLE_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "double", 1);
+    public final static FunctionIdentifier POINT_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "point", 1);
+    public final static FunctionIdentifier POINT3D_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "point3d", 1);
+    public final static FunctionIdentifier LINE_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "line", 1);
+    public final static FunctionIdentifier CIRCLE_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "circle", 1);
+    public final static FunctionIdentifier RECTANGLE_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "rectangle", 1);
+    public final static FunctionIdentifier POLYGON_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "polygon", 1);
+    public final static FunctionIdentifier TIME_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "time", 1);
+    public final static FunctionIdentifier DATE_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "date", 1);
+    public final static FunctionIdentifier DATETIME_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "datetime", 1);
+    public final static FunctionIdentifier DURATION_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "duration", 1);
+
+    public final static FunctionIdentifier YEAR_MONTH_DURATION_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "year-month-duration", 1);
+    public final static FunctionIdentifier DAY_TIME_DURATION_CONSTRUCTOR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "day-time-duration", 1);
+
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_DATE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-from-date", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-from-date", 2);
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_TIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-from-time", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-from-time", 2);
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_DATETIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-from-datetime", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-from-datetime", 2);
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_START_FROM_DATE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-start-from-date", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-start-from-date", 2);
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_START_FROM_TIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-start-from-time", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-start-from-time", 2);
     public final static FunctionIdentifier INTERVAL_CONSTRUCTOR_START_FROM_DATETIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-start-from-datetime", 2);
-    public final static FunctionIdentifier INTERVAL_BEFORE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-before", 2);
-    public final static FunctionIdentifier INTERVAL_AFTER = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-after", 2);
-    public final static FunctionIdentifier INTERVAL_MEETS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-meets", 2);
-    public final static FunctionIdentifier INTERVAL_MET_BY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-met-by", 2);
-    public final static FunctionIdentifier INTERVAL_OVERLAPS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-overlaps", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-start-from-datetime", 2);
+    public final static FunctionIdentifier INTERVAL_BEFORE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-before", 2);
+    public final static FunctionIdentifier INTERVAL_AFTER = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-after", 2);
+    public final static FunctionIdentifier INTERVAL_MEETS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-meets", 2);
+    public final static FunctionIdentifier INTERVAL_MET_BY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-met-by", 2);
+    public final static FunctionIdentifier INTERVAL_OVERLAPS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-overlaps", 2);
     public final static FunctionIdentifier INTERVAL_OVERLAPPED_BY = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "interval-overlapped-by", 2);
-    public final static FunctionIdentifier OVERLAP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "overlap", 2);
-    public final static FunctionIdentifier INTERVAL_STARTS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-starts", 2);
-    public final static FunctionIdentifier INTERVAL_STARTED_BY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-started-by", 2);
-    public final static FunctionIdentifier INTERVAL_COVERS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-covers", 2);
-    public final static FunctionIdentifier INTERVAL_COVERED_BY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-covered-by", 2);
-    public final static FunctionIdentifier INTERVAL_ENDS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-ends", 2);
-    public final static FunctionIdentifier INTERVAL_ENDED_BY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-ended-by", 2);
-    public final static FunctionIdentifier CURRENT_TIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "current-time", 0);
-    public final static FunctionIdentifier CURRENT_DATE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "current-date", 0);
-    public final static FunctionIdentifier CURRENT_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "current-datetime", 0);
-    public final static FunctionIdentifier DURATION_EQUAL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "duration-equal", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-overlapped-by", 2);
+    public final static FunctionIdentifier OVERLAP = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
+            "overlap", 2);
+    public final static FunctionIdentifier INTERVAL_STARTS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-starts", 2);
+    public final static FunctionIdentifier INTERVAL_STARTED_BY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-started-by", 2);
+    public final static FunctionIdentifier INTERVAL_COVERS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-covers", 2);
+    public final static FunctionIdentifier INTERVAL_COVERED_BY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-covered-by", 2);
+    public final static FunctionIdentifier INTERVAL_ENDS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-ends", 2);
+    public final static FunctionIdentifier INTERVAL_ENDED_BY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "interval-ended-by", 2);
+    public final static FunctionIdentifier CURRENT_TIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "current-time", 0);
+    public final static FunctionIdentifier CURRENT_DATE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "current-date", 0);
+    public final static FunctionIdentifier CURRENT_DATETIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "current-datetime", 0);
+    public final static FunctionIdentifier DURATION_EQUAL = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "duration-equal", 2);
     public final static FunctionIdentifier YEAR_MONTH_DURATION_GREATER_THAN = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "year-month-duration-greater-than", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "year-month-duration-greater-than", 2);
     public final static FunctionIdentifier YEAR_MONTH_DURATION_LESS_THAN = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "year-month-duration-less-than", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "year-month-duration-less-than", 2);
     public final static FunctionIdentifier DAY_TIME_DURATION_GREATER_THAN = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "day-time-duration-greater-than", 2);
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "day-time-duration-greater-than", 2);
     public final static FunctionIdentifier DAY_TIME_DURATION_LESS_THAN = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "day-time-duration-less-than", 2);
-    public final static FunctionIdentifier DURATION_FROM_MONTHS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "duration-from-months", 1);
-    public final static FunctionIdentifier MONTHS_OF_YEAR_MONTH_DURATION = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "months-of-year-month-duration", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "day-time-duration-less-than", 2);
+    public final static FunctionIdentifier DURATION_FROM_MONTHS = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "duration-from-months", 1);
+    public final static FunctionIdentifier MONTHS_FROM_YEAR_MONTH_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "months-from-year-month-duration", 1);
     public final static FunctionIdentifier DURATION_FROM_MILLISECONDS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "duration-from-ms", 1);
-    public final static FunctionIdentifier MILLISECONDS_OF_DAY_TIME_DURATION = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "ms-of-day-time-duration", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "duration-from-ms", 1);
+    public final static FunctionIdentifier MILLISECONDS_FROM_DAY_TIME_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "ms-from-day-time-duration", 1);
+
+    public final static FunctionIdentifier GET_YEAR_MONTH_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-year-month-duration", 1);
+    public final static FunctionIdentifier GET_DAY_TIME_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-day-time-duration", 1);
 
     // spatial
-    public final static FunctionIdentifier CREATE_POINT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-point", 2);
-    public final static FunctionIdentifier CREATE_LINE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-line", 2);
-    public final static FunctionIdentifier CREATE_POLYGON = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-polygon", FunctionIdentifier.VARARGS);
-    public final static FunctionIdentifier CREATE_CIRCLE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-circle", 2);
-    public final static FunctionIdentifier CREATE_RECTANGLE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-rectangle", 2);
-    public final static FunctionIdentifier SPATIAL_INTERSECT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-intersect", 2);
-    public final static FunctionIdentifier SPATIAL_AREA = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-area", 1);
-    public final static FunctionIdentifier SPATIAL_DISTANCE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-distance", 2);
-    public final static FunctionIdentifier CREATE_MBR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-mbr", 3);
-    public final static FunctionIdentifier SPATIAL_CELL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-cell", 4);
-    public final static FunctionIdentifier SWITCH_CASE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "switch-case", FunctionIdentifier.VARARGS);
-    public final static FunctionIdentifier REG_EXP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "reg-exp", 2);
+    public final static FunctionIdentifier CREATE_POINT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "create-point", 2);
+    public final static FunctionIdentifier CREATE_LINE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "create-line", 2);
+    public final static FunctionIdentifier CREATE_POLYGON = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "create-polygon", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier CREATE_CIRCLE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "create-circle", 2);
+    public final static FunctionIdentifier CREATE_RECTANGLE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "create-rectangle", 2);
+    public final static FunctionIdentifier SPATIAL_INTERSECT = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "spatial-intersect", 2);
+    public final static FunctionIdentifier SPATIAL_AREA = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "spatial-area", 1);
+    public final static FunctionIdentifier SPATIAL_DISTANCE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "spatial-distance", 2);
+    public final static FunctionIdentifier CREATE_MBR = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "create-mbr", 3);
+    public final static FunctionIdentifier SPATIAL_CELL = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "spatial-cell", 4);
+    public final static FunctionIdentifier SWITCH_CASE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "switch-case", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier REG_EXP = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "reg-exp", 2);
 
-    public final static FunctionIdentifier INJECT_FAILURE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "inject-failure", 2);
-    public final static FunctionIdentifier CAST_RECORD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "cast-record", 1);
-    public final static FunctionIdentifier CAST_LIST = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+    public final static FunctionIdentifier INJECT_FAILURE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "inject-failure", 2);
+    public final static FunctionIdentifier CAST_RECORD = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PRIVATE.name(), "cast-record", 1);
+    public final static FunctionIdentifier CAST_LIST = new FunctionIdentifier(FunctionNamespace.ASTERIX_PUBLIC.name(),
             "cast-list", 1);
 
     // Spatial and temporal type accessors
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_YEAR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "year", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "year", 1);
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_MONTH = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "month", 1);
-    public static final FunctionIdentifier ACCESSOR_TEMPORAL_DAY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "day", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "month", 1);
+    public static final FunctionIdentifier ACCESSOR_TEMPORAL_DAY = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "day", 1);
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_HOUR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "hour", 1);
-    public static final FunctionIdentifier ACCESSOR_TEMPORAL_MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "minute", 1);
-    public static final FunctionIdentifier ACCESSOR_TEMPORAL_SEC = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "second", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "hour", 1);
+    public static final FunctionIdentifier ACCESSOR_TEMPORAL_MIN = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "minute", 1);
+    public static final FunctionIdentifier ACCESSOR_TEMPORAL_SEC = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "second", 1);
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_MILLISEC = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "millisecond", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "millisecond", 1);
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_START = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-interval-start", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-interval-start", 1);
     public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-interval-end", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-interval-end", 1);
 
     // Temporal functions
     public static final FunctionIdentifier DATE_FROM_UNIX_TIME_IN_DAYS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "date-from-unix-time-in-days", 1);
-    public static final FunctionIdentifier DATE_FROM_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "date-from-datetime", 1);
-    public final static FunctionIdentifier ADD_DATE_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "add-date-duration", 2);
-    public final static FunctionIdentifier SUBTRACT_DATE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subtract-date", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "date-from-unix-time-in-days", 1);
+    public static final FunctionIdentifier DATE_FROM_DATETIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "date-from-datetime", 1);
+    public final static FunctionIdentifier ADD_DATE_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "add-date-duration", 2);
+    public final static FunctionIdentifier SUBTRACT_DATE = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "subtract-date", 2);
     public final static FunctionIdentifier TIME_FROM_UNIX_TIME_IN_MS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "time-from-unix-time-in-ms", 1);
-    public final static FunctionIdentifier TIME_FROM_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "time-from-datetime", 1);
-    public final static FunctionIdentifier SUBTRACT_TIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subtract-time", 2);
-    public final static FunctionIdentifier ADD_TIME_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "add-time-duration", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "time-from-unix-time-in-ms", 1);
+    public final static FunctionIdentifier TIME_FROM_DATETIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "time-from-datetime", 1);
+    public final static FunctionIdentifier SUBTRACT_TIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "subtract-time", 2);
+    public final static FunctionIdentifier ADD_TIME_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "add-time-duration", 2);
     public final static FunctionIdentifier DATETIME_FROM_UNIX_TIME_IN_MS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "datetime-from-unix-time-in-ms", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "datetime-from-unix-time-in-ms", 1);
     public final static FunctionIdentifier DATETIME_FROM_DATE_TIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "datetime-from-date-time", 2);
-    public final static FunctionIdentifier SUBTRACT_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subtract-datetime", 2);
-    public final static FunctionIdentifier ADD_DATETIME_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "add-datetime-duration", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "datetime-from-date-time", 2);
+    public final static FunctionIdentifier SUBTRACT_DATETIME = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "subtract-datetime", 2);
+    public final static FunctionIdentifier ADD_DATETIME_DURATION = new FunctionIdentifier(
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "add-datetime-duration", 2);
     public final static FunctionIdentifier CALENDAR_DURATION_FROM_DATETIME = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "calendar-duration-from-datetime", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "calendar-duration-from-datetime", 2);
     public final static FunctionIdentifier CALENDAR_DURATION_FROM_DATE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "calendar-duration-from-date", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "calendar-duration-from-date", 2);
     public final static FunctionIdentifier ADJUST_TIME_FOR_TIMEZONE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "adjust-time-for-timezone", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "adjust-time-for-timezone", 2);
     public final static FunctionIdentifier ADJUST_DATETIME_FOR_TIMEZONE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "adjust-datetime-for-timezone", 2);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "adjust-datetime-for-timezone", 2);
 
     public final static FunctionIdentifier GET_POINT_X_COORDINATE_ACCESSOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-x", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-x", 1);
     public final static FunctionIdentifier GET_POINT_Y_COORDINATE_ACCESSOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-y", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-y", 1);
     public final static FunctionIdentifier GET_CIRCLE_RADIUS_ACCESSOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-radius", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-radius", 1);
     public final static FunctionIdentifier GET_CIRCLE_CENTER_ACCESSOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-center", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-center", 1);
     public final static FunctionIdentifier GET_POINTS_LINE_RECTANGLE_POLYGON_ACCESSOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "get-points", 1);
+            FunctionNamespace.ASTERIX_PUBLIC.name(), "get-points", 1);
 
     public static final FunctionIdentifier EQ = AlgebricksBuiltinFunctions.EQ;
     public static final FunctionIdentifier LE = AlgebricksBuiltinFunctions.LE;
@@ -543,11 +582,11 @@
     public static final FunctionIdentifier NUMERIC_ADD = AlgebricksBuiltinFunctions.NUMERIC_ADD;
     public static final FunctionIdentifier IS_NULL = AlgebricksBuiltinFunctions.IS_NULL;
 
-    public static final FunctionIdentifier NOT_NULL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "not-null",
-            1);
+    public static final FunctionIdentifier NOT_NULL = new FunctionIdentifier(FunctionNamespace.ASTERIX_PRIVATE.name(),
+            "not-null", 1);
 
     public static IFunctionInfo getAsterixFunctionInfo(FunctionIdentifier fid) {
-        IFunctionInfo finfo = finfoRepo.get(fid);;
+        IFunctionInfo finfo = registeredFunctions.get(fid);
         if (finfo == null) {
             finfo = new AsterixFunctionInfo(fid);
         }
@@ -555,7 +594,7 @@
     }
 
     public static AsterixFunctionInfo lookupFunction(FunctionIdentifier fid) {
-        return (AsterixFunctionInfo) finfoRepo.get(fid);
+        return (AsterixFunctionInfo) registeredFunctions.get(fid);
     }
 
     static {
@@ -576,7 +615,7 @@
         // and then, Asterix builtin functions
         add(NOT_NULL, NotNullTypeComputer.INSTANCE);
         add(ANY_COLLECTION_MEMBER, NonTaggedCollectionMemberResultType.INSTANCE);
-        addPrivateFunction(AVG, OptionalADoubleTypeComputer.INSTANCE);
+        add(AVG, OptionalADoubleTypeComputer.INSTANCE);
         add(BOOLEAN_CONSTRUCTOR, UnaryBooleanOrNullFunctionTypeComputer.INSTANCE);
         add(CARET, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE);
         add(CIRCLE_CONSTRUCTOR, OptionalACircleTypeComputer.INSTANCE);
@@ -598,7 +637,7 @@
             }
         });
         add(CONTAINS, ABooleanTypeComputer.INSTANCE);
-        addPrivateFunction(COUNT, AInt32TypeComputer.INSTANCE);
+        add(COUNT, AInt32TypeComputer.INSTANCE);
         add(COUNTHASHED_GRAM_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE);
         add(COUNTHASHED_WORD_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE);
         add(CREATE_CIRCLE, ACircleTypeComputer.INSTANCE);
@@ -612,6 +651,8 @@
         add(DATETIME_CONSTRUCTOR, OptionalADateTimeTypeComputer.INSTANCE);
         add(DOUBLE_CONSTRUCTOR, OptionalADoubleTypeComputer.INSTANCE);
         add(DURATION_CONSTRUCTOR, OptionalADurationTypeComputer.INSTANCE);
+        add(YEAR_MONTH_DURATION_CONSTRUCTOR, OptionalAYearMonthDurationTypeComputer.INSTANCE);
+        add(DAY_TIME_DURATION_CONSTRUCTOR, OptionalADayTimeDurationTypeComputer.INSTANCE);
         add(EDIT_DISTANCE, AInt32TypeComputer.INSTANCE);
         add(EDIT_DISTANCE_CHECK, OrderedListOfAnyTypeComputer.INSTANCE);
         add(EDIT_DISTANCE_STRING_IS_FILTERABLE, ABooleanTypeComputer.INSTANCE);
@@ -633,7 +674,7 @@
         add(GET_HANDLE, null); // TODO
         add(GET_ITEM, NonTaggedGetItemResultType.INSTANCE);
         add(GET_DATA, null); // TODO
-        addPrivateFunction(GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE);
+        add(GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE);
         add(GRAM_TOKENS, OrderedListOfAStringTypeComputer.INSTANCE);
         add(GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE);
         add(HASHED_GRAM_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE);
@@ -654,7 +695,7 @@
         add(LIKE, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE);
         add(LINE_CONSTRUCTOR, OptionalALineTypeComputer.INSTANCE);
         add(LISTIFY, OrderedListConstructorResultType.INSTANCE);
-        addPrivateFunction(LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE);
+        add(LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE);
         add(MAKE_FIELD_INDEX_HANDLE, null); // TODO
         add(MAKE_FIELD_NAME_HANDLE, null); // TODO
         add(MAX, NonTaggedSumTypeComputer.INSTANCE);
@@ -772,7 +813,7 @@
             }
         });
         add(SUBSTRING, SubstringTypeComputer.INSTANCE);
-        addPrivateFunction(SUM, NonTaggedSumTypeComputer.INSTANCE);
+        add(SUM, NonTaggedSumTypeComputer.INSTANCE);
         add(LOCAL_SUM, NonTaggedSumTypeComputer.INSTANCE);
         add(SWITCH_CASE, NonTaggedSwitchCaseComputer.INSTANCE);
         add(REG_EXP, ABooleanTypeComputer.INSTANCE);
@@ -844,8 +885,10 @@
         add(DURATION_EQUAL, OptionalABooleanTypeComputer.INSTANCE);
         add(DURATION_FROM_MONTHS, OptionalADurationTypeComputer.INSTANCE);
         add(DURATION_FROM_MILLISECONDS, OptionalADurationTypeComputer.INSTANCE);
-        add(MONTHS_OF_YEAR_MONTH_DURATION, OptionalAInt32TypeComputer.INSTANCE);
-        add(MILLISECONDS_OF_DAY_TIME_DURATION, OptionalAInt64TypeComputer.INSTANCE);
+        add(MONTHS_FROM_YEAR_MONTH_DURATION, OptionalAInt32TypeComputer.INSTANCE);
+        add(MILLISECONDS_FROM_DAY_TIME_DURATION, OptionalAInt64TypeComputer.INSTANCE);
+        add(GET_DAY_TIME_DURATION, OptionalADayTimeDurationTypeComputer.INSTANCE);
+        add(GET_YEAR_MONTH_DURATION, OptionalAYearMonthDurationTypeComputer.INSTANCE);
 
         // interval constructors
         add(INTERVAL_CONSTRUCTOR_DATE, OptionalAIntervalTypeComputer.INSTANCE);
@@ -933,6 +976,7 @@
 
     static {
         addUnnestFun(DATASET, false);
+        addUnnestFun(FEED_INGEST, false);
         addUnnestFun(RANGE, true);
         addUnnestFun(SCAN_COLLECTION, false);
         addUnnestFun(SUBSET_COLLECTION, false);
@@ -1036,14 +1080,7 @@
         IFunctionInfo functionInfo = getAsterixFunctionInfo(fi);
         builtinFunctionsSet.put(functionInfo, functionInfo);
         funTypeComputer.put(functionInfo, typeComputer);
-        finfoRepo.put(fi);
-    }
-
-    private static IFunctionInfo addPrivateFunction(FunctionIdentifier fi, IResultTypeComputer typeComputer) {
-        IFunctionInfo functionInfo = getAsterixFunctionInfo(fi);
-        builtinFunctionsSet.put(functionInfo, functionInfo);
-        funTypeComputer.put(functionInfo, typeComputer);
-        return functionInfo;
+        registeredFunctions.put(fi);
     }
 
     private static void addAgg(FunctionIdentifier fi) {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
index b78308d..cdbf5ca 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
@@ -24,6 +24,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ACirclePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ADatePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ADateTimePrinter;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ADayTimeDurationPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ADoublePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ADurationPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AFloatPrinter;
@@ -40,6 +41,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ARectanglePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AStringPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ATimePrinter;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AYearMonthDurationPrinter;
 import edu.uci.ics.asterix.om.pointables.AFlatValuePointable;
 import edu.uci.ics.asterix.om.pointables.AListPointable;
 import edu.uci.ics.asterix.om.pointables.ARecordPointable;
@@ -146,6 +148,14 @@
                     ADurationPrinter.INSTANCE.print(b, s, l, ps);
                     break;
                 }
+                case YEARMONTHDURATION: {
+                    AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
+                    break;
+                }
+                case DAYTIMEDURATION: {
+                    ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
+                    break;
+                }
                 case POINT: {
                     APointPrinter.INSTANCE.print(b, s, l, ps);
                     break;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java
index b2d5339..e88ed7e 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java
@@ -24,6 +24,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ACirclePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADatePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADateTimePrinter;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADayTimeDurationPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADoublePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADurationPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AFloatPrinter;
@@ -39,6 +40,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ARectanglePrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AStringPrinter;
 import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ATimePrinter;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AYearMonthDurationPrinter;
 import edu.uci.ics.asterix.om.pointables.AFlatValuePointable;
 import edu.uci.ics.asterix.om.pointables.AListPointable;
 import edu.uci.ics.asterix.om.pointables.ARecordPointable;
@@ -173,6 +175,14 @@
                     AStringPrinter.INSTANCE.print(b, s, l, ps);
                     break;
                 }
+                case YEARMONTHDURATION: {
+                    AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
+                    break;
+                }
+                case DAYTIMEDURATION: {
+                    ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
+                    break;
+                }
                 default: {
                     throw new NotImplementedException("No printer for type " + typeTag);
                 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
new file mode 100644
index 0000000..38f76e3
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.typecomputer.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.AUnionType;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class OptionalADayTimeDurationTypeComputer implements IResultTypeComputer {
+
+    public static final OptionalADayTimeDurationTypeComputer INSTANCE = new OptionalADayTimeDurationTypeComputer();
+
+    private OptionalADayTimeDurationTypeComputer() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer#computeType(edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression, edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
+     */
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        List<IAType> unionList = new ArrayList<IAType>();
+        unionList.add(BuiltinType.ANULL);
+        unionList.add(BuiltinType.ADAYTIMEDURATION);
+        return new AUnionType(unionList, "OptionalDayTimeDuration");
+    }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
new file mode 100644
index 0000000..4c08142
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.typecomputer.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.AUnionType;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class OptionalAYearMonthDurationTypeComputer implements IResultTypeComputer {
+
+    public static final OptionalAYearMonthDurationTypeComputer INSTANCE = new OptionalAYearMonthDurationTypeComputer();
+
+    private OptionalAYearMonthDurationTypeComputer() {
+
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer#computeType(edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression, edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
+     */
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        List<IAType> unionList = new ArrayList<IAType>();
+        unionList.add(BuiltinType.ANULL);
+        unionList.add(BuiltinType.AYEARMONTHDURATION);
+        return new AUnionType(unionList, "OptionalYearMonthDuration");
+    }
+
+}
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 ca7bc24..037cd29 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
@@ -259,6 +259,11 @@
                 case FLOAT:
                 case DOUBLE:
                 case STRING:
+                case DATE:
+                case TIME:
+                case DATETIME:
+                case YEARMONTHDURATION:
+                case DAYTIMEDURATION:
                     break;
                 case UNION:
                     throw new AlgebricksException("The partitioning key \"" + fieldName + "\" cannot be nullable");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
index a0ad3e1..e88596d 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
@@ -1,6 +1,4 @@
-/**
- * 
- */
+
 package edu.uci.ics.asterix.om.types;
 
 /**
@@ -44,7 +42,9 @@
     CIRCLE(32),
     RECTANGLE(33),
     INTERVAL(34),
-    SYSTEM_NULL(35);
+    SYSTEM_NULL(35),
+    YEARMONTHDURATION(36),
+    DAYTIMEDURATION(37);
 
     private byte value;
 
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
index a70f15b..17d98d4 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
@@ -431,6 +431,60 @@
         }
     };
 
+    public final static BuiltinType AYEARMONTHDURATION = new LowerCaseConstructorType() {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String getDisplayName() {
+            return "AYearMonthDuration";
+        }
+
+        @Override
+        public ATypeTag getTypeTag() {
+            return ATypeTag.YEARMONTHDURATION;
+        }
+
+        @Override
+        public String getTypeName() {
+            return "year-month-duration";
+        }
+
+        @Override
+        public JSONObject toJSON() throws JSONException {
+            JSONObject type = new JSONObject();
+            type.put("type", "AYearMonthDuration");
+            return type;
+        }
+    };
+
+    public final static BuiltinType ADAYTIMEDURATION = new LowerCaseConstructorType() {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String getDisplayName() {
+            return "ADayTimeDuration";
+        }
+
+        @Override
+        public ATypeTag getTypeTag() {
+            return ATypeTag.DAYTIMEDURATION;
+        }
+
+        @Override
+        public String getTypeName() {
+            return "day-time-duration";
+        }
+
+        @Override
+        public JSONObject toJSON() throws JSONException {
+            JSONObject type = new JSONObject();
+            type.put("type", "ADayTimeDuration");
+            return type;
+        }
+    };
+
     public final static BuiltinType AINTERVAL = new LowerCaseConstructorType() {
 
         private static final long serialVersionUID = 1L;
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 047c459..b4cd23c 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
@@ -95,12 +95,14 @@
             case INT32:
             case FLOAT:
             case DATE:
+            case YEARMONTHDURATION:
                 return 4;
             case TIME:
                 return 4;
             case INT64:
             case DOUBLE:
             case DATETIME:
+            case DAYTIMEDURATION:
                 return 8;
             case DURATION:
                 return 12;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/IOMVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/IOMVisitor.java
index 703b792..d83f72d 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/IOMVisitor.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/IOMVisitor.java
@@ -7,6 +7,7 @@
 import edu.uci.ics.asterix.om.base.ACircle;
 import edu.uci.ics.asterix.om.base.ADate;
 import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
 import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.ADuration;
 import edu.uci.ics.asterix.om.base.AFloat;
@@ -26,6 +27,7 @@
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.base.ATime;
 import edu.uci.ics.asterix.om.base.AUnorderedList;
+import edu.uci.ics.asterix.om.base.AYearMonthDuration;
 import edu.uci.ics.asterix.om.types.IAType;
 
 public interface IOMVisitor {
@@ -47,6 +49,10 @@
 
     public void visitADuration(ADuration obj) throws AsterixException;
 
+    public void visitAYearMonthDuration(AYearMonthDuration obj) throws AsterixException;
+
+    public void visitADayTimeDuration(ADayTimeDuration obj) throws AsterixException;
+
     public void visitAInterval(AInterval obj) throws AsterixException;
 
     public void visitADate(ADate obj) throws AsterixException;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/OMPrintToStringVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/OMPrintToStringVisitor.java
index e7856f0..60c8700 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/OMPrintToStringVisitor.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/visitors/OMPrintToStringVisitor.java
@@ -8,6 +8,7 @@
 import edu.uci.ics.asterix.om.base.ACollectionCursor;
 import edu.uci.ics.asterix.om.base.ADate;
 import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
 import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.ADuration;
 import edu.uci.ics.asterix.om.base.AFloat;
@@ -27,6 +28,7 @@
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.base.ATime;
 import edu.uci.ics.asterix.om.base.AUnorderedList;
+import edu.uci.ics.asterix.om.base.AYearMonthDuration;
 import edu.uci.ics.asterix.om.base.IACursor;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.types.ARecordType;
@@ -252,4 +254,16 @@
         }
     }
 
+    @Override
+    public void visitAYearMonthDuration(AYearMonthDuration obj) throws AsterixException {
+        // TODO Auto-generated method stub
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void visitADayTimeDuration(ADayTimeDuration obj) throws AsterixException {
+        // TODO Auto-generated method stub
+        throw new NotImplementedException();
+    }
+
 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
index 3de05f8..232eace 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
@@ -20,21 +20,23 @@
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+
+        // The aggregate function will get a SingleFieldFrameTupleReference that points to the result of the ScanCollection.
+        // The list-item will always reside in the first field (column) of the SingleFieldFrameTupleReference.
+        ICopyEvaluatorFactory[] aggFuncArgs = new ICopyEvaluatorFactory[1];
+        aggFuncArgs[0] = new ColumnAccessEvalFactory(0);
+        // Create aggregate function from this scalar version.
+        FunctionIdentifier fid = AsterixBuiltinFunctions.getAggregateFunction(getIdentifier());
+        IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
+        IFunctionDescriptor fd = mgr.lookupFunction(fid);
+        AbstractAggregateFunctionDynamicDescriptor aggFuncDesc = (AbstractAggregateFunctionDynamicDescriptor) fd;
+        final ICopyAggregateFunctionFactory aggFuncFactory = aggFuncDesc.createAggregateFunctionFactory(aggFuncArgs);
+
         return new ICopyEvaluatorFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
             public ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {
-                // The aggregate function will get a SingleFieldFrameTupleReference that points to the result of the ScanCollection.
-                // The list-item will always reside in the first field (column) of the SingleFieldFrameTupleReference.
-                ICopyEvaluatorFactory[] aggFuncArgs = new ICopyEvaluatorFactory[1];
-                aggFuncArgs[0] = new ColumnAccessEvalFactory(0);
-                // Create aggregate function from this scalar version.
-                FunctionIdentifier fid = AsterixBuiltinFunctions.getAggregateFunction(getIdentifier());
-                IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
-                IFunctionDescriptor fd = mgr.lookupFunction(fid);
-                AbstractAggregateFunctionDynamicDescriptor aggFuncDesc = (AbstractAggregateFunctionDynamicDescriptor) fd;
-                ICopyAggregateFunctionFactory aggFuncFactory = aggFuncDesc.createAggregateFunctionFactory(aggFuncArgs);
                 // Use ScanCollection to iterate over list items.
                 ScanCollectionUnnestingFunctionFactory scanCollectionFactory = new ScanCollectionUnnestingFunctionFactory(
                         args[0]);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarAvgAggregateDescriptor.java
index ae2a485..fa8f930 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarAvgAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.scalar;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -8,7 +8,7 @@
 public class ScalarAvgAggregateDescriptor extends AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SCALAR_AVG;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScalarAvgAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarCountAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarCountAggregateDescriptor.java
index 6f3baa6..1f362c9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarCountAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarCountAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.scalar;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -8,7 +8,7 @@
 public class ScalarCountAggregateDescriptor extends AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "count", 1);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SCALAR_COUNT;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScalarCountAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMaxAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMaxAggregateDescriptor.java
index a71eb3c..26cb74e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMaxAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMaxAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.scalar;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -8,7 +8,7 @@
 public class ScalarMaxAggregateDescriptor extends AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "max", 1);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SCALAR_MAX;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScalarMaxAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMinAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMinAggregateDescriptor.java
index 4beae60..4d2bbd4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMinAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarMinAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.scalar;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -8,7 +8,7 @@
 public class ScalarMinAggregateDescriptor extends AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "min", 1);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SCALAR_MIN;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScalarMinAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarSumAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarSumAggregateDescriptor.java
index f3d9d1a..c82e3e2 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarSumAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/scalar/ScalarSumAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.scalar;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -8,7 +8,7 @@
 public class ScalarSumAggregateDescriptor extends AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sum", 1);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SCALAR_SUM;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScalarSumAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalSumAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalSumAggregateDescriptor.java
index 6badf0f..c3ee985 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalSumAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalSumAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.serializable.std;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
@@ -13,8 +13,7 @@
 public class SerializableLocalSumAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-sum-serial", 1);
+    private final static FunctionIdentifier FID = AsterixBuiltinFunctions.SERIAL_LOCAL_SUM;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SerializableLocalSumAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMaxAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMaxAggregateDescriptor.java
index 59287d5..e7346a8 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMaxAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMaxAggregateDescriptor.java
@@ -1,6 +1,6 @@
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
@@ -14,8 +14,8 @@
 public class LocalMaxAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-max",
-            1);
+    private final static FunctionIdentifier FID = AsterixBuiltinFunctions.LOCAL_MAX;
+
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new LocalMaxAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMinAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMinAggregateDescriptor.java
index ca32e2f..9e6747d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMinAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalMinAggregateDescriptor.java
@@ -1,6 +1,7 @@
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
 import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
@@ -14,8 +15,7 @@
 public class LocalMinAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-min",
-            1);
+    private final static FunctionIdentifier FID = AsterixBuiltinFunctions.LOCAL_MIN;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new LocalMinAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalSumAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalSumAggregateDescriptor.java
index c133e09..01f6d28 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalSumAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalSumAggregateDescriptor.java
@@ -1,6 +1,7 @@
 package edu.uci.ics.asterix.runtime.aggregates.std;
 
 import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
@@ -14,8 +15,7 @@
 public class LocalSumAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sum",
-            1);
+    private final static FunctionIdentifier FID = AsterixBuiltinFunctions.LOCAL_SUM;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new LocalSumAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/EmptyStreamAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/EmptyStreamAggregateDescriptor.java
index 587a113..28d3c5e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/EmptyStreamAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/EmptyStreamAggregateDescriptor.java
@@ -5,6 +5,7 @@
 import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.ABoolean;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -23,8 +24,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "empty-stream", 0);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.EMPTY_STREAM;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EmptyStreamAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
index 577a1fb..fe21cbb 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
@@ -25,6 +25,7 @@
 import edu.uci.ics.asterix.om.base.AMutablePoint;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.APoint;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,7 +44,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-center", 1);
+    private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_CIRCLE_CENTER_ACCESSOR;
     private static final byte SER_CICLE_TAG = ATypeTag.CIRCLE.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
index ffaae9e..0669f4c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
@@ -24,6 +24,7 @@
 import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.AMutableDouble;
 import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -42,7 +43,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-radius", 1);
+    private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_CIRCLE_RADIUS_ACCESSOR;
     private static final byte SER_CICLE_TAG = ATypeTag.CIRCLE.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
index d7f87df..8dbdf75 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
@@ -29,6 +29,7 @@
 import edu.uci.ics.asterix.om.base.AMutablePoint;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.APoint;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
@@ -49,7 +50,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-points", 1);
+    private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_POINTS_LINE_RECTANGLE_POLYGON_ACCESSOR;
     private static final byte SER_LINE_TAG = ATypeTag.LINE.serialize();
     private static final byte SER_RECTANGLE_TAG = ATypeTag.RECTANGLE.serialize();
     private static final byte SER_POLYGON_TAG = ATypeTag.POLYGON.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
index 7fcfd20..c42a1b4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
@@ -25,6 +25,7 @@
 import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.AMutableDouble;
 import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,7 +44,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-x", 1);
+    private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_POINT_X_COORDINATE_ACCESSOR;
     private static final byte SER_POINT_TAG = ATypeTag.POINT.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
index 1c47efa..02c6b30 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
@@ -25,6 +25,7 @@
 import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.AMutableDouble;
 import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,7 +44,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-y", 1);
+    private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_POINT_Y_COORDINATE_ACCESSOR;
     private static final byte SER_POINT_TAG = ATypeTag.POINT.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/FunctionManagerImpl.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/FunctionManagerImpl.java
index 6f834a7..127d4a6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/FunctionManagerImpl.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/FunctionManagerImpl.java
@@ -37,7 +37,11 @@
     @Override
     public synchronized IFunctionDescriptor lookupFunction(FunctionIdentifier fid) throws AlgebricksException {
         Pair<FunctionIdentifier, Integer> key = new Pair<FunctionIdentifier, Integer>(fid, fid.getArity());
-        return functions.get(key).createFunctionDescriptor();
+        IFunctionDescriptorFactory factory = functions.get(key);
+        if (factory == null) {
+            throw new AlgebricksException("Inappropriate use of function " + "'" + fid.getName() + "'");
+        }
+        return factory.createFunctionDescriptor();
     }
 
     @Override
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index 1565cb9..06a7823 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -2,8 +2,14 @@
 
 import java.io.DataOutput;
 
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateOrTimeAscBinaryComparatorFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateTimeAscBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APoint3DPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APointPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APolygonPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ARectanglePartialBinaryComparatorFactory;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -49,9 +55,21 @@
             .getSerializerDeserializer(BuiltinType.ANULL);
     protected IBinaryComparator strBinaryComp = AqlBinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE
             .createBinaryComparator();
-    protected IBinaryComparator dateTimeBinaryComp = ADateTimeAscBinaryComparatorFactory.INSTANCE
+    protected IBinaryComparator circleBinaryComp = ACirclePartialBinaryComparatorFactory.INSTANCE
             .createBinaryComparator();
-    protected IBinaryComparator dateOrTimeBinaryComp = ADateOrTimeAscBinaryComparatorFactory.INSTANCE
+    protected IBinaryComparator durationBinaryComp = ADurationPartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator intervalBinaryComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator lineBinaryComparator = ALinePartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator pointBinaryComparator = APointPartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator point3DBinaryComparator = APoint3DPartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator polygonBinaryComparator = APolygonPartialBinaryComparatorFactory.INSTANCE
+            .createBinaryComparator();
+    protected IBinaryComparator rectangleBinaryComparator = ARectanglePartialBinaryComparatorFactory.INSTANCE
             .createBinaryComparator();
 
     public AbstractComparisonEvaluator(DataOutput out, ICopyEvaluatorFactory evalLeftFactory,
@@ -68,6 +86,25 @@
         evalRight.evaluate(tuple);
     }
 
+    protected void checkComparable() throws AlgebricksException {
+        if (outLeft.getLength() != 0) {
+            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outLeft.getByteArray()[0]);
+            switch (typeTag) {
+                case DURATION:
+                case INTERVAL:
+                case LINE:
+                case POINT:
+                case POINT3D:
+                case POLYGON:
+                case CIRCLE:
+                case RECTANGLE:
+                    throw new AlgebricksException("Inequality comparison for " + typeTag + " is not defined.");
+                default:
+                    return;
+            }
+        }
+    }
+
     protected ComparisonResult compareResults() throws AlgebricksException {
         boolean isLeftNull = false;
         boolean isRightNull = false;
@@ -119,50 +156,73 @@
             case BOOLEAN: {
                 return compareBooleanWithArg(typeTag2);
             }
-            case DATETIME: {
-                return compareDateTimeWithArg(typeTag2);
-            }
-            case DATE:
-            case TIME: {
-                return compareDateOrTimeWithArg(typeTag2);
-            }
+
             default: {
-                throw new AlgebricksException("Comparison is undefined between types " + typeTag1 + " and " + typeTag2
-                        + " .");
+                return compareStrongTypedWithArg(typeTag1, typeTag2);
             }
         }
     }
 
-    private ComparisonResult compareDateOrTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
-        if (typeTag2 == ATypeTag.NULL) {
-            return ComparisonResult.GREATER_THAN;
-        } else if (typeTag2 == ATypeTag.DATE || typeTag2 == ATypeTag.TIME) {
-            int result = dateOrTimeBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
-                    outRight.getByteArray(), 1, outRight.getLength() - 1);
-            if (result == 0)
-                return ComparisonResult.EQUAL;
-            else if (result < 0)
-                return ComparisonResult.LESS_THAN;
-            else
-                return ComparisonResult.GREATER_THAN;
+    private ComparisonResult compareStrongTypedWithArg(ATypeTag expectedTypeTag, ATypeTag actualTypeTag)
+            throws AlgebricksException {
+        if (expectedTypeTag != actualTypeTag) {
+            throw new AlgebricksException("Comparison is undefined between " + expectedTypeTag + " and "
+                    + actualTypeTag + ".");
         }
-        throw new AlgebricksException("Comparison is undefined between types Date/Time and " + typeTag2 + " .");
-    }
-
-    private ComparisonResult compareDateTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
-        if (typeTag2 == ATypeTag.NULL) {
-            return ComparisonResult.GREATER_THAN;
-        } else if (typeTag2 == ATypeTag.DATETIME) {
-            int result = dateTimeBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
-                    outRight.getByteArray(), 1, outRight.getLength() - 1);
-            if (result == 0)
-                return ComparisonResult.EQUAL;
-            else if (result < 0)
-                return ComparisonResult.LESS_THAN;
-            else
-                return ComparisonResult.GREATER_THAN;
+        int result = 0;
+        switch (actualTypeTag) {
+            case YEARMONTHDURATION:
+            case TIME:
+            case DATE:
+                result = Integer.compare(AInt32SerializerDeserializer.getInt(outLeft.getByteArray(), 1),
+                        AInt32SerializerDeserializer.getInt(outRight.getByteArray(), 1));
+                break;
+            case DAYTIMEDURATION:
+            case DATETIME:
+                result = Long.compare(AInt64SerializerDeserializer.getLong(outLeft.getByteArray(), 1),
+                        AInt64SerializerDeserializer.getLong(outRight.getByteArray(), 1));
+                break;
+            case CIRCLE:
+                result = circleBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case LINE:
+                result = lineBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case POINT:
+                result = pointBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case POINT3D:
+                result = point3DBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case POLYGON:
+                result = polygonBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case DURATION:
+                result = durationBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case INTERVAL:
+                result = intervalBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            case RECTANGLE:
+                result = rectangleBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+                        outRight.getByteArray(), 1, outRight.getLength() - 1);
+                break;
+            default:
+                throw new AlgebricksException("Comparison for " + actualTypeTag + " is not supported.");
         }
-        throw new AlgebricksException("Comparison is undefined between types Datetime and " + typeTag2 + " .");
+        if (result == 0)
+            return ComparisonResult.EQUAL;
+        else if (result < 0)
+            return ComparisonResult.LESS_THAN;
+        else
+            return ComparisonResult.GREATER_THAN;
     }
 
     private ComparisonResult compareBooleanWithArg(ATypeTag typeTag2) throws AlgebricksException {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
index ed77276..8d57c2e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
@@ -121,6 +121,7 @@
         @Override
         public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
             evalInputs(tuple);
+            checkComparable();
             ComparisonResult r = compareResults();
             if (r == ComparisonResult.UNKNOWN) {
                 try {
@@ -150,6 +151,7 @@
         @Override
         public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
             evalInputs(tuple);
+            checkComparable();
             ComparisonResult r = compareResults();
             if (r == ComparisonResult.UNKNOWN) {
                 try {
@@ -178,6 +180,7 @@
         @Override
         public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
             evalInputs(tuple);
+            checkComparable();
             ComparisonResult r = compareResults();
             if (r == ComparisonResult.UNKNOWN) {
                 try {
@@ -207,6 +210,7 @@
         @Override
         public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
             evalInputs(tuple);
+            checkComparable();
             ComparisonResult r = compareResults();
             if (r == ComparisonResult.UNKNOWN) {
                 try {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java
new file mode 100644
index 0000000..0d43c3d
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.runtime.evaluators.constructors;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
+import edu.uci.ics.asterix.om.base.AMutableDayTimeDuration;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class ADayTimeDurationConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new ADayTimeDurationConstructorDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
+        return new ICopyEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+
+                    private ArrayBackedValueStorage outInput = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval = args[0].createEvaluator(outInput);
+                    private String errorMessage = "This can not be an instance of day-time-duration";
+                    private AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        try {
+                            outInput.reset();
+                            eval.evaluate(tuple);
+                            byte[] serString = outInput.getByteArray();
+
+                            if (serString[0] == SER_STRING_TYPE_TAG) {
+
+                                int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
+
+                                ADurationParserFactory.parseDuration(serString, 3, stringLength, aDayTimeDuration,
+                                        ADurationParseOption.DAY_TIME);
+
+                                dayTimeDurationSerde.serialize(aDayTimeDuration, out);
+                            } else if (serString[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                            } else {
+                                throw new AlgebricksException(errorMessage);
+                            }
+                        } catch (Exception e1) {
+                            throw new AlgebricksException(e1);
+                        }
+                    }
+
+                };
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.DAY_TIME_DURATION_CONSTRUCTOR;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
index a84ae1d..669c4f7 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
@@ -21,6 +21,7 @@
 import edu.uci.ics.asterix.om.base.AMutableDuration;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,7 +83,8 @@
 
                                 int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
 
-                                ADurationParserFactory.parseDuration(serString, 3, stringLength, aDuration);
+                                ADurationParserFactory.parseDuration(serString, 3, stringLength, aDuration,
+                                        ADurationParseOption.All);
 
                                 durationSerde.serialize(aDuration, out);
                             } else if (serString[0] == SER_NULL_TYPE_TAG) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
index 8daf9a6..4c8c60f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
@@ -17,7 +17,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.AInterval;
@@ -25,6 +24,7 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,8 +43,7 @@
 public class AIntervalFromDateConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-from-date", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_DATE;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
@@ -123,7 +122,7 @@
                                         + ": expects NULL/STRING/DATE for the second argument, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
-                            
+
                             if (intervalEnd < intervalStart) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": interval end must not be less than the interval start.");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
index 78d2e4a..42479f4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
@@ -25,6 +25,7 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,8 +44,7 @@
 public class AIntervalFromDateTimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-from-datetime", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_DATETIME;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
@@ -145,7 +145,7 @@
                                         + ": expects NULL/STRING/DATETIME for the second argument, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
-                            
+
                             if (intervalEnd < intervalStart) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": interval end must not be less than the interval start.");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
index 8816160..eb69037 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
@@ -25,6 +25,7 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -43,8 +44,7 @@
 public class AIntervalFromTimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-from-time", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_TIME;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 7ea8e90..2802f29 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -17,7 +17,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -27,8 +26,10 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -47,8 +48,7 @@
 public class AIntervalStartFromDateConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-start-from-date", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_START_FROM_DATE;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
@@ -128,8 +128,8 @@
                                 int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                ADurationParserFactory
-                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
+                                ADurationParserFactory.parseDuration(argOut1.getByteArray(), 3, stringLength,
+                                        aDuration, ADurationParseOption.All);
                                 intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
                                         aDuration.getMonths(), aDuration.getMilliseconds());
                             } else {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index f16dccb..0cab83b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -17,7 +17,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -29,6 +28,8 @@
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -47,8 +48,7 @@
 public class AIntervalStartFromDateTimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-start-from-datetime", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_START_FROM_DATETIME;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
@@ -141,8 +141,8 @@
                                 int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                ADurationParserFactory
-                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
+                                ADurationParserFactory.parseDuration(argOut1.getByteArray(), 3, stringLength,
+                                        aDuration, ADurationParseOption.All);
 
                                 intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
                                         aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index 35bfe17..40db774 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -17,7 +17,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -29,6 +28,8 @@
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -47,8 +48,7 @@
 public class AIntervalStartFromTimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "interval-start-from-time", 2);
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_CONSTRUCTOR_START_FROM_TIME;
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
@@ -138,8 +138,8 @@
                                 int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                ADurationParserFactory
-                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
+                                ADurationParserFactory.parseDuration(argOut1.getByteArray(), 3, stringLength,
+                                        aDuration, ADurationParseOption.All);
 
                                 if (aDuration.getMonths() != 0) {
                                     throw new AlgebricksException(FID.getName()
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
new file mode 100644
index 0000000..bc6099c
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.runtime.evaluators.constructors;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AMutableYearMonthDuration;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.AYearMonthDuration;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
+import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class AYearMonthDurationConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new AYearMonthDurationConstructorDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
+        return new ICopyEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+
+                    private ArrayBackedValueStorage outInput = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval = args[0].createEvaluator(outInput);
+                    private String errorMessage = "This can not be an instance of year-month-duration";
+                    private AMutableYearMonthDuration aYearMonthDuration = new AMutableYearMonthDuration(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        try {
+                            outInput.reset();
+                            eval.evaluate(tuple);
+                            byte[] serString = outInput.getByteArray();
+
+                            if (serString[0] == SER_STRING_TYPE_TAG) {
+
+                                int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
+
+                                ADurationParserFactory.parseDuration(serString, 3, stringLength, aYearMonthDuration,
+                                        ADurationParseOption.YEAR_MONTH);
+
+                                yearMonthDurationSerde.serialize(aYearMonthDuration, out);
+                            } else if (serString[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                            } else {
+                                throw new AlgebricksException(errorMessage);
+                            }
+                        } catch (Exception e1) {
+                            throw new AlgebricksException(e1);
+                        }
+                    }
+
+                };
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.YEAR_MONTH_DURATION_CONSTRUCTOR;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
similarity index 84%
copy from asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
copy to asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
index 97fa94a..17c6ba9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
@@ -18,8 +18,8 @@
 
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.AInt64;
-import edu.uci.ics.asterix.om.base.AMutableInt64;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
+import edu.uci.ics.asterix.om.base.AMutableDayTimeDuration;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -38,10 +38,10 @@
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class MillisecondsOfDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
-    private final static long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_OF_DAY_TIME_DURATION;
+    private static final long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.GET_DAY_TIME_DURATION;
 
     // allowed input types
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
@@ -51,7 +51,7 @@
 
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
-            return new MillisecondsOfDayTimeDurationDescriptor();
+            return new GetDayTimeDurationDescriptor();
         }
     };
 
@@ -74,10 +74,10 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
                     @SuppressWarnings("unchecked")
-                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
-                            .getSerializerDeserializer(BuiltinType.AINT64);
+                    private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
 
-                    AMutableInt64 aInt64 = new AMutableInt64(0);
+                    AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0);
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -95,9 +95,10 @@
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt64.setValue(ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
+                            aDayTimeDuration.setMilliseconds(ADurationSerializerDeserializer.getDayTime(
+                                    argOut0.getByteArray(), 1));
 
-                            int64Serde.serialize(aInt64, out);
+                            dayTimeDurationSerde.serialize(aDayTimeDuration, out);
 
                         } catch (HyracksDataException hex) {
                             throw new AlgebricksException(hex);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
similarity index 84%
copy from asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
copy to asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
index 97fa94a..b7b4278 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
@@ -18,9 +18,9 @@
 
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.AInt64;
-import edu.uci.ics.asterix.om.base.AMutableInt64;
+import edu.uci.ics.asterix.om.base.AMutableYearMonthDuration;
 import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.AYearMonthDuration;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -38,10 +38,10 @@
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class MillisecondsOfDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
-    private final static long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_OF_DAY_TIME_DURATION;
+    private static final long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.GET_YEAR_MONTH_DURATION;
 
     // allowed input types
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
@@ -51,7 +51,7 @@
 
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
-            return new MillisecondsOfDayTimeDurationDescriptor();
+            return new GetYearMonthDurationDescriptor();
         }
     };
 
@@ -74,10 +74,10 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
                     @SuppressWarnings("unchecked")
-                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
-                            .getSerializerDeserializer(BuiltinType.AINT64);
+                    private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION);
 
-                    AMutableInt64 aInt64 = new AMutableInt64(0);
+                    AMutableYearMonthDuration aYearMonthDuration = new AMutableYearMonthDuration(0);
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -95,9 +95,10 @@
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt64.setValue(ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
+                            aYearMonthDuration.setMonths(ADurationSerializerDeserializer.getYearMonth(
+                                    argOut0.getByteArray(), 1));
 
-                            int64Serde.serialize(aInt64, out);
+                            yearMonthDurationSerde.serialize(aYearMonthDuration, out);
 
                         } catch (HyracksDataException hex) {
                             throw new AlgebricksException(hex);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
similarity index 88%
rename from asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
rename to asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
index 97fa94a..14e16c6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
@@ -16,7 +16,7 @@
 
 import java.io.DataOutput;
 
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.AInt64;
 import edu.uci.ics.asterix.om.base.AMutableInt64;
@@ -38,20 +38,20 @@
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class MillisecondsOfDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private final static long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_OF_DAY_TIME_DURATION;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_FROM_DAY_TIME_DURATION;
 
     // allowed input types
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+    private final static byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
 
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
-            return new MillisecondsOfDayTimeDurationDescriptor();
+            return new MillisecondsFromDayTimeDurationDescriptor();
         }
     };
 
@@ -90,12 +90,12 @@
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+                            if (argOut0.getByteArray()[0] != SER_DAY_TIME_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(FID.getName() + ": expects NULL/DAY-TIME-DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt64.setValue(ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
+                            aInt64.setValue(ADayTimeDurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
 
                             int64Serde.serialize(aInt64, out);
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
similarity index 87%
rename from asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java
rename to asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index 55173a5..9a66d45 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -16,7 +16,7 @@
 
 import java.io.DataOutput;
 
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.AInt32;
 import edu.uci.ics.asterix.om.base.AMutableInt32;
@@ -38,20 +38,20 @@
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class MonthsOfYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private final static long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MONTHS_OF_YEAR_MONTH_DURATION;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MONTHS_FROM_YEAR_MONTH_DURATION;
 
     // allowed input types
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+    private final static byte SER_YEARMONTHDURATION_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
 
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
-            return new MonthsOfYearMonthDurationDescriptor();
+            return new MonthsFromYearMonthDurationDescriptor();
         }
     };
 
@@ -90,12 +90,14 @@
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+                            if (argOut0.getByteArray()[0] != SER_YEARMONTHDURATION_TYPE_TAG) {
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/YEAR-MONTH-DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt32.setValue(ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1));
+                            aInt32.setValue(AYearMonthDurationerializerDeserializer.getYearMonth(
+                                    argOut0.getByteArray(), 1));
 
                             int32Serde.serialize(aInt32, out);
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
index 8bc792c..2c81b7c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -90,6 +90,7 @@
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ACircleConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ADateConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ADateTimeConstructorDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.constructors.ADayTimeDurationConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ADoubleConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ADurationConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.AFloatConstructorDescriptor;
@@ -111,6 +112,7 @@
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ARectangleConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.AStringConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.constructors.ATimeConstructorDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.constructors.AYearMonthDurationConstructorDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.AndDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.AnyCollectionMemberDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.CastListDescriptor;
@@ -210,6 +212,8 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationEqualDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMillisecondsDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMonthsDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.GetDayTimeDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.GetYearMonthDurationDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalAfterDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalBeforeDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalCoveredByDescriptor;
@@ -218,12 +222,15 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalEndsDecriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalMeetsDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalMetByDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MillisecondsFromDayTimeDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MonthsFromYearMonthDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.OverlapDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalOverlappedByDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalOverlapsDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalStartedByDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalStartsDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MillisecondsOfDayTimeDurationDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MonthsOfYearMonthDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MillisecondsFromDayTimeDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MonthsFromYearMonthDurationDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.OverlapDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractDateDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractDatetimeDescriptor;
@@ -419,6 +426,8 @@
         temp.add(ADateConstructorDescriptor.FACTORY);
         temp.add(ADateTimeConstructorDescriptor.FACTORY);
         temp.add(ADurationConstructorDescriptor.FACTORY);
+        temp.add(AYearMonthDurationConstructorDescriptor.FACTORY);
+        temp.add(ADayTimeDurationConstructorDescriptor.FACTORY);
 
         // Spatial
         temp.add(CreatePointDescriptor.FACTORY);
@@ -519,9 +528,11 @@
         temp.add(YearMonthDurationComparatorDecriptor.LESS_THAN_FACTORY);
         temp.add(DayTimeDurationComparatorDescriptor.GREATER_THAN_FACTORY);
         temp.add(DayTimeDurationComparatorDescriptor.LESS_THAN_FACTORY);
-        temp.add(MonthsOfYearMonthDurationDescriptor.FACTORY);
-        temp.add(MillisecondsOfDayTimeDurationDescriptor.FACTORY);
+        temp.add(MonthsFromYearMonthDurationDescriptor.FACTORY);
+        temp.add(MillisecondsFromDayTimeDurationDescriptor.FACTORY);
         temp.add(DurationEqualDescriptor.FACTORY);
+        temp.add(GetYearMonthDurationDescriptor.FACTORY);
+        temp.add(GetDayTimeDurationDescriptor.FACTORY);
 
         // Interval constructor
         temp.add(AIntervalFromDateConstructorDescriptor.FACTORY);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index b32110b..35c0529 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -33,6 +33,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ALineSerializerDeserializer;
@@ -41,6 +42,7 @@
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APolygonSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARectangleSerializerDeserializer;
 import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
 import edu.uci.ics.asterix.om.base.ABoolean;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
@@ -288,6 +290,14 @@
                 parseConstructor(ATypeTag.DURATION, objectType, out);
                 break;
             }
+            case AdmLexer.TOKEN_YEAR_MONTH_DURATION_CONS: {
+                parseConstructor(ATypeTag.YEARMONTHDURATION, objectType, out);
+                break;
+            }
+            case AdmLexer.TOKEN_DAY_TIME_DURATION_CONS: {
+                parseConstructor(ATypeTag.DAYTIMEDURATION, objectType, out);
+                break;
+            }
             case AdmLexer.TOKEN_POINT_CONS: {
                 parseConstructor(ATypeTag.POINT, objectType, out);
                 break;
@@ -363,6 +373,22 @@
 
     }
 
+    private void parseYearMonthDuration(String duration, DataOutput out) throws AsterixException {
+        try {
+            AYearMonthDurationerializerDeserializer.parse(duration, out);
+        } catch (HyracksDataException e) {
+            throw new AsterixException(e);
+        }
+    }
+
+    private void parseDayTimeDuration(String duration, DataOutput out) throws AsterixException {
+        try {
+            ADayTimeDurationSerializerDeserializer.parse(duration, out);
+        } catch (HyracksDataException e) {
+            throw new AsterixException(e);
+        }
+    }
+
     private IAType getComplexType(IAType aObjectType, ATypeTag tag) {
 
         if (aObjectType == null) {
@@ -762,6 +788,16 @@
                                         admLexer.getLastTokenImage().substring(1,
                                                 admLexer.getLastTokenImage().length() - 1), out);
                                 break;
+                            case DAYTIMEDURATION:
+                                parseDayTimeDuration(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
+                                break;
+                            case YEARMONTHDURATION:
+                                parseYearMonthDuration(
+                                        admLexer.getLastTokenImage().substring(1,
+                                                admLexer.getLastTokenImage().length() - 1), out);
+                                break;
                             case POINT:
                                 parsePoint(
                                         admLexer.getLastTokenImage().substring(1,
diff --git a/asterix-runtime/src/main/resources/adm.grammar b/asterix-runtime/src/main/resources/adm.grammar
index 4d4158f..80e2cd4 100644
--- a/asterix-runtime/src/main/resources/adm.grammar
+++ b/asterix-runtime/src/main/resources/adm.grammar
@@ -29,6 +29,8 @@
 INTERVAL_TIME_CONS      = string(interval-time)
 INTERVAL_DATE_CONS      = string(interval-date)
 INTERVAL_DATETIME_CONS  = string(interval-datetime)
+YEAR_MONTH_DURATION_CONS = string(year-month-duration)
+DAY_TIME_DURATION_CONS   = string(day-time-duration) 
 
 NULL_LITERAL   = string(null)
 TRUE_LITERAL   = string(true)
diff --git a/asterix-test-framework/.gitignore b/asterix-test-framework/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/asterix-test-framework/.gitignore
@@ -0,0 +1 @@
+/target
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 e037e95..7ab0d10 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
@@ -48,7 +48,7 @@
         LSMBTree lsmBTree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager,
                 runtimeContextProvider.getIOManager(), file, runtimeContextProvider.getBufferCache(),
                 runtimeContextProvider.getFileMapManager(), typeTraits, cmpFactories, bloomFilterKeyFields,
-                runtimeContextProvider.getLSMMergePolicy(),
+                runtimeContextProvider.getBloomFilterFalsePositiveRate(), runtimeContextProvider.getLSMMergePolicy(),
                 runtimeContextProvider.getLSMBTreeOperationTrackerFactory(),
                 runtimeContextProvider.getLSMIOScheduler(),
                 runtimeContextProvider.getLSMBTreeIOOperationCallbackProvider(), partition);
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 894fc16..3bcb747 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
@@ -57,7 +57,9 @@
                 return InvertedIndexUtils.createPartitionedLSMInvertedIndex(memBufferCache, memFreePageManager,
                         runtimeContextProvider.getFileMapManager(), invListTypeTraits, invListCmpFactories,
                         tokenTypeTraits, tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
-                        runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider.getLSMMergePolicy(),
+                        runtimeContextProvider.getIOManager(), filePath,
+                        runtimeContextProvider.getBloomFilterFalsePositiveRate(),
+                        runtimeContextProvider.getLSMMergePolicy(),
                         runtimeContextProvider.getLSMInvertedIndexOperationTrackerFactory(),
                         runtimeContextProvider.getLSMIOScheduler(),
                         runtimeContextProvider.getLSMInvertedIndexIOOperationCallbackProvider(), partition);
@@ -65,7 +67,9 @@
                 return InvertedIndexUtils.createLSMInvertedIndex(memBufferCache, memFreePageManager,
                         runtimeContextProvider.getFileMapManager(), invListTypeTraits, invListCmpFactories,
                         tokenTypeTraits, tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
-                        runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider.getLSMMergePolicy(),
+                        runtimeContextProvider.getIOManager(), filePath,
+                        runtimeContextProvider.getBloomFilterFalsePositiveRate(),
+                        runtimeContextProvider.getLSMMergePolicy(),
                         runtimeContextProvider.getLSMInvertedIndexOperationTrackerFactory(),
                         runtimeContextProvider.getLSMIOScheduler(),
                         runtimeContextProvider.getLSMInvertedIndexIOOperationCallbackProvider(), partition);
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 1705dd3..ff26c54 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
@@ -62,7 +62,8 @@
             return LSMRTreeUtils.createLSMTree(memBufferCache, memFreePageManager,
                     runtimeContextProvider.getIOManager(), file, runtimeContextProvider.getBufferCache(),
                     runtimeContextProvider.getFileMapManager(), typeTraits, rtreeCmpFactories, btreeCmpFactories,
-                    valueProviderFactories, rtreePolicyType, runtimeContextProvider.getLSMMergePolicy(),
+                    valueProviderFactories, rtreePolicyType, runtimeContextProvider.getBloomFilterFalsePositiveRate(),
+                    runtimeContextProvider.getLSMMergePolicy(),
                     runtimeContextProvider.getLSMRTreeOperationTrackerFactory(),
                     runtimeContextProvider.getLSMIOScheduler(),
                     runtimeContextProvider.getLSMRTreeIOOperationCallbackProvider(), linearizeCmpFactory, partition);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockWaiterManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockWaiterManager.java
index dbe76ff..bd414de 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockWaiterManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockWaiterManager.java
@@ -223,45 +223,35 @@
      */
     private void shrink() {
         int i;
-        boolean bContiguous = true;
-        int decreaseCount = 0;
+        int removeCount = 0;
         int size = pArray.size();
         int maxDecreaseCount = size / 2;
         ChildLockWaiterArrayManager child;
-        for (i = size - 1; i >= 0; i--) {
-            child = pArray.get(i);
-            if (child.isEmpty() || child.isDeinitialized()) {
-                if (bContiguous) {
-                    pArray.remove(i);
-                    if (++decreaseCount == maxDecreaseCount) {
-                        break;
-                    }
-                } else {
-                    bContiguous = false;
-                    if (child.isEmpty()) {
-                        child.deinitialize();
-                        if (++decreaseCount == maxDecreaseCount) {
-                            break;
-                        }
-                    }
-                }
-            } else {
-                bContiguous = false;
+
+        //The first buffer never be deinitialized.
+        for (i = 1; i < size; i++) {
+            if (pArray.get(i).isEmpty()) {
+                pArray.get(i).deinitialize();
             }
         }
 
-        //reset allocChild when the child is removed or deinitialized.
-        size = pArray.size();
-        if (allocChild >= size || pArray.get(allocChild).isDeinitialized()) {
-            //set allocChild to any initialized one.
-            //It is guaranteed that there is at least one initialized child.
-            for (i = 0; i < size; i++) {
-                if (!pArray.get(i).isDeinitialized()) {
-                    allocChild = i;
+        //remove the empty buffers from the end
+        for (i = size - 1; i >= 1; i--) {
+            child = pArray.get(i);
+            if (child.isDeinitialized()) {
+                pArray.remove(i);
+                if (++removeCount == maxDecreaseCount) {
                     break;
                 }
+            } else {
+                break;
             }
         }
+        
+        //reset allocChild to the first buffer
+        allocChild = 0;
+
+        isShrinkTimerOn = false;
     }
 
     public String prettyPrint() {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
index 199fd0f..38d39cc 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
@@ -259,9 +259,16 @@
             }
 
             if (forwardPage) {
-
+                logPages[prevPage].acquireReadLatch();
+                // increment the counter as the transaction thread now holds a
+                // space in the log page and hence is an owner.
+                logPages[prevPage].incRefCnt();
+                logPages[prevPage].releaseReadLatch();
+                
                 // forward the nextWriteOffset in the log page
-                logPages[pageIndex].setBufferNextWriteOffset(logPageSize);
+                logPages[prevPage].setBufferNextWriteOffset(logPageSize);
+                
+                logPages[prevPage].decRefCnt();
 
                 addFlushRequest(prevPage, old, false);
 
@@ -433,7 +440,7 @@
 
                 // indicating that the transaction thread has released ownership
                 decremented = true;
-                
+
                 addFlushRequest(pageIndex, currentLSN, false);
             } else if (logType == LogType.COMMIT) {
 
@@ -872,16 +879,16 @@
                         if (logManager.getLastFlushedLsn().get() + 1 > logManager.getCurrentLsn().get()) {
                             logManager.getCurrentLsn().set(logManager.getLastFlushedLsn().get() + 1);
                         }
-                        
+
                         // Map the log page to a new region in the log file if the flushOffset reached the logPageSize
                         if (afterFlushOffset == logPageSize) {
-                            long diskNextWriteOffset = logManager.getLogPages()[flushPageIndex].getDiskNextWriteOffset()
-                                    + logBufferSize;
+                            long diskNextWriteOffset = logManager.getLogPages()[flushPageIndex]
+                                    .getDiskNextWriteOffset() + logBufferSize;
                             logManager.resetLogPage(logManager.getLastFlushedLsn().get() + 1 + logBufferSize,
                                     diskNextWriteOffset, flushPageIndex);
                             resetFlushPageIndex = true;
                         }
-                        
+
                         // decrement activeTxnCountOnIndexes
                         logManager.decrementActiveTxnCountOnIndexes(flushPageIndex);
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IAsterixAppRuntimeContextProvider.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IAsterixAppRuntimeContextProvider.java
index 3ae7da8..d96d5c2 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IAsterixAppRuntimeContextProvider.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IAsterixAppRuntimeContextProvider.java
@@ -22,27 +22,29 @@
 
     public IIndexLifecycleManager getIndexLifecycleManager();
 
+    public double getBloomFilterFalsePositiveRate();
+
     public ILSMMergePolicy getLSMMergePolicy();
 
     public ILSMOperationTrackerFactory getLSMBTreeOperationTrackerFactory();
-    
+
     public ILSMOperationTrackerFactory getLSMRTreeOperationTrackerFactory();
-    
+
     public ILSMOperationTrackerFactory getLSMInvertedIndexOperationTrackerFactory();
-    
+
     public ILSMIOOperationCallbackProvider getLSMBTreeIOOperationCallbackProvider();
-    
+
     public ILSMIOOperationCallbackProvider getLSMRTreeIOOperationCallbackProvider();
-    
+
     public ILSMIOOperationCallbackProvider getLSMInvertedIndexIOOperationCallbackProvider();
-    
+
     public ILSMIOOperationCallbackProvider getNoOpIOOperationCallbackProvider();
-    
+
     public ILSMIOOperationScheduler getLSMIOScheduler();
 
     public ILocalResourceRepository getLocalResourceRepository();
 
     public ResourceIdFactory getResourceIdFactory();
-    
+
     public IIOManager getIOManager();
 }