Created branch for keeping asterix consistent with the hyracks_scheduling branch

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_hyracks_scheduling@509 eaa15691-b419-025a-1212-ee371bd00084
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 e004a7d..06765d6 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
@@ -154,1255 +154,1507 @@
  * source for the current subtree.
  */
 
-public class AqlExpressionToPlanTranslator extends AbstractAqlTranslator implements
-        IAqlExpressionVisitor<Pair<ILogicalOperator, LogicalVariable>, Mutable<ILogicalOperator>> {
+public class AqlExpressionToPlanTranslator extends AbstractAqlTranslator
+		implements
+		IAqlExpressionVisitor<Pair<ILogicalOperator, LogicalVariable>, Mutable<ILogicalOperator>> {
 
-    private final MetadataTransactionContext mdTxnCtx;
-    private final long txnId;
-    private TranslationContext context;
-    private String outputDatasetName;
-    private Statement.Kind dmlKind;
-    private static AtomicLong outputFileID = new AtomicLong(0);
-    private static final String OUTPUT_FILE_PREFIX = "OUTPUT_";
+	private final MetadataTransactionContext mdTxnCtx;
+	private final long txnId;
+	private TranslationContext context;
+	private String outputDatasetName;
+	private Statement.Kind dmlKind;
+	private static AtomicLong outputFileID = new AtomicLong(0);
+	private static final String OUTPUT_FILE_PREFIX = "OUTPUT_";
 
-    private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
+	private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
 
-    public AqlExpressionToPlanTranslator(long txnId, MetadataTransactionContext mdTxnCtx, int currentVarCounter,
-            String outputDatasetName, Statement.Kind dmlKind) {
-        this.mdTxnCtx = mdTxnCtx;
-        this.txnId = txnId;
-        this.context = new TranslationContext(new Counter(currentVarCounter));
-        this.outputDatasetName = outputDatasetName;
-        this.dmlKind = dmlKind;
-    }
+	public AqlExpressionToPlanTranslator(long txnId,
+			MetadataTransactionContext mdTxnCtx, int currentVarCounter,
+			String outputDatasetName, Statement.Kind dmlKind) {
+		this.mdTxnCtx = mdTxnCtx;
+		this.txnId = txnId;
+		this.context = new TranslationContext(new Counter(currentVarCounter));
+		this.outputDatasetName = outputDatasetName;
+		this.dmlKind = dmlKind;
+	}
 
-    public int getVarCounter() {
-        return context.getVarCounter();
-    }
+	public int getVarCounter() {
+		return context.getVarCounter();
+	}
 
-    public ILogicalPlanAndMetadata translate(Query expr, AqlCompiledMetadataDeclarations compiledDeclarations)
-            throws AlgebricksException, AsterixException {
-        if (expr == null) {
-            return null;
-        }
-        if (compiledDeclarations == null) {
-            compiledDeclarations = compileMetadata(mdTxnCtx, expr.getPrologDeclList(), true);
-        }
-        if (!compiledDeclarations.isConnectedToDataverse())
-            compiledDeclarations.connectToDataverse(compiledDeclarations.getDataverseName());
-        IDataFormat format = compiledDeclarations.getFormat();
-        if (format == null) {
-            throw new AlgebricksException("Data format has not been set.");
-        }
-        format.registerRuntimeFunctions();
-        Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, new MutableObject<ILogicalOperator>(
-                new EmptyTupleSourceOperator()));
+	public ILogicalPlanAndMetadata translate(Query expr,
+			AqlCompiledMetadataDeclarations compiledDeclarations)
+			throws AlgebricksException, AsterixException {
+		if (expr == null) {
+			return null;
+		}
+		if (compiledDeclarations == null) {
+			compiledDeclarations = compileMetadata(mdTxnCtx,
+					expr.getPrologDeclList(), true);
+		}
+		if (!compiledDeclarations.isConnectedToDataverse())
+			compiledDeclarations.connectToDataverse(compiledDeclarations
+					.getDataverseName());
+		IDataFormat format = compiledDeclarations.getFormat();
+		if (format == null) {
+			throw new AlgebricksException("Data format has not been set.");
+		}
+		format.registerRuntimeFunctions();
+		Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+				new MutableObject<ILogicalOperator>(
+						new EmptyTupleSourceOperator()));
 
-        ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
+		ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
 
-        boolean isTransactionalWrite = false;
-        ILogicalOperator topOp = p.first;
-        ProjectOperator project = (ProjectOperator) topOp;
-        LogicalVariable resVar = project.getVariables().get(0);
-        if (outputDatasetName == null) {
-            FileSplit outputFileSplit = compiledDeclarations.getOutputFile();
-            if (outputFileSplit == null) {
-                outputFileSplit = getDefaultOutputFileLocation();
-            }
-            compiledDeclarations.setOutputFile(outputFileSplit);
-            List<Mutable<ILogicalExpression>> writeExprList = new ArrayList<Mutable<ILogicalExpression>>(1);
-            writeExprList.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(resVar)));
-            FileSplitSinkId fssi = new FileSplitSinkId(outputFileSplit);
-            FileSplitDataSink sink = new FileSplitDataSink(fssi, null);
-            topOp = new WriteOperator(writeExprList, sink);
-            topOp.getInputs().add(new MutableObject<ILogicalOperator>(project));
-        } else {
-            String dataVerseName = compiledDeclarations.getDataverseName();
-            Dataset dataset = compiledDeclarations.findDataset(outputDatasetName);
-            if (dataset == null) {
-                throw new AlgebricksException("Cannot find dataset " + outputDatasetName);
-            }
+		boolean isTransactionalWrite = false;
+		ILogicalOperator topOp = p.first;
+		ProjectOperator project = (ProjectOperator) topOp;
+		LogicalVariable resVar = project.getVariables().get(0);
+		if (outputDatasetName == null) {
+			FileSplit outputFileSplit = compiledDeclarations.getOutputFile();
+			if (outputFileSplit == null) {
+				outputFileSplit = getDefaultOutputFileLocation();
+			}
+			compiledDeclarations.setOutputFile(outputFileSplit);
+			List<Mutable<ILogicalExpression>> writeExprList = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			writeExprList.add(new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(resVar)));
+			FileSplitSinkId fssi = new FileSplitSinkId(outputFileSplit);
+			FileSplitDataSink sink = new FileSplitDataSink(fssi, null);
+			topOp = new WriteOperator(writeExprList, sink);
+			topOp.getInputs().add(new MutableObject<ILogicalOperator>(project));
+		} else {
+			String dataVerseName = compiledDeclarations.getDataverseName();
+			Dataset dataset = compiledDeclarations
+					.findDataset(outputDatasetName);
+			if (dataset == null) {
+				throw new AlgebricksException("Cannot find dataset "
+						+ outputDatasetName);
+			}
 
-            AqlSourceId sourceId = new AqlSourceId(dataVerseName, outputDatasetName);
-            String itemTypeName = dataset.getItemTypeName();
-            IAType itemType = compiledDeclarations.findType(itemTypeName);
-            AqlDataSource dataSource = new AqlDataSource(sourceId, dataset, itemType);
-            if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
-                throw new AlgebricksException("Cannot write output to an external dataset.");
-            }
-            ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>();
-            ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>();
-            List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<Mutable<ILogicalExpression>>();
+			AqlSourceId sourceId = new AqlSourceId(dataVerseName,
+					outputDatasetName);
+			String itemTypeName = dataset.getItemTypeName();
+			IAType itemType = compiledDeclarations.findType(itemTypeName);
+			AqlDataSource dataSource = new AqlDataSource(sourceId, dataset,
+					itemType);
+			if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
+				throw new AlgebricksException(
+						"Cannot write output to an external dataset.");
+			}
+			ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>();
+			ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>();
+			List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<Mutable<ILogicalExpression>>();
 
-            List<String> partitionKeys = DatasetUtils.getPartitioningKeys(dataset);
-            for (String keyFieldName : partitionKeys) {
-                IFunctionInfo finfoAccess = AsterixBuiltinFunctions
-                        .getAsterixFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME);
-                @SuppressWarnings("unchecked")
-                ScalarFunctionCallExpression f = new ScalarFunctionCallExpression(finfoAccess,
-                        new MutableObject<ILogicalExpression>(new VariableReferenceExpression(METADATA_DUMMY_VAR)),
-                        new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(
-                                new AString(keyFieldName)))));
-                f.substituteVar(METADATA_DUMMY_VAR, resVar);
-                exprs.add(new MutableObject<ILogicalExpression>(f));
-                LogicalVariable v = context.newVar();
-                vars.add(v);
-                varRefsForLoading.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(v)));
-            }
-            AssignOperator assign = new AssignOperator(vars, exprs);
-            assign.getInputs().add(new MutableObject<ILogicalOperator>(project));
+			List<String> partitionKeys = DatasetUtils
+					.getPartitioningKeys(dataset);
+			for (String keyFieldName : partitionKeys) {
+				IFunctionInfo finfoAccess = AsterixBuiltinFunctions
+						.getAsterixFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME);
+				@SuppressWarnings("unchecked")
+				ScalarFunctionCallExpression f = new ScalarFunctionCallExpression(
+						finfoAccess, new MutableObject<ILogicalExpression>(
+								new VariableReferenceExpression(
+										METADATA_DUMMY_VAR)),
+						new MutableObject<ILogicalExpression>(
+								new ConstantExpression(
+										new AsterixConstantValue(new AString(
+												keyFieldName)))));
+				f.substituteVar(METADATA_DUMMY_VAR, resVar);
+				exprs.add(new MutableObject<ILogicalExpression>(f));
+				LogicalVariable v = context.newVar();
+				vars.add(v);
+				varRefsForLoading.add(new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(v)));
+			}
+			AssignOperator assign = new AssignOperator(vars, exprs);
+			assign.getInputs()
+					.add(new MutableObject<ILogicalOperator>(project));
 
-            Mutable<ILogicalExpression> varRef = new MutableObject<ILogicalExpression>(new VariableReferenceExpression(
-                    resVar));
-            ILogicalOperator load = null;
+			Mutable<ILogicalExpression> varRef = new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(resVar));
+			ILogicalOperator load = null;
 
-            switch (dmlKind) {
-                case WRITE_FROM_QUERY_RESULT: {
-                    load = new WriteResultOperator(dataSource, varRef, varRefsForLoading);
-                    load.getInputs().add(new MutableObject<ILogicalOperator>(assign));
-                    break;
-                }
-                case INSERT: {
-                    ILogicalOperator insertOp = new InsertDeleteOperator(dataSource, varRef, varRefsForLoading,
-                            InsertDeleteOperator.Kind.INSERT);
-                    insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
-                    load = new SinkOperator();
-                    load.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
-                    isTransactionalWrite = true;
-                    break;
-                }
-                case DELETE: {
-                    ILogicalOperator deleteOp = new InsertDeleteOperator(dataSource, varRef, varRefsForLoading,
-                            InsertDeleteOperator.Kind.DELETE);
-                    deleteOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
-                    load = new SinkOperator();
-                    load.getInputs().add(new MutableObject<ILogicalOperator>(deleteOp));
-                    isTransactionalWrite = true;
-                    break;
-                }
-                case BEGIN_FEED: {
-                    ILogicalOperator insertOp = new InsertDeleteOperator(dataSource, varRef, varRefsForLoading,
-                            InsertDeleteOperator.Kind.INSERT);
-                    insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
-                    load = new SinkOperator();
-                    load.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
-                    isTransactionalWrite = false;
-                    break;
-                }
-            }
-            topOp = load;
-        }
+			switch (dmlKind) {
+			case WRITE_FROM_QUERY_RESULT: {
+				load = new WriteResultOperator(dataSource, varRef,
+						varRefsForLoading);
+				load.getInputs().add(
+						new MutableObject<ILogicalOperator>(assign));
+				break;
+			}
+			case INSERT: {
+				ILogicalOperator insertOp = new InsertDeleteOperator(
+						dataSource, varRef, varRefsForLoading,
+						InsertDeleteOperator.Kind.INSERT);
+				insertOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(assign));
+				load = new SinkOperator();
+				load.getInputs().add(
+						new MutableObject<ILogicalOperator>(insertOp));
+				isTransactionalWrite = true;
+				break;
+			}
+			case DELETE: {
+				ILogicalOperator deleteOp = new InsertDeleteOperator(
+						dataSource, varRef, varRefsForLoading,
+						InsertDeleteOperator.Kind.DELETE);
+				deleteOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(assign));
+				load = new SinkOperator();
+				load.getInputs().add(
+						new MutableObject<ILogicalOperator>(deleteOp));
+				isTransactionalWrite = true;
+				break;
+			}
+			case BEGIN_FEED: {
+				ILogicalOperator insertOp = new InsertDeleteOperator(
+						dataSource, varRef, varRefsForLoading,
+						InsertDeleteOperator.Kind.INSERT);
+				insertOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(assign));
+				load = new SinkOperator();
+				load.getInputs().add(
+						new MutableObject<ILogicalOperator>(insertOp));
+				isTransactionalWrite = false;
+				break;
+			}
+			}
+			topOp = load;
+		}
 
-        globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
-        ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
-        AqlMetadataProvider metadataProvider = new AqlMetadataProvider(txnId, isTransactionalWrite,
-                compiledDeclarations);
-        ILogicalPlanAndMetadata planAndMetadata = new AqlLogicalPlanAndMetadataImpl(plan, metadataProvider);
-        return planAndMetadata;
-    }
+		globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
+		ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
+		AqlMetadataProvider metadataProvider = new AqlMetadataProvider(txnId,
+				isTransactionalWrite, compiledDeclarations);
+		ILogicalPlanAndMetadata planAndMetadata = new AqlLogicalPlanAndMetadataImpl(
+				plan, metadataProvider);
+		return planAndMetadata;
+	}
 
-    private FileSplit getDefaultOutputFileLocation() throws MetadataException {
-        if (AsterixProperties.INSTANCE.getOutputDir() == null) {
-            throw new MetadataException(
-                    "Output location for query result not specified at the time of deployment, must specify explicitly using 'write output to ..' statement");
-        }
-        String filePath = AsterixProperties.INSTANCE.getOutputDir() + System.getProperty("file.separator")
-                + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
-        return new FileSplit(AsterixProperties.INSTANCE.getMetadataNodeName(), new FileReference(new File(filePath)));
-    }
+	private FileSplit getDefaultOutputFileLocation() throws MetadataException {
+		if (AsterixProperties.INSTANCE.getOutputDir() == null) {
+			throw new MetadataException(
+					"Output location for query result not specified at the time of deployment, must specify explicitly using 'write output to ..' statement");
+		}
+		String filePath = AsterixProperties.INSTANCE.getOutputDir()
+				+ System.getProperty("file.separator") + OUTPUT_FILE_PREFIX
+				+ outputFileID.incrementAndGet();
+		return new FileSplit(AsterixProperties.INSTANCE.getMetadataNodeName(),
+				new FileReference(new File(filePath)));
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitForClause(ForClause fc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v = context.newVar(fc.getVarExpr());
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitForClause(ForClause fc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		LogicalVariable v = context.newVar(fc.getVarExpr());
 
-        Expression inExpr = fc.getInExpr();
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(inExpr, tupSource);
-        ILogicalOperator returnedOp;
+		Expression inExpr = fc.getInExpr();
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+				inExpr, tupSource);
+		ILogicalOperator returnedOp;
 
-        if (fc.getPosVarExpr() == null) {
-            returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)));
-        } else {
-            LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
-            returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)),
-                    pVar, BuiltinType.AINT32);
-        }
-        returnedOp.getInputs().add(eo.second);
+		if (fc.getPosVarExpr() == null) {
+			returnedOp = new UnnestOperator(v,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo.first)));
+		} else {
+			LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
+			returnedOp = new UnnestOperator(v,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo.first)), pVar,
+					BuiltinType.AINT32);
+		}
+		returnedOp.getInputs().add(eo.second);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLetClause(LetClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v;
-        ILogicalOperator returnedOp;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLetClause(LetClause lc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		LogicalVariable v;
+		ILogicalOperator returnedOp;
 
-        switch (lc.getBindingExpr().getKind()) {
-            case VARIABLE_EXPRESSION: {
-                v = context.newVar(lc.getVarExpr());
-                LogicalVariable prev = context.getVar(((VariableExpr) lc.getBindingExpr()).getVar().getId());
-                returnedOp = new AssignOperator(v, new MutableObject<ILogicalExpression>(
-                        new VariableReferenceExpression(prev)));
-                returnedOp.getInputs().add(tupSource);
-                break;
-            }
-            default: {
-                Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(lc.getBindingExpr(),
-                        tupSource);
-                v = context.newVar(lc.getVarExpr());
-                returnedOp = new AssignOperator(v, new MutableObject<ILogicalExpression>(eo.first));
-                returnedOp.getInputs().add(eo.second);
-                break;
-            }
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
-    }
+		switch (lc.getBindingExpr().getKind()) {
+		case VARIABLE_EXPRESSION: {
+			v = context.newVar(lc.getVarExpr());
+			LogicalVariable prev = context.getVar(((VariableExpr) lc
+					.getBindingExpr()).getVar().getId());
+			returnedOp = new AssignOperator(v,
+					new MutableObject<ILogicalExpression>(
+							new VariableReferenceExpression(prev)));
+			returnedOp.getInputs().add(tupSource);
+			break;
+		}
+		default: {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					lc.getBindingExpr(), tupSource);
+			v = context.newVar(lc.getVarExpr());
+			returnedOp = new AssignOperator(v,
+					new MutableObject<ILogicalExpression>(eo.first));
+			returnedOp.getInputs().add(eo.second);
+			break;
+		}
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFlworExpression(FLWOGRExpression flwor,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> flworPlan = tupSource;
-        boolean isTop = context.isTopFlwor();
-        if (isTop) {
-            context.setTopFlwor(false);
-        }
-        for (Clause c : flwor.getClauseList()) {
-            Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this, flworPlan);
-            flworPlan = new MutableObject<ILogicalOperator>(pC.first);
-        }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFlworExpression(
+			FLWOGRExpression flwor, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> flworPlan = tupSource;
+		boolean isTop = context.isTopFlwor();
+		if (isTop) {
+			context.setTopFlwor(false);
+		}
+		for (Clause c : flwor.getClauseList()) {
+			Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this,
+					flworPlan);
+			flworPlan = new MutableObject<ILogicalOperator>(pC.first);
+		}
 
-        Expression r = flwor.getReturnExpr();
-        boolean noFlworClause = flwor.noForClause();
+		Expression r = flwor.getReturnExpr();
+		boolean noFlworClause = flwor.noForClause();
 
-        if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
-            VariableExpr v = (VariableExpr) r;
-            LogicalVariable var = context.getVar(v.getVar().getId());
+		if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
+			VariableExpr v = (VariableExpr) r;
+			LogicalVariable var = context.getVar(v.getVar().getId());
 
-            return produceFlwrResult(noFlworClause, isTop, flworPlan, var);
+			return produceFlwrResult(noFlworClause, isTop, flworPlan, var);
 
-        } else {
-            Mutable<ILogicalOperator> baseOp = new MutableObject<ILogicalOperator>(flworPlan.getValue());
-            Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this, baseOp);
-            ILogicalOperator rOp = rRes.first;
-            ILogicalOperator resOp;
-            if (expressionNeedsNoNesting(r)) {
-                baseOp.setValue(flworPlan.getValue());
-                resOp = rOp;
-            } else {
-                SubplanOperator s = new SubplanOperator(rOp);
-                s.getInputs().add(flworPlan);
-                resOp = s;
-                baseOp.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
-            }
-            Mutable<ILogicalOperator> resOpRef = new MutableObject<ILogicalOperator>(resOp);
-            return produceFlwrResult(noFlworClause, isTop, resOpRef, rRes.second);
-        }
-    }
+		} else {
+			Mutable<ILogicalOperator> baseOp = new MutableObject<ILogicalOperator>(
+					flworPlan.getValue());
+			Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this,
+					baseOp);
+			ILogicalOperator rOp = rRes.first;
+			ILogicalOperator resOp;
+			if (expressionNeedsNoNesting(r)) {
+				baseOp.setValue(flworPlan.getValue());
+				resOp = rOp;
+			} else {
+				SubplanOperator s = new SubplanOperator(rOp);
+				s.getInputs().add(flworPlan);
+				resOp = s;
+				baseOp.setValue(new NestedTupleSourceOperator(
+						new MutableObject<ILogicalOperator>(s)));
+			}
+			Mutable<ILogicalOperator> resOpRef = new MutableObject<ILogicalOperator>(
+					resOp);
+			return produceFlwrResult(noFlworClause, isTop, resOpRef,
+					rRes.second);
+		}
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFieldAccessor(FieldAccessor fa,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(fa.getExpr(), tupSource);
-        LogicalVariable v = context.newVar();
-        AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
-        fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        ILogicalExpression faExpr = new ConstantExpression(new AsterixConstantValue(new AString(fa.getIdent()
-                .getValue())));
-        fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(faExpr));
-        AssignOperator a = new AssignOperator(v, new MutableObject<ILogicalExpression>(fldAccess));
-        a.getInputs().add(p.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFieldAccessor(
+			FieldAccessor fa, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				fa.getExpr(), tupSource);
+		LogicalVariable v = context.newVar();
+		AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
+		fldAccess.getArguments().add(
+				new MutableObject<ILogicalExpression>(p.first));
+		ILogicalExpression faExpr = new ConstantExpression(
+				new AsterixConstantValue(new AString(fa.getIdent().getValue())));
+		fldAccess.getArguments().add(
+				new MutableObject<ILogicalExpression>(faExpr));
+		AssignOperator a = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(fldAccess));
+		a.getInputs().add(p.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v);
 
-    }
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIndexAccessor(IndexAccessor ia,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(ia.getExpr(), tupSource);
-        LogicalVariable v = context.newVar();
-        AbstractFunctionCallExpression f;
-        int i = ia.getIndex();
-        if (i == IndexAccessor.ANY) {
-            f = new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        } else {
-            f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-            f.getArguments().add(
-                    new MutableObject<ILogicalExpression>(new ConstantExpression(
-                            new AsterixConstantValue(new AInt32(i)))));
-        }
-        AssignOperator a = new AssignOperator(v, new MutableObject<ILogicalExpression>(f));
-        a.getInputs().add(p.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIndexAccessor(
+			IndexAccessor ia, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				ia.getExpr(), tupSource);
+		LogicalVariable v = context.newVar();
+		AbstractFunctionCallExpression f;
+		int i = ia.getIndex();
+		if (i == IndexAccessor.ANY) {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+		} else {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(
+							new ConstantExpression(new AsterixConstantValue(
+									new AInt32(i)))));
+		}
+		AssignOperator a = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(f));
+		a.getInputs().add(p.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCallExpr(CallExpr fcall, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v = context.newVar();
-        AsterixFunction fid = fcall.getIdent();
-        List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
-        Mutable<ILogicalOperator> topOp = tupSource;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCallExpr(
+			CallExpr fcall, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		LogicalVariable v = context.newVar();
+		AsterixFunction fid = fcall.getIdent();
+		List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        for (Expression expr : fcall.getExprList()) {
-            switch (expr.getKind()) {
-                case VARIABLE_EXPRESSION: {
-                    LogicalVariable var = context.getVar(((VariableExpr) expr).getVar().getId());
-                    args.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
-                    break;
-                }
-                case LITERAL_EXPRESSION: {
-                    LiteralExpr val = (LiteralExpr) expr;
-                    args.add(new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(
-                            ConstantHelper.objectFromLiteral(val.getValue())))));
-                    break;
-                }
-                default: {
-                    Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, topOp);
-                    AbstractLogicalOperator o1 = (AbstractLogicalOperator) eo.second.getValue();
-                    args.add(new MutableObject<ILogicalExpression>(eo.first));
-                    if (o1 != null && !(o1.getOperatorTag() == LogicalOperatorTag.ASSIGN && hasOnlyChild(o1, topOp))) {
-                        topOp = eo.second;
-                    }
-                    break;
-                }
-            }
-        }
+		for (Expression expr : fcall.getExprList()) {
+			switch (expr.getKind()) {
+			case VARIABLE_EXPRESSION: {
+				LogicalVariable var = context.getVar(((VariableExpr) expr)
+						.getVar().getId());
+				args.add(new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(var)));
+				break;
+			}
+			case LITERAL_EXPRESSION: {
+				LiteralExpr val = (LiteralExpr) expr;
+				args.add(new MutableObject<ILogicalExpression>(
+						new ConstantExpression(
+								new AsterixConstantValue(ConstantHelper
+										.objectFromLiteral(val.getValue())))));
+				break;
+			}
+			default: {
+				Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+						expr, topOp);
+				AbstractLogicalOperator o1 = (AbstractLogicalOperator) eo.second
+						.getValue();
+				args.add(new MutableObject<ILogicalExpression>(eo.first));
+				if (o1 != null
+						&& !(o1.getOperatorTag() == LogicalOperatorTag.ASSIGN && hasOnlyChild(
+								o1, topOp))) {
+					topOp = eo.second;
+				}
+				break;
+			}
+			}
+		}
 
-        FunctionIdentifier fi = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS, fid.getFunctionName(),
-                false);
-        AsterixFunctionInfo afi = AsterixBuiltinFunctions.lookupFunction(fi);
-        FunctionIdentifier builtinAquafi = afi == null ? null : afi.getFunctionIdentifier();
+		FunctionIdentifier fi = new FunctionIdentifier(
+				AlgebricksBuiltinFunctions.ALGEBRICKS_NS, fid.getFunctionName());
+		AsterixFunctionInfo afi = AsterixBuiltinFunctions.lookupFunction(fi);
+		FunctionIdentifier builtinAquafi = afi == null ? null : afi
+				.getFunctionIdentifier();
 
-        if (builtinAquafi != null) {
-            fi = builtinAquafi;
-        } else {
-            fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, fid.getFunctionName(), false);
-            FunctionIdentifier builtinAsterixFi = AsterixBuiltinFunctions.getBuiltinFunctionIdentifier(fi);
-            if (builtinAsterixFi != null) {
-                fi = builtinAsterixFi;
-            }
-        }
-        AbstractFunctionCallExpression f;
-        if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
-            f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi, args);
-        } else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
-            UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(fi), args);
-            ufce.setReturnsUniqueValues(AsterixBuiltinFunctions.returnsUniqueValues(fi));
-            f = ufce;
-        } else {
-            f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fi), args);
-        }
-        AssignOperator op = new AssignOperator(v, new MutableObject<ILogicalExpression>(f));
-        if (topOp != null) {
-            op.getInputs().add(topOp);
-        }
+		if (builtinAquafi != null) {
+			fi = builtinAquafi;
+		} else {
+			fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+					fid.getFunctionName());
+			FunctionIdentifier builtinAsterixFi = AsterixBuiltinFunctions
+					.getBuiltinFunctionIdentifier(fi);
+			if (builtinAsterixFi != null) {
+				fi = builtinAsterixFi;
+			}
+		}
+		AbstractFunctionCallExpression f;
+		if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
+			f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi,
+					args);
+		} else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
+			UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(
+					FunctionUtils.getFunctionInfo(fi), args);
+			ufce.setReturnsUniqueValues(AsterixBuiltinFunctions
+					.returnsUniqueValues(fi));
+			f = ufce;
+		} else {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils.getFunctionInfo(fi), args);
+		}
+		AssignOperator op = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(f));
+		if (topOp != null) {
+			op.getInputs().add(topOp);
+		}
 
-        return new Pair<ILogicalOperator, LogicalVariable>(op, v);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(op, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFunctionDecl(FunctionDecl fd,
-            Mutable<ILogicalOperator> tupSource) {
-        // TODO Auto-generated method stub
-        throw new NotImplementedException();
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFunctionDecl(
+			FunctionDecl fd, Mutable<ILogicalOperator> tupSource) {
+		// TODO Auto-generated method stub
+		throw new NotImplementedException();
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitGroupbyClause(GroupbyClause gc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        GroupByOperator gOp = new GroupByOperator();
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (GbyVariableExpressionPair ve : gc.getGbyPairList()) {
-            LogicalVariable v;
-            VariableExpr vexpr = ve.getVar();
-            if (vexpr != null) {
-                v = context.newVar(vexpr);
-            } else {
-                v = context.newVar();
-            }
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(ve.getExpr(), topOp);
-            gOp.addGbyExpression(v, eo.first);
-            topOp = eo.second;
-        }
-        for (GbyVariableExpressionPair ve : gc.getDecorPairList()) {
-            LogicalVariable v;
-            VariableExpr vexpr = ve.getVar();
-            if (vexpr != null) {
-                v = context.newVar(vexpr);
-            } else {
-                v = context.newVar();
-            }
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(ve.getExpr(), topOp);
-            gOp.addDecorExpression(v, eo.first);
-            topOp = eo.second;
-        }
-        gOp.getInputs().add(topOp);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitGroupbyClause(
+			GroupbyClause gc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		GroupByOperator gOp = new GroupByOperator();
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (GbyVariableExpressionPair ve : gc.getGbyPairList()) {
+			LogicalVariable v;
+			VariableExpr vexpr = ve.getVar();
+			if (vexpr != null) {
+				v = context.newVar(vexpr);
+			} else {
+				v = context.newVar();
+			}
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					ve.getExpr(), topOp);
+			gOp.addGbyExpression(v, eo.first);
+			topOp = eo.second;
+		}
+		for (GbyVariableExpressionPair ve : gc.getDecorPairList()) {
+			LogicalVariable v;
+			VariableExpr vexpr = ve.getVar();
+			if (vexpr != null) {
+				v = context.newVar(vexpr);
+			} else {
+				v = context.newVar();
+			}
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					ve.getExpr(), topOp);
+			gOp.addDecorExpression(v, eo.first);
+			topOp = eo.second;
+		}
+		gOp.getInputs().add(topOp);
 
-        for (VariableExpr var : gc.getWithVarList()) {
-            LogicalVariable aggVar = context.newVar();
-            LogicalVariable oldVar = context.getVar(var);
-            List<Mutable<ILogicalExpression>> flArgs = new ArrayList<Mutable<ILogicalExpression>>(1);
-            flArgs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oldVar)));
-            AggregateFunctionCallExpression fListify = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                    AsterixBuiltinFunctions.LISTIFY, flArgs);
-            AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(aggVar),
-                    (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(fListify)));
+		for (VariableExpr var : gc.getWithVarList()) {
+			LogicalVariable aggVar = context.newVar();
+			LogicalVariable oldVar = context.getVar(var);
+			List<Mutable<ILogicalExpression>> flArgs = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			flArgs.add(new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(oldVar)));
+			AggregateFunctionCallExpression fListify = AsterixBuiltinFunctions
+					.makeAggregateFunctionExpression(
+							AsterixBuiltinFunctions.LISTIFY, flArgs);
+			AggregateOperator agg = new AggregateOperator(
+					mkSingletonArrayList(aggVar),
+					(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+							fListify)));
 
-            agg.getInputs().add(
-                    new MutableObject<ILogicalOperator>(new NestedTupleSourceOperator(
-                            new MutableObject<ILogicalOperator>(gOp))));
-            ILogicalPlan plan = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(agg));
-            gOp.getNestedPlans().add(plan);
-            // Hide the variable that was part of the "with", replacing it with
-            // the one bound by the aggregation op.
-            context.setVar(var, aggVar);
-        }
+			agg.getInputs().add(
+					new MutableObject<ILogicalOperator>(
+							new NestedTupleSourceOperator(
+									new MutableObject<ILogicalOperator>(gOp))));
+			ILogicalPlan plan = new ALogicalPlanImpl(
+					new MutableObject<ILogicalOperator>(agg));
+			gOp.getNestedPlans().add(plan);
+			// Hide the variable that was part of the "with", replacing it with
+			// the one bound by the aggregation op.
+			context.setVar(var, aggVar);
+		}
 
-        gOp.getAnnotations().put(OperatorAnnotations.USE_HASH_GROUP_BY, gc.hasHashGroupByHint());
-        return new Pair<ILogicalOperator, LogicalVariable>(gOp, null);
-    }
+		gOp.getAnnotations().put(OperatorAnnotations.USE_HASH_GROUP_BY,
+				gc.hasHashGroupByHint());
+		return new Pair<ILogicalOperator, LogicalVariable>(gOp, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIfExpr(IfExpr ifexpr, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        // In the most general case, IfThenElse is translated in the following
-        // way.
-        //
-        // We assign the result of the condition to one variable varCond.
-        // We create one subplan which contains the plan for the "then" branch,
-        // on top of which there is a selection whose condition is varCond.
-        // Similarly, we create one subplan for the "else" branch, in which the
-        // selection is not(varCond).
-        // Finally, we concatenate the results. (??)
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIfExpr(IfExpr ifexpr,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		// In the most general case, IfThenElse is translated in the following
+		// way.
+		//
+		// We assign the result of the condition to one variable varCond.
+		// We create one subplan which contains the plan for the "then" branch,
+		// on top of which there is a selection whose condition is varCond.
+		// Similarly, we create one subplan for the "else" branch, in which the
+		// selection is not(varCond).
+		// Finally, we concatenate the results. (??)
 
-        Pair<ILogicalOperator, LogicalVariable> pCond = ifexpr.getCondExpr().accept(this, tupSource);
-        ILogicalOperator opCond = pCond.first;
-        LogicalVariable varCond = pCond.second;
+		Pair<ILogicalOperator, LogicalVariable> pCond = ifexpr.getCondExpr()
+				.accept(this, tupSource);
+		ILogicalOperator opCond = pCond.first;
+		LogicalVariable varCond = pCond.second;
 
-        SubplanOperator sp = new SubplanOperator();
-        Mutable<ILogicalOperator> nestedSource = new MutableObject<ILogicalOperator>(new NestedTupleSourceOperator(
-                new MutableObject<ILogicalOperator>(sp)));
+		SubplanOperator sp = new SubplanOperator();
+		Mutable<ILogicalOperator> nestedSource = new MutableObject<ILogicalOperator>(
+				new NestedTupleSourceOperator(
+						new MutableObject<ILogicalOperator>(sp)));
 
-        Pair<ILogicalOperator, LogicalVariable> pThen = ifexpr.getThenExpr().accept(this, nestedSource);
-        SelectOperator sel1 = new SelectOperator(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(
-                varCond)));
-        sel1.getInputs().add(new MutableObject<ILogicalOperator>(pThen.first));
+		Pair<ILogicalOperator, LogicalVariable> pThen = ifexpr.getThenExpr()
+				.accept(this, nestedSource);
+		SelectOperator sel1 = new SelectOperator(
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(varCond)));
+		sel1.getInputs().add(new MutableObject<ILogicalOperator>(pThen.first));
 
-        Pair<ILogicalOperator, LogicalVariable> pElse = ifexpr.getElseExpr().accept(this, nestedSource);
-        AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), new MutableObject<ILogicalExpression>(
-                        new VariableReferenceExpression(varCond)));
-        SelectOperator sel2 = new SelectOperator(new MutableObject<ILogicalExpression>(notVarCond));
-        sel2.getInputs().add(new MutableObject<ILogicalOperator>(pElse.first));
+		Pair<ILogicalOperator, LogicalVariable> pElse = ifexpr.getElseExpr()
+				.accept(this, nestedSource);
+		AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(varCond)));
+		SelectOperator sel2 = new SelectOperator(
+				new MutableObject<ILogicalExpression>(notVarCond));
+		sel2.getInputs().add(new MutableObject<ILogicalOperator>(pElse.first));
 
-        ILogicalPlan p1 = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(sel1));
-        sp.getNestedPlans().add(p1);
-        ILogicalPlan p2 = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(sel2));
-        sp.getNestedPlans().add(p2);
+		ILogicalPlan p1 = new ALogicalPlanImpl(
+				new MutableObject<ILogicalOperator>(sel1));
+		sp.getNestedPlans().add(p1);
+		ILogicalPlan p2 = new ALogicalPlanImpl(
+				new MutableObject<ILogicalOperator>(sel2));
+		sp.getNestedPlans().add(p2);
 
-        Mutable<ILogicalOperator> opCondRef = new MutableObject<ILogicalOperator>(opCond);
-        sp.getInputs().add(opCondRef);
+		Mutable<ILogicalOperator> opCondRef = new MutableObject<ILogicalOperator>(
+				opCond);
+		sp.getInputs().add(opCondRef);
 
-        LogicalVariable resV = context.newVar();
-        AbstractFunctionCallExpression concatNonNull = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
-                new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pThen.second)),
-                new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pElse.second)));
-        AssignOperator a = new AssignOperator(resV, new MutableObject<ILogicalExpression>(concatNonNull));
-        a.getInputs().add(new MutableObject<ILogicalOperator>(sp));
+		LogicalVariable resV = context.newVar();
+		AbstractFunctionCallExpression concatNonNull = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(pThen.second)),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(pElse.second)));
+		AssignOperator a = new AssignOperator(resV,
+				new MutableObject<ILogicalExpression>(concatNonNull));
+		a.getInputs().add(new MutableObject<ILogicalOperator>(sp));
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, resV);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(a, resV);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLiteralExpr(LiteralExpr l, Mutable<ILogicalOperator> tupSource) {
-        LogicalVariable var = context.newVar();
-        AssignOperator a = new AssignOperator(var, new MutableObject<ILogicalExpression>(new ConstantExpression(
-                new AsterixConstantValue(ConstantHelper.objectFromLiteral(l.getValue())))));
-        if (tupSource != null) {
-            a.getInputs().add(tupSource);
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(a, var);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLiteralExpr(
+			LiteralExpr l, Mutable<ILogicalOperator> tupSource) {
+		LogicalVariable var = context.newVar();
+		AssignOperator a = new AssignOperator(var,
+				new MutableObject<ILogicalExpression>(new ConstantExpression(
+						new AsterixConstantValue(ConstantHelper
+								.objectFromLiteral(l.getValue())))));
+		if (tupSource != null) {
+			a.getInputs().add(tupSource);
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(a, var);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOperatorExpr(OperatorExpr op,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        ArrayList<OperatorType> ops = op.getOpList();
-        int nOps = ops.size();
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOperatorExpr(
+			OperatorExpr op, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		ArrayList<OperatorType> ops = op.getOpList();
+		int nOps = ops.size();
 
-        if (nOps > 0 && (ops.get(0) == OperatorType.AND || ops.get(0) == OperatorType.OR)) {
-            return visitAndOrOperator(op, tupSource);
-        }
+		if (nOps > 0
+				&& (ops.get(0) == OperatorType.AND || ops.get(0) == OperatorType.OR)) {
+			return visitAndOrOperator(op, tupSource);
+		}
 
-        ArrayList<Expression> exprs = op.getExprList();
+		ArrayList<Expression> exprs = op.getExprList();
 
-        Mutable<ILogicalOperator> topOp = tupSource;
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        ILogicalExpression currExpr = null;
-        for (int i = 0; i <= nOps; i++) {
+		ILogicalExpression currExpr = null;
+		for (int i = 0; i <= nOps; i++) {
 
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(exprs.get(i), topOp);
-            topOp = p.second;
-            ILogicalExpression e = p.first;
-            // now look at the operator
-            if (i < nOps) {
-                if (OperatorExpr.opIsComparison(ops.get(i))) {
-                    AbstractFunctionCallExpression c = createComparisonExpression(ops.get(i));
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					exprs.get(i), topOp);
+			topOp = p.second;
+			ILogicalExpression e = p.first;
+			// now look at the operator
+			if (i < nOps) {
+				if (OperatorExpr.opIsComparison(ops.get(i))) {
+					AbstractFunctionCallExpression c = createComparisonExpression(ops
+							.get(i));
 
-                    // chain the operators
-                    if (i == 0) {
-                        c.getArguments().add(new MutableObject<ILogicalExpression>(e));
-                        currExpr = c;
-                        if (op.isBroadcastOperand(i)) {
-                            BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                            bcast.setObject(BroadcastSide.LEFT);
-                            c.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                        }
-                    } else {
-                        ((AbstractFunctionCallExpression) currExpr).getArguments().add(
-                                new MutableObject<ILogicalExpression>(e));
-                        c.getArguments().add(new MutableObject<ILogicalExpression>(currExpr));
-                        currExpr = c;
-                        if (i == 1 && op.isBroadcastOperand(i)) {
-                            BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                            bcast.setObject(BroadcastSide.RIGHT);
-                            c.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                        }
-                    }
-                } else {
-                    AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(ops.get(i));
+					// chain the operators
+					if (i == 0) {
+						c.getArguments().add(
+								new MutableObject<ILogicalExpression>(e));
+						currExpr = c;
+						if (op.isBroadcastOperand(i)) {
+							BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+							bcast.setObject(BroadcastSide.LEFT);
+							c.getAnnotations()
+									.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+											bcast);
+						}
+					} else {
+						((AbstractFunctionCallExpression) currExpr)
+								.getArguments()
+								.add(new MutableObject<ILogicalExpression>(e));
+						c.getArguments()
+								.add(new MutableObject<ILogicalExpression>(
+										currExpr));
+						currExpr = c;
+						if (i == 1 && op.isBroadcastOperand(i)) {
+							BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+							bcast.setObject(BroadcastSide.RIGHT);
+							c.getAnnotations()
+									.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+											bcast);
+						}
+					}
+				} else {
+					AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(ops
+							.get(i));
 
-                    if (i == 0) {
-                        f.getArguments().add(new MutableObject<ILogicalExpression>(e));
-                        currExpr = f;
-                    } else {
-                        ((AbstractFunctionCallExpression) currExpr).getArguments().add(
-                                new MutableObject<ILogicalExpression>(e));
-                        f.getArguments().add(new MutableObject<ILogicalExpression>(currExpr));
-                        currExpr = f;
-                    }
-                }
-            } else { // don't forget the last expression...
-                ((AbstractFunctionCallExpression) currExpr).getArguments()
-                        .add(new MutableObject<ILogicalExpression>(e));
-                if (i == 1 && op.isBroadcastOperand(i)) {
-                    BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                    bcast.setObject(BroadcastSide.RIGHT);
-                    ((AbstractFunctionCallExpression) currExpr).getAnnotations().put(
-                            BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                }
-            }
-        }
+					if (i == 0) {
+						f.getArguments().add(
+								new MutableObject<ILogicalExpression>(e));
+						currExpr = f;
+					} else {
+						((AbstractFunctionCallExpression) currExpr)
+								.getArguments()
+								.add(new MutableObject<ILogicalExpression>(e));
+						f.getArguments()
+								.add(new MutableObject<ILogicalExpression>(
+										currExpr));
+						currExpr = f;
+					}
+				}
+			} else { // don't forget the last expression...
+				((AbstractFunctionCallExpression) currExpr).getArguments().add(
+						new MutableObject<ILogicalExpression>(e));
+				if (i == 1 && op.isBroadcastOperand(i)) {
+					BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+					bcast.setObject(BroadcastSide.RIGHT);
+					((AbstractFunctionCallExpression) currExpr)
+							.getAnnotations()
+							.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+									bcast);
+				}
+			}
+		}
 
-        LogicalVariable assignedVar = context.newVar();
-        AssignOperator a = new AssignOperator(assignedVar, new MutableObject<ILogicalExpression>(currExpr));
+		LogicalVariable assignedVar = context.newVar();
+		AssignOperator a = new AssignOperator(assignedVar,
+				new MutableObject<ILogicalExpression>(currExpr));
 
-        a.getInputs().add(topOp);
+		a.getInputs().add(topOp);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOrderbyClause(OrderbyClause oc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOrderbyClause(
+			OrderbyClause oc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
 
-        OrderOperator ord = new OrderOperator();
-        Iterator<OrderModifier> modifIter = oc.getModifierList().iterator();
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (Expression e : oc.getOrderbyList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(e, topOp);
-            OrderModifier m = modifIter.next();
-            OrderOperator.IOrder comp = (m == OrderModifier.ASC) ? OrderOperator.ASC_ORDER : OrderOperator.DESC_ORDER;
-            ord.getOrderExpressions()
-                    .add(new Pair<IOrder, Mutable<ILogicalExpression>>(comp, new MutableObject<ILogicalExpression>(
-                            p.first)));
-            topOp = p.second;
-        }
-        ord.getInputs().add(topOp);
-        if (oc.getNumTuples() > 0) {
-            ord.getAnnotations().put(OperatorAnnotations.CARDINALITY, oc.getNumTuples());
-        }
-        if (oc.getNumFrames() > 0) {
-            ord.getAnnotations().put(OperatorAnnotations.MAX_NUMBER_FRAMES, oc.getNumFrames());
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(ord, null);
-    }
+		OrderOperator ord = new OrderOperator();
+		Iterator<OrderModifier> modifIter = oc.getModifierList().iterator();
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (Expression e : oc.getOrderbyList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					e, topOp);
+			OrderModifier m = modifIter.next();
+			OrderOperator.IOrder comp = (m == OrderModifier.ASC) ? OrderOperator.ASC_ORDER
+					: OrderOperator.DESC_ORDER;
+			ord.getOrderExpressions().add(
+					new Pair<IOrder, Mutable<ILogicalExpression>>(comp,
+							new MutableObject<ILogicalExpression>(p.first)));
+			topOp = p.second;
+		}
+		ord.getInputs().add(topOp);
+		if (oc.getNumTuples() > 0) {
+			ord.getAnnotations().put(OperatorAnnotations.CARDINALITY,
+					oc.getNumTuples());
+		}
+		if (oc.getNumFrames() > 0) {
+			ord.getAnnotations().put(OperatorAnnotations.MAX_NUMBER_FRAMES,
+					oc.getNumFrames());
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(ord, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitQuantifiedExpression(QuantifiedExpression qe,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> topOp = tupSource;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitQuantifiedExpression(
+			QuantifiedExpression qe, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        ILogicalOperator firstOp = null;
-        Mutable<ILogicalOperator> lastOp = null;
+		ILogicalOperator firstOp = null;
+		Mutable<ILogicalOperator> lastOp = null;
 
-        for (QuantifiedPair qt : qe.getQuantifiedList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(qt.getExpr(), topOp);
-            topOp = eo1.second;
-            LogicalVariable uVar = context.newVar(qt.getVarExpr());
-            ILogicalOperator u = new UnnestOperator(uVar, new MutableObject<ILogicalExpression>(
-                    makeUnnestExpression(eo1.first)));
+		for (QuantifiedPair qt : qe.getQuantifiedList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(
+					qt.getExpr(), topOp);
+			topOp = eo1.second;
+			LogicalVariable uVar = context.newVar(qt.getVarExpr());
+			ILogicalOperator u = new UnnestOperator(uVar,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo1.first)));
 
-            if (firstOp == null) {
-                firstOp = u;
-            }
-            if (lastOp != null) {
-                u.getInputs().add(lastOp);
-            }
-            lastOp = new MutableObject<ILogicalOperator>(u);
-        }
+			if (firstOp == null) {
+				firstOp = u;
+			}
+			if (lastOp != null) {
+				u.getInputs().add(lastOp);
+			}
+			lastOp = new MutableObject<ILogicalOperator>(u);
+		}
 
-        // We make all the unnest correspond. to quantif. vars. sit on top
-        // in the hope of enabling joins & other optimiz.
-        firstOp.getInputs().add(topOp);
-        topOp = lastOp;
+		// We make all the unnest correspond. to quantif. vars. sit on top
+		// in the hope of enabling joins & other optimiz.
+		firstOp.getInputs().add(topOp);
+		topOp = lastOp;
 
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(qe.getSatisfiesExpr(), topOp);
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(
+				qe.getSatisfiesExpr(), topOp);
 
-        AggregateFunctionCallExpression fAgg;
-        SelectOperator s;
-        if (qe.getQuantifier() == Quantifier.SOME) {
-            s = new SelectOperator(new MutableObject<ILogicalExpression>(eo2.first));
-            s.getInputs().add(eo2.second);
-            fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.NON_EMPTY_STREAM,
-                    new ArrayList<Mutable<ILogicalExpression>>());
-        } else { // EVERY
-            List<Mutable<ILogicalExpression>> satExprList = new ArrayList<Mutable<ILogicalExpression>>(1);
-            satExprList.add(new MutableObject<ILogicalExpression>(eo2.first));
-            s = new SelectOperator(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), satExprList)));
-            s.getInputs().add(eo2.second);
-            fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.EMPTY_STREAM,
-                    new ArrayList<Mutable<ILogicalExpression>>());
-        }
-        LogicalVariable qeVar = context.newVar();
-        AggregateOperator a = new AggregateOperator(mkSingletonArrayList(qeVar),
-                (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(fAgg)));
-        a.getInputs().add(new MutableObject<ILogicalOperator>(s));
-        return new Pair<ILogicalOperator, LogicalVariable>(a, qeVar);
-    }
+		AggregateFunctionCallExpression fAgg;
+		SelectOperator s;
+		if (qe.getQuantifier() == Quantifier.SOME) {
+			s = new SelectOperator(new MutableObject<ILogicalExpression>(
+					eo2.first));
+			s.getInputs().add(eo2.second);
+			fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+					AsterixBuiltinFunctions.NON_EMPTY_STREAM,
+					new ArrayList<Mutable<ILogicalExpression>>());
+		} else { // EVERY
+			List<Mutable<ILogicalExpression>> satExprList = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			satExprList.add(new MutableObject<ILogicalExpression>(eo2.first));
+			s = new SelectOperator(new MutableObject<ILogicalExpression>(
+					new ScalarFunctionCallExpression(FunctionUtils
+							.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+							satExprList)));
+			s.getInputs().add(eo2.second);
+			fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+					AsterixBuiltinFunctions.EMPTY_STREAM,
+					new ArrayList<Mutable<ILogicalExpression>>());
+		}
+		LogicalVariable qeVar = context.newVar();
+		AggregateOperator a = new AggregateOperator(
+				mkSingletonArrayList(qeVar),
+				(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+						fAgg)));
+		a.getInputs().add(new MutableObject<ILogicalOperator>(s));
+		return new Pair<ILogicalOperator, LogicalVariable>(a, qeVar);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitQuery(Query q, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        return q.getBody().accept(this, tupSource);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitQuery(Query q,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		return q.getBody().accept(this, tupSource);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitRecordConstructor(RecordConstructor rc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR));
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(f));
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (FieldBinding fb : rc.getFbList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(fb.getLeftExpr(), topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo1.first));
-            topOp = eo1.second;
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(fb.getRightExpr(), topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo2.first));
-            topOp = eo2.second;
-        }
-        a.getInputs().add(topOp);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitRecordConstructor(
+			RecordConstructor rc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR));
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a = new AssignOperator(v1,
+				new MutableObject<ILogicalExpression>(f));
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (FieldBinding fb : rc.getFbList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(
+					fb.getLeftExpr(), topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo1.first));
+			topOp = eo1.second;
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(
+					fb.getRightExpr(), topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo2.first));
+			topOp = eo2.second;
+		}
+		a.getInputs().add(topOp);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitListConstructor(ListConstructor lc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        FunctionIdentifier fid = (lc.getType() == Type.ORDERED_LIST_CONSTRUCTOR) ? AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR
-                : AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR;
-        AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fid));
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(f));
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (Expression expr : lc.getExprList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo.first));
-            topOp = eo.second;
-        }
-        a.getInputs().add(topOp);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitListConstructor(
+			ListConstructor lc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		FunctionIdentifier fid = (lc.getType() == Type.ORDERED_LIST_CONSTRUCTOR) ? AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR
+				: AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR;
+		AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(fid));
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a = new AssignOperator(v1,
+				new MutableObject<ILogicalExpression>(f));
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (Expression expr : lc.getExprList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					expr, topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo.first));
+			topOp = eo.second;
+		}
+		a.getInputs().add(topOp);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnaryExpr(UnaryExpr u, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Expression expr = u.getExpr();
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, tupSource);
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a;
-        if (u.getSign() == Sign.POSITIVE) {
-            a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(eo.first));
-        } else {
-            AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
-            m.getArguments().add(new MutableObject<ILogicalExpression>(eo.first));
-            a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(m));
-        }
-        a.getInputs().add(eo.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnaryExpr(UnaryExpr u,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		Expression expr = u.getExpr();
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+				expr, tupSource);
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a;
+		if (u.getSign() == Sign.POSITIVE) {
+			a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(
+					eo.first));
+		} else {
+			AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
+			m.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo.first));
+			a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(m));
+		}
+		a.getInputs().add(eo.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitVariableExpr(VariableExpr v, Mutable<ILogicalOperator> tupSource) {
-        // Should we ever get to this method?
-        LogicalVariable var = context.newVar();
-        LogicalVariable oldV = context.getVar(v.getVar().getId());
-        AssignOperator a = new AssignOperator(var, new MutableObject<ILogicalExpression>(
-                new VariableReferenceExpression(oldV)));
-        a.getInputs().add(tupSource);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, var);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitVariableExpr(
+			VariableExpr v, Mutable<ILogicalOperator> tupSource) {
+		// Should we ever get to this method?
+		LogicalVariable var = context.newVar();
+		LogicalVariable oldV = context.getVar(v.getVar().getId());
+		AssignOperator a = new AssignOperator(var,
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(oldV)));
+		a.getInputs().add(tupSource);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, var);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWhereClause(WhereClause w, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(w.getWhereExpr(), tupSource);
-        SelectOperator s = new SelectOperator(new MutableObject<ILogicalExpression>(p.first));
-        s.getInputs().add(p.second);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWhereClause(
+			WhereClause w, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				w.getWhereExpr(), tupSource);
+		SelectOperator s = new SelectOperator(
+				new MutableObject<ILogicalExpression>(p.first));
+		s.getInputs().add(p.second);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(s, null);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(s, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLimitClause(LimitClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getLimitExpr(), tupSource);
-        LimitOperator opLim;
-        Expression offset = lc.getOffset();
-        if (offset != null) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = aqlExprToAlgExpression(offset, p1.second);
-            opLim = new LimitOperator(p1.first, p2.first);
-            opLim.getInputs().add(p2.second);
-        } else {
-            opLim = new LimitOperator(p1.first);
-            opLim.getInputs().add(p1.second);
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(opLim, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLimitClause(
+			LimitClause lc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(
+				lc.getLimitExpr(), tupSource);
+		LimitOperator opLim;
+		Expression offset = lc.getOffset();
+		if (offset != null) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = aqlExprToAlgExpression(
+					offset, p1.second);
+			opLim = new LimitOperator(p1.first, p2.first);
+			opLim.getInputs().add(p2.second);
+		} else {
+			opLim = new LimitOperator(p1.first);
+			opLim.getInputs().add(p1.second);
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(opLim, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getDieExpr(), tupSource);
-        DieOperator opDie = new DieOperator(p1.first);
-        opDie.getInputs().add(p1.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(
+				lc.getDieExpr(), tupSource);
+		DieOperator opDie = new DieOperator(p1.first);
+		opDie.getInputs().add(p1.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(DistinctClause dc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
-        Mutable<ILogicalOperator> input = null;
-        for (Expression expr : dc.getDistinctByExpr()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(expr, tupSource);
-            exprList.add(new MutableObject<ILogicalExpression>(p.first));
-            input = p.second;
-        }
-        DistinctOperator opDistinct = new DistinctOperator(exprList);
-        opDistinct.getInputs().add(input);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDistinct, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(
+			DistinctClause dc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
+		Mutable<ILogicalOperator> input = null;
+		for (Expression expr : dc.getDistinctByExpr()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					expr, tupSource);
+			exprList.add(new MutableObject<ILogicalExpression>(p.first));
+			input = p.second;
+		}
+		DistinctOperator opDistinct = new DistinctOperator(exprList);
+		opDistinct.getInputs().add(input);
+		return new Pair<ILogicalOperator, LogicalVariable>(opDistinct, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnionExpr(UnionExpr unionExpr,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> ts = tupSource;
-        ILogicalOperator lastOp = null;
-        LogicalVariable lastVar = null;
-        boolean first = true;
-        for (Expression e : unionExpr.getExprs()) {
-            if (first) {
-                first = false;
-            } else {
-                ts = new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator());
-            }
-            Pair<ILogicalOperator, LogicalVariable> p1 = e.accept(this, ts);
-            if (lastOp == null) {
-                lastOp = p1.first;
-                lastVar = p1.second;
-            } else {
-                LogicalVariable unnestVar1 = context.newVar();
-                UnnestOperator unnest1 = new UnnestOperator(unnestVar1, new MutableObject<ILogicalExpression>(
-                        makeUnnestExpression(new VariableReferenceExpression(lastVar))));
-                unnest1.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
-                LogicalVariable unnestVar2 = context.newVar();
-                UnnestOperator unnest2 = new UnnestOperator(unnestVar2, new MutableObject<ILogicalExpression>(
-                        makeUnnestExpression(new VariableReferenceExpression(p1.second))));
-                unnest2.getInputs().add(new MutableObject<ILogicalOperator>(p1.first));
-                List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>(
-                        1);
-                LogicalVariable resultVar = context.newVar();
-                Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(
-                        unnestVar1, unnestVar2, resultVar);
-                varMap.add(triple);
-                UnionAllOperator unionOp = new UnionAllOperator(varMap);
-                unionOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest1));
-                unionOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest2));
-                lastVar = resultVar;
-                lastOp = unionOp;
-            }
-        }
-        LogicalVariable aggVar = context.newVar();
-        ArrayList<LogicalVariable> aggregVars = new ArrayList<LogicalVariable>(1);
-        aggregVars.add(aggVar);
-        List<Mutable<ILogicalExpression>> afcExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
-        afcExprs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lastVar)));
-        AggregateFunctionCallExpression afc = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                AsterixBuiltinFunctions.LISTIFY, afcExprs);
-        ArrayList<Mutable<ILogicalExpression>> aggregExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
-        aggregExprs.add(new MutableObject<ILogicalExpression>(afc));
-        AggregateOperator agg = new AggregateOperator(aggregVars, aggregExprs);
-        agg.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
-        return new Pair<ILogicalOperator, LogicalVariable>(agg, aggVar);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnionExpr(
+			UnionExpr unionExpr, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> ts = tupSource;
+		ILogicalOperator lastOp = null;
+		LogicalVariable lastVar = null;
+		boolean first = true;
+		for (Expression e : unionExpr.getExprs()) {
+			if (first) {
+				first = false;
+			} else {
+				ts = new MutableObject<ILogicalOperator>(
+						new EmptyTupleSourceOperator());
+			}
+			Pair<ILogicalOperator, LogicalVariable> p1 = e.accept(this, ts);
+			if (lastOp == null) {
+				lastOp = p1.first;
+				lastVar = p1.second;
+			} else {
+				LogicalVariable unnestVar1 = context.newVar();
+				UnnestOperator unnest1 = new UnnestOperator(
+						unnestVar1,
+						new MutableObject<ILogicalExpression>(
+								makeUnnestExpression(new VariableReferenceExpression(
+										lastVar))));
+				unnest1.getInputs().add(
+						new MutableObject<ILogicalOperator>(lastOp));
+				LogicalVariable unnestVar2 = context.newVar();
+				UnnestOperator unnest2 = new UnnestOperator(
+						unnestVar2,
+						new MutableObject<ILogicalExpression>(
+								makeUnnestExpression(new VariableReferenceExpression(
+										p1.second))));
+				unnest2.getInputs().add(
+						new MutableObject<ILogicalOperator>(p1.first));
+				List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>(
+						1);
+				LogicalVariable resultVar = context.newVar();
+				Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(
+						unnestVar1, unnestVar2, resultVar);
+				varMap.add(triple);
+				UnionAllOperator unionOp = new UnionAllOperator(varMap);
+				unionOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(unnest1));
+				unionOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(unnest2));
+				lastVar = resultVar;
+				lastOp = unionOp;
+			}
+		}
+		LogicalVariable aggVar = context.newVar();
+		ArrayList<LogicalVariable> aggregVars = new ArrayList<LogicalVariable>(
+				1);
+		aggregVars.add(aggVar);
+		List<Mutable<ILogicalExpression>> afcExprs = new ArrayList<Mutable<ILogicalExpression>>(
+				1);
+		afcExprs.add(new MutableObject<ILogicalExpression>(
+				new VariableReferenceExpression(lastVar)));
+		AggregateFunctionCallExpression afc = AsterixBuiltinFunctions
+				.makeAggregateFunctionExpression(
+						AsterixBuiltinFunctions.LISTIFY, afcExprs);
+		ArrayList<Mutable<ILogicalExpression>> aggregExprs = new ArrayList<Mutable<ILogicalExpression>>(
+				1);
+		aggregExprs.add(new MutableObject<ILogicalExpression>(afc));
+		AggregateOperator agg = new AggregateOperator(aggregVars, aggregExprs);
+		agg.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
+		return new Pair<ILogicalOperator, LogicalVariable>(agg, aggVar);
+	}
 
-    private AbstractFunctionCallExpression createComparisonExpression(OperatorType t) {
-        FunctionIdentifier fi = operatorTypeToFunctionIdentifier(t);
-        IFunctionInfo finfo = FunctionUtils.getFunctionInfo(fi);
-        return new ScalarFunctionCallExpression(finfo);
-    }
+	private AbstractFunctionCallExpression createComparisonExpression(
+			OperatorType t) {
+		FunctionIdentifier fi = operatorTypeToFunctionIdentifier(t);
+		IFunctionInfo finfo = FunctionUtils.getFunctionInfo(fi);
+		return new ScalarFunctionCallExpression(finfo);
+	}
 
-    private FunctionIdentifier operatorTypeToFunctionIdentifier(OperatorType t) {
-        switch (t) {
-            case EQ: {
-                return AlgebricksBuiltinFunctions.EQ;
-            }
-            case NEQ: {
-                return AlgebricksBuiltinFunctions.NEQ;
-            }
-            case GT: {
-                return AlgebricksBuiltinFunctions.GT;
-            }
-            case GE: {
-                return AlgebricksBuiltinFunctions.GE;
-            }
-            case LT: {
-                return AlgebricksBuiltinFunctions.LT;
-            }
-            case LE: {
-                return AlgebricksBuiltinFunctions.LE;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
-        }
-    }
+	private FunctionIdentifier operatorTypeToFunctionIdentifier(OperatorType t) {
+		switch (t) {
+		case EQ: {
+			return AlgebricksBuiltinFunctions.EQ;
+		}
+		case NEQ: {
+			return AlgebricksBuiltinFunctions.NEQ;
+		}
+		case GT: {
+			return AlgebricksBuiltinFunctions.GT;
+		}
+		case GE: {
+			return AlgebricksBuiltinFunctions.GE;
+		}
+		case LT: {
+			return AlgebricksBuiltinFunctions.LT;
+		}
+		case LE: {
+			return AlgebricksBuiltinFunctions.LE;
+		}
+		default: {
+			throw new IllegalStateException();
+		}
+		}
+	}
 
-    private AbstractFunctionCallExpression createFunctionCallExpressionForBuiltinOperator(OperatorType t)
-            throws AsterixException {
+	private AbstractFunctionCallExpression createFunctionCallExpressionForBuiltinOperator(
+			OperatorType t) throws AsterixException {
 
-        FunctionIdentifier fid = null;
-        switch (t) {
-            case PLUS: {
-                fid = AlgebricksBuiltinFunctions.NUMERIC_ADD;
-                break;
-            }
-            case MINUS: {
-                fid = AsterixBuiltinFunctions.NUMERIC_SUBTRACT;
-                break;
-            }
-            case MUL: {
-                fid = AsterixBuiltinFunctions.NUMERIC_MULTIPLY;
-                break;
-            }
-            case DIV: {
-                fid = AsterixBuiltinFunctions.NUMERIC_DIVIDE;
-                break;
-            }
-            case MOD: {
-                fid = AsterixBuiltinFunctions.NUMERIC_MOD;
-                break;
-            }
-            case IDIV: {
-                fid = AsterixBuiltinFunctions.NUMERIC_IDIV;
-                break;
-            }
-            case CARET: {
-                fid = AsterixBuiltinFunctions.CARET;
-                break;
-            }
-            case AND: {
-                fid = AlgebricksBuiltinFunctions.AND;
-                break;
-            }
-            case OR: {
-                fid = AlgebricksBuiltinFunctions.OR;
-                break;
-            }
-            case FUZZY_EQ: {
-                fid = AsterixBuiltinFunctions.FUZZY_EQ;
-                break;
-            }
+		FunctionIdentifier fid = null;
+		switch (t) {
+		case PLUS: {
+			fid = AlgebricksBuiltinFunctions.NUMERIC_ADD;
+			break;
+		}
+		case MINUS: {
+			fid = AsterixBuiltinFunctions.NUMERIC_SUBTRACT;
+			break;
+		}
+		case MUL: {
+			fid = AsterixBuiltinFunctions.NUMERIC_MULTIPLY;
+			break;
+		}
+		case DIV: {
+			fid = AsterixBuiltinFunctions.NUMERIC_DIVIDE;
+			break;
+		}
+		case MOD: {
+			fid = AsterixBuiltinFunctions.NUMERIC_MOD;
+			break;
+		}
+		case IDIV: {
+			fid = AsterixBuiltinFunctions.NUMERIC_IDIV;
+			break;
+		}
+		case CARET: {
+			fid = AsterixBuiltinFunctions.CARET;
+			break;
+		}
+		case AND: {
+			fid = AlgebricksBuiltinFunctions.AND;
+			break;
+		}
+		case OR: {
+			fid = AlgebricksBuiltinFunctions.OR;
+			break;
+		}
+		case FUZZY_EQ: {
+			fid = AsterixBuiltinFunctions.FUZZY_EQ;
+			break;
+		}
 
-            default: {
-                throw new NotImplementedException("Operator " + t + " is not yet implemented");
-            }
-        }
-        return new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fid));
-    }
+		default: {
+			throw new NotImplementedException("Operator " + t
+					+ " is not yet implemented");
+		}
+		}
+		return new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(fid));
+	}
 
-    private static boolean hasOnlyChild(ILogicalOperator parent, Mutable<ILogicalOperator> childCandidate) {
-        List<Mutable<ILogicalOperator>> inp = parent.getInputs();
-        if (inp == null || inp.size() != 1) {
-            return false;
-        }
-        return inp.get(0) == childCandidate;
-    }
+	private static boolean hasOnlyChild(ILogicalOperator parent,
+			Mutable<ILogicalOperator> childCandidate) {
+		List<Mutable<ILogicalOperator>> inp = parent.getInputs();
+		if (inp == null || inp.size() != 1) {
+			return false;
+		}
+		return inp.get(0) == childCandidate;
+	}
 
-    private Pair<ILogicalExpression, Mutable<ILogicalOperator>> aqlExprToAlgExpression(Expression expr,
-            Mutable<ILogicalOperator> topOp) throws AsterixException {
-        switch (expr.getKind()) {
-            case VARIABLE_EXPRESSION: {
-                VariableReferenceExpression ve = new VariableReferenceExpression(context.getVar(((VariableExpr) expr)
-                        .getVar().getId()));
-                return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(ve, topOp);
-            }
-            case LITERAL_EXPRESSION: {
-                LiteralExpr val = (LiteralExpr) expr;
-                return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new ConstantExpression(
-                        new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue()))), topOp);
-            }
-            default: {
-                // Mutable<ILogicalOperator> src = new
-                // Mutable<ILogicalOperator>();
-                // Mutable<ILogicalOperator> src = topOp;
-                if (expressionNeedsNoNesting(expr)) {
-                    Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, topOp);
-                    ILogicalExpression exp = ((AssignOperator) p.first).getExpressions().get(0).getValue();
-                    return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(exp, p.first.getInputs().get(0));
-                } else {
-                    Mutable<ILogicalOperator> src = new MutableObject<ILogicalOperator>();
+	private Pair<ILogicalExpression, Mutable<ILogicalOperator>> aqlExprToAlgExpression(
+			Expression expr, Mutable<ILogicalOperator> topOp)
+			throws AsterixException {
+		switch (expr.getKind()) {
+		case VARIABLE_EXPRESSION: {
+			VariableReferenceExpression ve = new VariableReferenceExpression(
+					context.getVar(((VariableExpr) expr).getVar().getId()));
+			return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(ve,
+					topOp);
+		}
+		case LITERAL_EXPRESSION: {
+			LiteralExpr val = (LiteralExpr) expr;
+			return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+					new ConstantExpression(new AsterixConstantValue(
+							ConstantHelper.objectFromLiteral(val.getValue()))),
+					topOp);
+		}
+		default: {
+			// Mutable<ILogicalOperator> src = new
+			// Mutable<ILogicalOperator>();
+			// Mutable<ILogicalOperator> src = topOp;
+			if (expressionNeedsNoNesting(expr)) {
+				Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+						topOp);
+				ILogicalExpression exp = ((AssignOperator) p.first)
+						.getExpressions().get(0).getValue();
+				return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+						exp, p.first.getInputs().get(0));
+			} else {
+				Mutable<ILogicalOperator> src = new MutableObject<ILogicalOperator>();
 
-                    Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, src);
+				Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+						src);
 
-                    if (((AbstractLogicalOperator) p.first).getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
-                        // src.setOperator(topOp.getOperator());
-                        Mutable<ILogicalOperator> top2 = new MutableObject<ILogicalOperator>(p.first);
-                        return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new VariableReferenceExpression(
-                                p.second), top2);
-                    } else {
-                        SubplanOperator s = new SubplanOperator();
-                        s.getInputs().add(topOp);
-                        src.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
-                        Mutable<ILogicalOperator> planRoot = new MutableObject<ILogicalOperator>(p.first);
-                        s.setRootOp(planRoot);
-                        return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new VariableReferenceExpression(
-                                p.second), new MutableObject<ILogicalOperator>(s));
-                    }
-                }
-            }
-        }
+				if (((AbstractLogicalOperator) p.first).getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
+					// src.setOperator(topOp.getOperator());
+					Mutable<ILogicalOperator> top2 = new MutableObject<ILogicalOperator>(
+							p.first);
+					return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+							new VariableReferenceExpression(p.second), top2);
+				} else {
+					SubplanOperator s = new SubplanOperator();
+					s.getInputs().add(topOp);
+					src.setValue(new NestedTupleSourceOperator(
+							new MutableObject<ILogicalOperator>(s)));
+					Mutable<ILogicalOperator> planRoot = new MutableObject<ILogicalOperator>(
+							p.first);
+					s.setRootOp(planRoot);
+					return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+							new VariableReferenceExpression(p.second),
+							new MutableObject<ILogicalOperator>(s));
+				}
+			}
+		}
+		}
 
-    }
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> produceFlwrResult(boolean noForClause, boolean isTop,
-            Mutable<ILogicalOperator> resOpRef, LogicalVariable resVar) {
-        if (isTop) {
-            ProjectOperator pr = new ProjectOperator(resVar);
-            pr.getInputs().add(resOpRef);
-            return new Pair<ILogicalOperator, LogicalVariable>(pr, resVar);
+	private Pair<ILogicalOperator, LogicalVariable> produceFlwrResult(
+			boolean noForClause, boolean isTop,
+			Mutable<ILogicalOperator> resOpRef, LogicalVariable resVar) {
+		if (isTop) {
+			ProjectOperator pr = new ProjectOperator(resVar);
+			pr.getInputs().add(resOpRef);
+			return new Pair<ILogicalOperator, LogicalVariable>(pr, resVar);
 
-        } else if (noForClause) {
-            return new Pair<ILogicalOperator, LogicalVariable>(resOpRef.getValue(), resVar);
-        } else {
-            return aggListify(resVar, resOpRef, false);
-        }
-    }
+		} else if (noForClause) {
+			return new Pair<ILogicalOperator, LogicalVariable>(
+					resOpRef.getValue(), resVar);
+		} else {
+			return aggListify(resVar, resOpRef, false);
+		}
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> aggListify(LogicalVariable var, Mutable<ILogicalOperator> opRef,
-            boolean bProject) {
-        AggregateFunctionCallExpression funAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                AsterixBuiltinFunctions.LISTIFY, new ArrayList<Mutable<ILogicalExpression>>());
-        funAgg.getArguments().add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
-        LogicalVariable varListified = context.newVar();
-        AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(varListified),
-                (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(funAgg)));
-        agg.getInputs().add(opRef);
-        ILogicalOperator res;
-        if (bProject) {
-            ProjectOperator pr = new ProjectOperator(varListified);
-            pr.getInputs().add(new MutableObject<ILogicalOperator>(agg));
-            res = pr;
-        } else {
-            res = agg;
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(res, varListified);
-    }
+	private Pair<ILogicalOperator, LogicalVariable> aggListify(
+			LogicalVariable var, Mutable<ILogicalOperator> opRef,
+			boolean bProject) {
+		AggregateFunctionCallExpression funAgg = AsterixBuiltinFunctions
+				.makeAggregateFunctionExpression(
+						AsterixBuiltinFunctions.LISTIFY,
+						new ArrayList<Mutable<ILogicalExpression>>());
+		funAgg.getArguments().add(
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(var)));
+		LogicalVariable varListified = context.newVar();
+		AggregateOperator agg = new AggregateOperator(
+				mkSingletonArrayList(varListified),
+				(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+						funAgg)));
+		agg.getInputs().add(opRef);
+		ILogicalOperator res;
+		if (bProject) {
+			ProjectOperator pr = new ProjectOperator(varListified);
+			pr.getInputs().add(new MutableObject<ILogicalOperator>(agg));
+			res = pr;
+		} else {
+			res = agg;
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(res, varListified);
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> visitAndOrOperator(OperatorExpr op,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        ArrayList<OperatorType> ops = op.getOpList();
-        int nOps = ops.size();
+	private Pair<ILogicalOperator, LogicalVariable> visitAndOrOperator(
+			OperatorExpr op, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		ArrayList<OperatorType> ops = op.getOpList();
+		int nOps = ops.size();
 
-        ArrayList<Expression> exprs = op.getExprList();
+		ArrayList<Expression> exprs = op.getExprList();
 
-        Mutable<ILogicalOperator> topOp = tupSource;
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        OperatorType opLogical = ops.get(0);
-        AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(opLogical);
+		OperatorType opLogical = ops.get(0);
+		AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(opLogical);
 
-        for (int i = 0; i <= nOps; i++) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(exprs.get(i), topOp);
-            topOp = p.second;
-            // now look at the operator
-            if (i < nOps) {
-                if (ops.get(i) != opLogical) {
-                    throw new TranslationException("Unexpected operator " + ops.get(i)
-                            + " in an OperatorExpr starting with " + opLogical);
-                }
-            }
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        }
+		for (int i = 0; i <= nOps; i++) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					exprs.get(i), topOp);
+			topOp = p.second;
+			// now look at the operator
+			if (i < nOps) {
+				if (ops.get(i) != opLogical) {
+					throw new TranslationException("Unexpected operator "
+							+ ops.get(i) + " in an OperatorExpr starting with "
+							+ opLogical);
+				}
+			}
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+		}
 
-        LogicalVariable assignedVar = context.newVar();
-        AssignOperator a = new AssignOperator(assignedVar, new MutableObject<ILogicalExpression>(f));
-        a.getInputs().add(topOp);
+		LogicalVariable assignedVar = context.newVar();
+		AssignOperator a = new AssignOperator(assignedVar,
+				new MutableObject<ILogicalExpression>(f));
+		a.getInputs().add(topOp);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
 
-    }
+	}
 
-    private static boolean expressionNeedsNoNesting(Expression expr) {
-        Kind k = expr.getKind();
-        return k == Kind.LITERAL_EXPRESSION || k == Kind.LIST_CONSTRUCTOR_EXPRESSION
-                || k == Kind.RECORD_CONSTRUCTOR_EXPRESSION || k == Kind.VARIABLE_EXPRESSION
-                || k == Kind.CALL_EXPRESSION || k == Kind.OP_EXPRESSION || k == Kind.FIELD_ACCESSOR_EXPRESSION
-                || k == Kind.INDEX_ACCESSOR_EXPRESSION || k == Kind.UNARY_EXPRESSION;
-    }
+	private static boolean expressionNeedsNoNesting(Expression expr) {
+		Kind k = expr.getKind();
+		return k == Kind.LITERAL_EXPRESSION
+				|| k == Kind.LIST_CONSTRUCTOR_EXPRESSION
+				|| k == Kind.RECORD_CONSTRUCTOR_EXPRESSION
+				|| k == Kind.VARIABLE_EXPRESSION || k == Kind.CALL_EXPRESSION
+				|| k == Kind.OP_EXPRESSION
+				|| k == Kind.FIELD_ACCESSOR_EXPRESSION
+				|| k == Kind.INDEX_ACCESSOR_EXPRESSION
+				|| k == Kind.UNARY_EXPRESSION;
+	}
 
-    private <T> ArrayList<T> mkSingletonArrayList(T item) {
-        ArrayList<T> array = new ArrayList<T>(1);
-        array.add(item);
-        return array;
-    }
+	private <T> ArrayList<T> mkSingletonArrayList(T item) {
+		ArrayList<T> array = new ArrayList<T>(1);
+		array.add(item);
+		return array;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeDecl(TypeDecl td, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeDecl(TypeDecl td,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitRecordTypeDefiniton(RecordTypeDefinition tre,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitRecordTypeDefiniton(
+			RecordTypeDefinition tre, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeReferenceExpression(TypeReferenceExpression tre,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeReferenceExpression(
+			TypeReferenceExpression tre, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitNodegroupDecl(NodegroupDecl ngd, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitNodegroupDecl(
+			NodegroupDecl ngd, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromFileStatement(LoadFromFileStatement stmtLoad,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLoadFromFileStatement(
+			LoadFromFileStatement stmtLoad, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
+			WriteFromQueryResultStatement stmtLoad,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(DropStatement del, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(
+			DropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitControlFeedStatement(ControlFeedStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitControlFeedStatement(
+			ControlFeedStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCreateIndexStatement(CreateIndexStatement cis,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCreateIndexStatement(
+			CreateIndexStatement cis, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOrderedListTypeDefiniton(OrderedListTypeDefinition olte,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOrderedListTypeDefiniton(
+			OrderedListTypeDefinition olte, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnorderedListTypeDefiniton(UnorderedListTypeDefinition ulte,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnorderedListTypeDefiniton(
+			UnorderedListTypeDefinition ulte, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    private ILogicalExpression makeUnnestExpression(ILogicalExpression expr) {
-        switch (expr.getExpressionTag()) {
-            case VARIABLE: {
-                return new UnnestingFunctionCallExpression(
-                        FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
-                        new MutableObject<ILogicalExpression>(expr));
-            }
-            case FUNCTION_CALL: {
-                AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
-                if (fce.getKind() == FunctionKind.UNNEST) {
-                    return expr;
-                } else {
-                    return new UnnestingFunctionCallExpression(
-                            FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
-                            new MutableObject<ILogicalExpression>(expr));
-                }
-            }
-            default: {
-                return expr;
-            }
-        }
-    }
+	private ILogicalExpression makeUnnestExpression(ILogicalExpression expr) {
+		switch (expr.getExpressionTag()) {
+		case VARIABLE: {
+			return new UnnestingFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
+					new MutableObject<ILogicalExpression>(expr));
+		}
+		case FUNCTION_CALL: {
+			AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
+			if (fce.getKind() == FunctionKind.UNNEST) {
+				return expr;
+			} else {
+				return new UnnestingFunctionCallExpression(
+						FunctionUtils
+								.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
+						new MutableObject<ILogicalExpression>(expr));
+			}
+		}
+		default: {
+			return expr;
+		}
+		}
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitInsertStatement(InsertStatement insert,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitInsertStatement(
+			InsertStatement insert, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDeleteStatement(DeleteStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDeleteStatement(
+			DeleteStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUpdateStatement(UpdateStatement update,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUpdateStatement(
+			UpdateStatement update, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUpdateClause(UpdateClause del, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUpdateClause(
+			UpdateClause del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDataverseDecl(DataverseDecl dv, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDataverseDecl(
+			DataverseDecl dv, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDatasetDecl(DatasetDecl dd, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDatasetDecl(
+			DatasetDecl dd, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitSetStatement(SetStatement ss, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitSetStatement(
+			SetStatement ss, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteStatement(WriteStatement ws, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWriteStatement(
+			WriteStatement ws, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
+			WriteFromQueryResultStatement stmtLoad,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(CreateDataverseStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(
+			CreateDataverseStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIndexDropStatement(IndexDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIndexDropStatement(
+			IndexDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitNodeGroupDropStatement(NodeGroupDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitNodeGroupDropStatement(
+			NodeGroupDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDataverseDropStatement(DataverseDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDataverseDropStatement(
+			DataverseDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeDropStatement(TypeDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeDropStatement(
+			TypeDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visit(CreateFunctionStatement cfs, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visit(
+			CreateFunctionStatement cfs, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFunctionDropStatement(FunctionDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFunctionDropStatement(
+			FunctionDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitBeginFeedStatement(BeginFeedStatement bf,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitBeginFeedStatement(
+			BeginFeedStatement bf, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }
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 d8f294d..4fc1fc8 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
@@ -148,1327 +148,1581 @@
  * Each visit returns a pair of an operator and a variable. The variable
  * corresponds to the new column, if any, added to the tuple flow. E.g., for
  * Unnest, the column is the variable bound to the elements in the list, for
- * Subplan it is null.
- * The first argument of a visit method is the expression which is translated.
- * The second argument of a visit method is the tuple source for the current
- * subtree.
+ * Subplan it is null. The first argument of a visit method is the expression
+ * which is translated. The second argument of a visit method is the tuple
+ * source for the current subtree.
  */
 
-public class AqlPlusExpressionToPlanTranslator extends AbstractAqlTranslator implements
-        IAqlPlusExpressionVisitor<Pair<ILogicalOperator, LogicalVariable>, Mutable<ILogicalOperator>> {
+public class AqlPlusExpressionToPlanTranslator extends AbstractAqlTranslator
+		implements
+		IAqlPlusExpressionVisitor<Pair<ILogicalOperator, LogicalVariable>, Mutable<ILogicalOperator>> {
 
-    private static final Logger LOGGER = Logger.getLogger(AqlPlusExpressionToPlanTranslator.class.getName());
+	private static final Logger LOGGER = Logger
+			.getLogger(AqlPlusExpressionToPlanTranslator.class.getName());
 
-    private class MetaScopeLogicalVariable {
-        private HashMap<Identifier, LogicalVariable> map = new HashMap<Identifier, LogicalVariable>();
+	private class MetaScopeLogicalVariable {
+		private HashMap<Identifier, LogicalVariable> map = new HashMap<Identifier, LogicalVariable>();
 
-        public VariableReferenceExpression getVariableReferenceExpression(Identifier id) throws AsterixException {
-            LogicalVariable var = map.get(id);
-            LOGGER.fine("get:" + id + ":" + var);
-            if (var == null) {
-                throw new AsterixException("Identifier " + id + " not found in AQL+ meta-scope.");
-            }
-            return new VariableReferenceExpression(var);
-        }
+		public VariableReferenceExpression getVariableReferenceExpression(
+				Identifier id) throws AsterixException {
+			LogicalVariable var = map.get(id);
+			LOGGER.fine("get:" + id + ":" + var);
+			if (var == null) {
+				throw new AsterixException("Identifier " + id
+						+ " not found in AQL+ meta-scope.");
+			}
+			return new VariableReferenceExpression(var);
+		}
 
-        public void put(Identifier id, LogicalVariable var) {
-            LOGGER.fine("put:" + id + ":" + var);
-            map.put(id, var);
-        }
-    }
+		public void put(Identifier id, LogicalVariable var) {
+			LOGGER.fine("put:" + id + ":" + var);
+			map.put(id, var);
+		}
+	}
 
-    private class MetaScopeILogicalOperator {
-        private HashMap<Identifier, ILogicalOperator> map = new HashMap<Identifier, ILogicalOperator>();
+	private class MetaScopeILogicalOperator {
+		private HashMap<Identifier, ILogicalOperator> map = new HashMap<Identifier, ILogicalOperator>();
 
-        public ILogicalOperator get(Identifier id) throws AsterixException {
-            ILogicalOperator op = map.get(id);
-            if (op == null) {
-                throw new AsterixException("Identifier " + id + " not found in AQL+ meta-scope.");
-            }
-            return op;
-        }
+		public ILogicalOperator get(Identifier id) throws AsterixException {
+			ILogicalOperator op = map.get(id);
+			if (op == null) {
+				throw new AsterixException("Identifier " + id
+						+ " not found in AQL+ meta-scope.");
+			}
+			return op;
+		}
 
-        public void put(Identifier id, ILogicalOperator op) {
-            LOGGER.fine("put:" + id + ":" + op);
-            map.put(id, op);
-        }
-    }
+		public void put(Identifier id, ILogicalOperator op) {
+			LOGGER.fine("put:" + id + ":" + op);
+			map.put(id, op);
+		}
+	}
 
-    private final long txnId;
-    private final MetadataTransactionContext mdTxnCtx;
-    private TranslationContext context;
-    private String outputDatasetName;
-    private MetaScopeLogicalVariable metaScopeExp = new MetaScopeLogicalVariable();
-    private MetaScopeILogicalOperator metaScopeOp = new MetaScopeILogicalOperator();
-    private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
+	private final long txnId;
+	private final MetadataTransactionContext mdTxnCtx;
+	private TranslationContext context;
+	private String outputDatasetName;
+	private MetaScopeLogicalVariable metaScopeExp = new MetaScopeLogicalVariable();
+	private MetaScopeILogicalOperator metaScopeOp = new MetaScopeILogicalOperator();
+	private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
 
-    public AqlPlusExpressionToPlanTranslator(long txnId, MetadataTransactionContext mdTxnCtx,
-            Counter currentVarCounter, String outputDatasetName) {
-        this.txnId = txnId;
-        this.mdTxnCtx = mdTxnCtx;
-        this.context = new TranslationContext(currentVarCounter);
-        this.outputDatasetName = outputDatasetName;
-        this.context.setTopFlwor(false);
-    }
+	public AqlPlusExpressionToPlanTranslator(long txnId,
+			MetadataTransactionContext mdTxnCtx, Counter currentVarCounter,
+			String outputDatasetName) {
+		this.txnId = txnId;
+		this.mdTxnCtx = mdTxnCtx;
+		this.context = new TranslationContext(currentVarCounter);
+		this.outputDatasetName = outputDatasetName;
+		this.context.setTopFlwor(false);
+	}
 
-    public int getVarCounter() {
-        return context.getVarCounter();
-    }
+	public int getVarCounter() {
+		return context.getVarCounter();
+	}
 
-    public ILogicalPlanAndMetadata translate(Query expr) throws AlgebricksException, AsterixException {
-        return translate(expr, null);
-    }
+	public ILogicalPlanAndMetadata translate(Query expr)
+			throws AlgebricksException, AsterixException {
+		return translate(expr, null);
+	}
 
-    public ILogicalPlanAndMetadata translate(Query expr, AqlCompiledMetadataDeclarations compiledDeclarations)
-            throws AlgebricksException, AsterixException {
-        if (expr == null) {
-            return null;
-        }
-        if (compiledDeclarations == null) {
-            compiledDeclarations = compileMetadata(mdTxnCtx, expr.getPrologDeclList(), true);
-        }
-        if (!compiledDeclarations.isConnectedToDataverse())
-            compiledDeclarations.connectToDataverse(compiledDeclarations.getDataverseName());
-        IDataFormat format = compiledDeclarations.getFormat();
-        if (format == null) {
-            throw new AlgebricksException("Data format has not been set.");
-        }
-        format.registerRuntimeFunctions();
-        Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, new MutableObject<ILogicalOperator>(
-                new EmptyTupleSourceOperator()));
+	public ILogicalPlanAndMetadata translate(Query expr,
+			AqlCompiledMetadataDeclarations compiledDeclarations)
+			throws AlgebricksException, AsterixException {
+		if (expr == null) {
+			return null;
+		}
+		if (compiledDeclarations == null) {
+			compiledDeclarations = compileMetadata(mdTxnCtx,
+					expr.getPrologDeclList(), true);
+		}
+		if (!compiledDeclarations.isConnectedToDataverse())
+			compiledDeclarations.connectToDataverse(compiledDeclarations
+					.getDataverseName());
+		IDataFormat format = compiledDeclarations.getFormat();
+		if (format == null) {
+			throw new AlgebricksException("Data format has not been set.");
+		}
+		format.registerRuntimeFunctions();
+		Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+				new MutableObject<ILogicalOperator>(
+						new EmptyTupleSourceOperator()));
 
-        ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
+		ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
 
-        boolean isTransactionalWrite = false;
-        ILogicalOperator topOp = p.first;
-        ProjectOperator project = (ProjectOperator) topOp;
-        LogicalVariable resVar = project.getVariables().get(0);
-        if (outputDatasetName == null) {
-            List<Mutable<ILogicalExpression>> writeExprList = new ArrayList<Mutable<ILogicalExpression>>(1);
-            writeExprList.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(resVar)));
-            FileSplitSinkId fssi = new FileSplitSinkId(compiledDeclarations.getOutputFile());
-            FileSplitDataSink sink = new FileSplitDataSink(fssi, null);
-            topOp = new WriteOperator(writeExprList, sink);
-            topOp.getInputs().add(new MutableObject<ILogicalOperator>(project));
-        } else {
-            Dataset dataset = compiledDeclarations.findDataset(outputDatasetName);
-            if (dataset == null) {
-                throw new AlgebricksException("Cannot find dataset " + outputDatasetName);
-            }
-            if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
-                throw new AlgebricksException("Cannot write output to an external dataset.");
-            }
-            ARecordType itemType = (ARecordType) compiledDeclarations.findType(dataset.getItemTypeName());
-            List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
-            ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>();
-            ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>();
-            List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<Mutable<ILogicalExpression>>();
-            for (String partitioningKey : partitioningKeys) {
-                Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioner = format
-                        .partitioningEvaluatorFactory(itemType, partitioningKey);
-                AbstractFunctionCallExpression f = partitioner.second.cloneExpression();
-                f.substituteVar(METADATA_DUMMY_VAR, resVar);
-                exprs.add(new MutableObject<ILogicalExpression>(f));
-                LogicalVariable v = context.newVar();
-                vars.add(v);
-                varRefsForLoading.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(v)));
-            }
-            AssignOperator assign = new AssignOperator(vars, exprs);
-            assign.getInputs().add(new MutableObject<ILogicalOperator>(project));
-        }
+		boolean isTransactionalWrite = false;
+		ILogicalOperator topOp = p.first;
+		ProjectOperator project = (ProjectOperator) topOp;
+		LogicalVariable resVar = project.getVariables().get(0);
+		if (outputDatasetName == null) {
+			List<Mutable<ILogicalExpression>> writeExprList = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			writeExprList.add(new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(resVar)));
+			FileSplitSinkId fssi = new FileSplitSinkId(
+					compiledDeclarations.getOutputFile());
+			FileSplitDataSink sink = new FileSplitDataSink(fssi, null);
+			topOp = new WriteOperator(writeExprList, sink);
+			topOp.getInputs().add(new MutableObject<ILogicalOperator>(project));
+		} else {
+			Dataset dataset = compiledDeclarations
+					.findDataset(outputDatasetName);
+			if (dataset == null) {
+				throw new AlgebricksException("Cannot find dataset "
+						+ outputDatasetName);
+			}
+			if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
+				throw new AlgebricksException(
+						"Cannot write output to an external dataset.");
+			}
+			ARecordType itemType = (ARecordType) compiledDeclarations
+					.findType(dataset.getItemTypeName());
+			List<String> partitioningKeys = DatasetUtils
+					.getPartitioningKeys(dataset);
+			ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>();
+			ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>();
+			List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<Mutable<ILogicalExpression>>();
+			for (String partitioningKey : partitioningKeys) {
+				Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioner = format
+						.partitioningEvaluatorFactory(itemType, partitioningKey);
+				AbstractFunctionCallExpression f = partitioner.second
+						.cloneExpression();
+				f.substituteVar(METADATA_DUMMY_VAR, resVar);
+				exprs.add(new MutableObject<ILogicalExpression>(f));
+				LogicalVariable v = context.newVar();
+				vars.add(v);
+				varRefsForLoading.add(new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(v)));
+			}
+			AssignOperator assign = new AssignOperator(vars, exprs);
+			assign.getInputs()
+					.add(new MutableObject<ILogicalOperator>(project));
+		}
 
-        globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
-        ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
-        AqlMetadataProvider metadataProvider = new AqlMetadataProvider(txnId, isTransactionalWrite,
-                compiledDeclarations);
-        ILogicalPlanAndMetadata planAndMetadata = new AqlLogicalPlanAndMetadataImpl(plan, metadataProvider);
-        return planAndMetadata;
-    }
+		globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
+		ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
+		AqlMetadataProvider metadataProvider = new AqlMetadataProvider(txnId,
+				isTransactionalWrite, compiledDeclarations);
+		ILogicalPlanAndMetadata planAndMetadata = new AqlLogicalPlanAndMetadataImpl(
+				plan, metadataProvider);
+		return planAndMetadata;
+	}
 
-    public ILogicalPlan translate(List<Clause> clauses) throws AlgebricksException, AsterixException {
+	public ILogicalPlan translate(List<Clause> clauses)
+			throws AlgebricksException, AsterixException {
 
-        if (clauses == null) {
-            return null;
-        }
+		if (clauses == null) {
+			return null;
+		}
 
-        Mutable<ILogicalOperator> opRef = new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator());
-        Pair<ILogicalOperator, LogicalVariable> p = null;
-        for (Clause c : clauses) {
-            p = c.accept(this, opRef);
-            opRef = new MutableObject<ILogicalOperator>(p.first);
-        }
+		Mutable<ILogicalOperator> opRef = new MutableObject<ILogicalOperator>(
+				new EmptyTupleSourceOperator());
+		Pair<ILogicalOperator, LogicalVariable> p = null;
+		for (Clause c : clauses) {
+			p = c.accept(this, opRef);
+			opRef = new MutableObject<ILogicalOperator>(p.first);
+		}
 
-        ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
+		ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
 
-        ILogicalOperator topOp = p.first;
+		ILogicalOperator topOp = p.first;
 
-        globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
-        ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
-        return plan;
-    }
+		globalPlanRoots.add(new MutableObject<ILogicalOperator>(topOp));
+		ILogicalPlan plan = new ALogicalPlanImpl(globalPlanRoots);
+		return plan;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitForClause(ForClause fc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v = context.newVar(fc.getVarExpr());
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitForClause(ForClause fc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		LogicalVariable v = context.newVar(fc.getVarExpr());
 
-        Expression inExpr = fc.getInExpr();
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(inExpr, tupSource);
-        ILogicalOperator returnedOp;
+		Expression inExpr = fc.getInExpr();
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+				inExpr, tupSource);
+		ILogicalOperator returnedOp;
 
-        if (fc.getPosVarExpr() == null) {
-            returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)));
-        } else {
-            LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
-            returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)),
-                    pVar, BuiltinType.AINT32);
-        }
-        returnedOp.getInputs().add(eo.second);
+		if (fc.getPosVarExpr() == null) {
+			returnedOp = new UnnestOperator(v,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo.first)));
+		} else {
+			LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
+			returnedOp = new UnnestOperator(v,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo.first)), pVar,
+					BuiltinType.AINT32);
+		}
+		returnedOp.getInputs().add(eo.second);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLetClause(LetClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v;
-        ILogicalOperator returnedOp;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLetClause(LetClause lc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		LogicalVariable v;
+		ILogicalOperator returnedOp;
 
-        switch (lc.getBindingExpr().getKind()) {
-            case VARIABLE_EXPRESSION: {
-                v = context.newVar(lc.getVarExpr());
-                LogicalVariable prev = context.getVar(((VariableExpr) lc.getBindingExpr()).getVar().getId());
-                returnedOp = new AssignOperator(v, new MutableObject<ILogicalExpression>(
-                        new VariableReferenceExpression(prev)));
-                returnedOp.getInputs().add(tupSource);
-                break;
-            }
-            default: {
-                Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(lc.getBindingExpr(),
-                        tupSource);
-                v = context.newVar(lc.getVarExpr());
-                returnedOp = new AssignOperator(v, new MutableObject<ILogicalExpression>(eo.first));
-                returnedOp.getInputs().add(eo.second);
-                break;
-            }
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
-    }
+		switch (lc.getBindingExpr().getKind()) {
+		case VARIABLE_EXPRESSION: {
+			v = context.newVar(lc.getVarExpr());
+			LogicalVariable prev = context.getVar(((VariableExpr) lc
+					.getBindingExpr()).getVar().getId());
+			returnedOp = new AssignOperator(v,
+					new MutableObject<ILogicalExpression>(
+							new VariableReferenceExpression(prev)));
+			returnedOp.getInputs().add(tupSource);
+			break;
+		}
+		default: {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					lc.getBindingExpr(), tupSource);
+			v = context.newVar(lc.getVarExpr());
+			returnedOp = new AssignOperator(v,
+					new MutableObject<ILogicalExpression>(eo.first));
+			returnedOp.getInputs().add(eo.second);
+			break;
+		}
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(returnedOp, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFlworExpression(FLWOGRExpression flwor,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> flworPlan = tupSource;
-        boolean isTop = context.isTopFlwor();
-        if (isTop) {
-            context.setTopFlwor(false);
-        }
-        for (Clause c : flwor.getClauseList()) {
-            Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this, flworPlan);
-            flworPlan = new MutableObject<ILogicalOperator>(pC.first);
-        }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFlworExpression(
+			FLWOGRExpression flwor, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> flworPlan = tupSource;
+		boolean isTop = context.isTopFlwor();
+		if (isTop) {
+			context.setTopFlwor(false);
+		}
+		for (Clause c : flwor.getClauseList()) {
+			Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this,
+					flworPlan);
+			flworPlan = new MutableObject<ILogicalOperator>(pC.first);
+		}
 
-        Expression r = flwor.getReturnExpr();
-        boolean noFlworClause = flwor.noForClause();
+		Expression r = flwor.getReturnExpr();
+		boolean noFlworClause = flwor.noForClause();
 
-        if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
-            VariableExpr v = (VariableExpr) r;
-            LogicalVariable var = context.getVar(v.getVar().getId());
+		if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
+			VariableExpr v = (VariableExpr) r;
+			LogicalVariable var = context.getVar(v.getVar().getId());
 
-            return produceFlwrResult(noFlworClause, isTop, flworPlan, var);
+			return produceFlwrResult(noFlworClause, isTop, flworPlan, var);
 
-        } else {
-            Mutable<ILogicalOperator> baseOp = new MutableObject<ILogicalOperator>(flworPlan.getValue());
-            Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this, baseOp);
-            ILogicalOperator rOp = rRes.first;
-            ILogicalOperator resOp;
-            if (expressionNeedsNoNesting(r)) {
-                baseOp.setValue(flworPlan.getValue());
-                resOp = rOp;
-            } else {
-                SubplanOperator s = new SubplanOperator(rOp);
-                s.getInputs().add(flworPlan);
-                resOp = s;
-                baseOp.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
-            }
-            Mutable<ILogicalOperator> resOpRef = new MutableObject<ILogicalOperator>(resOp);
-            return produceFlwrResult(noFlworClause, isTop, resOpRef, rRes.second);
-        }
-    }
+		} else {
+			Mutable<ILogicalOperator> baseOp = new MutableObject<ILogicalOperator>(
+					flworPlan.getValue());
+			Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this,
+					baseOp);
+			ILogicalOperator rOp = rRes.first;
+			ILogicalOperator resOp;
+			if (expressionNeedsNoNesting(r)) {
+				baseOp.setValue(flworPlan.getValue());
+				resOp = rOp;
+			} else {
+				SubplanOperator s = new SubplanOperator(rOp);
+				s.getInputs().add(flworPlan);
+				resOp = s;
+				baseOp.setValue(new NestedTupleSourceOperator(
+						new MutableObject<ILogicalOperator>(s)));
+			}
+			Mutable<ILogicalOperator> resOpRef = new MutableObject<ILogicalOperator>(
+					resOp);
+			return produceFlwrResult(noFlworClause, isTop, resOpRef,
+					rRes.second);
+		}
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFieldAccessor(FieldAccessor fa,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(fa.getExpr(), tupSource);
-        LogicalVariable v = context.newVar();
-        AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
-        fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        ILogicalExpression faExpr = new ConstantExpression(new AsterixConstantValue(new AString(fa.getIdent()
-                .getValue())));
-        fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(faExpr));
-        AssignOperator a = new AssignOperator(v, new MutableObject<ILogicalExpression>(fldAccess));
-        a.getInputs().add(p.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFieldAccessor(
+			FieldAccessor fa, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				fa.getExpr(), tupSource);
+		LogicalVariable v = context.newVar();
+		AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
+		fldAccess.getArguments().add(
+				new MutableObject<ILogicalExpression>(p.first));
+		ILogicalExpression faExpr = new ConstantExpression(
+				new AsterixConstantValue(new AString(fa.getIdent().getValue())));
+		fldAccess.getArguments().add(
+				new MutableObject<ILogicalExpression>(faExpr));
+		AssignOperator a = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(fldAccess));
+		a.getInputs().add(p.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v);
 
-    }
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIndexAccessor(IndexAccessor ia,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(ia.getExpr(), tupSource);
-        LogicalVariable v = context.newVar();
-        AbstractFunctionCallExpression f;
-        int i = ia.getIndex();
-        if (i == IndexAccessor.ANY) {
-            f = new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        } else {
-            f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-            f.getArguments().add(
-                    new MutableObject<ILogicalExpression>(new ConstantExpression(
-                            new AsterixConstantValue(new AInt32(i)))));
-        }
-        AssignOperator a = new AssignOperator(v, new MutableObject<ILogicalExpression>(f));
-        a.getInputs().add(p.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIndexAccessor(
+			IndexAccessor ia, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				ia.getExpr(), tupSource);
+		LogicalVariable v = context.newVar();
+		AbstractFunctionCallExpression f;
+		int i = ia.getIndex();
+		if (i == IndexAccessor.ANY) {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+		} else {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(
+							new ConstantExpression(new AsterixConstantValue(
+									new AInt32(i)))));
+		}
+		AssignOperator a = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(f));
+		a.getInputs().add(p.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCallExpr(CallExpr fcall, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        LogicalVariable v = context.newVar();
-        AsterixFunction fid = fcall.getIdent();
-        List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
-        Mutable<ILogicalOperator> topOp = tupSource;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCallExpr(
+			CallExpr fcall, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		LogicalVariable v = context.newVar();
+		AsterixFunction fid = fcall.getIdent();
+		List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        for (Expression expr : fcall.getExprList()) {
-            switch (expr.getKind()) {
-                case VARIABLE_EXPRESSION: {
-                    LogicalVariable var = context.getVar(((VariableExpr) expr).getVar().getId());
-                    args.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
-                    break;
-                }
-                case LITERAL_EXPRESSION: {
-                    LiteralExpr val = (LiteralExpr) expr;
-                    args.add(new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(
-                            ConstantHelper.objectFromLiteral(val.getValue())))));
-                    break;
-                }
-                default: {
-                    Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, topOp);
-                    AbstractLogicalOperator o1 = (AbstractLogicalOperator) eo.second.getValue();
-                    args.add(new MutableObject<ILogicalExpression>(eo.first));
-                    if (o1 != null && !(o1.getOperatorTag() == LogicalOperatorTag.ASSIGN && hasOnlyChild(o1, topOp))) {
-                        topOp = eo.second;
-                    }
-                    break;
-                }
-            }
-        }
+		for (Expression expr : fcall.getExprList()) {
+			switch (expr.getKind()) {
+			case VARIABLE_EXPRESSION: {
+				LogicalVariable var = context.getVar(((VariableExpr) expr)
+						.getVar().getId());
+				args.add(new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(var)));
+				break;
+			}
+			case LITERAL_EXPRESSION: {
+				LiteralExpr val = (LiteralExpr) expr;
+				args.add(new MutableObject<ILogicalExpression>(
+						new ConstantExpression(
+								new AsterixConstantValue(ConstantHelper
+										.objectFromLiteral(val.getValue())))));
+				break;
+			}
+			default: {
+				Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+						expr, topOp);
+				AbstractLogicalOperator o1 = (AbstractLogicalOperator) eo.second
+						.getValue();
+				args.add(new MutableObject<ILogicalExpression>(eo.first));
+				if (o1 != null
+						&& !(o1.getOperatorTag() == LogicalOperatorTag.ASSIGN && hasOnlyChild(
+								o1, topOp))) {
+					topOp = eo.second;
+				}
+				break;
+			}
+			}
+		}
 
-        FunctionIdentifier fi = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS, fid.getFunctionName(),
-                false);
-        AsterixFunctionInfo afi = AsterixBuiltinFunctions.lookupFunction(fi);
-        FunctionIdentifier builtinAquafi = afi == null ? null : afi.getFunctionIdentifier();
+		FunctionIdentifier fi = new FunctionIdentifier(
+				AlgebricksBuiltinFunctions.ALGEBRICKS_NS, fid.getFunctionName());
+		AsterixFunctionInfo afi = AsterixBuiltinFunctions.lookupFunction(fi);
+		FunctionIdentifier builtinAquafi = afi == null ? null : afi
+				.getFunctionIdentifier();
 
-        if (builtinAquafi != null) {
-            fi = builtinAquafi;
-        } else {
-            fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, fid.getFunctionName(), false);
-            FunctionIdentifier builtinAsterixFi = AsterixBuiltinFunctions.getBuiltinFunctionIdentifier(fi);
-            if (builtinAsterixFi != null) {
-                fi = builtinAsterixFi;
-            }
-        }
-        AbstractFunctionCallExpression f;
-        if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
-            f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi, args);
-        } else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
-            UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(fi), args);
-            ufce.setReturnsUniqueValues(AsterixBuiltinFunctions.returnsUniqueValues(fi));
-            f = ufce;
-        } else {
-            f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fi), args);
-        }
-        AssignOperator op = new AssignOperator(v, new MutableObject<ILogicalExpression>(f));
-        if (topOp != null) {
-            op.getInputs().add(topOp);
-        }
+		if (builtinAquafi != null) {
+			fi = builtinAquafi;
+		} else {
+			fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+					fid.getFunctionName());
+			FunctionIdentifier builtinAsterixFi = AsterixBuiltinFunctions
+					.getBuiltinFunctionIdentifier(fi);
+			if (builtinAsterixFi != null) {
+				fi = builtinAsterixFi;
+			}
+		}
+		AbstractFunctionCallExpression f;
+		if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
+			f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi,
+					args);
+		} else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
+			UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(
+					FunctionUtils.getFunctionInfo(fi), args);
+			ufce.setReturnsUniqueValues(AsterixBuiltinFunctions
+					.returnsUniqueValues(fi));
+			f = ufce;
+		} else {
+			f = new ScalarFunctionCallExpression(
+					FunctionUtils.getFunctionInfo(fi), args);
+		}
+		AssignOperator op = new AssignOperator(v,
+				new MutableObject<ILogicalExpression>(f));
+		if (topOp != null) {
+			op.getInputs().add(topOp);
+		}
 
-        return new Pair<ILogicalOperator, LogicalVariable>(op, v);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(op, v);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFunctionDecl(FunctionDecl fd,
-            Mutable<ILogicalOperator> tupSource) {
-        // TODO Auto-generated method stub
-        throw new NotImplementedException();
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFunctionDecl(
+			FunctionDecl fd, Mutable<ILogicalOperator> tupSource) {
+		// TODO Auto-generated method stub
+		throw new NotImplementedException();
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitGroupbyClause(GroupbyClause gc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        GroupByOperator gOp = new GroupByOperator();
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (GbyVariableExpressionPair ve : gc.getGbyPairList()) {
-            LogicalVariable v;
-            VariableExpr vexpr = ve.getVar();
-            if (vexpr != null) {
-                v = context.newVar(vexpr);
-            } else {
-                v = context.newVar();
-            }
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(ve.getExpr(), topOp);
-            gOp.addGbyExpression(v, eo.first);
-            topOp = eo.second;
-        }
-        for (GbyVariableExpressionPair ve : gc.getDecorPairList()) {
-            LogicalVariable v;
-            VariableExpr vexpr = ve.getVar();
-            if (vexpr != null) {
-                v = context.newVar(vexpr);
-            } else {
-                v = context.newVar();
-            }
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(ve.getExpr(), topOp);
-            gOp.addDecorExpression(v, eo.first);
-            topOp = eo.second;
-        }
-        gOp.getInputs().add(topOp);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitGroupbyClause(
+			GroupbyClause gc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		GroupByOperator gOp = new GroupByOperator();
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (GbyVariableExpressionPair ve : gc.getGbyPairList()) {
+			LogicalVariable v;
+			VariableExpr vexpr = ve.getVar();
+			if (vexpr != null) {
+				v = context.newVar(vexpr);
+			} else {
+				v = context.newVar();
+			}
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					ve.getExpr(), topOp);
+			gOp.addGbyExpression(v, eo.first);
+			topOp = eo.second;
+		}
+		for (GbyVariableExpressionPair ve : gc.getDecorPairList()) {
+			LogicalVariable v;
+			VariableExpr vexpr = ve.getVar();
+			if (vexpr != null) {
+				v = context.newVar(vexpr);
+			} else {
+				v = context.newVar();
+			}
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					ve.getExpr(), topOp);
+			gOp.addDecorExpression(v, eo.first);
+			topOp = eo.second;
+		}
+		gOp.getInputs().add(topOp);
 
-        for (VariableExpr var : gc.getWithVarList()) {
-            LogicalVariable aggVar = context.newVar();
-            LogicalVariable oldVar = context.getVar(var);
-            List<Mutable<ILogicalExpression>> flArgs = new ArrayList<Mutable<ILogicalExpression>>(1);
-            flArgs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oldVar)));
-            AggregateFunctionCallExpression fListify = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                    AsterixBuiltinFunctions.LISTIFY, flArgs);
-            AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(aggVar),
-                    (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(fListify)));
-            agg.getInputs().add(
-                    new MutableObject<ILogicalOperator>(new NestedTupleSourceOperator(
-                            new MutableObject<ILogicalOperator>(gOp))));
-            ILogicalPlan plan = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(agg));
-            gOp.getNestedPlans().add(plan);
-            // Hide the variable that was part of the "with", replacing it with
-            // the one bound by the aggregation op.
-            context.setVar(var, aggVar);
-        }
+		for (VariableExpr var : gc.getWithVarList()) {
+			LogicalVariable aggVar = context.newVar();
+			LogicalVariable oldVar = context.getVar(var);
+			List<Mutable<ILogicalExpression>> flArgs = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			flArgs.add(new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(oldVar)));
+			AggregateFunctionCallExpression fListify = AsterixBuiltinFunctions
+					.makeAggregateFunctionExpression(
+							AsterixBuiltinFunctions.LISTIFY, flArgs);
+			AggregateOperator agg = new AggregateOperator(
+					mkSingletonArrayList(aggVar),
+					(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+							fListify)));
+			agg.getInputs().add(
+					new MutableObject<ILogicalOperator>(
+							new NestedTupleSourceOperator(
+									new MutableObject<ILogicalOperator>(gOp))));
+			ILogicalPlan plan = new ALogicalPlanImpl(
+					new MutableObject<ILogicalOperator>(agg));
+			gOp.getNestedPlans().add(plan);
+			// Hide the variable that was part of the "with", replacing it with
+			// the one bound by the aggregation op.
+			context.setVar(var, aggVar);
+		}
 
-        gOp.getAnnotations().put(OperatorAnnotations.USE_HASH_GROUP_BY, gc.hasHashGroupByHint());
-        return new Pair<ILogicalOperator, LogicalVariable>(gOp, null);
-    }
+		gOp.getAnnotations().put(OperatorAnnotations.USE_HASH_GROUP_BY,
+				gc.hasHashGroupByHint());
+		return new Pair<ILogicalOperator, LogicalVariable>(gOp, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIfExpr(IfExpr ifexpr, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        // In the most general case, IfThenElse is translated in the following
-        // way.
-        //
-        // We assign the result of the condition to one variable varCond.
-        // We create one subplan which contains the plan for the "then" branch,
-        // on top of which there is a selection whose condition is varCond.
-        // Similarly, we create one subplan for the "else" branch, in which the
-        // selection is not(varCond).
-        // Finally, we concatenate the results. (??)
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIfExpr(IfExpr ifexpr,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		// In the most general case, IfThenElse is translated in the following
+		// way.
+		//
+		// We assign the result of the condition to one variable varCond.
+		// We create one subplan which contains the plan for the "then" branch,
+		// on top of which there is a selection whose condition is varCond.
+		// Similarly, we create one subplan for the "else" branch, in which the
+		// selection is not(varCond).
+		// Finally, we concatenate the results. (??)
 
-        Pair<ILogicalOperator, LogicalVariable> pCond = ifexpr.getCondExpr().accept(this, tupSource);
-        ILogicalOperator opCond = pCond.first;
-        LogicalVariable varCond = pCond.second;
+		Pair<ILogicalOperator, LogicalVariable> pCond = ifexpr.getCondExpr()
+				.accept(this, tupSource);
+		ILogicalOperator opCond = pCond.first;
+		LogicalVariable varCond = pCond.second;
 
-        SubplanOperator sp = new SubplanOperator();
-        Mutable<ILogicalOperator> nestedSource = new MutableObject<ILogicalOperator>(new NestedTupleSourceOperator(
-                new MutableObject<ILogicalOperator>(sp)));
+		SubplanOperator sp = new SubplanOperator();
+		Mutable<ILogicalOperator> nestedSource = new MutableObject<ILogicalOperator>(
+				new NestedTupleSourceOperator(
+						new MutableObject<ILogicalOperator>(sp)));
 
-        Pair<ILogicalOperator, LogicalVariable> pThen = ifexpr.getThenExpr().accept(this, nestedSource);
-        SelectOperator sel1 = new SelectOperator(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(
-                varCond)));
-        sel1.getInputs().add(new MutableObject<ILogicalOperator>(pThen.first));
+		Pair<ILogicalOperator, LogicalVariable> pThen = ifexpr.getThenExpr()
+				.accept(this, nestedSource);
+		SelectOperator sel1 = new SelectOperator(
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(varCond)));
+		sel1.getInputs().add(new MutableObject<ILogicalOperator>(pThen.first));
 
-        Pair<ILogicalOperator, LogicalVariable> pElse = ifexpr.getElseExpr().accept(this, nestedSource);
-        AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), new MutableObject<ILogicalExpression>(
-                        new VariableReferenceExpression(varCond)));
-        SelectOperator sel2 = new SelectOperator(new MutableObject<ILogicalExpression>(notVarCond));
-        sel2.getInputs().add(new MutableObject<ILogicalOperator>(pElse.first));
+		Pair<ILogicalOperator, LogicalVariable> pElse = ifexpr.getElseExpr()
+				.accept(this, nestedSource);
+		AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(varCond)));
+		SelectOperator sel2 = new SelectOperator(
+				new MutableObject<ILogicalExpression>(notVarCond));
+		sel2.getInputs().add(new MutableObject<ILogicalOperator>(pElse.first));
 
-        ILogicalPlan p1 = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(sel1));
-        sp.getNestedPlans().add(p1);
-        ILogicalPlan p2 = new ALogicalPlanImpl(new MutableObject<ILogicalOperator>(sel2));
-        sp.getNestedPlans().add(p2);
+		ILogicalPlan p1 = new ALogicalPlanImpl(
+				new MutableObject<ILogicalOperator>(sel1));
+		sp.getNestedPlans().add(p1);
+		ILogicalPlan p2 = new ALogicalPlanImpl(
+				new MutableObject<ILogicalOperator>(sel2));
+		sp.getNestedPlans().add(p2);
 
-        Mutable<ILogicalOperator> opCondRef = new MutableObject<ILogicalOperator>(opCond);
-        sp.getInputs().add(opCondRef);
+		Mutable<ILogicalOperator> opCondRef = new MutableObject<ILogicalOperator>(
+				opCond);
+		sp.getInputs().add(opCondRef);
 
-        LogicalVariable resV = context.newVar();
-        AbstractFunctionCallExpression concatNonNull = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
-                new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pThen.second)),
-                new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pElse.second)));
-        AssignOperator a = new AssignOperator(resV, new MutableObject<ILogicalExpression>(concatNonNull));
-        a.getInputs().add(new MutableObject<ILogicalOperator>(sp));
+		LogicalVariable resV = context.newVar();
+		AbstractFunctionCallExpression concatNonNull = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(pThen.second)),
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(pElse.second)));
+		AssignOperator a = new AssignOperator(resV,
+				new MutableObject<ILogicalExpression>(concatNonNull));
+		a.getInputs().add(new MutableObject<ILogicalOperator>(sp));
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, resV);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(a, resV);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLiteralExpr(LiteralExpr l, Mutable<ILogicalOperator> tupSource) {
-        LogicalVariable var = context.newVar();
-        AssignOperator a = new AssignOperator(var, new MutableObject<ILogicalExpression>(new ConstantExpression(
-                new AsterixConstantValue(ConstantHelper.objectFromLiteral(l.getValue())))));
-        if (tupSource != null) {
-            a.getInputs().add(tupSource);
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(a, var);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLiteralExpr(
+			LiteralExpr l, Mutable<ILogicalOperator> tupSource) {
+		LogicalVariable var = context.newVar();
+		AssignOperator a = new AssignOperator(var,
+				new MutableObject<ILogicalExpression>(new ConstantExpression(
+						new AsterixConstantValue(ConstantHelper
+								.objectFromLiteral(l.getValue())))));
+		if (tupSource != null) {
+			a.getInputs().add(tupSource);
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(a, var);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOperatorExpr(OperatorExpr op,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        ArrayList<OperatorType> ops = op.getOpList();
-        int nOps = ops.size();
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOperatorExpr(
+			OperatorExpr op, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		ArrayList<OperatorType> ops = op.getOpList();
+		int nOps = ops.size();
 
-        if (nOps > 0 && (ops.get(0) == OperatorType.AND || ops.get(0) == OperatorType.OR)) {
-            return visitAndOrOperator(op, tupSource);
-        }
+		if (nOps > 0
+				&& (ops.get(0) == OperatorType.AND || ops.get(0) == OperatorType.OR)) {
+			return visitAndOrOperator(op, tupSource);
+		}
 
-        ArrayList<Expression> exprs = op.getExprList();
+		ArrayList<Expression> exprs = op.getExprList();
 
-        Mutable<ILogicalOperator> topOp = tupSource;
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        ILogicalExpression currExpr = null;
-        for (int i = 0; i <= nOps; i++) {
+		ILogicalExpression currExpr = null;
+		for (int i = 0; i <= nOps; i++) {
 
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(exprs.get(i), topOp);
-            topOp = p.second;
-            ILogicalExpression e = p.first;
-            // now look at the operator
-            if (i < nOps) {
-                if (OperatorExpr.opIsComparison(ops.get(i))) {
-                    AbstractFunctionCallExpression c = createComparisonExpression(ops.get(i));
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					exprs.get(i), topOp);
+			topOp = p.second;
+			ILogicalExpression e = p.first;
+			// now look at the operator
+			if (i < nOps) {
+				if (OperatorExpr.opIsComparison(ops.get(i))) {
+					AbstractFunctionCallExpression c = createComparisonExpression(ops
+							.get(i));
 
-                    // chain the operators
-                    if (i == 0) {
-                        c.getArguments().add(new MutableObject<ILogicalExpression>(e));
-                        currExpr = c;
-                        if (op.isBroadcastOperand(i)) {
-                            BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                            bcast.setObject(BroadcastSide.LEFT);
-                            c.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                        }
-                    } else {
-                        ((AbstractFunctionCallExpression) currExpr).getArguments().add(
-                                new MutableObject<ILogicalExpression>(e));
-                        c.getArguments().add(new MutableObject<ILogicalExpression>(currExpr));
-                        currExpr = c;
-                        if (i == 1 && op.isBroadcastOperand(i)) {
-                            BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                            bcast.setObject(BroadcastSide.RIGHT);
-                            c.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                        }
-                    }
-                } else {
-                    AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(ops.get(i));
+					// chain the operators
+					if (i == 0) {
+						c.getArguments().add(
+								new MutableObject<ILogicalExpression>(e));
+						currExpr = c;
+						if (op.isBroadcastOperand(i)) {
+							BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+							bcast.setObject(BroadcastSide.LEFT);
+							c.getAnnotations()
+									.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+											bcast);
+						}
+					} else {
+						((AbstractFunctionCallExpression) currExpr)
+								.getArguments()
+								.add(new MutableObject<ILogicalExpression>(e));
+						c.getArguments()
+								.add(new MutableObject<ILogicalExpression>(
+										currExpr));
+						currExpr = c;
+						if (i == 1 && op.isBroadcastOperand(i)) {
+							BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+							bcast.setObject(BroadcastSide.RIGHT);
+							c.getAnnotations()
+									.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+											bcast);
+						}
+					}
+				} else {
+					AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(ops
+							.get(i));
 
-                    if (i == 0) {
-                        f.getArguments().add(new MutableObject<ILogicalExpression>(e));
-                        currExpr = f;
-                    } else {
-                        ((AbstractFunctionCallExpression) currExpr).getArguments().add(
-                                new MutableObject<ILogicalExpression>(e));
-                        f.getArguments().add(new MutableObject<ILogicalExpression>(currExpr));
-                        currExpr = f;
-                    }
-                }
-            } else { // don't forget the last expression...
-                ((AbstractFunctionCallExpression) currExpr).getArguments()
-                        .add(new MutableObject<ILogicalExpression>(e));
-                if (i == 1 && op.isBroadcastOperand(i)) {
-                    BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
-                    bcast.setObject(BroadcastSide.RIGHT);
-                    ((AbstractFunctionCallExpression) currExpr).getAnnotations().put(
-                            BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);
-                }
-            }
-        }
+					if (i == 0) {
+						f.getArguments().add(
+								new MutableObject<ILogicalExpression>(e));
+						currExpr = f;
+					} else {
+						((AbstractFunctionCallExpression) currExpr)
+								.getArguments()
+								.add(new MutableObject<ILogicalExpression>(e));
+						f.getArguments()
+								.add(new MutableObject<ILogicalExpression>(
+										currExpr));
+						currExpr = f;
+					}
+				}
+			} else { // don't forget the last expression...
+				((AbstractFunctionCallExpression) currExpr).getArguments().add(
+						new MutableObject<ILogicalExpression>(e));
+				if (i == 1 && op.isBroadcastOperand(i)) {
+					BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation();
+					bcast.setObject(BroadcastSide.RIGHT);
+					((AbstractFunctionCallExpression) currExpr)
+							.getAnnotations()
+							.put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY,
+									bcast);
+				}
+			}
+		}
 
-        LogicalVariable assignedVar = context.newVar();
-        AssignOperator a = new AssignOperator(assignedVar, new MutableObject<ILogicalExpression>(currExpr));
+		LogicalVariable assignedVar = context.newVar();
+		AssignOperator a = new AssignOperator(assignedVar,
+				new MutableObject<ILogicalExpression>(currExpr));
 
-        a.getInputs().add(topOp);
+		a.getInputs().add(topOp);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOrderbyClause(OrderbyClause oc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOrderbyClause(
+			OrderbyClause oc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
 
-        OrderOperator ord = new OrderOperator();
-        Iterator<OrderModifier> modifIter = oc.getModifierList().iterator();
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (Expression e : oc.getOrderbyList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(e, topOp);
-            OrderModifier m = modifIter.next();
-            OrderOperator.IOrder comp = (m == OrderModifier.ASC) ? OrderOperator.ASC_ORDER : OrderOperator.DESC_ORDER;
-            ord.getOrderExpressions()
-                    .add(new Pair<IOrder, Mutable<ILogicalExpression>>(comp, new MutableObject<ILogicalExpression>(
-                            p.first)));
-            topOp = p.second;
-        }
-        ord.getInputs().add(topOp);
-        if (oc.getNumTuples() > 0) {
-            ord.getAnnotations().put(OperatorAnnotations.CARDINALITY, oc.getNumTuples());
-        }
-        if (oc.getNumFrames() > 0) {
-            ord.getAnnotations().put(OperatorAnnotations.MAX_NUMBER_FRAMES, oc.getNumFrames());
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(ord, null);
-    }
+		OrderOperator ord = new OrderOperator();
+		Iterator<OrderModifier> modifIter = oc.getModifierList().iterator();
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (Expression e : oc.getOrderbyList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					e, topOp);
+			OrderModifier m = modifIter.next();
+			OrderOperator.IOrder comp = (m == OrderModifier.ASC) ? OrderOperator.ASC_ORDER
+					: OrderOperator.DESC_ORDER;
+			ord.getOrderExpressions().add(
+					new Pair<IOrder, Mutable<ILogicalExpression>>(comp,
+							new MutableObject<ILogicalExpression>(p.first)));
+			topOp = p.second;
+		}
+		ord.getInputs().add(topOp);
+		if (oc.getNumTuples() > 0) {
+			ord.getAnnotations().put(OperatorAnnotations.CARDINALITY,
+					oc.getNumTuples());
+		}
+		if (oc.getNumFrames() > 0) {
+			ord.getAnnotations().put(OperatorAnnotations.MAX_NUMBER_FRAMES,
+					oc.getNumFrames());
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(ord, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitQuantifiedExpression(QuantifiedExpression qe,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> topOp = tupSource;
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitQuantifiedExpression(
+			QuantifiedExpression qe, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        ILogicalOperator firstOp = null;
-        Mutable<ILogicalOperator> lastOp = null;
+		ILogicalOperator firstOp = null;
+		Mutable<ILogicalOperator> lastOp = null;
 
-        for (QuantifiedPair qt : qe.getQuantifiedList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(qt.getExpr(), topOp);
-            topOp = eo1.second;
-            LogicalVariable uVar = context.newVar(qt.getVarExpr());
-            ILogicalOperator u = new UnnestOperator(uVar, new MutableObject<ILogicalExpression>(
-                    makeUnnestExpression(eo1.first)));
+		for (QuantifiedPair qt : qe.getQuantifiedList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(
+					qt.getExpr(), topOp);
+			topOp = eo1.second;
+			LogicalVariable uVar = context.newVar(qt.getVarExpr());
+			ILogicalOperator u = new UnnestOperator(uVar,
+					new MutableObject<ILogicalExpression>(
+							makeUnnestExpression(eo1.first)));
 
-            if (firstOp == null) {
-                firstOp = u;
-            }
-            if (lastOp != null) {
-                u.getInputs().add(lastOp);
-            }
-            lastOp = new MutableObject<ILogicalOperator>(u);
-        }
+			if (firstOp == null) {
+				firstOp = u;
+			}
+			if (lastOp != null) {
+				u.getInputs().add(lastOp);
+			}
+			lastOp = new MutableObject<ILogicalOperator>(u);
+		}
 
-        // We make all the unnest correspond. to quantif. vars. sit on top
-        // in the hope of enabling joins & other optimiz.
-        firstOp.getInputs().add(topOp);
-        topOp = lastOp;
+		// We make all the unnest correspond. to quantif. vars. sit on top
+		// in the hope of enabling joins & other optimiz.
+		firstOp.getInputs().add(topOp);
+		topOp = lastOp;
 
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(qe.getSatisfiesExpr(), topOp);
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(
+				qe.getSatisfiesExpr(), topOp);
 
-        AggregateFunctionCallExpression fAgg;
-        SelectOperator s;
-        if (qe.getQuantifier() == Quantifier.SOME) {
-            s = new SelectOperator(new MutableObject<ILogicalExpression>(eo2.first));
-            s.getInputs().add(eo2.second);
-            fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.NON_EMPTY_STREAM,
-                    new ArrayList<Mutable<ILogicalExpression>>());
-        } else { // EVERY
-            List<Mutable<ILogicalExpression>> satExprList = new ArrayList<Mutable<ILogicalExpression>>(1);
-            satExprList.add(new MutableObject<ILogicalExpression>(eo2.first));
-            s = new SelectOperator(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), satExprList)));
-            s.getInputs().add(eo2.second);
-            fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.EMPTY_STREAM,
-                    new ArrayList<Mutable<ILogicalExpression>>());
-        }
-        LogicalVariable qeVar = context.newVar();
-        AggregateOperator a = new AggregateOperator(mkSingletonArrayList(qeVar),
-                (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(fAgg)));
-        a.getInputs().add(new MutableObject<ILogicalOperator>(s));
-        return new Pair<ILogicalOperator, LogicalVariable>(a, qeVar);
-    }
+		AggregateFunctionCallExpression fAgg;
+		SelectOperator s;
+		if (qe.getQuantifier() == Quantifier.SOME) {
+			s = new SelectOperator(new MutableObject<ILogicalExpression>(
+					eo2.first));
+			s.getInputs().add(eo2.second);
+			fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+					AsterixBuiltinFunctions.NON_EMPTY_STREAM,
+					new ArrayList<Mutable<ILogicalExpression>>());
+		} else { // EVERY
+			List<Mutable<ILogicalExpression>> satExprList = new ArrayList<Mutable<ILogicalExpression>>(
+					1);
+			satExprList.add(new MutableObject<ILogicalExpression>(eo2.first));
+			s = new SelectOperator(new MutableObject<ILogicalExpression>(
+					new ScalarFunctionCallExpression(FunctionUtils
+							.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+							satExprList)));
+			s.getInputs().add(eo2.second);
+			fAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+					AsterixBuiltinFunctions.EMPTY_STREAM,
+					new ArrayList<Mutable<ILogicalExpression>>());
+		}
+		LogicalVariable qeVar = context.newVar();
+		AggregateOperator a = new AggregateOperator(
+				mkSingletonArrayList(qeVar),
+				(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+						fAgg)));
+		a.getInputs().add(new MutableObject<ILogicalOperator>(s));
+		return new Pair<ILogicalOperator, LogicalVariable>(a, qeVar);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitQuery(Query q, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        return q.getBody().accept(this, tupSource);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitQuery(Query q,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		return q.getBody().accept(this, tupSource);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitRecordConstructor(RecordConstructor rc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
-                FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR));
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(f));
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (FieldBinding fb : rc.getFbList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(fb.getLeftExpr(), topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo1.first));
-            topOp = eo1.second;
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(fb.getRightExpr(), topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo2.first));
-            topOp = eo2.second;
-        }
-        a.getInputs().add(topOp);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitRecordConstructor(
+			RecordConstructor rc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
+				FunctionUtils
+						.getFunctionInfo(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR));
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a = new AssignOperator(v1,
+				new MutableObject<ILogicalExpression>(f));
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (FieldBinding fb : rc.getFbList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(
+					fb.getLeftExpr(), topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo1.first));
+			topOp = eo1.second;
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = aqlExprToAlgExpression(
+					fb.getRightExpr(), topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo2.first));
+			topOp = eo2.second;
+		}
+		a.getInputs().add(topOp);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitListConstructor(ListConstructor lc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        FunctionIdentifier fid = (lc.getType() == Type.ORDERED_LIST_CONSTRUCTOR) ? AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR
-                : AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR;
-        AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fid));
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(f));
-        Mutable<ILogicalOperator> topOp = tupSource;
-        for (Expression expr : lc.getExprList()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, topOp);
-            f.getArguments().add(new MutableObject<ILogicalExpression>(eo.first));
-            topOp = eo.second;
-        }
-        a.getInputs().add(topOp);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitListConstructor(
+			ListConstructor lc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		FunctionIdentifier fid = (lc.getType() == Type.ORDERED_LIST_CONSTRUCTOR) ? AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR
+				: AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR;
+		AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(fid));
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a = new AssignOperator(v1,
+				new MutableObject<ILogicalExpression>(f));
+		Mutable<ILogicalOperator> topOp = tupSource;
+		for (Expression expr : lc.getExprList()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+					expr, topOp);
+			f.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo.first));
+			topOp = eo.second;
+		}
+		a.getInputs().add(topOp);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnaryExpr(UnaryExpr u, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Expression expr = u.getExpr();
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, tupSource);
-        LogicalVariable v1 = context.newVar();
-        AssignOperator a;
-        if (u.getSign() == Sign.POSITIVE) {
-            a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(eo.first));
-        } else {
-            AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
-                    FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
-            m.getArguments().add(new MutableObject<ILogicalExpression>(eo.first));
-            a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(m));
-        }
-        a.getInputs().add(eo.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnaryExpr(UnaryExpr u,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		Expression expr = u.getExpr();
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(
+				expr, tupSource);
+		LogicalVariable v1 = context.newVar();
+		AssignOperator a;
+		if (u.getSign() == Sign.POSITIVE) {
+			a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(
+					eo.first));
+		} else {
+			AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
+			m.getArguments().add(
+					new MutableObject<ILogicalExpression>(eo.first));
+			a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(m));
+		}
+		a.getInputs().add(eo.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, v1);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitVariableExpr(VariableExpr v, Mutable<ILogicalOperator> tupSource) {
-        // Should we ever get to this method?
-        LogicalVariable var = context.newVar();
-        LogicalVariable oldV = context.getVar(v.getVar().getId());
-        AssignOperator a = new AssignOperator(var, new MutableObject<ILogicalExpression>(
-                new VariableReferenceExpression(oldV)));
-        a.getInputs().add(tupSource);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, var);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitVariableExpr(
+			VariableExpr v, Mutable<ILogicalOperator> tupSource) {
+		// Should we ever get to this method?
+		LogicalVariable var = context.newVar();
+		LogicalVariable oldV = context.getVar(v.getVar().getId());
+		AssignOperator a = new AssignOperator(var,
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(oldV)));
+		a.getInputs().add(tupSource);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, var);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWhereClause(WhereClause w, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(w.getWhereExpr(), tupSource);
-        SelectOperator s = new SelectOperator(new MutableObject<ILogicalExpression>(p.first));
-        s.getInputs().add(p.second);
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWhereClause(
+			WhereClause w, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+				w.getWhereExpr(), tupSource);
+		SelectOperator s = new SelectOperator(
+				new MutableObject<ILogicalExpression>(p.first));
+		s.getInputs().add(p.second);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(s, null);
-    }
+		return new Pair<ILogicalOperator, LogicalVariable>(s, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLimitClause(LimitClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getLimitExpr(), tupSource);
-        LimitOperator opLim;
-        Expression offset = lc.getOffset();
-        if (offset != null) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = aqlExprToAlgExpression(offset, p1.second);
-            opLim = new LimitOperator(p1.first, p2.first);
-            opLim.getInputs().add(p2.second);
-        } else {
-            opLim = new LimitOperator(p1.first);
-            opLim.getInputs().add(p1.second);
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(opLim, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLimitClause(
+			LimitClause lc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(
+				lc.getLimitExpr(), tupSource);
+		LimitOperator opLim;
+		Expression offset = lc.getOffset();
+		if (offset != null) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = aqlExprToAlgExpression(
+					offset, p1.second);
+			opLim = new LimitOperator(p1.first, p2.first);
+			opLim.getInputs().add(p2.second);
+		} else {
+			opLim = new LimitOperator(p1.first);
+			opLim.getInputs().add(p1.second);
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(opLim, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getDieExpr(), tupSource);
-        DieOperator opDie = new DieOperator(p1.first);
-        opDie.getInputs().add(p1.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc,
+			Mutable<ILogicalOperator> tupSource) throws AsterixException {
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(
+				lc.getDieExpr(), tupSource);
+		DieOperator opDie = new DieOperator(p1.first);
+		opDie.getInputs().add(p1.second);
+		return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(DistinctClause dc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
-        Mutable<ILogicalOperator> input = null;
-        for (Expression expr : dc.getDistinctByExpr()) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(expr, tupSource);
-            exprList.add(new MutableObject<ILogicalExpression>(p.first));
-            input = p.second;
-        }
-        DistinctOperator opDistinct = new DistinctOperator(exprList);
-        opDistinct.getInputs().add(input);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDistinct, null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(
+			DistinctClause dc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
+		Mutable<ILogicalOperator> input = null;
+		for (Expression expr : dc.getDistinctByExpr()) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					expr, tupSource);
+			exprList.add(new MutableObject<ILogicalExpression>(p.first));
+			input = p.second;
+		}
+		DistinctOperator opDistinct = new DistinctOperator(exprList);
+		opDistinct.getInputs().add(input);
+		return new Pair<ILogicalOperator, LogicalVariable>(opDistinct, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnionExpr(UnionExpr unionExpr,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        Mutable<ILogicalOperator> ts = tupSource;
-        ILogicalOperator lastOp = null;
-        LogicalVariable lastVar = null;
-        boolean first = true;
-        for (Expression e : unionExpr.getExprs()) {
-            if (first) {
-                first = false;
-            } else {
-                ts = new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator());
-            }
-            Pair<ILogicalOperator, LogicalVariable> p1 = e.accept(this, ts);
-            if (lastOp == null) {
-                lastOp = p1.first;
-                lastVar = p1.second;
-            } else {
-                LogicalVariable unnestVar1 = context.newVar();
-                UnnestOperator unnest1 = new UnnestOperator(unnestVar1, new MutableObject<ILogicalExpression>(
-                        makeUnnestExpression(new VariableReferenceExpression(lastVar))));
-                unnest1.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
-                LogicalVariable unnestVar2 = context.newVar();
-                UnnestOperator unnest2 = new UnnestOperator(unnestVar2, new MutableObject<ILogicalExpression>(
-                        makeUnnestExpression(new VariableReferenceExpression(p1.second))));
-                unnest2.getInputs().add(new MutableObject<ILogicalOperator>(p1.first));
-                List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>(
-                        1);
-                LogicalVariable resultVar = context.newVar();
-                Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(
-                        unnestVar1, unnestVar2, resultVar);
-                varMap.add(triple);
-                UnionAllOperator unionOp = new UnionAllOperator(varMap);
-                unionOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest1));
-                unionOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest2));
-                lastVar = resultVar;
-                lastOp = unionOp;
-            }
-        }
-        LogicalVariable aggVar = context.newVar();
-        ArrayList<LogicalVariable> aggregVars = new ArrayList<LogicalVariable>(1);
-        aggregVars.add(aggVar);
-        List<Mutable<ILogicalExpression>> afcExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
-        afcExprs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lastVar)));
-        AggregateFunctionCallExpression afc = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                AsterixBuiltinFunctions.LISTIFY, afcExprs);
-        ArrayList<Mutable<ILogicalExpression>> aggregExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
-        aggregExprs.add(new MutableObject<ILogicalExpression>(afc));
-        AggregateOperator agg = new AggregateOperator(aggregVars, aggregExprs);
-        agg.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
-        return new Pair<ILogicalOperator, LogicalVariable>(agg, aggVar);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnionExpr(
+			UnionExpr unionExpr, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		Mutable<ILogicalOperator> ts = tupSource;
+		ILogicalOperator lastOp = null;
+		LogicalVariable lastVar = null;
+		boolean first = true;
+		for (Expression e : unionExpr.getExprs()) {
+			if (first) {
+				first = false;
+			} else {
+				ts = new MutableObject<ILogicalOperator>(
+						new EmptyTupleSourceOperator());
+			}
+			Pair<ILogicalOperator, LogicalVariable> p1 = e.accept(this, ts);
+			if (lastOp == null) {
+				lastOp = p1.first;
+				lastVar = p1.second;
+			} else {
+				LogicalVariable unnestVar1 = context.newVar();
+				UnnestOperator unnest1 = new UnnestOperator(
+						unnestVar1,
+						new MutableObject<ILogicalExpression>(
+								makeUnnestExpression(new VariableReferenceExpression(
+										lastVar))));
+				unnest1.getInputs().add(
+						new MutableObject<ILogicalOperator>(lastOp));
+				LogicalVariable unnestVar2 = context.newVar();
+				UnnestOperator unnest2 = new UnnestOperator(
+						unnestVar2,
+						new MutableObject<ILogicalExpression>(
+								makeUnnestExpression(new VariableReferenceExpression(
+										p1.second))));
+				unnest2.getInputs().add(
+						new MutableObject<ILogicalOperator>(p1.first));
+				List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>(
+						1);
+				LogicalVariable resultVar = context.newVar();
+				Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(
+						unnestVar1, unnestVar2, resultVar);
+				varMap.add(triple);
+				UnionAllOperator unionOp = new UnionAllOperator(varMap);
+				unionOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(unnest1));
+				unionOp.getInputs().add(
+						new MutableObject<ILogicalOperator>(unnest2));
+				lastVar = resultVar;
+				lastOp = unionOp;
+			}
+		}
+		LogicalVariable aggVar = context.newVar();
+		ArrayList<LogicalVariable> aggregVars = new ArrayList<LogicalVariable>(
+				1);
+		aggregVars.add(aggVar);
+		List<Mutable<ILogicalExpression>> afcExprs = new ArrayList<Mutable<ILogicalExpression>>(
+				1);
+		afcExprs.add(new MutableObject<ILogicalExpression>(
+				new VariableReferenceExpression(lastVar)));
+		AggregateFunctionCallExpression afc = AsterixBuiltinFunctions
+				.makeAggregateFunctionExpression(
+						AsterixBuiltinFunctions.LISTIFY, afcExprs);
+		ArrayList<Mutable<ILogicalExpression>> aggregExprs = new ArrayList<Mutable<ILogicalExpression>>(
+				1);
+		aggregExprs.add(new MutableObject<ILogicalExpression>(afc));
+		AggregateOperator agg = new AggregateOperator(aggregVars, aggregExprs);
+		agg.getInputs().add(new MutableObject<ILogicalOperator>(lastOp));
+		return new Pair<ILogicalOperator, LogicalVariable>(agg, aggVar);
+	}
 
-    private AbstractFunctionCallExpression createComparisonExpression(OperatorType t) {
-        FunctionIdentifier fi = operatorTypeToFunctionIdentifier(t);
-        IFunctionInfo finfo = FunctionUtils.getFunctionInfo(fi);
-        return new ScalarFunctionCallExpression(finfo);
-    }
+	private AbstractFunctionCallExpression createComparisonExpression(
+			OperatorType t) {
+		FunctionIdentifier fi = operatorTypeToFunctionIdentifier(t);
+		IFunctionInfo finfo = FunctionUtils.getFunctionInfo(fi);
+		return new ScalarFunctionCallExpression(finfo);
+	}
 
-    private FunctionIdentifier operatorTypeToFunctionIdentifier(OperatorType t) {
-        switch (t) {
-            case EQ: {
-                return AlgebricksBuiltinFunctions.EQ;
-            }
-            case NEQ: {
-                return AlgebricksBuiltinFunctions.NEQ;
-            }
-            case GT: {
-                return AlgebricksBuiltinFunctions.GT;
-            }
-            case GE: {
-                return AlgebricksBuiltinFunctions.GE;
-            }
-            case LT: {
-                return AlgebricksBuiltinFunctions.LT;
-            }
-            case LE: {
-                return AlgebricksBuiltinFunctions.LE;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
-        }
-    }
+	private FunctionIdentifier operatorTypeToFunctionIdentifier(OperatorType t) {
+		switch (t) {
+		case EQ: {
+			return AlgebricksBuiltinFunctions.EQ;
+		}
+		case NEQ: {
+			return AlgebricksBuiltinFunctions.NEQ;
+		}
+		case GT: {
+			return AlgebricksBuiltinFunctions.GT;
+		}
+		case GE: {
+			return AlgebricksBuiltinFunctions.GE;
+		}
+		case LT: {
+			return AlgebricksBuiltinFunctions.LT;
+		}
+		case LE: {
+			return AlgebricksBuiltinFunctions.LE;
+		}
+		default: {
+			throw new IllegalStateException();
+		}
+		}
+	}
 
-    private AbstractFunctionCallExpression createFunctionCallExpressionForBuiltinOperator(OperatorType t)
-            throws AsterixException {
+	private AbstractFunctionCallExpression createFunctionCallExpressionForBuiltinOperator(
+			OperatorType t) throws AsterixException {
 
-        FunctionIdentifier fid = null;
-        switch (t) {
-            case PLUS: {
-                fid = AlgebricksBuiltinFunctions.NUMERIC_ADD;
-                break;
-            }
-            case MINUS: {
-                fid = AsterixBuiltinFunctions.NUMERIC_SUBTRACT;
-                break;
-            }
-            case MUL: {
-                fid = AsterixBuiltinFunctions.NUMERIC_MULTIPLY;
-                break;
-            }
-            case DIV: {
-                fid = AsterixBuiltinFunctions.NUMERIC_DIVIDE;
-                break;
-            }
-            case MOD: {
-                fid = AsterixBuiltinFunctions.NUMERIC_MOD;
-                break;
-            }
-            case IDIV: {
-                fid = AsterixBuiltinFunctions.NUMERIC_IDIV;
-                break;
-            }
-            case CARET: {
-                fid = AsterixBuiltinFunctions.CARET;
-                break;
-            }
-            case AND: {
-                fid = AlgebricksBuiltinFunctions.AND;
-                break;
-            }
-            case OR: {
-                fid = AlgebricksBuiltinFunctions.OR;
-                break;
-            }
-            case FUZZY_EQ: {
-                fid = AsterixBuiltinFunctions.FUZZY_EQ;
-                break;
-            }
+		FunctionIdentifier fid = null;
+		switch (t) {
+		case PLUS: {
+			fid = AlgebricksBuiltinFunctions.NUMERIC_ADD;
+			break;
+		}
+		case MINUS: {
+			fid = AsterixBuiltinFunctions.NUMERIC_SUBTRACT;
+			break;
+		}
+		case MUL: {
+			fid = AsterixBuiltinFunctions.NUMERIC_MULTIPLY;
+			break;
+		}
+		case DIV: {
+			fid = AsterixBuiltinFunctions.NUMERIC_DIVIDE;
+			break;
+		}
+		case MOD: {
+			fid = AsterixBuiltinFunctions.NUMERIC_MOD;
+			break;
+		}
+		case IDIV: {
+			fid = AsterixBuiltinFunctions.NUMERIC_IDIV;
+			break;
+		}
+		case CARET: {
+			fid = AsterixBuiltinFunctions.CARET;
+			break;
+		}
+		case AND: {
+			fid = AlgebricksBuiltinFunctions.AND;
+			break;
+		}
+		case OR: {
+			fid = AlgebricksBuiltinFunctions.OR;
+			break;
+		}
+		case FUZZY_EQ: {
+			fid = AsterixBuiltinFunctions.FUZZY_EQ;
+			break;
+		}
 
-            default: {
-                throw new NotImplementedException("Operator " + t + " is not yet implemented");
-            }
-        }
-        return new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(fid));
-    }
+		default: {
+			throw new NotImplementedException("Operator " + t
+					+ " is not yet implemented");
+		}
+		}
+		return new ScalarFunctionCallExpression(
+				FunctionUtils.getFunctionInfo(fid));
+	}
 
-    private static boolean hasOnlyChild(ILogicalOperator parent, Mutable<ILogicalOperator> childCandidate) {
-        List<Mutable<ILogicalOperator>> inp = parent.getInputs();
-        if (inp == null || inp.size() != 1) {
-            return false;
-        }
-        return inp.get(0) == childCandidate;
-    }
+	private static boolean hasOnlyChild(ILogicalOperator parent,
+			Mutable<ILogicalOperator> childCandidate) {
+		List<Mutable<ILogicalOperator>> inp = parent.getInputs();
+		if (inp == null || inp.size() != 1) {
+			return false;
+		}
+		return inp.get(0) == childCandidate;
+	}
 
-    private Pair<ILogicalExpression, Mutable<ILogicalOperator>> aqlExprToAlgExpression(Expression expr,
-            Mutable<ILogicalOperator> topOp) throws AsterixException {
-        switch (expr.getKind()) {
-            case VARIABLE_EXPRESSION: {
-                VariableReferenceExpression ve = new VariableReferenceExpression(context.getVar(((VariableExpr) expr)
-                        .getVar().getId()));
-                return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(ve, topOp);
-            }
-            case METAVARIABLE_EXPRESSION: {
-                ILogicalExpression le = metaScopeExp.getVariableReferenceExpression(((VariableExpr) expr).getVar());
-                return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(le, topOp);
-            }
-            case LITERAL_EXPRESSION: {
-                LiteralExpr val = (LiteralExpr) expr;
-                return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new ConstantExpression(
-                        new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue()))), topOp);
-            }
-            default: {
-                // Mutable<ILogicalExpression> src = new
-                // Mutable<ILogicalExpression>();
-                // Mutable<ILogicalExpression> src = topOp;
-                if (expressionNeedsNoNesting(expr)) {
-                    Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, topOp);
-                    ILogicalExpression exp = ((AssignOperator) p.first).getExpressions().get(0).getValue();
-                    return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(exp, p.first.getInputs().get(0));
-                } else {
-                    Mutable<ILogicalOperator> src = new MutableObject<ILogicalOperator>();
+	private Pair<ILogicalExpression, Mutable<ILogicalOperator>> aqlExprToAlgExpression(
+			Expression expr, Mutable<ILogicalOperator> topOp)
+			throws AsterixException {
+		switch (expr.getKind()) {
+		case VARIABLE_EXPRESSION: {
+			VariableReferenceExpression ve = new VariableReferenceExpression(
+					context.getVar(((VariableExpr) expr).getVar().getId()));
+			return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(ve,
+					topOp);
+		}
+		case METAVARIABLE_EXPRESSION: {
+			ILogicalExpression le = metaScopeExp
+					.getVariableReferenceExpression(((VariableExpr) expr)
+							.getVar());
+			return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(le,
+					topOp);
+		}
+		case LITERAL_EXPRESSION: {
+			LiteralExpr val = (LiteralExpr) expr;
+			return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+					new ConstantExpression(new AsterixConstantValue(
+							ConstantHelper.objectFromLiteral(val.getValue()))),
+					topOp);
+		}
+		default: {
+			// Mutable<ILogicalExpression> src = new
+			// Mutable<ILogicalExpression>();
+			// Mutable<ILogicalExpression> src = topOp;
+			if (expressionNeedsNoNesting(expr)) {
+				Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+						topOp);
+				ILogicalExpression exp = ((AssignOperator) p.first)
+						.getExpressions().get(0).getValue();
+				return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+						exp, p.first.getInputs().get(0));
+			} else {
+				Mutable<ILogicalOperator> src = new MutableObject<ILogicalOperator>();
 
-                    Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this, src);
+				Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
+						src);
 
-                    if (((AbstractLogicalOperator) p.first).getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
-                        // src.setOperator(topOp.getOperator());
-                        Mutable<ILogicalOperator> top2 = new MutableObject<ILogicalOperator>(p.first);
-                        return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new VariableReferenceExpression(
-                                p.second), top2);
-                    } else {
-                        SubplanOperator s = new SubplanOperator();
-                        s.getInputs().add(topOp);
-                        src.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
-                        Mutable<ILogicalOperator> planRoot = new MutableObject<ILogicalOperator>(p.first);
-                        s.setRootOp(planRoot);
-                        return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(new VariableReferenceExpression(
-                                p.second), new MutableObject<ILogicalOperator>(s));
-                    }
-                }
-            }
-        }
+				if (((AbstractLogicalOperator) p.first).getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
+					// src.setOperator(topOp.getOperator());
+					Mutable<ILogicalOperator> top2 = new MutableObject<ILogicalOperator>(
+							p.first);
+					return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+							new VariableReferenceExpression(p.second), top2);
+				} else {
+					SubplanOperator s = new SubplanOperator();
+					s.getInputs().add(topOp);
+					src.setValue(new NestedTupleSourceOperator(
+							new MutableObject<ILogicalOperator>(s)));
+					Mutable<ILogicalOperator> planRoot = new MutableObject<ILogicalOperator>(
+							p.first);
+					s.setRootOp(planRoot);
+					return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(
+							new VariableReferenceExpression(p.second),
+							new MutableObject<ILogicalOperator>(s));
+				}
+			}
+		}
+		}
 
-    }
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> produceFlwrResult(boolean noForClause, boolean isTop,
-            Mutable<ILogicalOperator> resOpRef, LogicalVariable resVar) {
-        if (isTop) {
-            ProjectOperator pr = new ProjectOperator(resVar);
-            pr.getInputs().add(resOpRef);
-            return new Pair<ILogicalOperator, LogicalVariable>(pr, resVar);
+	private Pair<ILogicalOperator, LogicalVariable> produceFlwrResult(
+			boolean noForClause, boolean isTop,
+			Mutable<ILogicalOperator> resOpRef, LogicalVariable resVar) {
+		if (isTop) {
+			ProjectOperator pr = new ProjectOperator(resVar);
+			pr.getInputs().add(resOpRef);
+			return new Pair<ILogicalOperator, LogicalVariable>(pr, resVar);
 
-        } else if (noForClause) {
-            return new Pair<ILogicalOperator, LogicalVariable>(resOpRef.getValue(), resVar);
-        } else {
-            return aggListify(resVar, resOpRef, false);
-        }
-    }
+		} else if (noForClause) {
+			return new Pair<ILogicalOperator, LogicalVariable>(
+					resOpRef.getValue(), resVar);
+		} else {
+			return aggListify(resVar, resOpRef, false);
+		}
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> aggListify(LogicalVariable var, Mutable<ILogicalOperator> opRef,
-            boolean bProject) {
-        AggregateFunctionCallExpression funAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                AsterixBuiltinFunctions.LISTIFY, new ArrayList<Mutable<ILogicalExpression>>());
-        funAgg.getArguments().add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
-        LogicalVariable varListified = context.newVar();
-        AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(varListified),
-                (List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(funAgg)));
-        agg.getInputs().add(opRef);
-        ILogicalOperator res;
-        if (bProject) {
-            ProjectOperator pr = new ProjectOperator(varListified);
-            pr.getInputs().add(new MutableObject<ILogicalOperator>(agg));
-            res = pr;
-        } else {
-            res = agg;
-        }
-        return new Pair<ILogicalOperator, LogicalVariable>(res, varListified);
-    }
+	private Pair<ILogicalOperator, LogicalVariable> aggListify(
+			LogicalVariable var, Mutable<ILogicalOperator> opRef,
+			boolean bProject) {
+		AggregateFunctionCallExpression funAgg = AsterixBuiltinFunctions
+				.makeAggregateFunctionExpression(
+						AsterixBuiltinFunctions.LISTIFY,
+						new ArrayList<Mutable<ILogicalExpression>>());
+		funAgg.getArguments().add(
+				new MutableObject<ILogicalExpression>(
+						new VariableReferenceExpression(var)));
+		LogicalVariable varListified = context.newVar();
+		AggregateOperator agg = new AggregateOperator(
+				mkSingletonArrayList(varListified),
+				(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(
+						funAgg)));
+		agg.getInputs().add(opRef);
+		ILogicalOperator res;
+		if (bProject) {
+			ProjectOperator pr = new ProjectOperator(varListified);
+			pr.getInputs().add(new MutableObject<ILogicalOperator>(agg));
+			res = pr;
+		} else {
+			res = agg;
+		}
+		return new Pair<ILogicalOperator, LogicalVariable>(res, varListified);
+	}
 
-    private Pair<ILogicalOperator, LogicalVariable> visitAndOrOperator(OperatorExpr op,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        ArrayList<OperatorType> ops = op.getOpList();
-        int nOps = ops.size();
+	private Pair<ILogicalOperator, LogicalVariable> visitAndOrOperator(
+			OperatorExpr op, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		ArrayList<OperatorType> ops = op.getOpList();
+		int nOps = ops.size();
 
-        ArrayList<Expression> exprs = op.getExprList();
+		ArrayList<Expression> exprs = op.getExprList();
 
-        Mutable<ILogicalOperator> topOp = tupSource;
+		Mutable<ILogicalOperator> topOp = tupSource;
 
-        OperatorType opLogical = ops.get(0);
-        AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(opLogical);
+		OperatorType opLogical = ops.get(0);
+		AbstractFunctionCallExpression f = createFunctionCallExpressionForBuiltinOperator(opLogical);
 
-        for (int i = 0; i <= nOps; i++) {
-            Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(exprs.get(i), topOp);
-            topOp = p.second;
-            // now look at the operator
-            if (i < nOps) {
-                if (ops.get(i) != opLogical) {
-                    throw new TranslationException("Unexpected operator " + ops.get(i)
-                            + " in an OperatorExpr starting with " + opLogical);
-                }
-            }
-            f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
-        }
+		for (int i = 0; i <= nOps; i++) {
+			Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = aqlExprToAlgExpression(
+					exprs.get(i), topOp);
+			topOp = p.second;
+			// now look at the operator
+			if (i < nOps) {
+				if (ops.get(i) != opLogical) {
+					throw new TranslationException("Unexpected operator "
+							+ ops.get(i) + " in an OperatorExpr starting with "
+							+ opLogical);
+				}
+			}
+			f.getArguments()
+					.add(new MutableObject<ILogicalExpression>(p.first));
+		}
 
-        LogicalVariable assignedVar = context.newVar();
-        AssignOperator a = new AssignOperator(assignedVar, new MutableObject<ILogicalExpression>(f));
-        a.getInputs().add(topOp);
+		LogicalVariable assignedVar = context.newVar();
+		AssignOperator a = new AssignOperator(assignedVar,
+				new MutableObject<ILogicalExpression>(f));
+		a.getInputs().add(topOp);
 
-        return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, assignedVar);
 
-    }
+	}
 
-    private static boolean expressionNeedsNoNesting(Expression expr) {
-        Kind k = expr.getKind();
-        return k == Kind.LITERAL_EXPRESSION || k == Kind.LIST_CONSTRUCTOR_EXPRESSION
-                || k == Kind.RECORD_CONSTRUCTOR_EXPRESSION || k == Kind.VARIABLE_EXPRESSION
-                || k == Kind.CALL_EXPRESSION || k == Kind.OP_EXPRESSION || k == Kind.FIELD_ACCESSOR_EXPRESSION
-                || k == Kind.INDEX_ACCESSOR_EXPRESSION || k == Kind.UNARY_EXPRESSION;
-    }
+	private static boolean expressionNeedsNoNesting(Expression expr) {
+		Kind k = expr.getKind();
+		return k == Kind.LITERAL_EXPRESSION
+				|| k == Kind.LIST_CONSTRUCTOR_EXPRESSION
+				|| k == Kind.RECORD_CONSTRUCTOR_EXPRESSION
+				|| k == Kind.VARIABLE_EXPRESSION || k == Kind.CALL_EXPRESSION
+				|| k == Kind.OP_EXPRESSION
+				|| k == Kind.FIELD_ACCESSOR_EXPRESSION
+				|| k == Kind.INDEX_ACCESSOR_EXPRESSION
+				|| k == Kind.UNARY_EXPRESSION;
+	}
 
-    private <T> ArrayList<T> mkSingletonArrayList(T item) {
-        ArrayList<T> array = new ArrayList<T>(1);
-        array.add(item);
-        return array;
-    }
+	private <T> ArrayList<T> mkSingletonArrayList(T item) {
+		ArrayList<T> array = new ArrayList<T>(1);
+		array.add(item);
+		return array;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeDecl(TypeDecl td, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeDecl(TypeDecl td,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitRecordTypeDefiniton(RecordTypeDefinition tre,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitRecordTypeDefiniton(
+			RecordTypeDefinition tre, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeReferenceExpression(TypeReferenceExpression tre,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeReferenceExpression(
+			TypeReferenceExpression tre, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitNodegroupDecl(NodegroupDecl ngd, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitNodegroupDecl(
+			NodegroupDecl ngd, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromFileStatement(LoadFromFileStatement stmtLoad,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLoadFromFileStatement(
+			LoadFromFileStatement stmtLoad, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWriteFromQueryResultStatement(
+			WriteFromQueryResultStatement stmtLoad,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(DropStatement del, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDropStatement(
+			DropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCreateIndexStatement(CreateIndexStatement cis,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCreateIndexStatement(
+			CreateIndexStatement cis, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitOrderedListTypeDefiniton(OrderedListTypeDefinition olte,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitOrderedListTypeDefiniton(
+			OrderedListTypeDefinition olte, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUnorderedListTypeDefiniton(UnorderedListTypeDefinition ulte,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUnorderedListTypeDefiniton(
+			UnorderedListTypeDefinition ulte, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitMetaVariableClause(MetaVariableClause mc,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        return new Pair<ILogicalOperator, LogicalVariable>(metaScopeOp.get(mc.getVar()), null);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitMetaVariableClause(
+			MetaVariableClause mc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		return new Pair<ILogicalOperator, LogicalVariable>(metaScopeOp.get(mc
+				.getVar()), null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitJoinClause(JoinClause jc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        // Pair<ILogicalOperator, LogicalVariable> leftSide =
-        // jc.getLeftExpr().accept(this, tupSource);
-        Mutable<ILogicalOperator> opRef = tupSource;
-        Pair<ILogicalOperator, LogicalVariable> leftSide = null;
-        for (Clause c : jc.getLeftClauses()) {
-            leftSide = c.accept(this, opRef);
-            opRef = new MutableObject<ILogicalOperator>(leftSide.first);
-        }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitJoinClause(
+			JoinClause jc, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		// Pair<ILogicalOperator, LogicalVariable> leftSide =
+		// jc.getLeftExpr().accept(this, tupSource);
+		Mutable<ILogicalOperator> opRef = tupSource;
+		Pair<ILogicalOperator, LogicalVariable> leftSide = null;
+		for (Clause c : jc.getLeftClauses()) {
+			leftSide = c.accept(this, opRef);
+			opRef = new MutableObject<ILogicalOperator>(leftSide.first);
+		}
 
-        // Pair<ILogicalOperator, LogicalVariable> rightSide =
-        // jc.getRightExpr().accept(this, tupSource);
-        opRef = tupSource;
-        Pair<ILogicalOperator, LogicalVariable> rightSide = null;
-        for (Clause c : jc.getRightClauses()) {
-            rightSide = c.accept(this, opRef);
-            opRef = new MutableObject<ILogicalOperator>(rightSide.first);
-        }
+		// Pair<ILogicalOperator, LogicalVariable> rightSide =
+		// jc.getRightExpr().accept(this, tupSource);
+		opRef = tupSource;
+		Pair<ILogicalOperator, LogicalVariable> rightSide = null;
+		for (Clause c : jc.getRightClauses()) {
+			rightSide = c.accept(this, opRef);
+			opRef = new MutableObject<ILogicalOperator>(rightSide.first);
+		}
 
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> whereCond = aqlExprToAlgExpression(jc.getWhereExpr(),
-                tupSource);
+		Pair<ILogicalExpression, Mutable<ILogicalOperator>> whereCond = aqlExprToAlgExpression(
+				jc.getWhereExpr(), tupSource);
 
-        AbstractBinaryJoinOperator join;
-        switch (jc.getKind()) {
-            case INNER: {
-                join = new InnerJoinOperator(new MutableObject<ILogicalExpression>(whereCond.first));
-                break;
-            }
-            case LEFT_OUTER: {
-                join = new LeftOuterJoinOperator(new MutableObject<ILogicalExpression>(whereCond.first));
-                break;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
-        }
-        join.getInputs().add(new MutableObject<ILogicalOperator>(leftSide.first));
-        join.getInputs().add(new MutableObject<ILogicalOperator>(rightSide.first));
-        return new Pair<ILogicalOperator, LogicalVariable>(join, null);
-    }
+		AbstractBinaryJoinOperator join;
+		switch (jc.getKind()) {
+		case INNER: {
+			join = new InnerJoinOperator(new MutableObject<ILogicalExpression>(
+					whereCond.first));
+			break;
+		}
+		case LEFT_OUTER: {
+			join = new LeftOuterJoinOperator(
+					new MutableObject<ILogicalExpression>(whereCond.first));
+			break;
+		}
+		default: {
+			throw new IllegalStateException();
+		}
+		}
+		join.getInputs().add(
+				new MutableObject<ILogicalOperator>(leftSide.first));
+		join.getInputs().add(
+				new MutableObject<ILogicalOperator>(rightSide.first));
+		return new Pair<ILogicalOperator, LogicalVariable>(join, null);
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitMetaVariableExpr(MetaVariableExpr me,
-            Mutable<ILogicalOperator> tupSource) throws AsterixException {
-        LogicalVariable var = context.newVar();
-        AssignOperator a = new AssignOperator(var, new MutableObject<ILogicalExpression>(
-                metaScopeExp.getVariableReferenceExpression(me.getVar())));
-        a.getInputs().add(tupSource);
-        return new Pair<ILogicalOperator, LogicalVariable>(a, var);
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitMetaVariableExpr(
+			MetaVariableExpr me, Mutable<ILogicalOperator> tupSource)
+			throws AsterixException {
+		LogicalVariable var = context.newVar();
+		AssignOperator a = new AssignOperator(var,
+				new MutableObject<ILogicalExpression>(metaScopeExp
+						.getVariableReferenceExpression(me.getVar())));
+		a.getInputs().add(tupSource);
+		return new Pair<ILogicalOperator, LogicalVariable>(a, var);
+	}
 
-    public void addOperatorToMetaScope(Identifier id, ILogicalOperator op) {
-        metaScopeOp.put(id, op);
-    }
+	public void addOperatorToMetaScope(Identifier id, ILogicalOperator op) {
+		metaScopeOp.put(id, op);
+	}
 
-    public void addVariableToMetaScope(Identifier id, LogicalVariable var) {
-        metaScopeExp.put(id, var);
-    }
+	public void addVariableToMetaScope(Identifier id, LogicalVariable var) {
+		metaScopeExp.put(id, var);
+	}
 
-    private ILogicalExpression makeUnnestExpression(ILogicalExpression expr) {
-        switch (expr.getExpressionTag()) {
-            case VARIABLE: {
-                return new UnnestingFunctionCallExpression(
-                        FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
-                        new MutableObject<ILogicalExpression>(expr));
-            }
-            case FUNCTION_CALL: {
-                AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
-                if (fce.getKind() == FunctionKind.UNNEST) {
-                    return expr;
-                } else {
-                    return new UnnestingFunctionCallExpression(
-                            FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
-                            new MutableObject<ILogicalExpression>(expr));
-                }
-            }
-            default: {
-                return expr;
-            }
-        }
-    }
+	private ILogicalExpression makeUnnestExpression(ILogicalExpression expr) {
+		switch (expr.getExpressionTag()) {
+		case VARIABLE: {
+			return new UnnestingFunctionCallExpression(
+					FunctionUtils
+							.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
+					new MutableObject<ILogicalExpression>(expr));
+		}
+		case FUNCTION_CALL: {
+			AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
+			if (fce.getKind() == FunctionKind.UNNEST) {
+				return expr;
+			} else {
+				return new UnnestingFunctionCallExpression(
+						FunctionUtils
+								.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION),
+						new MutableObject<ILogicalExpression>(expr));
+			}
+		}
+		default: {
+			return expr;
+		}
+		}
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitInsertStatement(InsertStatement insert,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitInsertStatement(
+			InsertStatement insert, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDeleteStatement(DeleteStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDeleteStatement(
+			DeleteStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUpdateStatement(UpdateStatement update,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUpdateStatement(
+			UpdateStatement update, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitUpdateClause(UpdateClause del, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitUpdateClause(
+			UpdateClause del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDataverseDecl(DataverseDecl dv, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDataverseDecl(
+			DataverseDecl dv, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDatasetDecl(DatasetDecl dd, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDatasetDecl(
+			DatasetDecl dd, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitSetStatement(SetStatement ss, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitSetStatement(
+			SetStatement ss, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitWriteStatement(WriteStatement ws, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitWriteStatement(
+			WriteStatement ws, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
-            WriteFromQueryResultStatement stmtLoad, Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitLoadFromQueryResultStatement(
+			WriteFromQueryResultStatement stmtLoad,
+			Mutable<ILogicalOperator> arg) throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(CreateDataverseStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitCreateDataverseStatement(
+			CreateDataverseStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitIndexDropStatement(IndexDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitIndexDropStatement(
+			IndexDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitNodeGroupDropStatement(NodeGroupDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitNodeGroupDropStatement(
+			NodeGroupDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDataverseDropStatement(DataverseDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitDataverseDropStatement(
+			DataverseDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitTypeDropStatement(TypeDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitTypeDropStatement(
+			TypeDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitControlFeedStatement(ControlFeedStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitControlFeedStatement(
+			ControlFeedStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visit(CreateFunctionStatement cfs, Mutable<ILogicalOperator> arg)
-            throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visit(
+			CreateFunctionStatement cfs, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitFunctionDropStatement(FunctionDropStatement del,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitFunctionDropStatement(
+			FunctionDropStatement del, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 
-    @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitBeginFeedStatement(BeginFeedStatement bf,
-            Mutable<ILogicalOperator> arg) throws AsterixException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	@Override
+	public Pair<ILogicalOperator, LogicalVariable> visitBeginFeedStatement(
+			BeginFeedStatement bf, Mutable<ILogicalOperator> arg)
+			throws AsterixException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/DdlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/DdlTranslator.java
index dc3fb25..c68817c 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/DdlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/DdlTranslator.java
@@ -93,922 +93,1090 @@
 
 public class DdlTranslator extends AbstractAqlTranslator {
 
-    private final MetadataTransactionContext mdTxnCtx;
-    private final List<Statement> aqlStatements;
-    private final PrintWriter out;
-    private final SessionConfig pc;
-    private final DisplayFormat pdf;
-    private AqlCompiledMetadataDeclarations compiledDeclarations;
+	private final MetadataTransactionContext mdTxnCtx;
+	private final List<Statement> aqlStatements;
+	private final PrintWriter out;
+	private final SessionConfig pc;
+	private final DisplayFormat pdf;
+	private AqlCompiledMetadataDeclarations compiledDeclarations;
 
-    private static Map<String, BuiltinType> builtinTypeMap;
+	private static Map<String, BuiltinType> builtinTypeMap;
 
-    public DdlTranslator(MetadataTransactionContext mdTxnCtx, List<Statement> aqlStatements, PrintWriter out,
-            SessionConfig pc, DisplayFormat pdf) {
-        this.mdTxnCtx = mdTxnCtx;
-        this.aqlStatements = aqlStatements;
-        this.out = out;
-        this.pc = pc;
-        this.pdf = pdf;
-        builtinTypeMap = AsterixBuiltinTypeMap.getBuiltinTypes();
-    }
+	public DdlTranslator(MetadataTransactionContext mdTxnCtx,
+			List<Statement> aqlStatements, PrintWriter out, SessionConfig pc,
+			DisplayFormat pdf) {
+		this.mdTxnCtx = mdTxnCtx;
+		this.aqlStatements = aqlStatements;
+		this.out = out;
+		this.pc = pc;
+		this.pdf = pdf;
+		builtinTypeMap = AsterixBuiltinTypeMap.getBuiltinTypes();
+	}
 
-    public void translate(IHyracksClientConnection hcc, boolean disconnectFromDataverse) throws AlgebricksException {
-        try {
-            compiledDeclarations = compileMetadata(mdTxnCtx, aqlStatements, true);
-            compileAndExecuteDDLstatements(hcc, mdTxnCtx, disconnectFromDataverse);
-        } catch (Exception e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	public void translate(IHyracksClientConnection hcc,
+			boolean disconnectFromDataverse) throws AlgebricksException {
+		try {
+			compiledDeclarations = compileMetadata(mdTxnCtx, aqlStatements,
+					true);
+			compileAndExecuteDDLstatements(hcc, mdTxnCtx,
+					disconnectFromDataverse);
+		} catch (Exception e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    private void compileAndExecuteDDLstatements(IHyracksClientConnection hcc, MetadataTransactionContext mdTxnCtx,
-            boolean disconnectFromDataverse) throws Exception {
-        for (Statement stmt : aqlStatements) {
-            validateOperation(compiledDeclarations, stmt);
-            switch (stmt.getKind()) {
-                case DATAVERSE_DECL: {
-                    checkForDataverseConnection(false);
-                    DataverseDecl dvd = (DataverseDecl) stmt;
-                    String dataverseName = dvd.getDataverseName().getValue();
-                    compiledDeclarations.connectToDataverse(dataverseName);
-                    break;
-                }
+	private void compileAndExecuteDDLstatements(IHyracksClientConnection hcc,
+			MetadataTransactionContext mdTxnCtx, boolean disconnectFromDataverse)
+			throws Exception {
+		for (Statement stmt : aqlStatements) {
+			validateOperation(compiledDeclarations, stmt);
+			switch (stmt.getKind()) {
+			case DATAVERSE_DECL: {
+				checkForDataverseConnection(false);
+				DataverseDecl dvd = (DataverseDecl) stmt;
+				String dataverseName = dvd.getDataverseName().getValue();
+				compiledDeclarations.connectToDataverse(dataverseName);
+				break;
+			}
 
-                case CREATE_DATAVERSE: {
-                    checkForDataverseConnection(false);
-                    CreateDataverseStatement stmtCreateDataverse = (CreateDataverseStatement) stmt;
-                    String dvName = stmtCreateDataverse.getDataverseName().getValue();
-                    Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dvName);
-                    if (dv != null && !stmtCreateDataverse.getIfNotExists()) {
-                        throw new AlgebricksException("A dataverse with this name " + dvName + " already exists.");
-                    }
-                    MetadataManager.INSTANCE.addDataverse(mdTxnCtx,
-                            new Dataverse(dvName, stmtCreateDataverse.getFormat()));
-                    break;
-                }
+			case CREATE_DATAVERSE: {
+				checkForDataverseConnection(false);
+				CreateDataverseStatement stmtCreateDataverse = (CreateDataverseStatement) stmt;
+				String dvName = stmtCreateDataverse.getDataverseName()
+						.getValue();
+				Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx,
+						dvName);
+				if (dv != null && !stmtCreateDataverse.getIfNotExists()) {
+					throw new AlgebricksException("A dataverse with this name "
+							+ dvName + " already exists.");
+				}
+				MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(
+						dvName, stmtCreateDataverse.getFormat()));
+				break;
+			}
 
-                case DATASET_DECL: {
-                    checkForDataverseConnection(true);
-                    DatasetDecl dd = (DatasetDecl) stmt;
-                    String datasetName = dd.getName().getValue();
-                    DatasetType dsType = dd.getDatasetType();
-                    String itemTypeName = null;
-                    IDatasetDetails datasetDetails = null;
-                    Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                            datasetName);
-                    if (ds != null) {
-                        if (dd.getIfNotExists()) {
-                            continue;
-                        } else {
-                            throw new AlgebricksException("A dataset with this name " + datasetName
-                                    + " already exists.");
-                        }
-                    }
-                    itemTypeName = dd.getItemTypeName().getValue();
-                    Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
-                            compiledDeclarations.getDataverseName(), itemTypeName);
-                    if (dt == null) {
-                        throw new AlgebricksException(": type " + itemTypeName + " could not be found.");
-                    }
-                    switch (dd.getDatasetType()) {
-                        case INTERNAL: {
-                            IAType itemType = dt.getDatatype();
-                            if (itemType.getTypeTag() != ATypeTag.RECORD) {
-                                throw new AlgebricksException("Can only partition ARecord's.");
-                            }
-                            List<String> partitioningExprs = ((InternalDetailsDecl) dd.getDatasetDetailsDecl())
-                                    .getPartitioningExprs();
-                            String ngName = ((InternalDetailsDecl) dd.getDatasetDetailsDecl()).getNodegroupName()
-                                    .getValue();
-                            datasetDetails = new InternalDatasetDetails(InternalDatasetDetails.FileStructure.BTREE,
-                                    InternalDatasetDetails.PartitioningStrategy.HASH, partitioningExprs,
-                                    partitioningExprs, ngName);
-                            break;
-                        }
-                        case EXTERNAL: {
-                            String adapter = ((ExternalDetailsDecl) dd.getDatasetDetailsDecl()).getAdapter();
-                            Map<String, String> properties = ((ExternalDetailsDecl) dd.getDatasetDetailsDecl())
-                                    .getProperties();
-                            datasetDetails = new ExternalDatasetDetails(adapter, properties);
-                            break;
-                        }
-                        case FEED: {
-                            IAType itemType = dt.getDatatype();
-                            if (itemType.getTypeTag() != ATypeTag.RECORD) {
-                                throw new AlgebricksException("Can only partition ARecord's.");
-                            }
-                            List<String> partitioningExprs = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
-                                    .getPartitioningExprs();
-                            String ngName = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getNodegroupName()
-                                    .getValue();
-                            String adapter = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getAdapterClassname();
-                            Map<String, String> properties = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
-                                    .getProperties();
-                            String functionIdentifier = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
-                                    .getFunctionIdentifier();
-                            datasetDetails = new FeedDatasetDetails(InternalDatasetDetails.FileStructure.BTREE,
-                                    InternalDatasetDetails.PartitioningStrategy.HASH, partitioningExprs,
-                                    partitioningExprs, ngName, adapter, properties, functionIdentifier,
-                                    FeedDatasetDetails.FeedState.INACTIVE.toString());
-                            break;
-                        }
-                    }
-                    MetadataManager.INSTANCE.addDataset(mdTxnCtx, new Dataset(compiledDeclarations.getDataverseName(),
-                            datasetName, itemTypeName, datasetDetails, dsType));
-                    if (dd.getDatasetType() == DatasetType.INTERNAL || dd.getDatasetType() == DatasetType.FEED) {
-                        runCreateDatasetJob(hcc, datasetName);
-                    }
-                    break;
-                }
+			case DATASET_DECL: {
+				checkForDataverseConnection(true);
+				DatasetDecl dd = (DatasetDecl) stmt;
+				String datasetName = dd.getName().getValue();
+				DatasetType dsType = dd.getDatasetType();
+				String itemTypeName = null;
+				IDatasetDetails datasetDetails = null;
+				Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), datasetName);
+				if (ds != null) {
+					if (dd.getIfNotExists()) {
+						continue;
+					} else {
+						throw new AlgebricksException(
+								"A dataset with this name " + datasetName
+										+ " already exists.");
+					}
+				}
+				itemTypeName = dd.getItemTypeName().getValue();
+				Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), itemTypeName);
+				if (dt == null) {
+					throw new AlgebricksException(": type " + itemTypeName
+							+ " could not be found.");
+				}
+				switch (dd.getDatasetType()) {
+				case INTERNAL: {
+					IAType itemType = dt.getDatatype();
+					if (itemType.getTypeTag() != ATypeTag.RECORD) {
+						throw new AlgebricksException(
+								"Can only partition ARecord's.");
+					}
+					List<String> partitioningExprs = ((InternalDetailsDecl) dd
+							.getDatasetDetailsDecl()).getPartitioningExprs();
+					String ngName = ((InternalDetailsDecl) dd
+							.getDatasetDetailsDecl()).getNodegroupName()
+							.getValue();
+					datasetDetails = new InternalDatasetDetails(
+							InternalDatasetDetails.FileStructure.BTREE,
+							InternalDatasetDetails.PartitioningStrategy.HASH,
+							partitioningExprs, partitioningExprs, ngName);
+					break;
+				}
+				case EXTERNAL: {
+					String adapter = ((ExternalDetailsDecl) dd
+							.getDatasetDetailsDecl()).getAdapter();
+					Map<String, String> properties = ((ExternalDetailsDecl) dd
+							.getDatasetDetailsDecl()).getProperties();
+					datasetDetails = new ExternalDatasetDetails(adapter,
+							properties);
+					break;
+				}
+				case FEED: {
+					IAType itemType = dt.getDatatype();
+					if (itemType.getTypeTag() != ATypeTag.RECORD) {
+						throw new AlgebricksException(
+								"Can only partition ARecord's.");
+					}
+					List<String> partitioningExprs = ((FeedDetailsDecl) dd
+							.getDatasetDetailsDecl()).getPartitioningExprs();
+					String ngName = ((FeedDetailsDecl) dd
+							.getDatasetDetailsDecl()).getNodegroupName()
+							.getValue();
+					String adapter = ((FeedDetailsDecl) dd
+							.getDatasetDetailsDecl()).getAdapterClassname();
+					Map<String, String> properties = ((FeedDetailsDecl) dd
+							.getDatasetDetailsDecl()).getProperties();
+					String functionIdentifier = ((FeedDetailsDecl) dd
+							.getDatasetDetailsDecl()).getFunctionIdentifier();
+					datasetDetails = new FeedDatasetDetails(
+							InternalDatasetDetails.FileStructure.BTREE,
+							InternalDatasetDetails.PartitioningStrategy.HASH,
+							partitioningExprs, partitioningExprs, ngName,
+							adapter, properties, functionIdentifier,
+							FeedDatasetDetails.FeedState.INACTIVE.toString());
+					break;
+				}
+				}
+				MetadataManager.INSTANCE.addDataset(mdTxnCtx, new Dataset(
+						compiledDeclarations.getDataverseName(), datasetName,
+						itemTypeName, datasetDetails, dsType));
+				if (dd.getDatasetType() == DatasetType.INTERNAL
+						|| dd.getDatasetType() == DatasetType.FEED) {
+					runCreateDatasetJob(hcc, datasetName);
+				}
+				break;
+			}
 
-                case CREATE_INDEX: {
-                    checkForDataverseConnection(true);
-                    CreateIndexStatement stmtCreateIndex = (CreateIndexStatement) stmt;
-                    String datasetName = stmtCreateIndex.getDatasetName().getValue();
-                    Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                            datasetName);
-                    if (ds == null) {
-                        throw new AlgebricksException("There is no dataset with this name " + datasetName);
-                    }
-                    String indexName = stmtCreateIndex.getIndexName().getValue();
-                    Index idx = MetadataManager.INSTANCE.getIndex(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                            datasetName, indexName);
-                    if (idx != null) {
-                        if (!stmtCreateIndex.getIfNotExists()) {
-                            throw new AlgebricksException("An index with this name " + indexName + " already exists.");
-                        } else {
-                            stmtCreateIndex.setNeedToCreate(false);
-                        }
-                    } else {
-                        MetadataManager.INSTANCE.addIndex(mdTxnCtx, new Index(compiledDeclarations.getDataverseName(),
-                                datasetName, indexName, stmtCreateIndex.getIndexType(),
-                                stmtCreateIndex.getFieldExprs(), stmtCreateIndex.getGramLength(), false));
-                        runCreateIndexJob(hcc, stmtCreateIndex);
-                    }
-                    break;
-                }
-                case TYPE_DECL: {
-                    checkForDataverseConnection(true);
-                    TypeDecl stmtCreateType = (TypeDecl) stmt;
-                    String typeName = stmtCreateType.getIdent().getValue();
-                    Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
-                            compiledDeclarations.getDataverseName(), typeName);
-                    if (dt != null) {
-                        if (!stmtCreateType.getIfNotExists())
-                            throw new AlgebricksException("A datatype with this name " + typeName + " already exists.");
-                    } else {
-                        if (builtinTypeMap.get(typeName) != null) {
-                            throw new AlgebricksException("Cannot redefine builtin type " + typeName + ".");
-                        } else {
-                            Map<String, IAType> typeMap = computeTypes(mdTxnCtx, (TypeDecl) stmt);
-                            IAType type = typeMap.get(typeName);
-                            MetadataManager.INSTANCE.addDatatype(mdTxnCtx,
-                                    new Datatype(compiledDeclarations.getDataverseName(), typeName, type, false));
-                        }
-                    }
-                    break;
-                }
-                case NODEGROUP_DECL: {
-                    NodegroupDecl stmtCreateNodegroup = (NodegroupDecl) stmt;
-                    String ngName = stmtCreateNodegroup.getNodegroupName().getValue();
-                    NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, ngName);
-                    if (ng != null) {
-                        if (!stmtCreateNodegroup.getIfNotExists())
-                            throw new AlgebricksException("A nodegroup with this name " + ngName + " already exists.");
-                    } else {
-                        List<Identifier> ncIdentifiers = stmtCreateNodegroup.getNodeControllerNames();
-                        List<String> ncNames = new ArrayList<String>(ncIdentifiers.size());
-                        for (Identifier id : ncIdentifiers) {
-                            ncNames.add(id.getValue());
-                        }
-                        MetadataManager.INSTANCE.addNodegroup(mdTxnCtx, new NodeGroup(ngName, ncNames));
-                    }
-                    break;
-                }
-                // drop statements
-                case DATAVERSE_DROP: {
-                    DataverseDropStatement stmtDelete = (DataverseDropStatement) stmt;
-                    String dvName = stmtDelete.getDataverseName().getValue();
-                    if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(ARTIFACT_KIND.DATAVERSE, dvName)) {
-                        throw new AsterixException("Invalid Operation cannot drop dataverse " + dvName
-                                + " (protected by system)");
-                    }
+			case CREATE_INDEX: {
+				checkForDataverseConnection(true);
+				CreateIndexStatement stmtCreateIndex = (CreateIndexStatement) stmt;
+				String datasetName = stmtCreateIndex.getDatasetName()
+						.getValue();
+				Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), datasetName);
+				if (ds == null) {
+					throw new AlgebricksException(
+							"There is no dataset with this name " + datasetName);
+				}
+				String indexName = stmtCreateIndex.getIndexName().getValue();
+				Index idx = MetadataManager.INSTANCE.getIndex(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), datasetName,
+						indexName);
+				if (idx != null) {
+					if (!stmtCreateIndex.getIfNotExists()) {
+						throw new AlgebricksException(
+								"An index with this name " + indexName
+										+ " already exists.");
+					} else {
+						stmtCreateIndex.setNeedToCreate(false);
+					}
+				} else {
+					MetadataManager.INSTANCE.addIndex(
+							mdTxnCtx,
+							new Index(compiledDeclarations.getDataverseName(),
+									datasetName, indexName, stmtCreateIndex
+											.getIndexType(), stmtCreateIndex
+											.getFieldExprs(), stmtCreateIndex
+											.getGramLength(), false));
+					runCreateIndexJob(hcc, stmtCreateIndex);
+				}
+				break;
+			}
+			case TYPE_DECL: {
+				checkForDataverseConnection(true);
+				TypeDecl stmtCreateType = (TypeDecl) stmt;
+				String typeName = stmtCreateType.getIdent().getValue();
+				Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), typeName);
+				if (dt != null) {
+					if (!stmtCreateType.getIfNotExists())
+						throw new AlgebricksException(
+								"A datatype with this name " + typeName
+										+ " already exists.");
+				} else {
+					if (builtinTypeMap.get(typeName) != null) {
+						throw new AlgebricksException(
+								"Cannot redefine builtin type " + typeName
+										+ ".");
+					} else {
+						Map<String, IAType> typeMap = computeTypes(mdTxnCtx,
+								(TypeDecl) stmt);
+						IAType type = typeMap.get(typeName);
+						MetadataManager.INSTANCE.addDatatype(
+								mdTxnCtx,
+								new Datatype(compiledDeclarations
+										.getDataverseName(), typeName, type,
+										false));
+					}
+				}
+				break;
+			}
+			case NODEGROUP_DECL: {
+				NodegroupDecl stmtCreateNodegroup = (NodegroupDecl) stmt;
+				String ngName = stmtCreateNodegroup.getNodegroupName()
+						.getValue();
+				NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx,
+						ngName);
+				if (ng != null) {
+					if (!stmtCreateNodegroup.getIfNotExists())
+						throw new AlgebricksException(
+								"A nodegroup with this name " + ngName
+										+ " already exists.");
+				} else {
+					List<Identifier> ncIdentifiers = stmtCreateNodegroup
+							.getNodeControllerNames();
+					List<String> ncNames = new ArrayList<String>(
+							ncIdentifiers.size());
+					for (Identifier id : ncIdentifiers) {
+						ncNames.add(id.getValue());
+					}
+					MetadataManager.INSTANCE.addNodegroup(mdTxnCtx,
+							new NodeGroup(ngName, ncNames));
+				}
+				break;
+			}
+			// drop statements
+			case DATAVERSE_DROP: {
+				DataverseDropStatement stmtDelete = (DataverseDropStatement) stmt;
+				String dvName = stmtDelete.getDataverseName().getValue();
+				if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(
+						ARTIFACT_KIND.DATAVERSE, dvName)) {
+					throw new AsterixException(
+							"Invalid Operation cannot drop dataverse " + dvName
+									+ " (protected by system)");
+				}
 
-                    if (compiledDeclarations.isConnectedToDataverse())
-                        compiledDeclarations.disconnectFromDataverse();
-                    checkForDataverseConnection(false);
+				if (compiledDeclarations.isConnectedToDataverse())
+					compiledDeclarations.disconnectFromDataverse();
+				checkForDataverseConnection(false);
 
-                    Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dvName);
-                    if (dv == null) {
-                        if (!stmtDelete.getIfExists()) {
-                            throw new AlgebricksException("There is no dataverse with this name " + dvName + ".");
-                        }
-                    } else {
-                        compiledDeclarations.connectToDataverse(dvName);
-                        List<Dataset> datasets = MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dvName);
-                        for (int j = 0; j < datasets.size(); j++) {
-                            String datasetName = datasets.get(j).getDatasetName();
-                            DatasetType dsType = datasets.get(j).getDatasetType();
-                            if (dsType == DatasetType.INTERNAL || dsType == DatasetType.FEED) {
-                                List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dvName,
-                                        datasetName);
-                                for (int k = 0; k < indexes.size(); k++) {
-                                    if (indexes.get(k).isSecondaryIndex()) {
-                                        compileIndexDropStatement(hcc, mdTxnCtx, datasetName, indexes.get(k)
-                                                .getIndexName());
-                                    }
-                                }
-                            }
-                            compileDatasetDropStatement(hcc, mdTxnCtx, datasetName);
-                        }
-                        MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
-                        if (compiledDeclarations.isConnectedToDataverse())
-                            compiledDeclarations.disconnectFromDataverse();
-                    }
-                    break;
-                }
-                case DATASET_DROP: {
-                    checkForDataverseConnection(true);
-                    DropStatement stmtDelete = (DropStatement) stmt;
-                    String datasetName = stmtDelete.getDatasetName().getValue();
-                    if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(ARTIFACT_KIND.DATASET, datasetName)) {
-                        throw new AsterixException("Invalid Operation cannot drop dataset " + datasetName
-                                + " (protected by system)");
-                    }
-                    Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                            datasetName);
-                    if (ds == null) {
-                        if (!stmtDelete.getIfExists())
-                            throw new AlgebricksException("There is no dataset with this name " + datasetName + ".");
-                    } else {
-                        if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
-                            List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx,
-                                    compiledDeclarations.getDataverseName(), datasetName);
-                            for (int j = 0; j < indexes.size(); j++) {
-                                if (indexes.get(j).isPrimaryIndex()) {
-                                    compileIndexDropStatement(hcc, mdTxnCtx, datasetName, indexes.get(j).getIndexName());
-                                }
-                            }
-                        }
-                        compileDatasetDropStatement(hcc, mdTxnCtx, datasetName);
-                    }
-                    break;
-                }
-                case INDEX_DROP: {
-                    checkForDataverseConnection(true);
-                    IndexDropStatement stmtDelete = (IndexDropStatement) stmt;
-                    String datasetName = stmtDelete.getDatasetName().getValue();
-                    Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                            datasetName);
-                    if (ds == null)
-                        throw new AlgebricksException("There is no dataset with this name " + datasetName + ".");
-                    if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
-                        String indexName = stmtDelete.getIndexName().getValue();
-                        Index idx = MetadataManager.INSTANCE.getIndex(mdTxnCtx,
-                                compiledDeclarations.getDataverseName(), datasetName, indexName);
-                        if (idx == null) {
-                            if (!stmtDelete.getIfExists())
-                                throw new AlgebricksException("There is no index with this name " + indexName + ".");
-                        } else
-                            compileIndexDropStatement(hcc, mdTxnCtx, datasetName, indexName);
-                    } else {
-                        throw new AlgebricksException(datasetName
-                                + " is an external dataset. Indexes are not maintained for external datasets.");
-                    }
-                    break;
-                }
-                case TYPE_DROP: {
-                    checkForDataverseConnection(true);
-                    TypeDropStatement stmtDelete = (TypeDropStatement) stmt;
-                    String typeName = stmtDelete.getTypeName().getValue();
-                    Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
-                            compiledDeclarations.getDataverseName(), typeName);
-                    if (dt == null) {
-                        if (!stmtDelete.getIfExists())
-                            throw new AlgebricksException("There is no datatype with this name " + typeName + ".");
-                    } else
-                        MetadataManager.INSTANCE.dropDatatype(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                                typeName);
-                    break;
-                }
-                case NODEGROUP_DROP: {
-                    NodeGroupDropStatement stmtDelete = (NodeGroupDropStatement) stmt;
-                    String nodegroupName = stmtDelete.getNodeGroupName().getValue();
-                    if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(ARTIFACT_KIND.NODEGROUP, nodegroupName)) {
-                        throw new AsterixException("Invalid Operation cannot drop nodegroup " + nodegroupName
-                                + " (protected by system)");
-                    }
-                    NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodegroupName);
-                    if (ng == null) {
-                        if (!stmtDelete.getIfExists())
-                            throw new AlgebricksException("There is no nodegroup with this name " + nodegroupName + ".");
-                    } else
-                        MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx, nodegroupName);
-                    break;
-                }
+				Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx,
+						dvName);
+				if (dv == null) {
+					if (!stmtDelete.getIfExists()) {
+						throw new AlgebricksException(
+								"There is no dataverse with this name "
+										+ dvName + ".");
+					}
+				} else {
+					compiledDeclarations.connectToDataverse(dvName);
+					List<Dataset> datasets = MetadataManager.INSTANCE
+							.getDataverseDatasets(mdTxnCtx, dvName);
+					for (int j = 0; j < datasets.size(); j++) {
+						String datasetName = datasets.get(j).getDatasetName();
+						DatasetType dsType = datasets.get(j).getDatasetType();
+						if (dsType == DatasetType.INTERNAL
+								|| dsType == DatasetType.FEED) {
+							List<Index> indexes = MetadataManager.INSTANCE
+									.getDatasetIndexes(mdTxnCtx, dvName,
+											datasetName);
+							for (int k = 0; k < indexes.size(); k++) {
+								if (indexes.get(k).isSecondaryIndex()) {
+									compileIndexDropStatement(hcc, mdTxnCtx,
+											datasetName, indexes.get(k)
+													.getIndexName());
+								}
+							}
+						}
+						compileDatasetDropStatement(hcc, mdTxnCtx, datasetName);
+					}
+					MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
+					if (compiledDeclarations.isConnectedToDataverse())
+						compiledDeclarations.disconnectFromDataverse();
+				}
+				break;
+			}
+			case DATASET_DROP: {
+				checkForDataverseConnection(true);
+				DropStatement stmtDelete = (DropStatement) stmt;
+				String datasetName = stmtDelete.getDatasetName().getValue();
+				if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(
+						ARTIFACT_KIND.DATASET, datasetName)) {
+					throw new AsterixException(
+							"Invalid Operation cannot drop dataset "
+									+ datasetName + " (protected by system)");
+				}
+				Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), datasetName);
+				if (ds == null) {
+					if (!stmtDelete.getIfExists())
+						throw new AlgebricksException(
+								"There is no dataset with this name "
+										+ datasetName + ".");
+				} else {
+					if (ds.getDatasetType() == DatasetType.INTERNAL
+							|| ds.getDatasetType() == DatasetType.FEED) {
+						List<Index> indexes = MetadataManager.INSTANCE
+								.getDatasetIndexes(
+										mdTxnCtx,
+										compiledDeclarations.getDataverseName(),
+										datasetName);
+						for (int j = 0; j < indexes.size(); j++) {
+							if (indexes.get(j).isPrimaryIndex()) {
+								compileIndexDropStatement(hcc, mdTxnCtx,
+										datasetName, indexes.get(j)
+												.getIndexName());
+							}
+						}
+					}
+					compileDatasetDropStatement(hcc, mdTxnCtx, datasetName);
+				}
+				break;
+			}
+			case INDEX_DROP: {
+				checkForDataverseConnection(true);
+				IndexDropStatement stmtDelete = (IndexDropStatement) stmt;
+				String datasetName = stmtDelete.getDatasetName().getValue();
+				Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), datasetName);
+				if (ds == null)
+					throw new AlgebricksException(
+							"There is no dataset with this name " + datasetName
+									+ ".");
+				if (ds.getDatasetType() == DatasetType.INTERNAL
+						|| ds.getDatasetType() == DatasetType.FEED) {
+					String indexName = stmtDelete.getIndexName().getValue();
+					Index idx = MetadataManager.INSTANCE.getIndex(mdTxnCtx,
+							compiledDeclarations.getDataverseName(),
+							datasetName, indexName);
+					if (idx == null) {
+						if (!stmtDelete.getIfExists())
+							throw new AlgebricksException(
+									"There is no index with this name "
+											+ indexName + ".");
+					} else
+						compileIndexDropStatement(hcc, mdTxnCtx, datasetName,
+								indexName);
+				} else {
+					throw new AlgebricksException(
+							datasetName
+									+ " is an external dataset. Indexes are not maintained for external datasets.");
+				}
+				break;
+			}
+			case TYPE_DROP: {
+				checkForDataverseConnection(true);
+				TypeDropStatement stmtDelete = (TypeDropStatement) stmt;
+				String typeName = stmtDelete.getTypeName().getValue();
+				Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+						compiledDeclarations.getDataverseName(), typeName);
+				if (dt == null) {
+					if (!stmtDelete.getIfExists())
+						throw new AlgebricksException(
+								"There is no datatype with this name "
+										+ typeName + ".");
+				} else
+					MetadataManager.INSTANCE.dropDatatype(mdTxnCtx,
+							compiledDeclarations.getDataverseName(), typeName);
+				break;
+			}
+			case NODEGROUP_DROP: {
+				NodeGroupDropStatement stmtDelete = (NodeGroupDropStatement) stmt;
+				String nodegroupName = stmtDelete.getNodeGroupName().getValue();
+				if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(
+						ARTIFACT_KIND.NODEGROUP, nodegroupName)) {
+					throw new AsterixException(
+							"Invalid Operation cannot drop nodegroup "
+									+ nodegroupName + " (protected by system)");
+				}
+				NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx,
+						nodegroupName);
+				if (ng == null) {
+					if (!stmtDelete.getIfExists())
+						throw new AlgebricksException(
+								"There is no nodegroup with this name "
+										+ nodegroupName + ".");
+				} else
+					MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx,
+							nodegroupName);
+				break;
+			}
 
-                case CREATE_FUNCTION: {
-                    CreateFunctionStatement cfs = (CreateFunctionStatement) stmt;
-                    Function function = new Function(compiledDeclarations.getDataverseName(), cfs
-                            .getFunctionIdentifier().getFunctionName(), cfs.getFunctionIdentifier().getArity(),
-                            cfs.getParamList(), cfs.getFunctionBody());
-                    try {
-                        FunctionUtils.getFunctionDecl(function);
-                    } catch (Exception e) {
-                        throw new AsterixException("Unable to compile function definition", e);
-                    }
-                    MetadataManager.INSTANCE.addFunction(mdTxnCtx, new Function(
-                            compiledDeclarations.getDataverseName(), cfs.getFunctionIdentifier().getFunctionName(), cfs
-                                    .getFunctionIdentifier().getArity(), cfs.getParamList(), cfs.getFunctionBody()));
-                    break;
-                }
+			case CREATE_FUNCTION: {
+				CreateFunctionStatement cfs = (CreateFunctionStatement) stmt;
+				Function function = new Function(
+						compiledDeclarations.getDataverseName(), cfs
+								.getFunctionIdentifier().getFunctionName(), cfs
+								.getFunctionIdentifier().getArity(),
+						cfs.getParamList(), cfs.getFunctionBody());
+				try {
+					FunctionUtils.getFunctionDecl(function);
+				} catch (Exception e) {
+					throw new AsterixException(
+							"Unable to compile function definition", e);
+				}
+				MetadataManager.INSTANCE
+						.addFunction(mdTxnCtx, new Function(
+								compiledDeclarations.getDataverseName(), cfs
+										.getFunctionIdentifier()
+										.getFunctionName(), cfs
+										.getFunctionIdentifier().getArity(),
+								cfs.getParamList(), cfs.getFunctionBody()));
+				break;
+			}
 
-                case FUNCTION_DROP: {
-                    checkForDataverseConnection(true);
-                    FunctionDropStatement stmtDropFunction = (FunctionDropStatement) stmt;
-                    String functionName = stmtDropFunction.getFunctionName().getValue();
-                    FunctionIdentifier fId = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, functionName,
-                            stmtDropFunction.getArity(), false);
-                    if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(ARTIFACT_KIND.FUNCTION, fId)) {
-                        throw new AsterixException("Invalid Operation cannot drop function " + functionName
-                                + " (protected by system)");
-                    }
-                    Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx,
-                            compiledDeclarations.getDataverseName(), functionName, stmtDropFunction.getArity());
-                    if (function == null) {
-                        if (!stmtDropFunction.getIfExists())
-                            throw new AlgebricksException("There is no function with this name " + functionName + ".");
-                    } else {
-                        MetadataManager.INSTANCE.dropFunction(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                                functionName, stmtDropFunction.getArity());
-                    }
-                    break;
-                }
-            }
-        }
+			case FUNCTION_DROP: {
+				checkForDataverseConnection(true);
+				FunctionDropStatement stmtDropFunction = (FunctionDropStatement) stmt;
+				String functionName = stmtDropFunction.getFunctionName()
+						.getValue();
+                    FunctionIdentifier fId = new FunctionIdentifier(
+						FunctionConstants.ASTERIX_NS, functionName,
+						stmtDropFunction.getArity());
+				if (AsterixBuiltinArtifactMap.isSystemProtectedArtifact(
+						ARTIFACT_KIND.FUNCTION, fId)) {
+					throw new AsterixException(
+							"Invalid Operation cannot drop function "
+									+ functionName + " (protected by system)");
+				}
+				Function function = MetadataManager.INSTANCE.getFunction(
+						mdTxnCtx, compiledDeclarations.getDataverseName(),
+						functionName, stmtDropFunction.getArity());
+				if (function == null) {
+					if (!stmtDropFunction.getIfExists())
+						throw new AlgebricksException(
+								"There is no function with this name "
+										+ functionName + ".");
+				} else {
+					MetadataManager.INSTANCE.dropFunction(mdTxnCtx,
+							compiledDeclarations.getDataverseName(),
+							functionName, stmtDropFunction.getArity());
+				}
+				break;
+			}
+			}
+		}
 
-        if (disconnectFromDataverse) {
-            if (compiledDeclarations.isConnectedToDataverse()) {
-                compiledDeclarations.disconnectFromDataverse();
-            }
-        }
-    }
+		if (disconnectFromDataverse) {
+			if (compiledDeclarations.isConnectedToDataverse()) {
+				compiledDeclarations.disconnectFromDataverse();
+			}
+		}
+	}
 
-    private void checkForDataverseConnection(boolean needConnection) throws AlgebricksException {
-        if (compiledDeclarations.isConnectedToDataverse() != needConnection) {
-            if (needConnection)
-                throw new AlgebricksException("You need first to connect to a dataverse.");
-            else
-                throw new AlgebricksException("You need first to disconnect from the dataverse.");
-        }
-    }
+	private void checkForDataverseConnection(boolean needConnection)
+			throws AlgebricksException {
+		if (compiledDeclarations.isConnectedToDataverse() != needConnection) {
+			if (needConnection)
+				throw new AlgebricksException(
+						"You need first to connect to a dataverse.");
+			else
+				throw new AlgebricksException(
+						"You need first to disconnect from the dataverse.");
+		}
+	}
 
-    private void runJob(IHyracksClientConnection hcc, JobSpecification jobSpec) throws Exception {
-        System.out.println(jobSpec.toString());
-        executeJobArray(hcc, new JobSpecification[] { jobSpec }, out, pdf);
-    }
+	private void runJob(IHyracksClientConnection hcc, JobSpecification jobSpec)
+			throws Exception {
+		System.out.println(jobSpec.toString());
+		executeJobArray(hcc, new JobSpecification[] { jobSpec }, out, pdf);
+	}
 
-    public void executeJobArray(IHyracksClientConnection hcc, JobSpecification[] specs, PrintWriter out,
-            DisplayFormat pdf) throws Exception {
-        for (int i = 0; i < specs.length; i++) {
-            specs[i].setMaxReattempts(0);
-            JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, specs[i]);
-            hcc.waitForCompletion(jobId);
-        }
-    }
+	public void executeJobArray(IHyracksClientConnection hcc,
+			JobSpecification[] specs, PrintWriter out, DisplayFormat pdf)
+			throws Exception {
+		for (int i = 0; i < specs.length; i++) {
+			specs[i].setMaxReattempts(0);
+			JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, specs[i]);
+			hcc.waitForCompletion(jobId);
+		}
+	}
 
-    private void runCreateDatasetJob(IHyracksClientConnection hcc, String datasetName) throws AsterixException,
-            AlgebricksException, Exception {
-        runJob(hcc, DatasetOperations.createDatasetJobSpec(datasetName, compiledDeclarations));
-    }
+	private void runCreateDatasetJob(IHyracksClientConnection hcc,
+			String datasetName) throws AsterixException, AlgebricksException,
+			Exception {
+		runJob(hcc, DatasetOperations.createDatasetJobSpec(datasetName,
+				compiledDeclarations));
+	}
 
-    private void runCreateIndexJob(IHyracksClientConnection hcc, CreateIndexStatement stmtCreateIndex) throws Exception {
-        // TODO: Eventually CreateIndexStatement and CompiledCreateIndexStatement should be replaced by the corresponding metadata entity.
-        // For now we must still convert to a CompiledCreateIndexStatement here.
-        CompiledCreateIndexStatement createIndexStmt = new CompiledCreateIndexStatement(stmtCreateIndex.getIndexName()
-                .getValue(), stmtCreateIndex.getDatasetName().getValue(), stmtCreateIndex.getFieldExprs(),
-                stmtCreateIndex.getGramLength(), stmtCreateIndex.getIndexType());
-        JobSpecification spec = IndexOperations.buildSecondaryIndexCreationJobSpec(createIndexStmt,
-                compiledDeclarations);
-        if (spec == null) {
-            throw new AsterixException("Failed to create job spec for creating index '"
-                    + stmtCreateIndex.getDatasetName() + "." + stmtCreateIndex.getIndexName() + "'");
-        }
-        runJob(hcc, spec);
-    }
+	private void runCreateIndexJob(IHyracksClientConnection hcc,
+			CreateIndexStatement stmtCreateIndex) throws Exception {
+		// TODO: Eventually CreateIndexStatement and
+		// CompiledCreateIndexStatement should be replaced by the corresponding
+		// metadata entity.
+		// For now we must still convert to a CompiledCreateIndexStatement here.
+		CompiledCreateIndexStatement createIndexStmt = new CompiledCreateIndexStatement(
+				stmtCreateIndex.getIndexName().getValue(), stmtCreateIndex
+						.getDatasetName().getValue(),
+				stmtCreateIndex.getFieldExprs(),
+				stmtCreateIndex.getGramLength(), stmtCreateIndex.getIndexType());
+		JobSpecification spec = IndexOperations
+				.buildSecondaryIndexCreationJobSpec(createIndexStmt,
+						compiledDeclarations);
+		if (spec == null) {
+			throw new AsterixException(
+					"Failed to create job spec for creating index '"
+							+ stmtCreateIndex.getDatasetName() + "."
+							+ stmtCreateIndex.getIndexName() + "'");
+		}
+		runJob(hcc, spec);
+	}
 
-    private void compileDatasetDropStatement(IHyracksClientConnection hcc, MetadataTransactionContext mdTxnCtx,
-            String datasetName) throws Exception {
-        CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(datasetName);
-        Dataset ds = MetadataManager.INSTANCE
-                .getDataset(mdTxnCtx, compiledDeclarations.getDataverseName(), datasetName);
-        if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
-            JobSpecification[] jobs = DatasetOperations.createDropDatasetJobSpec(cds, compiledDeclarations);
-            for (JobSpecification job : jobs)
-                runJob(hcc, job);
-        }
-        MetadataManager.INSTANCE.dropDataset(mdTxnCtx, compiledDeclarations.getDataverseName(), datasetName);
-    }
+	private void compileDatasetDropStatement(IHyracksClientConnection hcc,
+			MetadataTransactionContext mdTxnCtx, String datasetName)
+			throws Exception {
+		CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(
+				datasetName);
+		Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx,
+				compiledDeclarations.getDataverseName(), datasetName);
+		if (ds.getDatasetType() == DatasetType.INTERNAL
+				|| ds.getDatasetType() == DatasetType.FEED) {
+			JobSpecification[] jobs = DatasetOperations
+					.createDropDatasetJobSpec(cds, compiledDeclarations);
+			for (JobSpecification job : jobs)
+				runJob(hcc, job);
+		}
+		MetadataManager.INSTANCE.dropDataset(mdTxnCtx,
+				compiledDeclarations.getDataverseName(), datasetName);
+	}
 
-    public AqlCompiledMetadataDeclarations getCompiledDeclarations() {
-        return compiledDeclarations;
-    }
+	public AqlCompiledMetadataDeclarations getCompiledDeclarations() {
+		return compiledDeclarations;
+	}
 
-    private void compileIndexDropStatement(IHyracksClientConnection hcc, MetadataTransactionContext mdTxnCtx,
-            String datasetName, String indexName) throws Exception {
-        CompiledIndexDropStatement cds = new CompiledIndexDropStatement(datasetName, indexName);
-        runJob(hcc, IndexOperations.buildDropSecondaryIndexJobSpec(cds, compiledDeclarations));
-        MetadataManager.INSTANCE.dropIndex(mdTxnCtx, compiledDeclarations.getDataverseName(), datasetName, indexName);
-    }
+	private void compileIndexDropStatement(IHyracksClientConnection hcc,
+			MetadataTransactionContext mdTxnCtx, String datasetName,
+			String indexName) throws Exception {
+		CompiledIndexDropStatement cds = new CompiledIndexDropStatement(
+				datasetName, indexName);
+		runJob(hcc, IndexOperations.buildDropSecondaryIndexJobSpec(cds,
+				compiledDeclarations));
+		MetadataManager.INSTANCE
+				.dropIndex(mdTxnCtx, compiledDeclarations.getDataverseName(),
+						datasetName, indexName);
+	}
 
-    private Map<String, IAType> computeTypes(MetadataTransactionContext mdTxnCtx, TypeDecl tDec)
-            throws AlgebricksException, MetadataException {
-        Map<String, IAType> typeMap = new HashMap<String, IAType>();
-        Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes = new HashMap<String, Map<ARecordType, List<Integer>>>();
-        Map<String, List<AbstractCollectionType>> incompleteItemTypes = new HashMap<String, List<AbstractCollectionType>>();
-        Map<String, List<String>> incompleteTopLevelTypeReferences = new HashMap<String, List<String>>();
+	private Map<String, IAType> computeTypes(
+			MetadataTransactionContext mdTxnCtx, TypeDecl tDec)
+			throws AlgebricksException, MetadataException {
+		Map<String, IAType> typeMap = new HashMap<String, IAType>();
+		Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes = new HashMap<String, Map<ARecordType, List<Integer>>>();
+		Map<String, List<AbstractCollectionType>> incompleteItemTypes = new HashMap<String, List<AbstractCollectionType>>();
+		Map<String, List<String>> incompleteTopLevelTypeReferences = new HashMap<String, List<String>>();
 
-        firstPass(tDec, typeMap, incompleteFieldTypes, incompleteItemTypes, incompleteTopLevelTypeReferences);
-        secondPass(mdTxnCtx, typeMap, incompleteFieldTypes, incompleteItemTypes, incompleteTopLevelTypeReferences);
+		firstPass(tDec, typeMap, incompleteFieldTypes, incompleteItemTypes,
+				incompleteTopLevelTypeReferences);
+		secondPass(mdTxnCtx, typeMap, incompleteFieldTypes,
+				incompleteItemTypes, incompleteTopLevelTypeReferences);
 
-        return typeMap;
-    }
+		return typeMap;
+	}
 
-    private void secondPass(MetadataTransactionContext mdTxnCtx, Map<String, IAType> typeMap,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
-            Map<String, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, List<String>> incompleteTopLevelTypeReferences) throws AlgebricksException, MetadataException {
-        // solve remaining top level references
-        for (String trefName : incompleteTopLevelTypeReferences.keySet()) {
-            IAType t;// = typeMap.get(trefName);
-            Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                    trefName);
-            if (dt == null) {
-                throw new AlgebricksException("Could not resolve type " + trefName);
-            } else
-                t = dt.getDatatype();
-            for (String tname : incompleteTopLevelTypeReferences.get(trefName)) {
-                typeMap.put(tname, t);
-            }
-        }
-        // solve remaining field type references
-        for (String trefName : incompleteFieldTypes.keySet()) {
-            IAType t;// = typeMap.get(trefName);
-            Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                    trefName);
-            if (dt == null) {
-                throw new AlgebricksException("Could not resolve type " + trefName);
-            } else
-                t = dt.getDatatype();
-            Map<ARecordType, List<Integer>> fieldsToFix = incompleteFieldTypes.get(trefName);
-            for (ARecordType recType : fieldsToFix.keySet()) {
-                List<Integer> positions = fieldsToFix.get(recType);
-                IAType[] fldTypes = recType.getFieldTypes();
-                for (Integer pos : positions) {
-                    if (fldTypes[pos] == null) {
-                        fldTypes[pos] = t;
-                    } else { // nullable
-                        AUnionType nullableUnion = (AUnionType) fldTypes[pos];
-                        nullableUnion.setTypeAtIndex(t, 1);
-                    }
-                }
-            }
-        }
-        // solve remaining item type references
-        for (String trefName : incompleteItemTypes.keySet()) {
-            IAType t;// = typeMap.get(trefName);
-            Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, compiledDeclarations.getDataverseName(),
-                    trefName);
-            if (dt == null) {
-                throw new AlgebricksException("Could not resolve type " + trefName);
-            } else
-                t = dt.getDatatype();
-            for (AbstractCollectionType act : incompleteItemTypes.get(trefName)) {
-                act.setItemType(t);
-            }
-        }
-    }
+	private void secondPass(MetadataTransactionContext mdTxnCtx,
+			Map<String, IAType> typeMap,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes,
+			Map<String, List<String>> incompleteTopLevelTypeReferences)
+			throws AlgebricksException, MetadataException {
+		// solve remaining top level references
+		for (String trefName : incompleteTopLevelTypeReferences.keySet()) {
+			IAType t;// = typeMap.get(trefName);
+			Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+					compiledDeclarations.getDataverseName(), trefName);
+			if (dt == null) {
+				throw new AlgebricksException("Could not resolve type "
+						+ trefName);
+			} else
+				t = dt.getDatatype();
+			for (String tname : incompleteTopLevelTypeReferences.get(trefName)) {
+				typeMap.put(tname, t);
+			}
+		}
+		// solve remaining field type references
+		for (String trefName : incompleteFieldTypes.keySet()) {
+			IAType t;// = typeMap.get(trefName);
+			Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+					compiledDeclarations.getDataverseName(), trefName);
+			if (dt == null) {
+				throw new AlgebricksException("Could not resolve type "
+						+ trefName);
+			} else
+				t = dt.getDatatype();
+			Map<ARecordType, List<Integer>> fieldsToFix = incompleteFieldTypes
+					.get(trefName);
+			for (ARecordType recType : fieldsToFix.keySet()) {
+				List<Integer> positions = fieldsToFix.get(recType);
+				IAType[] fldTypes = recType.getFieldTypes();
+				for (Integer pos : positions) {
+					if (fldTypes[pos] == null) {
+						fldTypes[pos] = t;
+					} else { // nullable
+						AUnionType nullableUnion = (AUnionType) fldTypes[pos];
+						nullableUnion.setTypeAtIndex(t, 1);
+					}
+				}
+			}
+		}
+		// solve remaining item type references
+		for (String trefName : incompleteItemTypes.keySet()) {
+			IAType t;// = typeMap.get(trefName);
+			Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx,
+					compiledDeclarations.getDataverseName(), trefName);
+			if (dt == null) {
+				throw new AlgebricksException("Could not resolve type "
+						+ trefName);
+			} else
+				t = dt.getDatatype();
+			for (AbstractCollectionType act : incompleteItemTypes.get(trefName)) {
+				act.setItemType(t);
+			}
+		}
+	}
 
-    private void firstPass(TypeDecl td, Map<String, IAType> typeMap,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
-            Map<String, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, List<String>> incompleteTopLevelTypeReferences) throws AlgebricksException {
+	private void firstPass(TypeDecl td, Map<String, IAType> typeMap,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes,
+			Map<String, List<String>> incompleteTopLevelTypeReferences)
+			throws AlgebricksException {
 
-        TypeExpression texpr = td.getTypeDef();
-        String tdname = td.getIdent().getValue();
-        if (builtinTypeMap.get(tdname) != null) {
-            throw new AlgebricksException("Cannot redefine builtin type " + tdname + " .");
-        }
-        switch (texpr.getTypeKind()) {
-            case TYPEREFERENCE: {
-                TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
-                IAType t = solveTypeReference(tre, typeMap);
-                if (t != null) {
-                    typeMap.put(tdname, t);
-                } else {
-                    addIncompleteTopLevelTypeReference(tdname, tre, incompleteTopLevelTypeReferences);
-                }
-                break;
-            }
-            case RECORD: {
-                RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
-                ARecordType recType = computeRecordType(tdname, rtd, typeMap, incompleteFieldTypes, incompleteItemTypes);
-                typeMap.put(tdname, recType);
-                break;
-            }
-            case ORDEREDLIST: {
-                OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
-                AOrderedListType olType = computeOrderedListType(tdname, oltd, typeMap, incompleteItemTypes,
-                        incompleteFieldTypes);
-                typeMap.put(tdname, olType);
-                break;
-            }
-            case UNORDEREDLIST: {
-                UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
-                AUnorderedListType ulType = computeUnorderedListType(tdname, ultd, typeMap, incompleteItemTypes,
-                        incompleteFieldTypes);
-                typeMap.put(tdname, ulType);
-                break;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
-        }
-    }
+		TypeExpression texpr = td.getTypeDef();
+		String tdname = td.getIdent().getValue();
+		if (builtinTypeMap.get(tdname) != null) {
+			throw new AlgebricksException("Cannot redefine builtin type "
+					+ tdname + " .");
+		}
+		switch (texpr.getTypeKind()) {
+		case TYPEREFERENCE: {
+			TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
+			IAType t = solveTypeReference(tre, typeMap);
+			if (t != null) {
+				typeMap.put(tdname, t);
+			} else {
+				addIncompleteTopLevelTypeReference(tdname, tre,
+						incompleteTopLevelTypeReferences);
+			}
+			break;
+		}
+		case RECORD: {
+			RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
+			ARecordType recType = computeRecordType(tdname, rtd, typeMap,
+					incompleteFieldTypes, incompleteItemTypes);
+			typeMap.put(tdname, recType);
+			break;
+		}
+		case ORDEREDLIST: {
+			OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
+			AOrderedListType olType = computeOrderedListType(tdname, oltd,
+					typeMap, incompleteItemTypes, incompleteFieldTypes);
+			typeMap.put(tdname, olType);
+			break;
+		}
+		case UNORDEREDLIST: {
+			UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
+			AUnorderedListType ulType = computeUnorderedListType(tdname, ultd,
+					typeMap, incompleteItemTypes, incompleteFieldTypes);
+			typeMap.put(tdname, ulType);
+			break;
+		}
+		default: {
+			throw new IllegalStateException();
+		}
+		}
+	}
 
-    private AOrderedListType computeOrderedListType(String typeName, OrderedListTypeDefinition oltd,
-            Map<String, IAType> typeMap, Map<String, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
-        TypeExpression tExpr = oltd.getItemTypeExpression();
-        AOrderedListType aolt = new AOrderedListType(null, typeName);
-        setCollectionItemType(tExpr, typeMap, incompleteItemTypes, incompleteFieldTypes, aolt);
-        return aolt;
-    }
+	private AOrderedListType computeOrderedListType(String typeName,
+			OrderedListTypeDefinition oltd, Map<String, IAType> typeMap,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
+		TypeExpression tExpr = oltd.getItemTypeExpression();
+		AOrderedListType aolt = new AOrderedListType(null, typeName);
+		setCollectionItemType(tExpr, typeMap, incompleteItemTypes,
+				incompleteFieldTypes, aolt);
+		return aolt;
+	}
 
-    private AUnorderedListType computeUnorderedListType(String typeName, UnorderedListTypeDefinition ultd,
-            Map<String, IAType> typeMap, Map<String, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
-        TypeExpression tExpr = ultd.getItemTypeExpression();
-        AUnorderedListType ault = new AUnorderedListType(null, typeName);
-        setCollectionItemType(tExpr, typeMap, incompleteItemTypes, incompleteFieldTypes, ault);
-        return ault;
-    }
+	private AUnorderedListType computeUnorderedListType(String typeName,
+			UnorderedListTypeDefinition ultd, Map<String, IAType> typeMap,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
+		TypeExpression tExpr = ultd.getItemTypeExpression();
+		AUnorderedListType ault = new AUnorderedListType(null, typeName);
+		setCollectionItemType(tExpr, typeMap, incompleteItemTypes,
+				incompleteFieldTypes, ault);
+		return ault;
+	}
 
-    private void setCollectionItemType(TypeExpression tExpr, Map<String, IAType> typeMap,
-            Map<String, List<AbstractCollectionType>> incompleteItemTypes,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, AbstractCollectionType act) {
-        switch (tExpr.getTypeKind()) {
-            case ORDEREDLIST: {
-                OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) tExpr;
-                IAType t = computeOrderedListType(null, oltd, typeMap, incompleteItemTypes, incompleteFieldTypes);
-                act.setItemType(t);
-                break;
-            }
-            case UNORDEREDLIST: {
-                UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) tExpr;
-                IAType t = computeUnorderedListType(null, ultd, typeMap, incompleteItemTypes, incompleteFieldTypes);
-                act.setItemType(t);
-                break;
-            }
-            case RECORD: {
-                RecordTypeDefinition rtd = (RecordTypeDefinition) tExpr;
-                IAType t = computeRecordType(null, rtd, typeMap, incompleteFieldTypes, incompleteItemTypes);
-                act.setItemType(t);
-                break;
-            }
-            case TYPEREFERENCE: {
-                TypeReferenceExpression tre = (TypeReferenceExpression) tExpr;
-                IAType tref = solveTypeReference(tre, typeMap);
-                if (tref != null) {
-                    act.setItemType(tref);
-                } else {
-                    addIncompleteCollectionTypeReference(act, tre, incompleteItemTypes);
-                }
-                break;
-            }
-            default: {
-                throw new IllegalStateException();
-            }
-        }
-    }
+	private void setCollectionItemType(TypeExpression tExpr,
+			Map<String, IAType> typeMap,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
+			AbstractCollectionType act) {
+		switch (tExpr.getTypeKind()) {
+		case ORDEREDLIST: {
+			OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) tExpr;
+			IAType t = computeOrderedListType(null, oltd, typeMap,
+					incompleteItemTypes, incompleteFieldTypes);
+			act.setItemType(t);
+			break;
+		}
+		case UNORDEREDLIST: {
+			UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) tExpr;
+			IAType t = computeUnorderedListType(null, ultd, typeMap,
+					incompleteItemTypes, incompleteFieldTypes);
+			act.setItemType(t);
+			break;
+		}
+		case RECORD: {
+			RecordTypeDefinition rtd = (RecordTypeDefinition) tExpr;
+			IAType t = computeRecordType(null, rtd, typeMap,
+					incompleteFieldTypes, incompleteItemTypes);
+			act.setItemType(t);
+			break;
+		}
+		case TYPEREFERENCE: {
+			TypeReferenceExpression tre = (TypeReferenceExpression) tExpr;
+			IAType tref = solveTypeReference(tre, typeMap);
+			if (tref != null) {
+				act.setItemType(tref);
+			} else {
+				addIncompleteCollectionTypeReference(act, tre,
+						incompleteItemTypes);
+			}
+			break;
+		}
+		default: {
+			throw new IllegalStateException();
+		}
+		}
+	}
 
-    private ARecordType computeRecordType(String typeName, RecordTypeDefinition rtd, Map<String, IAType> typeMap,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
-            Map<String, List<AbstractCollectionType>> incompleteItemTypes) {
-        List<String> names = rtd.getFieldNames();
-        int n = names.size();
-        String[] fldNames = new String[n];
-        IAType[] fldTypes = new IAType[n];
-        int i = 0;
-        for (String s : names) {
-            fldNames[i++] = s;
-        }
-        boolean isOpen = rtd.getRecordKind() == RecordKind.OPEN;
-        ARecordType recType = new ARecordType(typeName, fldNames, fldTypes, isOpen);
-        for (int j = 0; j < n; j++) {
-            TypeExpression texpr = rtd.getFieldTypes().get(j);
-            switch (texpr.getTypeKind()) {
-                case TYPEREFERENCE: {
-                    TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
-                    IAType tref = solveTypeReference(tre, typeMap);
-                    if (tref != null) {
-                        if (!rtd.getNullableFields().get(j)) { // not nullable
-                            fldTypes[j] = tref;
-                        } else { // nullable
-                            fldTypes[j] = makeUnionWithNull(null, tref);
-                        }
-                    } else {
-                        addIncompleteFieldTypeReference(recType, j, tre, incompleteFieldTypes);
-                        if (rtd.getNullableFields().get(j)) {
-                            fldTypes[j] = makeUnionWithNull(null, null);
-                        }
-                    }
-                    break;
-                }
-                case RECORD: {
-                    RecordTypeDefinition recTypeDef2 = (RecordTypeDefinition) texpr;
-                    IAType t2 = computeRecordType(null, recTypeDef2, typeMap, incompleteFieldTypes, incompleteItemTypes);
-                    if (!rtd.getNullableFields().get(j)) { // not nullable
-                        fldTypes[j] = t2;
-                    } else { // nullable
-                        fldTypes[j] = makeUnionWithNull(null, t2);
-                    }
-                    break;
-                }
-                case ORDEREDLIST: {
-                    OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
-                    IAType t2 = computeOrderedListType(null, oltd, typeMap, incompleteItemTypes, incompleteFieldTypes);
-                    fldTypes[j] = (rtd.getNullableFields().get(j)) ? makeUnionWithNull(null, t2) : t2;
-                    break;
-                }
-                case UNORDEREDLIST: {
-                    UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
-                    IAType t2 = computeUnorderedListType(null, ultd, typeMap, incompleteItemTypes, incompleteFieldTypes);
-                    fldTypes[j] = (rtd.getNullableFields().get(j)) ? makeUnionWithNull(null, t2) : t2;
-                    break;
-                }
-                default: {
-                    throw new IllegalStateException();
-                }
-            }
+	private ARecordType computeRecordType(String typeName,
+			RecordTypeDefinition rtd, Map<String, IAType> typeMap,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes) {
+		List<String> names = rtd.getFieldNames();
+		int n = names.size();
+		String[] fldNames = new String[n];
+		IAType[] fldTypes = new IAType[n];
+		int i = 0;
+		for (String s : names) {
+			fldNames[i++] = s;
+		}
+		boolean isOpen = rtd.getRecordKind() == RecordKind.OPEN;
+		ARecordType recType = new ARecordType(typeName, fldNames, fldTypes,
+				isOpen);
+		for (int j = 0; j < n; j++) {
+			TypeExpression texpr = rtd.getFieldTypes().get(j);
+			switch (texpr.getTypeKind()) {
+			case TYPEREFERENCE: {
+				TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
+				IAType tref = solveTypeReference(tre, typeMap);
+				if (tref != null) {
+					if (!rtd.getNullableFields().get(j)) { // not nullable
+						fldTypes[j] = tref;
+					} else { // nullable
+						fldTypes[j] = makeUnionWithNull(null, tref);
+					}
+				} else {
+					addIncompleteFieldTypeReference(recType, j, tre,
+							incompleteFieldTypes);
+					if (rtd.getNullableFields().get(j)) {
+						fldTypes[j] = makeUnionWithNull(null, null);
+					}
+				}
+				break;
+			}
+			case RECORD: {
+				RecordTypeDefinition recTypeDef2 = (RecordTypeDefinition) texpr;
+				IAType t2 = computeRecordType(null, recTypeDef2, typeMap,
+						incompleteFieldTypes, incompleteItemTypes);
+				if (!rtd.getNullableFields().get(j)) { // not nullable
+					fldTypes[j] = t2;
+				} else { // nullable
+					fldTypes[j] = makeUnionWithNull(null, t2);
+				}
+				break;
+			}
+			case ORDEREDLIST: {
+				OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
+				IAType t2 = computeOrderedListType(null, oltd, typeMap,
+						incompleteItemTypes, incompleteFieldTypes);
+				fldTypes[j] = (rtd.getNullableFields().get(j)) ? makeUnionWithNull(
+						null, t2) : t2;
+				break;
+			}
+			case UNORDEREDLIST: {
+				UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
+				IAType t2 = computeUnorderedListType(null, ultd, typeMap,
+						incompleteItemTypes, incompleteFieldTypes);
+				fldTypes[j] = (rtd.getNullableFields().get(j)) ? makeUnionWithNull(
+						null, t2) : t2;
+				break;
+			}
+			default: {
+				throw new IllegalStateException();
+			}
+			}
 
-        }
+		}
 
-        return recType;
-    }
+		return recType;
+	}
 
-    private AUnionType makeUnionWithNull(String unionTypeName, IAType type) {
-        ArrayList<IAType> unionList = new ArrayList<IAType>(2);
-        unionList.add(BuiltinType.ANULL);
-        unionList.add(type);
-        return new AUnionType(unionList, unionTypeName);
-    }
+	private AUnionType makeUnionWithNull(String unionTypeName, IAType type) {
+		ArrayList<IAType> unionList = new ArrayList<IAType>(2);
+		unionList.add(BuiltinType.ANULL);
+		unionList.add(type);
+		return new AUnionType(unionList, unionTypeName);
+	}
 
-    private void addIncompleteCollectionTypeReference(AbstractCollectionType collType, TypeReferenceExpression tre,
-            Map<String, List<AbstractCollectionType>> incompleteItemTypes) {
-        String typeName = tre.getIdent().getValue();
-        List<AbstractCollectionType> typeList = incompleteItemTypes.get(typeName);
-        if (typeList == null) {
-            typeList = new LinkedList<AbstractCollectionType>();
-            incompleteItemTypes.put(typeName, typeList);
-        }
-        typeList.add(collType);
-    }
+	private void addIncompleteCollectionTypeReference(
+			AbstractCollectionType collType, TypeReferenceExpression tre,
+			Map<String, List<AbstractCollectionType>> incompleteItemTypes) {
+		String typeName = tre.getIdent().getValue();
+		List<AbstractCollectionType> typeList = incompleteItemTypes
+				.get(typeName);
+		if (typeList == null) {
+			typeList = new LinkedList<AbstractCollectionType>();
+			incompleteItemTypes.put(typeName, typeList);
+		}
+		typeList.add(collType);
+	}
 
-    private void addIncompleteFieldTypeReference(ARecordType recType, int fldPosition, TypeReferenceExpression tre,
-            Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
-        String typeName = tre.getIdent().getValue();
-        Map<ARecordType, List<Integer>> refMap = incompleteFieldTypes.get(typeName);
-        if (refMap == null) {
-            refMap = new HashMap<ARecordType, List<Integer>>();
-            incompleteFieldTypes.put(typeName, refMap);
-        }
-        List<Integer> typeList = refMap.get(recType);
-        if (typeList == null) {
-            typeList = new ArrayList<Integer>();
-            refMap.put(recType, typeList);
-        }
-        typeList.add(fldPosition);
-    }
+	private void addIncompleteFieldTypeReference(ARecordType recType,
+			int fldPosition, TypeReferenceExpression tre,
+			Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes) {
+		String typeName = tre.getIdent().getValue();
+		Map<ARecordType, List<Integer>> refMap = incompleteFieldTypes
+				.get(typeName);
+		if (refMap == null) {
+			refMap = new HashMap<ARecordType, List<Integer>>();
+			incompleteFieldTypes.put(typeName, refMap);
+		}
+		List<Integer> typeList = refMap.get(recType);
+		if (typeList == null) {
+			typeList = new ArrayList<Integer>();
+			refMap.put(recType, typeList);
+		}
+		typeList.add(fldPosition);
+	}
 
-    private void addIncompleteTopLevelTypeReference(String tdeclName, TypeReferenceExpression tre,
-            Map<String, List<String>> incompleteTopLevelTypeReferences) {
-        String name = tre.getIdent().getValue();
-        List<String> refList = incompleteTopLevelTypeReferences.get(name);
-        if (refList == null) {
-            refList = new LinkedList<String>();
-            incompleteTopLevelTypeReferences.put(name, refList);
-        }
-        refList.add(tdeclName);
-    }
+	private void addIncompleteTopLevelTypeReference(String tdeclName,
+			TypeReferenceExpression tre,
+			Map<String, List<String>> incompleteTopLevelTypeReferences) {
+		String name = tre.getIdent().getValue();
+		List<String> refList = incompleteTopLevelTypeReferences.get(name);
+		if (refList == null) {
+			refList = new LinkedList<String>();
+			incompleteTopLevelTypeReferences.put(name, refList);
+		}
+		refList.add(tdeclName);
+	}
 
-    private IAType solveTypeReference(TypeReferenceExpression tre, Map<String, IAType> typeMap) {
-        String name = tre.getIdent().getValue();
-        IAType builtin = builtinTypeMap.get(name);
-        if (builtin != null) {
-            return builtin;
-        } else {
-            return typeMap.get(name);
-        }
-    }
+	private IAType solveTypeReference(TypeReferenceExpression tre,
+			Map<String, IAType> typeMap) {
+		String name = tre.getIdent().getValue();
+		IAType builtin = builtinTypeMap.get(name);
+		if (builtin != null) {
+			return builtin;
+		} else {
+			return typeMap.get(name);
+		}
+	}
 
-    public static interface ICompiledStatement {
+	public static interface ICompiledStatement {
 
-        public abstract Kind getKind();
-    }
+		public abstract Kind getKind();
+	}
 
-    public static class CompiledLoadFromFileStatement implements ICompiledStatement, IParseFileSplitsDecl {
-        private String datasetName;
-        private FileSplit[] splits;
-        private boolean alreadySorted;
-        private Character delimChar;
+	public static class CompiledLoadFromFileStatement implements
+			ICompiledStatement, IParseFileSplitsDecl {
+		private String datasetName;
+		private FileSplit[] splits;
+		private boolean alreadySorted;
+		private Character delimChar;
 
-        public CompiledLoadFromFileStatement(String datasetName, FileSplit[] splits, Character delimChar,
-                boolean alreadySorted) {
-            this.datasetName = datasetName;
-            this.splits = splits;
-            this.delimChar = delimChar;
-            this.alreadySorted = alreadySorted;
-        }
+		public CompiledLoadFromFileStatement(String datasetName,
+				FileSplit[] splits, Character delimChar, boolean alreadySorted) {
+			this.datasetName = datasetName;
+			this.splits = splits;
+			this.delimChar = delimChar;
+			this.alreadySorted = alreadySorted;
+		}
 
-        public String getDatasetName() {
-            return datasetName;
-        }
+		public String getDatasetName() {
+			return datasetName;
+		}
 
-        @Override
-        public FileSplit[] getSplits() {
-            return splits;
-        }
+		@Override
+		public FileSplit[] getSplits() {
+			return splits;
+		}
 
-        @Override
-        public Character getDelimChar() {
-            return delimChar;
-        }
+		@Override
+		public Character getDelimChar() {
+			return delimChar;
+		}
 
-        public boolean alreadySorted() {
-            return alreadySorted;
-        }
+		public boolean alreadySorted() {
+			return alreadySorted;
+		}
 
-        @Override
-        public boolean isDelimitedFileFormat() {
-            return delimChar != null;
-        }
+		@Override
+		public boolean isDelimitedFileFormat() {
+			return delimChar != null;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.LOAD_FROM_FILE;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.LOAD_FROM_FILE;
+		}
+	}
 
-    public static class CompiledWriteFromQueryResultStatement implements ICompiledStatement {
+	public static class CompiledWriteFromQueryResultStatement implements
+			ICompiledStatement {
 
-        private String datasetName;
-        private Query query;
-        private int varCounter;
+		private String datasetName;
+		private Query query;
+		private int varCounter;
 
-        public CompiledWriteFromQueryResultStatement(String datasetName, Query query, int varCounter) {
-            this.datasetName = datasetName;
-            this.query = query;
-            this.varCounter = varCounter;
-        }
+		public CompiledWriteFromQueryResultStatement(String datasetName,
+				Query query, int varCounter) {
+			this.datasetName = datasetName;
+			this.query = query;
+			this.varCounter = varCounter;
+		}
 
-        public String getDatasetName() {
-            return datasetName;
-        }
+		public String getDatasetName() {
+			return datasetName;
+		}
 
-        public int getVarCounter() {
-            return varCounter;
-        }
+		public int getVarCounter() {
+			return varCounter;
+		}
 
-        public Query getQuery() {
-            return query;
-        }
+		public Query getQuery() {
+			return query;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.WRITE_FROM_QUERY_RESULT;
-        }
+		@Override
+		public Kind getKind() {
+			return Kind.WRITE_FROM_QUERY_RESULT;
+		}
 
-    }
+	}
 
-    public static class CompiledDatasetDropStatement implements ICompiledStatement {
-        private String datasetName;
+	public static class CompiledDatasetDropStatement implements
+			ICompiledStatement {
+		private String datasetName;
 
-        public CompiledDatasetDropStatement(String datasetName) {
-            this.datasetName = datasetName;
-        }
+		public CompiledDatasetDropStatement(String datasetName) {
+			this.datasetName = datasetName;
+		}
 
-        public String getDatasetName() {
-            return datasetName;
-        }
+		public String getDatasetName() {
+			return datasetName;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.DATASET_DROP;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.DATASET_DROP;
+		}
+	}
 
-    // added by yasser
-    public static class CompiledCreateDataverseStatement implements ICompiledStatement {
-        private String dataverseName;
-        private String format;
+	// added by yasser
+	public static class CompiledCreateDataverseStatement implements
+			ICompiledStatement {
+		private String dataverseName;
+		private String format;
 
-        public CompiledCreateDataverseStatement(String dataverseName, String format) {
-            this.dataverseName = dataverseName;
-            this.format = format;
-        }
+		public CompiledCreateDataverseStatement(String dataverseName,
+				String format) {
+			this.dataverseName = dataverseName;
+			this.format = format;
+		}
 
-        public String getDataverseName() {
-            return dataverseName;
-        }
+		public String getDataverseName() {
+			return dataverseName;
+		}
 
-        public String getFormat() {
-            return format;
-        }
+		public String getFormat() {
+			return format;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.CREATE_DATAVERSE;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.CREATE_DATAVERSE;
+		}
+	}
 
-    public static class CompiledNodeGroupDropStatement implements ICompiledStatement {
-        private String nodeGroupName;
+	public static class CompiledNodeGroupDropStatement implements
+			ICompiledStatement {
+		private String nodeGroupName;
 
-        public CompiledNodeGroupDropStatement(String nodeGroupName) {
-            this.nodeGroupName = nodeGroupName;
-        }
+		public CompiledNodeGroupDropStatement(String nodeGroupName) {
+			this.nodeGroupName = nodeGroupName;
+		}
 
-        public String getNodeGroupName() {
-            return nodeGroupName;
-        }
+		public String getNodeGroupName() {
+			return nodeGroupName;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.NODEGROUP_DROP;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.NODEGROUP_DROP;
+		}
+	}
 
-    public static class CompiledIndexDropStatement implements ICompiledStatement {
-        private String datasetName;
-        private String indexName;
+	public static class CompiledIndexDropStatement implements
+			ICompiledStatement {
+		private String datasetName;
+		private String indexName;
 
-        public CompiledIndexDropStatement(String datasetName, String indexName) {
-            this.datasetName = datasetName;
-            this.indexName = indexName;
-        }
+		public CompiledIndexDropStatement(String datasetName, String indexName) {
+			this.datasetName = datasetName;
+			this.indexName = indexName;
+		}
 
-        public String getDatasetName() {
-            return datasetName;
-        }
+		public String getDatasetName() {
+			return datasetName;
+		}
 
-        public String getIndexName() {
-            return indexName;
-        }
+		public String getIndexName() {
+			return indexName;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.INDEX_DROP;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.INDEX_DROP;
+		}
+	}
 
-    public static class CompiledDataverseDropStatement implements ICompiledStatement {
-        private String dataverseName;
-        private boolean ifExists;
+	public static class CompiledDataverseDropStatement implements
+			ICompiledStatement {
+		private String dataverseName;
+		private boolean ifExists;
 
-        public CompiledDataverseDropStatement(String dataverseName, boolean ifExists) {
-            this.dataverseName = dataverseName;
-            this.ifExists = ifExists;
-        }
+		public CompiledDataverseDropStatement(String dataverseName,
+				boolean ifExists) {
+			this.dataverseName = dataverseName;
+			this.ifExists = ifExists;
+		}
 
-        public String getDataverseName() {
-            return dataverseName;
-        }
+		public String getDataverseName() {
+			return dataverseName;
+		}
 
-        public boolean getIfExists() {
-            return ifExists;
-        }
+		public boolean getIfExists() {
+			return ifExists;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.DATAVERSE_DROP;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.DATAVERSE_DROP;
+		}
+	}
 
-    public static class CompiledTypeDropStatement implements ICompiledStatement {
-        private String typeName;
+	public static class CompiledTypeDropStatement implements ICompiledStatement {
+		private String typeName;
 
-        public CompiledTypeDropStatement(String nodeGroupName) {
-            this.typeName = nodeGroupName;
-        }
+		public CompiledTypeDropStatement(String nodeGroupName) {
+			this.typeName = nodeGroupName;
+		}
 
-        public String getTypeName() {
-            return typeName;
-        }
+		public String getTypeName() {
+			return typeName;
+		}
 
-        @Override
-        public Kind getKind() {
-            return Kind.TYPE_DROP;
-        }
-    }
+		@Override
+		public Kind getKind() {
+			return Kind.TYPE_DROP;
+		}
+	}
 }
diff --git a/asterix-app/src/test/resources/runtimets/ignore.txt b/asterix-app/src/test/resources/runtimets/ignore.txt
index dc40231..1cf8519 100644
--- a/asterix-app/src/test/resources/runtimets/ignore.txt
+++ b/asterix-app/src/test/resources/runtimets/ignore.txt
@@ -32,3 +32,8 @@
 open-closed/heterog-list02
 open-closed/heterog-list03
 open-closed/c2c
+quantifiers/somesat_03.aql
+quantifiers/somesat_04.aql
+quantifiers/somesat_05.aql
+quantifiers/everysat_02.aql
+quantifiers/everysat_03.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql
new file mode 100644
index 0000000..0c87734
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/drop-index.aql
@@ -0,0 +1,50 @@
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed {
+unique1:  int32,
+unique2:  int32,
+two:  int32,
+four:  int32,
+ten:  int32,
+twenty:  int32,
+onePercent: int32,
+tenPercent:  int32,
+twentyPercent:  int32,
+fiftyPercent:  int32,
+unique3:  int32,
+evenOnePercent: int32,
+oddOnePercent:  int32,
+stringu1:  string,
+stringu2:  string,
+string4:  string
+}
+
+create dataset t1(Schema) partitioned by key unique2;
+
+// Load data
+load dataset t1
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/wisc/onektup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+// create secondary indexes
+create index idx_t1_str1 on t1(stringu1);
+create index idx_t1_unique1 on t1(unique1);
+
+// drop secondary indexes
+drop index t1.idx_t1_str1;
+drop index t1.idx_t1_unique1;
+
+write output to nc1:"rttest/dml_drop-index.adm";
+
+for $a in dataset('t1')
+where $a.unique1 > 10 and $a.stringu1="DGAAAAXXXXXXXXXXXXXXXXXXX"
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql
new file mode 100644
index 0000000..fad06ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql
@@ -0,0 +1,29 @@
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_everysat_02.adm";
+
+let $a := [
+every $x in [1, 2] satisfies $x + $x = 3,
+every $x in [1, 1] satisfies $x + $x = 2,
+every $x in [1, 2] satisfies $x - 2 = 2,
+every $x in [2, 2] satisfies $x - 2 = 0,
+every $x in [1, 2] satisfies $x * 2 = 4,
+every $x in [1, 2] satisfies $x / 2 = 1,
+every $x in [1, 2] satisfies $x = 1 or $x = 2,
+every $x in [1, 2] satisfies $x = 1 and ($x +1) = 2,
+every $x in ["A","B","C"] satisfies $x = "A",
+every $x in [1,2,3], $y in [4,5,6] satisfies $x + $y = 5,
+every $x in [1,2,3], $y in [4,5,6] satisfies $x - $y = 5,
+every $x in [1,2,3], $y in [4,5,6] satisfies $x * $y = 10
+]
+for $i in $a
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql
new file mode 100644
index 0000000..7f9824e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql
@@ -0,0 +1,33 @@
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_everysat_02.adm";
+
+let $a := [
+every $x in [1, 2] satisfies avg([$x, 1]) = 1,
+every $x in [1, 2] satisfies string($x) = "1",
+every $x in [1, 2] satisfies string-length(string($x)) = 1,
+every $x in [[1, 2],[10],[1,5,7,8]] satisfies count($x) = 1,
+every $x in [[2],[10],[8]] satisfies count($x) = 1,
+every $x in [1, 2] satisfies boolean("true"),
+every $x in [1, 2] satisfies not($x),
+every $x in [1,2,3], $y in [4,5,6] satisfies $x + $y = 5,
+every $x in [1,2,3], $y in [4,5,6] satisfies $x - $y = 5,
+every $x in [1,2,3], $y in [4,5,6] satisfies $x * $y = 10,
+every $x in [1,2,3], $y in [4,5,6] satisfies string($x) = string($y),
+every $x in [1,2,3], $y in [4,5,6] satisfies int32($x) = int32($y),
+every $x in [1,2,3], $y in [4,5,6] satisfies float($x) = float($y),
+every $x in [1,2,3], $y in [4,5,6] satisfies double($x) = double($y),
+every $x in ["true", "false"], $y in ["false","true"] satisfies boolean($x) = boolean($y),
+every $x in ["1980-05-05T13:13:13Z", "1980-05-05T13:13:13Z"], $y in ["1980-05-05T13:13:13Z","1980-05-05T13:13:13Z"] satisfies datetime($x) = datetime($y)
+]
+for $i in $a
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql
new file mode 100644
index 0000000..5995b9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql
@@ -0,0 +1,30 @@
+/*
+ * Description     :  Test quantified expressions; some variable in [ordered list] satisfies expression.
+ * Expected Result : Success
+ * Date            : 6th July 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_somesat_03.adm";
+
+let $a := [
+some $x in [1, 2] satisfies $x + $x = 3,
+some $x in [1, 2] satisfies $x + $x = 2,
+some $x in [1, 2] satisfies $x - 2 = 2,
+some $x in [1, 2] satisfies $x - 2 = 0,
+some $x in [1, 2] satisfies $x * 2 = 4,
+some $x in [1, 2] satisfies $x / 2 = 1,
+some $x in [1, 2] satisfies avg([$x,1]) = 1,
+some $x in [1, 2] satisfies boolean("true"),
+some $x in [1, 2] satisfies boolean("false"),
+some $x in [1, 2] satisfies not($x),
+some $x in [1, 2] satisfies $x = 1 or $x = 2,
+some $x in [1, 2] satisfies $x = 1 and ($x +1) = 2 
+]
+for $i in $a
+return $i
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql
new file mode 100644
index 0000000..8d92cbb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql
@@ -0,0 +1,28 @@
+/*
+ * Description      : Test Quantified Expressions
+ *                  : some <variable-name> in [ordered-list] satisfies function expression
+ *                  : some <variable-name> in [ordered-list],<variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_somesat_04.adm";
+
+let $a := [
+some $x in ["foo","foobar","foot","fox"] satisfies string-length($x) = 1,
+some $x in [1,2,3,4,5,6,7,8] satisfies count($x) = 8,
+some $x in [1, 2] satisfies $x = 1 or $x = 2,
+some $x in [1, 2] satisfies $x = 1 and ($x +1) = 2,
+some $x in ["A","B","C"] satisfies $x = "A",
+some $x in [1,2,3], $y in [4,5,6] satisfies $x + $y = 5,
+some $x in [1,2,3], $y in [4,5,6] satisfies $x - $y = 5,
+some $x in [1,2,3], $y in [4,5,6] satisfies $x * $y = 10,
+some $x in [1,2,3], $y in [4,5,6] satisfies $x / $y = 2
+]
+for $i in $a
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql
new file mode 100644
index 0000000..fefd86d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql
@@ -0,0 +1,24 @@
+/*
+ * Description      :  Test Quantified Expressions 
+ *                  :  some <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies function expression
+ * Expected Result  :  Success
+ * Date             :  5th July 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_somesat_05.adm";
+
+let $a := [
+some $x in ["foo","foobar","footnote"], $y in ["foofoo","fool","foolish","foot","foo"] satisfies string($x) = string($y),
+some $x in ["1","2","3"], $y in ["4","5","6"] satisfies int32($x) = int32($y),
+some $x in ["1.1","2.2","3.3"], $y in ["4.4","5.5","6.6"] satisfies float($x) = float($y),
+some $x in ["1.1d","2.2d","3.3d"], $y in ["4.4d","5.5d","6.6d"] satisfies double($x) = double($y),
+some $x in ["true", "false"], $y in ["false","true"] satisfies boolean($x) = boolean($y),
+some $x in ["1980-05-05T13:13:13Z", "1980-05-05T13:13:13Z"], $y in ["1980-05-05T13:13:13Z","1980-05-05T13:13:13Z"] satisfies datetime($x) = datetime($y),
+some $x in ["1985-07-05Z", "1985-07-05Z"], $y in ["1985-07-05Z","1985-07-05Z"] satisfies date($x) = date($y)
+]
+for $i in $a
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/drop-index.adm b/asterix-app/src/test/resources/runtimets/results/dml/drop-index.adm
new file mode 100644
index 0000000..f3c688b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/drop-index.adm
@@ -0,0 +1 @@
+{ "unique1": 84, "unique2": 10, "two": 0, "four": 0, "ten": 4, "twenty": 4, "onePercent": 84, "tenPercent": 4, "twentyPercent": 4, "fiftyPercent": 0, "unique3": 84, "evenOnePercent": 168, "oddOnePercent": 169, "stringu1": "DGAAAAXXXXXXXXXXXXXXXXXXX", "stringu2": "KAAAAAXXXXXXXXXXXXXXXXXXX", "string4": "OOOOXXXXXXXXXXXXXXXXXXXXXX" }
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 fdb56be..8f0a3ff 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
@@ -83,7 +83,9 @@
     private String dataverseName;
 
     private enum DfsColor {
-        WHITE, GRAY, BLACK
+        WHITE,
+        GRAY,
+        BLACK
     }
 
     public AqlRewriter(Query topExpr, int varCounter, MetadataTransactionContext txnContext, String dataverseName) {
@@ -156,15 +158,15 @@
         List<AsterixFunction> functionCalls = getFunctionCalls(expression);
         for (AsterixFunction funId : functionCalls) {
             if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-                    funId.getFunctionName(), false))) {
+                    funId.getFunctionName()))) {
                 continue;
             }
 
-            if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS,
-                    funId.getFunctionName(), false))) {
+            if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(new FunctionIdentifier(
+                    AlgebricksBuiltinFunctions.ALGEBRICKS_NS, funId.getFunctionName()))) {
                 continue;
             }
-            
+
             if (declaredFunctions != null && declaredFunctions.contains(funId)) {
                 continue;
             }
@@ -179,8 +181,8 @@
     }
 
     private FunctionDecl getFunctionDecl(AsterixFunction funId) throws AsterixException {
-        Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, dataverseName, funId.getFunctionName(), funId
-                .getArity());
+        Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, dataverseName, funId.getFunctionName(),
+                funId.getArity());
         if (function == null) {
             throw new AsterixException(" unknown function " + funId);
         }
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 d246a92..1a30693 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
@@ -77,19 +77,17 @@
     public static IFunctionInfo getFunctionInfo(MetadataTransactionContext mdTxnCtx, String dataverseName,
             AsterixFunction asterixFunction) throws MetadataException {
         FunctionIdentifier fid = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-                asterixFunction.getFunctionName(), asterixFunction.getArity(), true);
+                asterixFunction.getFunctionName(), asterixFunction.getArity());
         IFunctionInfo finfo = AsterixBuiltinFunctions.getAsterixFunctionInfo(fid);
         if (fid == null) {
             fid = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS, asterixFunction.getFunctionName(),
-                    asterixFunction.getArity(), true);
+                    asterixFunction.getArity());
         }
         if (fid == null) {
-            Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, dataverseName, asterixFunction
-                    .getFunctionName(), asterixFunction.getArity());
+            Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, dataverseName,
+                    asterixFunction.getFunctionName(), asterixFunction.getArity());
             if (function != null) {
-                finfo = new AsterixFunctionInfo(dataverseName, asterixFunction, false);
-                // todo: for external functions, we shall construct another kind of function info (that extends AsterixFunctionInfo)
-                // and has additional information.
+                finfo = new AsterixFunctionInfo(dataverseName, asterixFunction);
             }
         }
         return finfo; // could be null
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataCache.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataCache.java
index 65a6d8e..e205acf 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataCache.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataCache.java
@@ -35,267 +35,259 @@
  * simply ignored, i.e., updates are not not applied to the cache.
  */
 public class MetadataCache {
-	// Key is dataverse name.
-	protected final Map<String, Dataverse> dataverses = new HashMap<String, Dataverse>();
-	// Key is dataverse name. Key of value map is dataset name.
-	protected final Map<String, Map<String, Dataset>> datasets = new HashMap<String, Map<String, Dataset>>();
-	// Key is dataverse name. Key of value map is datatype name.
-	protected final Map<String, Map<String, Datatype>> datatypes = new HashMap<String, Map<String, Datatype>>();
-	// Key is dataverse name.
-	protected final Map<String, NodeGroup> nodeGroups = new HashMap<String, NodeGroup>();
-	// Key is function Identifier . Key of value map is function name.
-	protected final Map<FunctionIdentifier, Function> functions = new HashMap<FunctionIdentifier, Function>();
+    // Key is dataverse name.
+    protected final Map<String, Dataverse> dataverses = new HashMap<String, Dataverse>();
+    // Key is dataverse name. Key of value map is dataset name.
+    protected final Map<String, Map<String, Dataset>> datasets = new HashMap<String, Map<String, Dataset>>();
+    // Key is dataverse name. Key of value map is datatype name.
+    protected final Map<String, Map<String, Datatype>> datatypes = new HashMap<String, Map<String, Datatype>>();
+    // Key is dataverse name.
+    protected final Map<String, NodeGroup> nodeGroups = new HashMap<String, NodeGroup>();
+    // Key is function Identifier . Key of value map is function name.
+    protected final Map<FunctionIdentifier, Function> functions = new HashMap<FunctionIdentifier, Function>();
 
-	// Atomically executes all metadata operations in ctx's log.
-	public void commit(MetadataTransactionContext ctx) {
-		// Forward roll the operations written in ctx's log.
-		int logIx = 0;
-		ArrayList<MetadataLogicalOperation> opLog = ctx.getOpLog();
-		try {
-			for (logIx = 0; logIx < opLog.size(); logIx++) {
-				doOperation(opLog.get(logIx));
-			}
-		} catch (Exception e) {
-			// Undo operations.
-			try {
-				for (int i = logIx - 1; i >= 0; i--) {
-					undoOperation(opLog.get(i));
-				}
-			} catch (Exception e2) {
-				// We encountered an error in undo. This case should never
-				// happen. Our only remedy to ensure cache consistency
-				// is to clear everything.
-				clear();
-			}
-		} finally {
-			ctx.clear();
-		}
-	}
+    // Atomically executes all metadata operations in ctx's log.
+    public void commit(MetadataTransactionContext ctx) {
+        // Forward roll the operations written in ctx's log.
+        int logIx = 0;
+        ArrayList<MetadataLogicalOperation> opLog = ctx.getOpLog();
+        try {
+            for (logIx = 0; logIx < opLog.size(); logIx++) {
+                doOperation(opLog.get(logIx));
+            }
+        } catch (Exception e) {
+            // Undo operations.
+            try {
+                for (int i = logIx - 1; i >= 0; i--) {
+                    undoOperation(opLog.get(i));
+                }
+            } catch (Exception e2) {
+                // We encountered an error in undo. This case should never
+                // happen. Our only remedy to ensure cache consistency
+                // is to clear everything.
+                clear();
+            }
+        } finally {
+            ctx.clear();
+        }
+    }
 
-	public void clear() {
-		synchronized (dataverses) {
-			synchronized (nodeGroups) {
-				synchronized (datasets) {
-					synchronized (datatypes) {
-						synchronized (functions) {
-							dataverses.clear();
-							nodeGroups.clear();
-							datasets.clear();
-							datatypes.clear();
-						}
-					}
-				}
-			}
-		}
-	}
+    public void clear() {
+        synchronized (dataverses) {
+            synchronized (nodeGroups) {
+                synchronized (datasets) {
+                    synchronized (datatypes) {
+                        synchronized (functions) {
+                            dataverses.clear();
+                            nodeGroups.clear();
+                            datasets.clear();
+                            datatypes.clear();
+                        }
+                    }
+                }
+            }
+        }
+    }
 
-	public Object addDataverseIfNotExists(Dataverse dataverse) {
-		synchronized (dataverses) {
-			synchronized (datasets) {
-				synchronized (datatypes) {
-					synchronized (functions) {
-						if (!dataverses.containsKey(dataverse)) {
-							datasets.put(dataverse.getDataverseName(),
-									new HashMap<String, Dataset>());
-							datatypes.put(dataverse.getDataverseName(),
-									new HashMap<String, Datatype>());
-							return dataverses.put(dataverse.getDataverseName(),
-									dataverse);
-						}
-					}
-					return null;
-				}
-			}
-		}
-	}
+    public Object addDataverseIfNotExists(Dataverse dataverse) {
+        synchronized (dataverses) {
+            synchronized (datasets) {
+                synchronized (datatypes) {
+                    synchronized (functions) {
+                        if (!dataverses.containsKey(dataverse)) {
+                            datasets.put(dataverse.getDataverseName(), new HashMap<String, Dataset>());
+                            datatypes.put(dataverse.getDataverseName(), new HashMap<String, Datatype>());
+                            return dataverses.put(dataverse.getDataverseName(), dataverse);
+                        }
+                    }
+                    return null;
+                }
+            }
+        }
+    }
 
-	public Object addDatasetIfNotExists(Dataset dataset) {
-		synchronized (datasets) {
-			Map<String, Dataset> m = datasets.get(dataset.getDataverseName());
-			if (m == null) {
-				m = new HashMap<String, Dataset>();
-				datasets.put(dataset.getDataverseName(), m);
-			}
-			if (!m.containsKey(dataset.getDatasetName())) {
-				return m.put(dataset.getDatasetName(), dataset);
-			}
-			return null;
-		}
-	}
+    public Object addDatasetIfNotExists(Dataset dataset) {
+        synchronized (datasets) {
+            Map<String, Dataset> m = datasets.get(dataset.getDataverseName());
+            if (m == null) {
+                m = new HashMap<String, Dataset>();
+                datasets.put(dataset.getDataverseName(), m);
+            }
+            if (!m.containsKey(dataset.getDatasetName())) {
+                return m.put(dataset.getDatasetName(), dataset);
+            }
+            return null;
+        }
+    }
 
-	public Object addDatatypeIfNotExists(Datatype datatype) {
-		synchronized (datatypes) {
-			Map<String, Datatype> m = datatypes
-					.get(datatype.getDataverseName());
-			if (m == null) {
-				m = new HashMap<String, Datatype>();
-				datatypes.put(datatype.getDataverseName(), m);
-			}
-			if (!m.containsKey(datatype.getDatatypeName())) {
-				return m.put(datatype.getDatatypeName(), datatype);
-			}
-			return null;
-		}
-	}
+    public Object addDatatypeIfNotExists(Datatype datatype) {
+        synchronized (datatypes) {
+            Map<String, Datatype> m = datatypes.get(datatype.getDataverseName());
+            if (m == null) {
+                m = new HashMap<String, Datatype>();
+                datatypes.put(datatype.getDataverseName(), m);
+            }
+            if (!m.containsKey(datatype.getDatatypeName())) {
+                return m.put(datatype.getDatatypeName(), datatype);
+            }
+            return null;
+        }
+    }
 
-	public Object addNodeGroupIfNotExists(NodeGroup nodeGroup) {
-		synchronized (nodeGroups) {
-			if (!nodeGroups.containsKey(nodeGroup.getNodeGroupName())) {
-				return nodeGroups.put(nodeGroup.getNodeGroupName(), nodeGroup);
-			}
-			return null;
-		}
-	}
+    public Object addNodeGroupIfNotExists(NodeGroup nodeGroup) {
+        synchronized (nodeGroups) {
+            if (!nodeGroups.containsKey(nodeGroup.getNodeGroupName())) {
+                return nodeGroups.put(nodeGroup.getNodeGroupName(), nodeGroup);
+            }
+            return null;
+        }
+    }
 
-	public Object dropDataverse(Dataverse dataverse) {
-		synchronized (dataverses) {
-			synchronized (datasets) {
-				synchronized (datatypes) {
-					synchronized (functions) {
-						datasets.remove(dataverse.getDataverseName());
-						datatypes.remove(dataverse.getDataverseName());
-						return dataverses.remove(dataverse.getDataverseName());
-					}
-				}
-			}
-		}
-	}
+    public Object dropDataverse(Dataverse dataverse) {
+        synchronized (dataverses) {
+            synchronized (datasets) {
+                synchronized (datatypes) {
+                    synchronized (functions) {
+                        datasets.remove(dataverse.getDataverseName());
+                        datatypes.remove(dataverse.getDataverseName());
+                        return dataverses.remove(dataverse.getDataverseName());
+                    }
+                }
+            }
+        }
+    }
 
-	public Object dropDataset(Dataset dataset) {
-		synchronized (datasets) {
-			Map<String, Dataset> m = datasets.get(dataset.getDataverseName());
-			if (m == null) {
-				return null;
-			}
-			return m.remove(dataset.getDatasetName());
-		}
-	}
+    public Object dropDataset(Dataset dataset) {
+        synchronized (datasets) {
+            Map<String, Dataset> m = datasets.get(dataset.getDataverseName());
+            if (m == null) {
+                return null;
+            }
+            return m.remove(dataset.getDatasetName());
+        }
+    }
 
-	public Object dropDatatype(Datatype datatype) {
-		synchronized (datatypes) {
-			Map<String, Datatype> m = datatypes
-					.get(datatype.getDataverseName());
-			if (m == null) {
-				return null;
-			}
-			return m.remove(datatype.getDatatypeName());
-		}
-	}
+    public Object dropDatatype(Datatype datatype) {
+        synchronized (datatypes) {
+            Map<String, Datatype> m = datatypes.get(datatype.getDataverseName());
+            if (m == null) {
+                return null;
+            }
+            return m.remove(datatype.getDatatypeName());
+        }
+    }
 
-	public Object dropNodeGroup(NodeGroup nodeGroup) {
-		synchronized (nodeGroups) {
-			return nodeGroups.remove(nodeGroup.getNodeGroupName());
-		}
-	}
+    public Object dropNodeGroup(NodeGroup nodeGroup) {
+        synchronized (nodeGroups) {
+            return nodeGroups.remove(nodeGroup.getNodeGroupName());
+        }
+    }
 
-	public Dataverse getDataverse(String dataverseName) {
-		synchronized (dataverses) {
-			return dataverses.get(dataverseName);
-		}
-	}
+    public Dataverse getDataverse(String dataverseName) {
+        synchronized (dataverses) {
+            return dataverses.get(dataverseName);
+        }
+    }
 
-	public Dataset getDataset(String dataverseName, String datasetName) {
-		synchronized (datasets) {
-			Map<String, Dataset> m = datasets.get(dataverseName);
-			if (m == null) {
-				return null;
-			}
-			return m.get(datasetName);
-		}
-	}
+    public Dataset getDataset(String dataverseName, String datasetName) {
+        synchronized (datasets) {
+            Map<String, Dataset> m = datasets.get(dataverseName);
+            if (m == null) {
+                return null;
+            }
+            return m.get(datasetName);
+        }
+    }
 
-	public Datatype getDatatype(String dataverseName, String datatypeName) {
-		synchronized (datatypes) {
-			Map<String, Datatype> m = datatypes.get(dataverseName);
-			if (m == null) {
-				return null;
-			}
-			return m.get(datatypeName);
-		}
-	}
+    public Datatype getDatatype(String dataverseName, String datatypeName) {
+        synchronized (datatypes) {
+            Map<String, Datatype> m = datatypes.get(dataverseName);
+            if (m == null) {
+                return null;
+            }
+            return m.get(datatypeName);
+        }
+    }
 
-	public NodeGroup getNodeGroup(String nodeGroupName) {
-		synchronized (nodeGroups) {
-			return nodeGroups.get(nodeGroupName);
-		}
-	}
+    public NodeGroup getNodeGroup(String nodeGroupName) {
+        synchronized (nodeGroups) {
+            return nodeGroups.get(nodeGroupName);
+        }
+    }
 
-	public Function getFunction(String dataverse, String functionName, int arity) {
-		synchronized (functions) {
-			return functions.get(new FunctionIdentifier(dataverse,
-					functionName, arity, false));
-		}
-	}
+    public Function getFunction(String dataverse, String functionName, int arity) {
+        synchronized (functions) {
+            return functions.get(new FunctionIdentifier(dataverse, functionName, arity));
+        }
+    }
 
-	public List<Dataset> getDataverseDatasets(String dataverseName) {
-		List<Dataset> retDatasets = new ArrayList<Dataset>();
-		synchronized (datasets) {
-			Map<String, Dataset> m = datasets.get(dataverseName);
-			if (m == null) {
-				return retDatasets;
-			}
-			for (Map.Entry<String, Dataset> entry : m.entrySet()) {
-				retDatasets.add(entry.getValue());
-			}
-			return retDatasets;
-		}
-	}
+    public List<Dataset> getDataverseDatasets(String dataverseName) {
+        List<Dataset> retDatasets = new ArrayList<Dataset>();
+        synchronized (datasets) {
+            Map<String, Dataset> m = datasets.get(dataverseName);
+            if (m == null) {
+                return retDatasets;
+            }
+            for (Map.Entry<String, Dataset> entry : m.entrySet()) {
+                retDatasets.add(entry.getValue());
+            }
+            return retDatasets;
+        }
+    }
 
-	/**
-	 * Represents a logical operation against the metadata.
-	 */
-	protected class MetadataLogicalOperation {
-		// Entity to be added/dropped.
-		public final IMetadataEntity entity;
-		// True for add, false for drop.
-		public final boolean isAdd;
+    /**
+     * Represents a logical operation against the metadata.
+     */
+    protected class MetadataLogicalOperation {
+        // Entity to be added/dropped.
+        public final IMetadataEntity entity;
+        // True for add, false for drop.
+        public final boolean isAdd;
 
-		public MetadataLogicalOperation(IMetadataEntity entity, boolean isAdd) {
-			this.entity = entity;
-			this.isAdd = isAdd;
-		}
-	};
+        public MetadataLogicalOperation(IMetadataEntity entity, boolean isAdd) {
+            this.entity = entity;
+            this.isAdd = isAdd;
+        }
+    };
 
-	protected void doOperation(MetadataLogicalOperation op) {
-		if (op.isAdd) {
-			op.entity.addToCache(this);
-		} else {
-			op.entity.dropFromCache(this);
-		}
-	}
+    protected void doOperation(MetadataLogicalOperation op) {
+        if (op.isAdd) {
+            op.entity.addToCache(this);
+        } else {
+            op.entity.dropFromCache(this);
+        }
+    }
 
-	protected void undoOperation(MetadataLogicalOperation op) {
-		if (!op.isAdd) {
-			op.entity.addToCache(this);
-		} else {
-			op.entity.dropFromCache(this);
-		}
-	}
+    protected void undoOperation(MetadataLogicalOperation op) {
+        if (!op.isAdd) {
+            op.entity.addToCache(this);
+        } else {
+            op.entity.dropFromCache(this);
+        }
+    }
 
-	public Object addFunctionIfNotExists(Function function) {
-		synchronized (functions) {
-			FunctionIdentifier fId = new FunctionIdentifier(
-					function.getDataverseName(), function.getFunctionName(),
-					function.getFunctionArity(), false);
+    public Object addFunctionIfNotExists(Function function) {
+        synchronized (functions) {
+            FunctionIdentifier fId = new FunctionIdentifier(function.getDataverseName(), function.getFunctionName(),
+                    function.getFunctionArity());
 
-			Function fun = functions.get(fId);
-			if (fun == null) {
-				return functions.put(fId, function);
-			}
-			return null;
-		}
-	}
+            Function fun = functions.get(fId);
+            if (fun == null) {
+                return functions.put(fId, function);
+            }
+            return null;
+        }
+    }
 
-	public Object dropFunction(Function function) {
-		synchronized (functions) {
-			FunctionIdentifier fId = new FunctionIdentifier(
-					function.getDataverseName(), function.getFunctionName(),
-					function.getFunctionArity(), false);
-			Function fun = functions.get(fId);
-			if (fun == null) {
-				return null;
-			}
-			return functions.remove(fId);
-		}
-	}
+    public Object dropFunction(Function function) {
+        synchronized (functions) {
+            FunctionIdentifier fId = new FunctionIdentifier(function.getDataverseName(), function.getFunctionName(),
+                    function.getFunctionArity());
+            Function fun = functions.get(fId);
+            if (fun == null) {
+                return null;
+            }
+            return functions.remove(fId);
+        }
+    }
 }
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 ee99c0d..9ebf8d6 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
@@ -97,253 +97,239 @@
     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,
-            true);
+    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, true);
+            "get-handle", 2);
     public final static FunctionIdentifier GET_DATA = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-data",
-            2, true);
+            2);
     public final static FunctionIdentifier EMBED_TYPE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "embed-type", 1, true);
+            "embed-type", 1);
 
     public final static FunctionIdentifier GET_ITEM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item",
-            2, true);
+            2);
     public final static FunctionIdentifier ANY_COLLECTION_MEMBER = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "any-collection-member", 1, true);
-    public final static FunctionIdentifier LISTIFY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1,
-            true);
+            "any-collection-member", 1);
+    public final static FunctionIdentifier LISTIFY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "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, true);
+    public final static FunctionIdentifier LEN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "len", 1);
 
     public final static FunctionIdentifier CONCAT_NON_NULL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "concat-non-null", FunctionIdentifier.VARARGS, true);
+            "concat-non-null", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier EMPTY_STREAM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "empty-stream", 0, true);
+            "empty-stream", 0);
     public final static FunctionIdentifier NON_EMPTY_STREAM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "non-empty-stream", 0, true);
+            "non-empty-stream", 0);
     public final static FunctionIdentifier ORDERED_LIST_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "ordered-list-constructor", FunctionIdentifier.VARARGS, true);
+            FunctionConstants.ASTERIX_NS, "ordered-list-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier UNORDERED_LIST_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "unordered-list-constructor", FunctionIdentifier.VARARGS, true);
+            FunctionConstants.ASTERIX_NS, "unordered-list-constructor", FunctionIdentifier.VARARGS);
 
     // records
     public final static FunctionIdentifier CLOSED_RECORD_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "closed-record-constructor", FunctionIdentifier.VARARGS, true);
+            FunctionConstants.ASTERIX_NS, "closed-record-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier OPEN_RECORD_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "open-record-constructor", FunctionIdentifier.VARARGS, true);
+            FunctionConstants.ASTERIX_NS, "open-record-constructor", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier RECORD_TYPE_CONSTRUCTOR = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "record-type-constructor", FunctionIdentifier.VARARGS, true);
+            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, true);
+            "field-access-by-index", 2);
     public final static FunctionIdentifier FIELD_ACCESS_BY_NAME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "field-access-by-name", 2, true);
+            "field-access-by-name", 2);
 
     public final static FunctionIdentifier NUMERIC_UNARY_MINUS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-unary-minus", 1, true);
+            "numeric-unary-minus", 1);
 
     public final static FunctionIdentifier NUMERIC_SUBTRACT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-subtract", 2, true);
+            "numeric-subtract", 2);
     public final static FunctionIdentifier NUMERIC_MULTIPLY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-multiply", 2, true);
+            "numeric-multiply", 2);
     public final static FunctionIdentifier NUMERIC_DIVIDE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-divide", 2, true);
+            "numeric-divide", 2);
     public final static FunctionIdentifier NUMERIC_MOD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-mod", 2, true);
+            "numeric-mod", 2);
     public final static FunctionIdentifier NUMERIC_IDIV = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-idiv", 2, true);
-    public final static FunctionIdentifier CARET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "caret", 2,
-            true);
+            "numeric-idiv", 2);
+    public final static FunctionIdentifier CARET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "caret", 2);
 
-    public final static FunctionIdentifier DATASET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "dataset", 1,
-            true);
+    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, true);
+            "feed-ingest", 1);
 
     public final static FunctionIdentifier INDEX_SEARCH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "index-search", FunctionIdentifier.VARARGS, true);
+            "index-search", FunctionIdentifier.VARARGS);
 
     public final static FunctionIdentifier MAKE_FIELD_INDEX_HANDLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "make-field-index-handle", 2, true);
+            FunctionConstants.ASTERIX_NS, "make-field-index-handle", 2);
     public final static FunctionIdentifier MAKE_FIELD_NAME_HANDLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "make-field-name-handle", 1, true);
+            FunctionConstants.ASTERIX_NS, "make-field-name-handle", 1);
 
     public final static FunctionIdentifier SUBSTRING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "substring", 3, true);
-    public final static FunctionIdentifier LIKE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "like", 2, true);
+            "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, true);
+            2);
     private final static FunctionIdentifier STARTS_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "starts-with", 2, true);
+            "starts-with", 2);
     private final static FunctionIdentifier ENDS_WITH = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "ends-with", 2, true);
+            "ends-with", 2);
 
-    public final static FunctionIdentifier AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-avg", 1,
-            true);
-    public final static FunctionIdentifier COUNT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-count", 1,
-            true);
-    public final static FunctionIdentifier SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sum", 1,
-            true);
-    public final static FunctionIdentifier MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-max", 1,
-            true);
-    public final static FunctionIdentifier MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-min", 1,
-            true);
+    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 MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-max", 1);
+    public final static FunctionIdentifier MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-min", 1);
     public final static FunctionIdentifier GLOBAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "agg-global-avg", 1, true);
+            "agg-global-avg", 1);
     public final static FunctionIdentifier LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "agg-local-avg", 1, true);
+            "agg-local-avg", 1);
 
-    public final static FunctionIdentifier SCALAR_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1,
-            true);
+    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, true);
-    public final static FunctionIdentifier SCALAR_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sum", 1,
-            true);
-    public final static FunctionIdentifier SCALAR_MAX = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "max", 1,
-            true);
-    public final static FunctionIdentifier SCALAR_MIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "min", 1,
-            true);
+            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, true);
+            "global-avg", 1);
     public final static FunctionIdentifier SCALAR_LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-avg", 1, true);
+            "local-avg", 1);
 
     // serializable aggregate functions
     public final static FunctionIdentifier SERIAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "avg-serial", 1, true);
+            "avg-serial", 1);
     public final static FunctionIdentifier SERIAL_COUNT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "count-serial", 1, true);
+            "count-serial", 1);
     public final static FunctionIdentifier SERIAL_SUM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "sum-serial", 1, true);
+            "sum-serial", 1);
     public final static FunctionIdentifier SERIAL_GLOBAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "global-avg-serial", 1, true);
+            "global-avg-serial", 1);
     public final static FunctionIdentifier SERIAL_LOCAL_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-avg-serial", 1, true);
+            "local-avg-serial", 1);
 
-    public final static FunctionIdentifier YEAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "year", 1, true);
+    public final static FunctionIdentifier YEAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "year", 1);
 
     public final static FunctionIdentifier SCAN_COLLECTION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "scan-collection", 1, true);
+            "scan-collection", 1);
     public final static FunctionIdentifier SUBSET_COLLECTION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subset-collection", 3, true);
+            "subset-collection", 3);
 
-    public final static FunctionIdentifier RANGE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "range", 2,
-            true);
+    public final static FunctionIdentifier RANGE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "range", 2);
 
     // fuzzy functions:
     public final static FunctionIdentifier FUZZY_EQ = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "fuzzy-eq",
-            2, true);
+            2);
 
     public final static FunctionIdentifier PREFIX_LEN_JACCARD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "prefix-len-jaccard", 2, true);
+            "prefix-len-jaccard", 2);
 
     public final static FunctionIdentifier SIMILARITY_JACCARD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard", 2, true);
+            "similarity-jaccard", 2);
     public final static FunctionIdentifier SIMILARITY_JACCARD_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-check", 3, true);
+            FunctionConstants.ASTERIX_NS, "similarity-jaccard-check", 3);
     public final static FunctionIdentifier SIMILARITY_JACCARD_SORTED = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted", 2, true);
+            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted", 2);
     public final static FunctionIdentifier SIMILARITY_JACCARD_SORTED_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted-check", 3, true);
+            FunctionConstants.ASTERIX_NS, "similarity-jaccard-sorted-check", 3);
     public final static FunctionIdentifier SIMILARITY_JACCARD_PREFIX = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix", 6, true);
+            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix", 6);
     public final static FunctionIdentifier SIMILARITY_JACCARD_PREFIX_CHECK = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix-check", 6, true);
+            FunctionConstants.ASTERIX_NS, "similarity-jaccard-prefix-check", 6);
 
     public final static FunctionIdentifier EDIT_DISTANCE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance", 2, true);
+            "edit-distance", 2);
     public final static FunctionIdentifier EDIT_DISTANCE_CHECK = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance-check", 3, true);
+            "edit-distance-check", 3);
     public final static FunctionIdentifier EDIT_DISTANCE_LIST_IS_FILTERABLE = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "edit-distance-list-is-filterable", 2, true);
+            FunctionConstants.ASTERIX_NS, "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, true);
+            FunctionConstants.ASTERIX_NS, "edit-distance-string-is-filterable", 4);
 
     // tokenizers:
     public final static FunctionIdentifier WORD_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "word-tokens", 1, true);
+            "word-tokens", 1);
     public final static FunctionIdentifier HASHED_WORD_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-word-tokens", 1, true);
+            "hashed-word-tokens", 1);
     public final static FunctionIdentifier COUNTHASHED_WORD_TOKENS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "counthashed-word-tokens", 1, true);
+            FunctionConstants.ASTERIX_NS, "counthashed-word-tokens", 1);
     public final static FunctionIdentifier GRAM_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "gram-tokens", 3, true);
+            "gram-tokens", 3);
     public final static FunctionIdentifier HASHED_GRAM_TOKENS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-gram-tokens", 3, true);
+            "hashed-gram-tokens", 3);
     public final static FunctionIdentifier COUNTHASHED_GRAM_TOKENS = new FunctionIdentifier(
-            FunctionConstants.ASTERIX_NS, "counthashed-gram-tokens", 3, true);
+            FunctionConstants.ASTERIX_NS, "counthashed-gram-tokens", 3);
 
-    public final static FunctionIdentifier TID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tid", 0, true);
+    public final static FunctionIdentifier TID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tid", 0);
 
     // constructors:
     public final static FunctionIdentifier BOOLEAN_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "boolean", 1, false);
+            "boolean", 1);
     public final static FunctionIdentifier NULL_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "null", 1, false);
+            "null", 1);
     public final static FunctionIdentifier STRING_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "string", 1, false);
+            "string", 1);
     public final static FunctionIdentifier INT8_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int8", 1, false);
+            "int8", 1);
     public final static FunctionIdentifier INT16_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int16", 1, false);
+            "int16", 1);
     public final static FunctionIdentifier INT32_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int32", 1, false);
+            "int32", 1);
     public final static FunctionIdentifier INT64_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "int64", 1, false);
+            "int64", 1);
     public final static FunctionIdentifier FLOAT_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "float", 1, false);
+            "float", 1);
     public final static FunctionIdentifier DOUBLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "double", 1, false);
+            "double", 1);
     public final static FunctionIdentifier POINT_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "point", 1, false);
+            "point", 1);
     public final static FunctionIdentifier POINT3D_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "point3d", 1, false);
+            "point3d", 1);
     public final static FunctionIdentifier LINE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "line", 1, false);
+            "line", 1);
     public final static FunctionIdentifier CIRCLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "circle", 1, false);
+            "circle", 1);
     public final static FunctionIdentifier RECTANGLE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "rectangle", 1, false);
+            "rectangle", 1);
     public final static FunctionIdentifier POLYGON_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "polygon", 1, false);
+            "polygon", 1);
     public final static FunctionIdentifier TIME_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "time", 1, false);
+            "time", 1);
     public final static FunctionIdentifier DATE_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "date", 1, false);
+            "date", 1);
     public final static FunctionIdentifier DATETIME_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "datetime", 1, false);
+            "datetime", 1);
     public final static FunctionIdentifier DURATION_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "duration", 1, false);
+            "duration", 1);
 
     // spatial
     public final static FunctionIdentifier CREATE_POINT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-point", 2, true);
+            "create-point", 2);
     public final static FunctionIdentifier CREATE_LINE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-line", 2, true);
+            "create-line", 2);
     public final static FunctionIdentifier CREATE_POLYGON = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-polygon", FunctionIdentifier.VARARGS, true);
+            "create-polygon", FunctionIdentifier.VARARGS);
     public final static FunctionIdentifier CREATE_CIRCLE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-circle", 2, true);
+            "create-circle", 2);
     public final static FunctionIdentifier CREATE_RECTANGLE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-rectangle", 2, true);
+            "create-rectangle", 2);
     public final static FunctionIdentifier SPATIAL_INTERSECT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-intersect", 2, true);
+            "spatial-intersect", 2);
     public final static FunctionIdentifier SPATIAL_AREA = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-area", 1, true);
+            "spatial-area", 1);
     public final static FunctionIdentifier SPATIAL_DISTANCE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-distance", 2, true);
+            "spatial-distance", 2);
     public final static FunctionIdentifier CREATE_MBR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-mbr", 3, true);
+            "create-mbr", 3);
     public final static FunctionIdentifier SPATIAL_CELL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-cell", 4, true);
+            "spatial-cell", 4);
     public final static FunctionIdentifier SWITCH_CASE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "switch-case", FunctionIdentifier.VARARGS, true);
-    public final static FunctionIdentifier REG_EXP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "reg-exp", 2,
-            true);
+            "switch-case", FunctionIdentifier.VARARGS);
+    public final static FunctionIdentifier REG_EXP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "reg-exp", 2);
+
     public final static FunctionIdentifier INJECT_FAILURE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "inject-failure", 2, true);
+            "inject-failure", 2);
     public final static FunctionIdentifier CAST_RECORD = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "cast-record", 1, true);
+            "cast-record", 1);
 
     public static final FunctionIdentifier EQ = AlgebricksBuiltinFunctions.EQ;
     public static final FunctionIdentifier LE = AlgebricksBuiltinFunctions.LE;
@@ -360,10 +346,10 @@
     public static IFunctionInfo getAsterixFunctionInfo(FunctionIdentifier fid) {
         IFunctionInfo finfo = asterixFunctionIdToInfo.get(fid);
         if (finfo == null) {
-            finfo = new AsterixFunctionInfo(fid, fid.isBuiltin());
-            if (fid.isBuiltin()) {
-                asterixFunctionIdToInfo.put(fid, finfo);
-            }
+            finfo = new AsterixFunctionInfo(fid);
+            //   if (fid.isBuiltin()) {
+            asterixFunctionIdToInfo.put(fid, finfo);
+            //  }
         }
         return finfo;
     }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixFunctionInfo.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixFunctionInfo.java
index 8580d33..61e47c0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixFunctionInfo.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixFunctionInfo.java
@@ -20,15 +20,13 @@
 public class AsterixFunctionInfo implements IFunctionInfo {
 
     private final FunctionIdentifier functionIdentifier;
-    
 
-    public AsterixFunctionInfo(String namespace, AsterixFunction asterixFunction, boolean isBuiltin) {
+    public AsterixFunctionInfo(String namespace, AsterixFunction asterixFunction) {
         this.functionIdentifier = new FunctionIdentifier(namespace, asterixFunction.getFunctionName(),
-                asterixFunction.getArity(), isBuiltin);
+                asterixFunction.getArity());
     }
 
-    public AsterixFunctionInfo(FunctionIdentifier functionIdentifier,
-            boolean isBuiltin) {
+    public AsterixFunctionInfo(FunctionIdentifier functionIdentifier) {
         this.functionIdentifier = functionIdentifier;
     }
 
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 0e2f825..1cf6ba7 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
@@ -17,8 +17,8 @@
     private String[] fieldNames;
     private IAType[] fieldTypes;
     private boolean isOpen;
-    private transient final List<IRecordTypeAnnotation> annotations = new ArrayList<IRecordTypeAnnotation>();
-    private transient final Map<String, Integer> typeMap = new HashMap<String, Integer>();
+    private final List<IRecordTypeAnnotation> annotations = new ArrayList<IRecordTypeAnnotation>();
+    private final Map<String, Integer> typeMap = new HashMap<String, Integer>();
 
     public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean isOpen) {
         super(typeName);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/collections/ListifyAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/collections/ListifyAggregateDescriptor.java
index 05aa2ea..8ddcb3f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/collections/ListifyAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/collections/ListifyAggregateDescriptor.java
@@ -13,8 +13,7 @@
 public class ListifyAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ListifyAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateDescriptor.java
index c8cfbbe..cfbfa4e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateDescriptor.java
@@ -35,8 +35,7 @@
 public class SerializableAvgAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg-serial", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg-serial", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SerializableAvgAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableCountAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableCountAggregateDescriptor.java
index b030d11..98e86d2 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableCountAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableCountAggregateDescriptor.java
@@ -26,7 +26,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "count-serial",
-            1, true);
+            1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SerializableCountAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
index d281750..e4c4931 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
@@ -43,7 +43,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "global-avg-serial", 1, true);
+            "global-avg-serial", 1);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
index c04dcf0..f5c9538 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
@@ -47,7 +47,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "local-avg-serial", 1, true);
+            "local-avg-serial", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SerializableLocalAvgAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateDescriptor.java
index cbc5358..e689ab4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateDescriptor.java
@@ -39,8 +39,7 @@
 public class SerializableSumAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sum-serial", 1,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sum-serial", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SerializableSumAggregateDescriptor();
@@ -106,8 +105,8 @@
                         inputVal.reset();
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     metInt8s = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
index 078e32d..ecdd194 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
@@ -47,8 +47,7 @@
 public class AvgAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-avg", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-avg", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new AvgAggregateDescriptor();
@@ -119,8 +118,8 @@
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
                             ++count;
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/CountAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/CountAggregateDescriptor.java
index f0f7602..040e2d0 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/CountAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/CountAggregateDescriptor.java
@@ -26,8 +26,7 @@
 public class CountAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-count", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-count", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CountAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
index 172cd62..e86b2bc 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
@@ -44,7 +44,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-avg",
-            1, true);
+            1);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
index f58a084..fa05d4b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
@@ -48,7 +48,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-avg",
-            1, true);
+            1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new LocalAvgAggregateDescriptor();
@@ -120,8 +120,8 @@
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
                             ++count;
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MaxAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MaxAggregateDescriptor.java
index 2fcca4c..e409910 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MaxAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MaxAggregateDescriptor.java
@@ -38,8 +38,7 @@
 public class MaxAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-max", 1,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-max", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new MaxAggregateDescriptor();
@@ -105,8 +104,8 @@
                         inputVal.reset();
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     metInt8s = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinAggregateDescriptor.java
index 8abf8b5..af54c14 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinAggregateDescriptor.java
@@ -38,8 +38,7 @@
 public class MinAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-min", 1,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-min", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new MinAggregateDescriptor();
@@ -105,8 +104,8 @@
                         inputVal.reset();
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     metInt8s = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateDescriptor.java
index 197878b..5e45432 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateDescriptor.java
@@ -40,8 +40,7 @@
 public class SumAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sum", 1,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sum", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SumAggregateDescriptor();
@@ -97,8 +96,8 @@
                         inputVal.reset();
                         eval.evaluate(tuple);
                         if (inputVal.getLength() > 0) {
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                                    .deserialize(inputVal.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal
+                                    .getByteArray()[0]);
                             switch (typeTag) {
                                 case INT8: {
                                     metInt8s = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/NonEmptyStreamAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/NonEmptyStreamAggregateDescriptor.java
index a48a99f..9d235e5 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/NonEmptyStreamAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/stream/NonEmptyStreamAggregateDescriptor.java
@@ -24,7 +24,7 @@
     private static final long serialVersionUID = 1L;
 
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "non-empty-stream", 0, true);
+            "non-empty-stream", 0);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NonEmptyStreamAggregateDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
index 1617dc0..12a1b9a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
@@ -26,8 +26,7 @@
 public class ABooleanConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "boolean", 1,
-            false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "boolean", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
index dd4f9ef..2eb9c20 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
@@ -26,7 +26,7 @@
 public class ACircleConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "circle", 1, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "circle", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index cfbddf5..25b2f84 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "date", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "date", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index 56c9dcf..c37d646 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -25,8 +25,7 @@
 public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "datetime", 1,
-            false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "datetime", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
index eea58651..f0aed55 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
@@ -27,8 +27,7 @@
 public class ADoubleConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "double", 1,
-            false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "double", 1);
     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() {
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 feb2fd7..c2215ff 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
@@ -25,8 +25,7 @@
 public class ADurationConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "duration", 1,
-            false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "duration", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
index 852b6d4..8737d7b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
@@ -27,7 +27,7 @@
 public class AFloatConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "float", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "float", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
index 46e6987..b282476 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class AInt16ConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int16", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int16", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
index a8befc7..3368f41 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class AInt32ConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int32", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int32", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
index a3b635d..11242f6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class AInt64ConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int64", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int64", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
index 0e6e94d..4bacb74 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class AInt8ConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int8", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "int8", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
index c64f745..cb90362 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
@@ -26,7 +26,7 @@
 public class ALineConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "line", 1, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "line", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
index ff76339..e9e5353 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class ANullConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "null", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "null", 1);
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
@@ -48,7 +48,7 @@
                     private String errorMessage = "This can not be an instance of null";
                     private final byte[] NULL = { 0, 4, 'n', 'u', 'l', 'l' };
                     IBinaryComparator utf8BinaryComparator = AqlBinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE
-                    .createBinaryComparator();
+                            .createBinaryComparator();
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
index 0434a5f..9b6e851 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
@@ -25,8 +25,7 @@
 public class APoint3DConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "point3d", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "point3d", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
index 840f141..f79a403 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class APointConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "point", 1, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "point", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
index 705ae78..8ad7fa9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
@@ -24,8 +24,7 @@
 public class APolygonConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "polygon", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "polygon", 1);
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_POLYGON_TYPE_TAG = ATypeTag.POLYGON.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/constructors/ARectangleConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
index 5f5b3b3..e8a39ca 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
@@ -26,8 +26,7 @@
 public class ARectangleConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "rectangle", 1,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "rectangle", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
index abe1743..d443a5e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
@@ -23,8 +23,7 @@
 public class AStringConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "string", 1,
-            false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "string", 1);
     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() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index c262d9f..8a7ac44 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -25,7 +25,7 @@
 public class ATimeConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "time", 1, false);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "time", 1);
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.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/functions/AndDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AndDescriptor.java
index 355d30e..3d05651 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AndDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AndDescriptor.java
@@ -24,7 +24,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS,
-            "and", FunctionIdentifier.VARARGS, true);
+            "and", FunctionIdentifier.VARARGS);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
index a71436c..e4ada73 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
@@ -29,7 +29,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "any-collection-member", 1, true);
+            "any-collection-member", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new AnyCollectionMemberDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
index a9f25f4..aad2c27 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
@@ -23,7 +23,7 @@
 public class CastRecordDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     protected static final FunctionIdentifier FID_CAST = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "cast-record", 1, true);
+            "cast-record", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CastRecordDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ClosedRecordConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ClosedRecordConstructorDescriptor.java
index 980a6c8..d92aff9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ClosedRecordConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ClosedRecordConstructorDescriptor.java
@@ -12,7 +12,7 @@
 public class ClosedRecordConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     protected static final FunctionIdentifier FID_CLOSED = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "closed-record-constructor", FunctionIdentifier.VARARGS, true);
+            "closed-record-constructor", FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ClosedRecordConstructorDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ContainsDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ContainsDescriptor.java
index ab4fb3a..cf1abc6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ContainsDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/ContainsDescriptor.java
@@ -16,8 +16,7 @@
 public class ContainsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
 
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "contains", 2,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "contains", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ContainsDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedGramTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedGramTokensDescriptor.java
index c5d0aa3c2..1e72adf 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedGramTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedGramTokensDescriptor.java
@@ -20,7 +20,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "counthashed-gram-tokens", 3, true);
+            "counthashed-gram-tokens", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CountHashedGramTokensDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedWordTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedWordTokensDescriptor.java
index f3a43d6..4462098 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedWordTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CountHashedWordTokensDescriptor.java
@@ -21,7 +21,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "counthashed-word-tokens", 1, true);
+            "counthashed-word-tokens", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CountHashedWordTokensDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateCircleDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateCircleDescriptor.java
index e8c57c4..dc2c1e1 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateCircleDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateCircleDescriptor.java
@@ -28,7 +28,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-circle",
-            2, true);
+            2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreateCircleDescriptor();
@@ -68,7 +68,8 @@
                                     APointSerializerDeserializer.getCoordinateOffset(Coordinate.X)),
                                     ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
                                             APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y)));
-                            aCircle.setValue(aPoint, ADoubleSerializerDeserializer.getDouble(outInput1.getByteArray(), 1));
+                            aCircle.setValue(aPoint,
+                                    ADoubleSerializerDeserializer.getDouble(outInput1.getByteArray(), 1));
                             circleSerde.serialize(aCircle, out);
                         } catch (IOException e1) {
                             throw new AlgebricksException(e1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateLineDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateLineDescriptor.java
index a6ca67b..370ed56 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateLineDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateLineDescriptor.java
@@ -27,8 +27,7 @@
 public class CreateLineDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-line", 2,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-line", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreateLineDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateMBRDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateMBRDescriptor.java
index cd3790c..b1c3564 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateMBRDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateMBRDescriptor.java
@@ -12,8 +12,7 @@
 public class CreateMBRDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-mbr", 3,
-            true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-mbr", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreateMBRDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePointDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
index 82d1013..58cd6a8 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
@@ -24,8 +24,7 @@
 public class CreatePointDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-point",
-            2, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-point", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreatePointDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePolygonDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePolygonDescriptor.java
index a095111..f967a69 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePolygonDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreatePolygonDescriptor.java
@@ -20,7 +20,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "create-polygon",
-            FunctionIdentifier.VARARGS, true);
+            FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreatePolygonDescriptor();
@@ -62,7 +62,8 @@
                             outInput.reset();
                             argEvals[i].evaluate(tuple);
                             try {
-                                out.write(outInput.getByteArray(), outInput.getStartOffset() + 1, outInput.getLength() - 1);
+                                out.write(outInput.getByteArray(), outInput.getStartOffset() + 1,
+                                        outInput.getLength() - 1);
                             } catch (IOException e) {
                                 throw new AlgebricksException(e);
                             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateRectangleDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateRectangleDescriptor.java
index d7945fa..44d6881 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateRectangleDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CreateRectangleDescriptor.java
@@ -28,7 +28,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "create-rectangle", 2, true);
+            "create-rectangle", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new CreateRectangleDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceCheckDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceCheckDescriptor.java
index 1c1dae3..c261f1f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceCheckDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceCheckDescriptor.java
@@ -28,7 +28,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance-check", 3, true);
+            "edit-distance-check", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EditDistanceCheckDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceDescriptor.java
index a7246fc..8a7e356 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceDescriptor.java
@@ -1,6 +1,5 @@
 package edu.uci.ics.asterix.runtime.evaluators.functions;
 
-
 import edu.uci.ics.asterix.common.functions.FunctionConstants;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -16,7 +15,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "edit-distance",
-            2, true);
+            2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EditDistanceDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java
index 61a795e..f5bfc4f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java
@@ -34,7 +34,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance-list-is-filterable", 2, true);
+            "edit-distance-list-is-filterable", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EditDistanceListIsFilterable();
@@ -59,13 +59,13 @@
     }
 
     private static class EditDistanceListIsFilterableEvaluator implements ICopyEvaluator {
-    	
+
         protected final ArrayBackedValueStorage argBuf = new ArrayBackedValueStorage();
         protected final IDataOutputProvider output;
-        
+
         protected final ICopyEvaluator listEval;
         protected final ICopyEvaluator edThreshEval;
-    	
+
         @SuppressWarnings("unchecked")
         private final ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
                 .getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -74,42 +74,45 @@
                 throws AlgebricksException {
             this.output = output;
             listEval = args[0].createEvaluator(argBuf);
-        	edThreshEval = args[1].createEvaluator(argBuf);
+            edThreshEval = args[1].createEvaluator(argBuf);
         }
 
-		@Override
-		public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-			ATypeTag typeTag = null;
-			
-			// Check type and compute string length.
-			argBuf.reset();
-			listEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			int listLen = 0;
-			switch (typeTag) {
-			    case UNORDEREDLIST: {
-			        listLen = AUnorderedListSerializerDeserializer.getNumberOfItems(argBuf.getByteArray(), 0);
-			        break;
-			    }
-			    case ORDEREDLIST: {
-			        listLen = AOrderedListSerializerDeserializer.getNumberOfItems(argBuf.getByteArray(), 0);
-			        break;
-			    }
-			    default: {
-			        throw new AlgebricksException("Expected type 'ORDEREDLIST' or 'UNORDEREDLIST' as first argument. Encountered '" + typeTag.toString() + "'.");
-			    }
-			}
-			
-	        // Check type and extract edit-distance threshold.
-	        argBuf.reset();
-	        edThreshEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			if (!typeTag.equals(ATypeTag.INT32)) {
-				throw new AlgebricksException("Expected type 'INT32' as second argument. Encountered '" + typeTag.toString() + "'.");
-			}
-			int edThresh = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
-			
-			// Compute result.
+        @Override
+        public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+            ATypeTag typeTag = null;
+
+            // Check type and compute string length.
+            argBuf.reset();
+            listEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            int listLen = 0;
+            switch (typeTag) {
+                case UNORDEREDLIST: {
+                    listLen = AUnorderedListSerializerDeserializer.getNumberOfItems(argBuf.getByteArray(), 0);
+                    break;
+                }
+                case ORDEREDLIST: {
+                    listLen = AOrderedListSerializerDeserializer.getNumberOfItems(argBuf.getByteArray(), 0);
+                    break;
+                }
+                default: {
+                    throw new AlgebricksException(
+                            "Expected type 'ORDEREDLIST' or 'UNORDEREDLIST' as first argument. Encountered '"
+                                    + typeTag.toString() + "'.");
+                }
+            }
+
+            // Check type and extract edit-distance threshold.
+            argBuf.reset();
+            edThreshEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            if (!typeTag.equals(ATypeTag.INT32)) {
+                throw new AlgebricksException("Expected type 'INT32' as second argument. Encountered '"
+                        + typeTag.toString() + "'.");
+            }
+            int edThresh = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
+
+            // Compute result.
             int lowerBound = listLen - edThresh;
             try {
                 if (lowerBound <= 0) {
@@ -120,6 +123,6 @@
             } catch (IOException e) {
                 throw new AlgebricksException(e);
             }
-		}
+        }
     }
 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java
index 389fc1f..443f792 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java
@@ -34,7 +34,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "edit-distance-string-is-filterable", 4, true);
+            "edit-distance-string-is-filterable", 4);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EditDistanceStringIsFilterable();
@@ -59,15 +59,15 @@
     }
 
     private static class EditDistanceStringIsFilterableEvaluator implements ICopyEvaluator {
-    	
+
         protected final ArrayBackedValueStorage argBuf = new ArrayBackedValueStorage();
         protected final IDataOutputProvider output;
-        
+
         protected final ICopyEvaluator stringEval;
         protected final ICopyEvaluator edThreshEval;
         protected final ICopyEvaluator gramLenEval;
-        protected final ICopyEvaluator usePrePostEval;        
-    	
+        protected final ICopyEvaluator usePrePostEval;
+
         @SuppressWarnings("unchecked")
         private final ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
                 .getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -76,59 +76,63 @@
                 throws AlgebricksException {
             this.output = output;
             stringEval = args[0].createEvaluator(argBuf);
-        	edThreshEval = args[1].createEvaluator(argBuf);
-        	gramLenEval = args[2].createEvaluator(argBuf);
-        	usePrePostEval = args[3].createEvaluator(argBuf);
+            edThreshEval = args[1].createEvaluator(argBuf);
+            gramLenEval = args[2].createEvaluator(argBuf);
+            usePrePostEval = args[3].createEvaluator(argBuf);
         }
 
-		@Override
-		public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-			ATypeTag typeTag = null;
-			
-			// Check type and compute string length.
-			argBuf.reset();
-			stringEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			if (!typeTag.equals(ATypeTag.STRING)) {
-				throw new AlgebricksException("Expected type 'STRING' as first argument. Encountered '" + typeTag.toString() + "'.");
-			}
-			int utf8Length = UTF8StringPointable.getUTFLength(argBuf.getByteArray(), 1); 
-			int pos = 3;
-			int strLen = 0;	        
-	        int end = pos + utf8Length;
-	        while (pos < end) {
-	        	strLen++;
-	            pos += UTF8StringPointable.charSize(argBuf.getByteArray(), pos);
-	        }
-			
-	        // Check type and extract edit-distance threshold.
-	        argBuf.reset();
-	        edThreshEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			if (!typeTag.equals(ATypeTag.INT32)) {
-				throw new AlgebricksException("Expected type 'INT32' as second argument. Encountered '" + typeTag.toString() + "'.");
-			}
-			int edThresh = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
-			
-	        // Check type and extract gram length.
-			argBuf.reset();
-			gramLenEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			if (!typeTag.equals(ATypeTag.INT32)) {
-				throw new AlgebricksException("Expected type 'INT32' as third argument. Encountered '" + typeTag.toString() + "'.");
-			}
-			int gramLen = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
-			
-			// Check type and extract usePrePost flag.
-			argBuf.reset();
-			usePrePostEval.evaluate(tuple);
-			typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
-			if (!typeTag.equals(ATypeTag.BOOLEAN)) {
-				throw new AlgebricksException("Expected type 'BOOLEAN' as fourth argument. Encountered '" + typeTag.toString() + "'.");
-			}
-			boolean usePrePost = BooleanSerializerDeserializer.getBoolean(argBuf.getByteArray(), 1);
-			
-			// Compute result.			
+        @Override
+        public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+            ATypeTag typeTag = null;
+
+            // Check type and compute string length.
+            argBuf.reset();
+            stringEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            if (!typeTag.equals(ATypeTag.STRING)) {
+                throw new AlgebricksException("Expected type 'STRING' as first argument. Encountered '"
+                        + typeTag.toString() + "'.");
+            }
+            int utf8Length = UTF8StringPointable.getUTFLength(argBuf.getByteArray(), 1);
+            int pos = 3;
+            int strLen = 0;
+            int end = pos + utf8Length;
+            while (pos < end) {
+                strLen++;
+                pos += UTF8StringPointable.charSize(argBuf.getByteArray(), pos);
+            }
+
+            // Check type and extract edit-distance threshold.
+            argBuf.reset();
+            edThreshEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            if (!typeTag.equals(ATypeTag.INT32)) {
+                throw new AlgebricksException("Expected type 'INT32' as second argument. Encountered '"
+                        + typeTag.toString() + "'.");
+            }
+            int edThresh = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
+
+            // Check type and extract gram length.
+            argBuf.reset();
+            gramLenEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            if (!typeTag.equals(ATypeTag.INT32)) {
+                throw new AlgebricksException("Expected type 'INT32' as third argument. Encountered '"
+                        + typeTag.toString() + "'.");
+            }
+            int gramLen = IntegerSerializerDeserializer.getInt(argBuf.getByteArray(), 1);
+
+            // Check type and extract usePrePost flag.
+            argBuf.reset();
+            usePrePostEval.evaluate(tuple);
+            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argBuf.getByteArray()[0]);
+            if (!typeTag.equals(ATypeTag.BOOLEAN)) {
+                throw new AlgebricksException("Expected type 'BOOLEAN' as fourth argument. Encountered '"
+                        + typeTag.toString() + "'.");
+            }
+            boolean usePrePost = BooleanSerializerDeserializer.getBoolean(argBuf.getByteArray(), 1);
+
+            // Compute result.			
             int numGrams = (usePrePost) ? strLen + gramLen - 1 : strLen - gramLen + 1;
             int lowerBound = numGrams - edThresh * gramLen;
             try {
@@ -140,6 +144,6 @@
             } catch (IOException e) {
                 throw new AlgebricksException(e);
             }
-		}
+        }
     }
 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
index 26bfea4..d1f3d25 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
@@ -15,14 +15,13 @@
 public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "embed-type", 1,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "embed-type", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EmbedTypeDescriptor();
         }
     };
-    
+
     @SuppressWarnings("unused")
     private IAType fieldType;
 
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EndsWithDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EndsWithDescriptor.java
index 19a3be7..0ef6375 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EndsWithDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/EndsWithDescriptor.java
@@ -16,8 +16,7 @@
 public class EndsWithDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
 
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "ends-with", 2,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "ends-with", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new EndsWithDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByIndexDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByIndexDescriptor.java
index a0c1ad2..2bb81ad 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByIndexDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByIndexDescriptor.java
@@ -13,13 +13,13 @@
 
     private static final long serialVersionUID = 1L;
     private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "field-access-by-index", 2, true);
+            "field-access-by-index", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new FieldAccessByIndexDescriptor();
         }
     };
-    
+
     private ARecordType recType;
 
     public void reset(ARecordType recType) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByNameDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByNameDescriptor.java
index 2ac483b..b6e376b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByNameDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FieldAccessByNameDescriptor.java
@@ -28,7 +28,7 @@
 
     private static final long serialVersionUID = 1L;
     private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "field-access-by-name", 2, true);
+            "field-access-by-name", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new FieldAccessByNameDescriptor();
@@ -55,7 +55,8 @@
         private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
         private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
 
-        public FieldAccessByNameEvalFactory(ICopyEvaluatorFactory recordEvalFactory, ICopyEvaluatorFactory fldNameEvalFactory) {
+        public FieldAccessByNameEvalFactory(ICopyEvaluatorFactory recordEvalFactory,
+                ICopyEvaluatorFactory fldNameEvalFactory) {
             this.recordEvalFactory = recordEvalFactory;
             this.fldNameEvalFactory = fldNameEvalFactory;
         }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java
index 623783e..9ad2f2b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java
@@ -12,8 +12,7 @@
 public class FuzzyEqDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "fuzzy-eq", 2,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "fuzzy-eq", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new FuzzyEqDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GetItemDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GetItemDescriptor.java
index f8470b0..e098ef9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GetItemDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GetItemDescriptor.java
@@ -28,8 +28,7 @@
 public class GetItemDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item", 2,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new GetItemDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GramTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GramTokensDescriptor.java
index 94c6375..b01c29c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GramTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/GramTokensDescriptor.java
@@ -19,8 +19,7 @@
 public class GramTokensDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "gram-tokens",
-            3, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "gram-tokens", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new GramTokensDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedGramTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedGramTokensDescriptor.java
index 8b375ab..097df8c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedGramTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedGramTokensDescriptor.java
@@ -20,7 +20,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-gram-tokens", 3, true);
+            "hashed-gram-tokens", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new HashedGramTokensDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedWordTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedWordTokensDescriptor.java
index 40d15ee..4e44523 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedWordTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/HashedWordTokensDescriptor.java
@@ -21,13 +21,13 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "hashed-word-tokens", 1, true);
+            "hashed-word-tokens", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new HashedWordTokensDescriptor();
         }
     };
-    
+
     @Override
     public FunctionIdentifier getIdentifier() {
         return FID;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
index abd3ae5..b2ac3ca 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
@@ -21,7 +21,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "inject-failure", 2, true);
+            "inject-failure", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new InjectFailureDescriptor();
@@ -55,7 +55,8 @@
                             // evaluator the failure condition
                             argOut.reset();
                             evals[1].evaluate(tuple);
-                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]);
+                            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                                    .deserialize(argOut.getByteArray()[0]);
                             if (typeTag == ATypeTag.BOOLEAN) {
                                 boolean argResult = ABooleanSerializerDeserializer.getBoolean(argOut.getByteArray(), 1);
                                 if (argResult)
@@ -65,7 +66,8 @@
                             // evaluate the real evaluator
                             argOut.reset();
                             evals[0].evaluate(tuple);
-                            output.getDataOutput().write(argOut.getByteArray(), argOut.getStartOffset(), argOut.getLength());
+                            output.getDataOutput().write(argOut.getByteArray(), argOut.getStartOffset(),
+                                    argOut.getLength());
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/IsNullDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/IsNullDescriptor.java
index 5e3b7ab..813fc41 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/IsNullDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/IsNullDescriptor.java
@@ -23,7 +23,7 @@
     private static final long serialVersionUID = 1L;
 
     public final static FunctionIdentifier FID = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS,
-            "is-null", 1, true);
+            "is-null", 1);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LenDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LenDescriptor.java
index 0e15a18..e09035e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LenDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LenDescriptor.java
@@ -28,7 +28,7 @@
 public class LenDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "len", 1, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "len", 1);
     private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
     private final static byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.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/functions/LikeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LikeDescriptor.java
index 1b43441..a3bd5bd 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LikeDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/LikeDescriptor.java
@@ -39,7 +39,7 @@
 public class LikeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "like", 2, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "like", 2);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
@@ -100,8 +100,8 @@
                                 first = false;
                                 newPattern = true;
                             } else {
-                                int c = strComp.compare(array0.getByteArray(), array0.getStartOffset(), array0.getLength(),
-                                        lastPattern.getByteArray(), 0, lastPattern.size());
+                                int c = strComp.compare(array0.getByteArray(), array0.getStartOffset(),
+                                        array0.getLength(), lastPattern.getByteArray(), 0, lastPattern.size());
                                 if (c != 0) {
                                     newPattern = true;
                                 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NotDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NotDescriptor.java
index abb4e25..a3f78e4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NotDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NotDescriptor.java
@@ -26,7 +26,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS,
-            "not", 1, true);
+            "not", 1);
 
     private final static byte SER_BOOLEAN_TYPE_TAG = ATypeTag.BOOLEAN.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/functions/NumericAddDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
index baa20cd..27b4a2a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS,
-            "numeric-add", 2, true);
+            "numeric-add", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NumericAddDescriptor();
@@ -127,11 +127,10 @@
                                         return;
                                     }
                                     default: {
-                                        throw new NotImplementedException(i == 0 ? "Left"
-                                                : "Right"
-                                                        + " Operand of Addition can not be "
-                                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                                .getByteArray()[0]));
+                                        throw new NotImplementedException(i == 0 ? "Left" : "Right"
+                                                + " Operand of Addition can not be "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
+                                                        .getByteArray()[0]));
                                     }
                                 }
                             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
index b226ad7..00e7838 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "numeric-divide",
-            2, true);
+            2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NumericDivideDescriptor();
@@ -127,11 +127,10 @@
                                         return;
                                     }
                                     default: {
-                                        throw new NotImplementedException(i == 0 ? "Left"
-                                                : "Right"
-                                                        + " Operand of Division can not be "
-                                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                                .getByteArray()[0]));
+                                        throw new NotImplementedException(i == 0 ? "Left" : "Right"
+                                                + " Operand of Division can not be "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
+                                                        .getByteArray()[0]));
                                     }
                                 }
                             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java
new file mode 100644
index 0000000..c92d75f
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.runtime.evaluators.functions;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AMutableDouble;
+import edu.uci.ics.asterix.om.base.AMutableFloat;
+import edu.uci.ics.asterix.om.base.AMutableInt16;
+import edu.uci.ics.asterix.om.base.AMutableInt32;
+import edu.uci.ics.asterix.om.base.AMutableInt64;
+import edu.uci.ics.asterix.om.base.AMutableInt8;
+import edu.uci.ics.asterix.om.base.ANull;
+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.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
+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.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IDataOutputProvider;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+/**
+ * @author kisskys
+ */
+public class NumericModuloDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "numeric-mod", 2);
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new NumericModuloDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        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();
+                    // one temp. buffer re-used by both children
+                    private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+                    private ICopyEvaluator evalLeft = args[0].createEvaluator(argOut);
+                    private ICopyEvaluator evalRight = args[1].createEvaluator(argOut);
+                    private double[] operands = new double[args.length];
+                    private boolean metInt8 = false, metInt16 = false, metInt32 = false, metInt64 = false,
+                            metFloat = false, metDouble = false;
+                    private ATypeTag typeTag;
+                    private AMutableDouble aDouble = new AMutableDouble(0);
+                    private AMutableFloat aFloat = new AMutableFloat(0);
+                    private AMutableInt64 aInt64 = new AMutableInt64(0);
+                    private AMutableInt32 aInt32 = new AMutableInt32(0);
+                    private AMutableInt16 aInt16 = new AMutableInt16((short) 0);
+                    private AMutableInt8 aInt8 = new AMutableInt8((byte) 0);
+                    @SuppressWarnings("rawtypes")
+                    private ISerializerDeserializer serde;
+
+                    @SuppressWarnings("unchecked")
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+
+                        try {
+                            for (int i = 0; i < args.length; i++) {
+                                argOut.reset();
+                                if (i == 0)
+                                    evalLeft.evaluate(tuple);
+                                else
+                                    evalRight.evaluate(tuple);
+                                typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]);
+                                switch (typeTag) {
+                                    case INT8: {
+                                        metInt8 = true;
+                                        operands[i] = AInt8SerializerDeserializer.getByte(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case INT16: {
+                                        metInt16 = true;
+                                        operands[i] = AInt16SerializerDeserializer.getShort(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case INT32: {
+                                        metInt32 = true;
+                                        operands[i] = AInt32SerializerDeserializer.getInt(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case INT64: {
+                                        metInt64 = true;
+                                        operands[i] = AInt64SerializerDeserializer.getLong(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case FLOAT: {
+                                        metFloat = true;
+                                        operands[i] = AFloatSerializerDeserializer.getFloat(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case DOUBLE: {
+                                        metDouble = true;
+                                        operands[i] = ADoubleSerializerDeserializer.getDouble(argOut.getByteArray(), 1);
+                                        break;
+                                    }
+                                    case NULL: {
+                                        serde = AqlSerializerDeserializerProvider.INSTANCE
+                                                .getSerializerDeserializer(BuiltinType.ANULL);
+                                        serde.serialize(ANull.NULL, out);
+                                        return;
+                                    }
+                                    default: {
+                                        throw new NotImplementedException(i == 0 ? "Left" : "Right"
+                                                + " Operand of Modulo can not be "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
+                                                        .getByteArray()[0]));
+                                    }
+                                }
+                            }
+
+                            if (metDouble) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.ADOUBLE);
+                                aDouble.setValue(operands[0] % operands[1]);
+                                serde.serialize(aDouble, out);
+                            } else if (metFloat) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AFLOAT);
+                                aFloat.setValue((float) (operands[0] % operands[1]));
+                                serde.serialize(aFloat, out);
+                            } else if (metInt64) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT64);
+                                aInt64.setValue((long) (operands[0] % operands[1]));
+                                serde.serialize(aInt64, out);
+                            } else if (metInt32) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT32);
+                                aInt32.setValue((int) (operands[0] % operands[1]));
+                                serde.serialize(aInt32, out);
+                            } else if (metInt16) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT16);
+                                aInt16.setValue((short) (operands[0] % operands[1]));
+                                serde.serialize(aInt16, out);
+                            } else if (metInt8) {
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT8);
+                                aInt8.setValue((byte) (operands[0] % operands[1]));
+                                serde.serialize(aInt8, out);
+                            }
+
+                        } catch (HyracksDataException hde) {
+                            throw new AlgebricksException(hde);
+                        }
+                    }
+                };
+            }
+        };
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
index aa5eaaa..76657bd 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-multiply", 2, true);
+            "numeric-multiply", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NumericMultiplyDescriptor();
@@ -127,11 +127,10 @@
                                         return;
                                     }
                                     default: {
-                                        throw new NotImplementedException(i == 0 ? "Left"
-                                                : "Right"
-                                                        + " Operand of Multiplication can not be "
-                                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                                .getByteArray()[0]));
+                                        throw new NotImplementedException(i == 0 ? "Left" : "Right"
+                                                + " Operand of Multiplication can not be "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
+                                                        .getByteArray()[0]));
                                     }
                                 }
                             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
index 0b53f18..9abbf47 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-subtract", 2, true);
+            "numeric-subtract", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NumericSubtractDescriptor();
@@ -127,11 +127,10 @@
                                         return;
                                     }
                                     default: {
-                                        throw new NotImplementedException(i == 0 ? "Left"
-                                                : "Right"
-                                                        + " Operand of Substraction can not be "
-                                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                                .getByteArray()[0]));
+                                        throw new NotImplementedException(i == 0 ? "Left" : "Right"
+                                                + " Operand of Substraction can not be "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
+                                                        .getByteArray()[0]));
                                     }
                                 }
                             }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
index 7998618..9e3b188 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "numeric-unary-minus", 1, true);
+            "numeric-unary-minus", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new NumericUnaryMinusDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
index f3681f2..37d6ce0 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
@@ -21,7 +21,7 @@
 public class OpenRecordConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     protected static final FunctionIdentifier FID_OPEN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "open-record-constructor", FunctionIdentifier.VARARGS, true);
+            "open-record-constructor", FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new OpenRecordConstructorDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrDescriptor.java
index 8349c97..a54ec54 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrDescriptor.java
@@ -24,7 +24,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS, "or",
-            FunctionIdentifier.VARARGS, true);
+            FunctionIdentifier.VARARGS);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrderedListConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrderedListConstructorDescriptor.java
index b9e341d..520b386 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrderedListConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OrderedListConstructorDescriptor.java
@@ -22,7 +22,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "ordered-list-constructor", FunctionIdentifier.VARARGS, true);
+            "ordered-list-constructor", FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new OrderedListConstructorDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenDescriptor.java
index 57b7acd..25cbf74 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenDescriptor.java
@@ -27,8 +27,7 @@
 public class PrefixLenDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "prefix-len", 3,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "prefix-len", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new PrefixLenDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
index 2612583..927ade5 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
@@ -27,7 +27,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "prefix-len-jaccard", 2, true);
+            "prefix-len-jaccard", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new PrefixLenJaccardDescriptor();
@@ -69,8 +69,8 @@
                         // similarity threshold
                         inputVal.reset();
                         evalThreshold.evaluate(tuple);
-                        float similarityThreshold = (float) AFloatSerializerDeserializer.getFloat(inputVal.getByteArray(),
-                                1);
+                        float similarityThreshold = (float) AFloatSerializerDeserializer.getFloat(
+                                inputVal.getByteArray(), 1);
 
                         if (similarityThreshold != similarityThresholdCache || similarityFilters == null) {
                             similarityFilters = new SimilarityFiltersJaccard(similarityThreshold);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/RegExpDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/RegExpDescriptor.java
index 1815085..01b00a0 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/RegExpDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/RegExpDescriptor.java
@@ -38,8 +38,7 @@
 public class RegExpDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "reg-exp", 2,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "reg-exp", 2);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
@@ -100,8 +99,8 @@
                                 first = false;
                                 newPattern = true;
                             } else {
-                                int c = strComp.compare(array0.getByteArray(), array0.getStartOffset(), array0.getLength(),
-                                        lastPattern.getByteArray(), 0, lastPattern.size());
+                                int c = strComp.compare(array0.getByteArray(), array0.getStartOffset(),
+                                        array0.getLength(), lastPattern.getByteArray(), 0, lastPattern.size());
                                 if (c != 0) {
                                     newPattern = true;
                                 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
index d3218ff..ec21b96 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
@@ -35,8 +35,7 @@
 public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "similarity", 7,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "similarity", 7);
 
     private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
     private final static byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.serialize();
@@ -122,8 +121,8 @@
 
                             int lengthTokens1;
                             if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                                lengthTokens1 = AOrderedListSerializerDeserializer
-                                        .getNumberOfItems(inputVal.getByteArray());
+                                lengthTokens1 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal
+                                        .getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens1; i++) {
                                     int itemOffset;
@@ -166,8 +165,8 @@
 
                             int lengthTokens2;
                             if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                                lengthTokens2 = AOrderedListSerializerDeserializer
-                                        .getNumberOfItems(inputVal.getByteArray());
+                                lengthTokens2 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal
+                                        .getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens2; i++) {
                                     int itemOffset;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardCheckDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardCheckDescriptor.java
index bb9d75e..4881e2a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardCheckDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardCheckDescriptor.java
@@ -15,7 +15,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard-check", 3, true);
+            "similarity-jaccard-check", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardCheckDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardDescriptor.java
index 7328cfa..95d994f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardDescriptor.java
@@ -15,7 +15,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard", 2, true);
+            "similarity-jaccard", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixCheckDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixCheckDescriptor.java
index 4008419..24f012e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixCheckDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixCheckDescriptor.java
@@ -28,7 +28,7 @@
     private static final long serialVersionUID = 1L;
 
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard-prefix-check", 6, true);
+            "similarity-jaccard-prefix-check", 6);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardPrefixCheckDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixDescriptor.java
index 4d9c528..54d4280 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardPrefixDescriptor.java
@@ -15,7 +15,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard-prefix", 6, true);
+            "similarity-jaccard-prefix", 6);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardPrefixDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedCheckDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedCheckDescriptor.java
index 9b941c6..23b7a5d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedCheckDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedCheckDescriptor.java
@@ -16,13 +16,13 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard-sorted-check", 3, true);
+            "similarity-jaccard-sorted-check", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardSortedCheckDescriptor();
         }
     };
-    
+
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
         return new ICopyEvaluatorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedDescriptor.java
index 3c550ab..db944d4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SimilarityJaccardSortedDescriptor.java
@@ -16,13 +16,13 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "similarity-jaccard-sorted", 2, true);
+            "similarity-jaccard-sorted", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityJaccardSortedDescriptor();
         }
     };
-    
+
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
         return new ICopyEvaluatorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
index 644e89d..f35adee 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
@@ -28,8 +28,7 @@
 public class SpatialAreaDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "spatial-area",
-            1, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "spatial-area", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialAreaDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
index 0fe63f5..c2a4d66 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
@@ -30,8 +30,7 @@
 public class SpatialCellDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "spatial-cell",
-            4, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "spatial-cell", 4);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialCellDescriptor();
@@ -75,7 +74,8 @@
                         eval3.evaluate(tuple);
 
                         try {
-                            ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput0.getByteArray()[0]);
+                            ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER
+                                    .deserialize(outInput0.getByteArray()[0]);
                             if (tag == ATypeTag.POINT) {
                                 double xLoc = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
                                         APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
index 97e70b2..22132cc 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
@@ -26,7 +26,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-distance", 2, true);
+            "spatial-distance", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialDistanceDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
index be31eed..b519a23 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
@@ -37,7 +37,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "spatial-intersect", 2, true);
+            "spatial-intersect", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialIntersectDescriptor();
@@ -751,8 +751,10 @@
 
                         try {
                             boolean res = false;
-                            ATypeTag tag0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput0.getByteArray()[0]);
-                            ATypeTag tag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput1.getByteArray()[0]);
+                            ATypeTag tag0 = EnumDeserializer.ATYPETAGDESERIALIZER
+                                    .deserialize(outInput0.getByteArray()[0]);
+                            ATypeTag tag1 = EnumDeserializer.ATYPETAGDESERIALIZER
+                                    .deserialize(outInput1.getByteArray()[0]);
 
                             switch (tag0) {
                                 case POINT:
@@ -805,12 +807,12 @@
                                             double startY1 = ADoubleSerializerDeserializer.getDouble(outInput0
                                                     .getByteArray(), ALineSerializerDeserializer
                                                     .getStartPointCoordinateOffset(Coordinate.Y));
-                                            double endX1 = ADoubleSerializerDeserializer.getDouble(
-                                                    outInput0.getByteArray(), ALineSerializerDeserializer
-                                                            .getEndPointCoordinateOffset(Coordinate.X));
-                                            double endY1 = ADoubleSerializerDeserializer.getDouble(
-                                                    outInput0.getByteArray(), ALineSerializerDeserializer
-                                                            .getEndPointCoordinateOffset(Coordinate.Y));
+                                            double endX1 = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.X));
+                                            double endY1 = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.Y));
 
                                             double startX2 = ADoubleSerializerDeserializer.getDouble(outInput1
                                                     .getByteArray(), ALineSerializerDeserializer
@@ -818,23 +820,26 @@
                                             double startY2 = ADoubleSerializerDeserializer.getDouble(outInput1
                                                     .getByteArray(), ALineSerializerDeserializer
                                                     .getStartPointCoordinateOffset(Coordinate.Y));
-                                            double endX2 = ADoubleSerializerDeserializer.getDouble(
-                                                    outInput1.getByteArray(), ALineSerializerDeserializer
-                                                            .getEndPointCoordinateOffset(Coordinate.X));
-                                            double endY2 = ADoubleSerializerDeserializer.getDouble(
-                                                    outInput1.getByteArray(), ALineSerializerDeserializer
-                                                            .getEndPointCoordinateOffset(Coordinate.Y));
+                                            double endX2 = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.X));
+                                            double endY2 = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.Y));
                                             res = lineLineIntersection(startX1, startY1, endX1, endY1, startX2,
                                                     startY2, endX2, endY2);
                                             break;
                                         case POLYGON:
-                                            res = linePolygonIntersection(outInput0.getByteArray(), outInput1.getByteArray());
+                                            res = linePolygonIntersection(outInput0.getByteArray(),
+                                                    outInput1.getByteArray());
                                             break;
                                         case CIRCLE:
-                                            res = lineCircleIntersection(outInput0.getByteArray(), outInput1.getByteArray());
+                                            res = lineCircleIntersection(outInput0.getByteArray(),
+                                                    outInput1.getByteArray());
                                             break;
                                         case RECTANGLE:
-                                            res = lineRectangleIntersection(outInput0.getByteArray(), outInput1.getByteArray());
+                                            res = lineRectangleIntersection(outInput0.getByteArray(),
+                                                    outInput1.getByteArray());
                                             break;
                                         case NULL:
                                             res = false;
@@ -852,7 +857,8 @@
                                             res = pointInPolygon(outInput1.getByteArray(), outInput0.getByteArray());
                                             break;
                                         case LINE:
-                                            res = linePolygonIntersection(outInput1.getByteArray(), outInput0.getByteArray());
+                                            res = linePolygonIntersection(outInput1.getByteArray(),
+                                                    outInput0.getByteArray());
                                             break;
                                         case POLYGON:
                                             int numOfPoints0 = AInt16SerializerDeserializer.getShort(
@@ -880,9 +886,9 @@
                                             trianglesX1.reset();
                                             trianglesY1.reset();
                                             while (true) {
-                                                middleVertex1 = triangulatePolygon(outInput1.getByteArray(), numOfPoints1,
-                                                        pointsOffsets1, trianglesX1, trianglesY1, numOfTriangles1,
-                                                        nonSimplePolygonDetection1, middleVertex1);
+                                                middleVertex1 = triangulatePolygon(outInput1.getByteArray(),
+                                                        numOfPoints1, pointsOffsets1, trianglesX1, trianglesY1,
+                                                        numOfTriangles1, nonSimplePolygonDetection1, middleVertex1);
 
                                                 if (middleVertex1 == -1) {
                                                     break;
@@ -896,9 +902,9 @@
                                             trianglesX0.reset();
                                             trianglesY0.reset();
                                             while (true) {
-                                                middleVertex0 = triangulatePolygon(outInput0.getByteArray(), numOfPoints0,
-                                                        pointsOffsets0, trianglesX0, trianglesY0, numOfTriangles0,
-                                                        nonSimplePolygonDetection0, middleVertex0);
+                                                middleVertex0 = triangulatePolygon(outInput0.getByteArray(),
+                                                        numOfPoints0, pointsOffsets0, trianglesX0, trianglesY0,
+                                                        numOfTriangles0, nonSimplePolygonDetection0, middleVertex0);
 
                                                 if (middleVertex0 == -1) {
                                                     break;
@@ -929,7 +935,8 @@
                                             }
                                             break;
                                         case CIRCLE:
-                                            res = polygonCircleIntersection(outInput0.getByteArray(), outInput1.getByteArray());
+                                            res = polygonCircleIntersection(outInput0.getByteArray(),
+                                                    outInput1.getByteArray());
                                             break;
                                         case RECTANGLE:
                                             res = rectanglePolygonIntersection(outInput1.getByteArray(),
@@ -951,13 +958,16 @@
                                             res = pointInCircle(outInput1.getByteArray(), outInput0.getByteArray());
                                             break;
                                         case LINE:
-                                            res = lineCircleIntersection(outInput1.getByteArray(), outInput0.getByteArray());
+                                            res = lineCircleIntersection(outInput1.getByteArray(),
+                                                    outInput0.getByteArray());
                                             break;
                                         case POLYGON:
-                                            res = polygonCircleIntersection(outInput1.getByteArray(), outInput0.getByteArray());
+                                            res = polygonCircleIntersection(outInput1.getByteArray(),
+                                                    outInput0.getByteArray());
                                             break;
                                         case CIRCLE:
-                                            res = circleCircleIntersection(outInput0.getByteArray(), outInput1.getByteArray());
+                                            res = circleCircleIntersection(outInput0.getByteArray(),
+                                                    outInput1.getByteArray());
                                             break;
                                         case RECTANGLE:
                                             res = rectangleCircleIntersection(outInput1.getByteArray(),
@@ -979,7 +989,8 @@
                                             res = pointInRectangle(outInput1.getByteArray(), outInput0.getByteArray());
                                             break;
                                         case LINE:
-                                            res = lineRectangleIntersection(outInput1.getByteArray(), outInput0.getByteArray());
+                                            res = lineRectangleIntersection(outInput1.getByteArray(),
+                                                    outInput0.getByteArray());
                                             break;
                                         case POLYGON:
                                             res = rectanglePolygonIntersection(outInput0.getByteArray(),
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StartsWithDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StartsWithDescriptor.java
index 2405ad9..cd8079d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StartsWithDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StartsWithDescriptor.java
@@ -16,8 +16,7 @@
 public class StartsWithDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
 
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "starts-with",
-            2, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "starts-with", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StartsWithDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SubstringDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SubstringDescriptor.java
index c6d0627..5d3007f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SubstringDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SubstringDescriptor.java
@@ -21,8 +21,7 @@
 public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "substring", 3,
-            true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "substring", 3);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SubstringDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SwitchCaseDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SwitchCaseDescriptor.java
index 29fbb7f..4a33010 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SwitchCaseDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SwitchCaseDescriptor.java
@@ -19,7 +19,7 @@
 
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "switch-case",
-            FunctionIdentifier.VARARGS, true);
+            FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SwitchCaseDescriptor();
@@ -79,7 +79,8 @@
                             // the default case
                             argOut.reset();
                             evals[n - 1].evaluate(tuple);
-                            output.getDataOutput().write(argOut.getByteArray(), argOut.getStartOffset(), argOut.getLength());
+                            output.getDataOutput().write(argOut.getByteArray(), argOut.getStartOffset(),
+                                    argOut.getLength());
                         } catch (HyracksDataException hde) {
                             throw new AlgebricksException(hde);
                         } catch (IOException ioe) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/UnorderedListConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/UnorderedListConstructorDescriptor.java
index ea0765e..39149ac 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/UnorderedListConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/UnorderedListConstructorDescriptor.java
@@ -22,7 +22,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "unordered-list-constructor", FunctionIdentifier.VARARGS, true);
+            "unordered-list-constructor", FunctionIdentifier.VARARGS);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new UnorderedListConstructorDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/WordTokensDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/WordTokensDescriptor.java
index 122bd99..8f8c5f3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/WordTokensDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/WordTokensDescriptor.java
@@ -20,8 +20,7 @@
 public class WordTokensDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "word-tokens",
-            1, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "word-tokens", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new WordTokensDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/YearDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/YearDescriptor.java
index b95fbfa..e6da3ac 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/YearDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/YearDescriptor.java
@@ -27,7 +27,7 @@
 public class YearDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "year", 1, true);
+    public final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "year", 1);
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
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 240587f..e28e59c 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
@@ -109,6 +109,7 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.NotDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.NumericAddDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.NumericDivideDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.NumericModuloDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.NumericMultiplyDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.NumericSubtractDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.NumericUnaryMinusDescriptor;
@@ -238,6 +239,7 @@
         temp.add(NumericDivideDescriptor.FACTORY);
         temp.add(NumericMultiplyDescriptor.FACTORY);
         temp.add(NumericSubtractDescriptor.FACTORY);
+        temp.add(NumericModuloDescriptor.FACTORY);
         temp.add(IsNullDescriptor.FACTORY);
         temp.add(NotDescriptor.FACTORY);
         temp.add(LenDescriptor.FACTORY);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/runningaggregates/std/TidRunningAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/runningaggregates/std/TidRunningAggregateDescriptor.java
index 69e823b..f4bc68d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/runningaggregates/std/TidRunningAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/runningaggregates/std/TidRunningAggregateDescriptor.java
@@ -23,13 +23,13 @@
 public class TidRunningAggregateDescriptor extends AbstractRunningAggregateFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tid", 0, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tid", 0);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new TidRunningAggregateDescriptor();
         }
     };
-    
+
     @Override
     public ICopyRunningAggregateFunctionFactory createRunningAggregateFunctionFactory(ICopyEvaluatorFactory[] args)
             throws AlgebricksException {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/RangeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/RangeDescriptor.java
index fb7f8f0..03d2677 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/RangeDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/RangeDescriptor.java
@@ -26,13 +26,13 @@
 
     private static final long serialVersionUID = 1L;
 
-    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "range", 2, true);
+    private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "range", 2);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new RangeDescriptor();
         }
     };
-    
+
     @Override
     public FunctionIdentifier getIdentifier() {
         return FID;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
index bfd23eb..cfac382 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
@@ -31,7 +31,7 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "scan-collection", 1, true);
+            "scan-collection", 1);
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ScanCollectionDescriptor();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
index cd69f5b..8aee5cf 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
@@ -32,12 +32,12 @@
 
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
-            "subset-collection", 3, true);
+            "subset-collection", 3);
 
     private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
     private final static byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    
+
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SubsetCollectionDescriptor();
@@ -51,7 +51,8 @@
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyUnnestingFunction createUnnestingFunction(IDataOutputProvider provider) throws AlgebricksException {
+            public ICopyUnnestingFunction createUnnestingFunction(IDataOutputProvider provider)
+                    throws AlgebricksException {
 
                 final DataOutput out = provider.getDataOutput();