diff --git a/hivesterix/pom.xml b/hivesterix/pom.xml
index cf9c4b5..55f837e 100644
--- a/hivesterix/pom.xml
+++ b/hivesterix/pom.xml
@@ -4,7 +4,7 @@
 	<groupId>edu.uci.ics.hivesterix</groupId>
 	<artifactId>hivesterix</artifactId>
 	<version>0.2.3-SNAPSHOT</version>
- 	<name>hivesterix</name>
+	<name>hivesterix</name>
 	<dependencies>
 		<dependency>
 			<groupId>javax.servlet</groupId>
@@ -313,6 +313,25 @@
 				</configuration>
 			</plugin>
 			<plugin>
+				<artifactId>maven-jar-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>patch</id>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+						<phase>package</phase>
+						<configuration>
+							<classifier>patch</classifier>
+							<finalName>a-hive</finalName>
+							<includes>
+								<include>**/org/apache/**</include>
+							</includes>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
 				<groupId>org.codehaus.mojo</groupId>
 				<artifactId>appassembler-maven-plugin</artifactId>
 				<version>1.3</version>
@@ -358,8 +377,8 @@
 				<version>2.13</version>
 				<configuration>
 					<forkMode>pertest</forkMode>
-					<argLine>-enableassertions -Xmx2047m -Dfile.encoding=UTF-8 
-                        -Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
+					<argLine>-enableassertions -Xmx2047m -Dfile.encoding=UTF-8
+						-Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
 					<includes>
 						<include>**/test/optimizer/*TestSuite.java</include>
 						<include>**/test/optimizer/*Test.java</include>
diff --git a/hivesterix/src/main/assembly/binary-assembly.xml b/hivesterix/src/main/assembly/binary-assembly.xml
index 0500499..906f199 100755
--- a/hivesterix/src/main/assembly/binary-assembly.xml
+++ b/hivesterix/src/main/assembly/binary-assembly.xml
@@ -1,19 +1,26 @@
 <assembly>
-  <id>binary-assembly</id>
-  <formats>
-    <format>zip</format>
-    <format>dir</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <fileSets>
-    <fileSet>
-      <directory>target/appassembler/bin</directory>
-      <outputDirectory>bin</outputDirectory>
-      <fileMode>0755</fileMode>
-    </fileSet>
-    <fileSet>
-      <directory>target/appassembler/lib</directory>
-      <outputDirectory>lib</outputDirectory>
-    </fileSet>
-  </fileSets>
+	<id>binary-assembly</id>
+	<formats>
+		<format>zip</format>
+		<format>dir</format>
+	</formats>
+	<includeBaseDirectory>false</includeBaseDirectory>
+	<fileSets>
+		<fileSet>
+			<directory>target/appassembler/bin</directory>
+			<outputDirectory>bin</outputDirectory>
+			<fileMode>0755</fileMode>
+		</fileSet>
+		<fileSet>
+			<directory>target/appassembler/lib</directory>
+			<outputDirectory>lib</outputDirectory>
+		</fileSet>
+		<fileSet>
+			<directory>target</directory>
+			<outputDirectory>lib</outputDirectory>
+			<includes>
+				<include>**/*.jar</include>
+			</includes>
+		</fileSet>
+	</fileSets>
 </assembly>
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
index 1fb973e..2765e44 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
@@ -80,729 +80,770 @@
 @SuppressWarnings("rawtypes")
 public class HiveAlgebricksTranslator implements Translator {
 
-    private int currentVariable = 0;
+	private int currentVariable = 0;
 
-    private List<Mutable<ILogicalOperator>> logicalOp = new ArrayList<Mutable<ILogicalOperator>>();
+	private List<Mutable<ILogicalOperator>> logicalOp = new ArrayList<Mutable<ILogicalOperator>>();
 
-    private boolean continueTraverse = true;
+	private boolean continueTraverse = true;
 
-    private IMetadataProvider<PartitionDesc, Object> metaData;
+	private IMetadataProvider<PartitionDesc, Object> metaData;
 
-    /**
-     * map variable name to the logical variable
-     */
-    private HashMap<String, LogicalVariable> nameToLogicalVariableMap = new HashMap<String, LogicalVariable>();
+	/**
+	 * map variable name to the logical variable
+	 */
+	private HashMap<String, LogicalVariable> nameToLogicalVariableMap = new HashMap<String, LogicalVariable>();
 
-    /**
-     * map field name to LogicalVariable
-     */
-    private HashMap<String, LogicalVariable> fieldToLogicalVariableMap = new HashMap<String, LogicalVariable>();
+	/**
+	 * map field name to LogicalVariable
+	 */
+	private HashMap<String, LogicalVariable> fieldToLogicalVariableMap = new HashMap<String, LogicalVariable>();
 
-    /**
-     * map logical variable to name
-     */
-    private HashMap<LogicalVariable, String> logicalVariableToFieldMap = new HashMap<LogicalVariable, String>();
+	/**
+	 * map logical variable to name
+	 */
+	private HashMap<LogicalVariable, String> logicalVariableToFieldMap = new HashMap<LogicalVariable, String>();
 
-    /**
-     * asterix root operators
-     */
-    private List<Mutable<ILogicalOperator>> rootOperators = new ArrayList<Mutable<ILogicalOperator>>();
+	/**
+	 * asterix root operators
+	 */
+	private List<Mutable<ILogicalOperator>> rootOperators = new ArrayList<Mutable<ILogicalOperator>>();
 
-    /**
-     * a list of visitors
-     */
-    private List<Visitor> visitors = new ArrayList<Visitor>();
+	/**
+	 * a list of visitors
+	 */
+	private List<Visitor> visitors = new ArrayList<Visitor>();
 
-    /**
-     * output writer to print things out
-     */
-    private static PrintWriter outputWriter = new PrintWriter(new OutputStreamWriter(System.out));
+	/**
+	 * output writer to print things out
+	 */
+	private static PrintWriter outputWriter = new PrintWriter(
+			new OutputStreamWriter(System.out));
 
-    /**
-     * map a logical variable to type info
-     */
-    private HashMap<LogicalVariable, TypeInfo> variableToType = new HashMap<LogicalVariable, TypeInfo>();
+	/**
+	 * map a logical variable to type info
+	 */
+	private HashMap<LogicalVariable, TypeInfo> variableToType = new HashMap<LogicalVariable, TypeInfo>();
 
-    @Override
-    public LogicalVariable getVariable(String fieldName, TypeInfo type) {
-        LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);
-        if (var == null) {
-            currentVariable++;
-            var = new LogicalVariable(currentVariable);
-            fieldToLogicalVariableMap.put(fieldName, var);
-            nameToLogicalVariableMap.put(var.toString(), var);
-            variableToType.put(var, type);
-            logicalVariableToFieldMap.put(var, fieldName);
-        }
-        return var;
-    }
+	@Override
+	public LogicalVariable getVariable(String fieldName, TypeInfo type) {
+		LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);
+		if (var == null) {
+			currentVariable++;
+			var = new LogicalVariable(currentVariable);
+			fieldToLogicalVariableMap.put(fieldName, var);
+			nameToLogicalVariableMap.put(var.toString(), var);
+			variableToType.put(var, type);
+			logicalVariableToFieldMap.put(var, fieldName);
+		}
+		return var;
+	}
 
-    @Override
-    public LogicalVariable getNewVariable(String fieldName, TypeInfo type) {
-        currentVariable++;
-        LogicalVariable var = new LogicalVariable(currentVariable);
-        fieldToLogicalVariableMap.put(fieldName, var);
-        nameToLogicalVariableMap.put(var.toString(), var);
-        variableToType.put(var, type);
-        logicalVariableToFieldMap.put(var, fieldName);
-        return var;
-    }
+	@Override
+	public LogicalVariable getNewVariable(String fieldName, TypeInfo type) {
+		currentVariable++;
+		LogicalVariable var = new LogicalVariable(currentVariable);
+		fieldToLogicalVariableMap.put(fieldName, var);
+		nameToLogicalVariableMap.put(var.toString(), var);
+		variableToType.put(var, type);
+		logicalVariableToFieldMap.put(var, fieldName);
+		return var;
+	}
 
-    @Override
-    public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar) {
-        String name = this.logicalVariableToFieldMap.get(oldVar);
-        if (name != null) {
-            fieldToLogicalVariableMap.put(name, newVar);
-            nameToLogicalVariableMap.put(newVar.toString(), newVar);
-            nameToLogicalVariableMap.put(oldVar.toString(), newVar);
-            logicalVariableToFieldMap.put(newVar, name);
-        }
-    }
+	@Override
+	public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar) {
+		String name = this.logicalVariableToFieldMap.get(oldVar);
+		if (name != null) {
+			fieldToLogicalVariableMap.put(name, newVar);
+			nameToLogicalVariableMap.put(newVar.toString(), newVar);
+			nameToLogicalVariableMap.put(oldVar.toString(), newVar);
+			logicalVariableToFieldMap.put(newVar, name);
+		}
+	}
 
-    @Override
-    public IMetadataProvider<PartitionDesc, Object> getMetadataProvider() {
-        return metaData;
-    }
+	@Override
+	public IMetadataProvider<PartitionDesc, Object> getMetadataProvider() {
+		return metaData;
+	}
 
-    /**
-     * only get an variable, without rewriting it
-     * 
-     * @param fieldName
-     * @return
-     */
-    private LogicalVariable getVariableOnly(String fieldName) {
-        return fieldToLogicalVariableMap.get(fieldName);
-    }
+	/**
+	 * only get an variable, without rewriting it
+	 * 
+	 * @param fieldName
+	 * @return
+	 */
+	private LogicalVariable getVariableOnly(String fieldName) {
+		return fieldToLogicalVariableMap.get(fieldName);
+	}
 
-    private void updateVariable(String fieldName, LogicalVariable variable) {
-        LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);
-        if (var == null) {
-            fieldToLogicalVariableMap.put(fieldName, variable);
-            nameToLogicalVariableMap.put(fieldName, variable);
-        } else if (!var.equals(variable)) {
-            // System.out.println("!!!replace variables!!!");
-            fieldToLogicalVariableMap.put(fieldName, variable);
-            nameToLogicalVariableMap.put(fieldName, variable);
-        }
-    }
+	private void updateVariable(String fieldName, LogicalVariable variable) {
+		LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);
+		if (var == null) {
+			fieldToLogicalVariableMap.put(fieldName, variable);
+			nameToLogicalVariableMap.put(fieldName, variable);
+		} else if (!var.equals(variable)) {
+			fieldToLogicalVariableMap.put(fieldName, variable);
+			nameToLogicalVariableMap.put(fieldName, variable);
+		}
+	}
 
-    /**
-     * get a list of logical variables from the schema
-     * 
-     * @param schema
-     * @return
-     */
-    @Override
-    public List<LogicalVariable> getVariablesFromSchema(Schema schema) {
-        List<LogicalVariable> variables = new ArrayList<LogicalVariable>();
-        List<String> names = schema.getNames();
+	/**
+	 * get a list of logical variables from the schema
+	 * 
+	 * @param schema
+	 * @return
+	 */
+	@Override
+	public List<LogicalVariable> getVariablesFromSchema(Schema schema) {
+		List<LogicalVariable> variables = new ArrayList<LogicalVariable>();
+		List<String> names = schema.getNames();
 
-        for (String name : names)
-            variables.add(nameToLogicalVariableMap.get(name));
-        return variables;
-    }
+		for (String name : names)
+			variables.add(nameToLogicalVariableMap.get(name));
+		return variables;
+	}
 
-    /**
-     * get variable to typeinfo map
-     * 
-     * @return
-     */
-    public HashMap<LogicalVariable, TypeInfo> getVariableContext() {
-        return this.variableToType;
-    }
+	/**
+	 * get variable to typeinfo map
+	 * 
+	 * @return
+	 */
+	public HashMap<LogicalVariable, TypeInfo> getVariableContext() {
+		return this.variableToType;
+	}
 
-    /**
-     * get the number of variables
-     * s
-     * 
-     * @return
-     */
-    public int getVariableCounter() {
-        return currentVariable + 1;
-    }
+	/**
+	 * get the number of variables s
+	 * 
+	 * @return
+	 */
+	public int getVariableCounter() {
+		return currentVariable + 1;
+	}
 
-    /**
-     * translate from hive operator tree to asterix operator tree
-     * 
-     * @param hive
-     *            roots
-     * @return Algebricks roots
-     */
-    public void translate(List<Operator> hiveRoot, ILogicalOperator parentOperator,
-            HashMap<String, PartitionDesc> aliasToPathMap) throws AlgebricksException {
-        /**
-         * register visitors
-         */
-        visitors.add(new FilterVisitor());
-        visitors.add(new GroupByVisitor());
-        visitors.add(new JoinVisitor());
-        visitors.add(new LateralViewJoinVisitor());
-        visitors.add(new UnionVisitor());
-        visitors.add(new LimitVisitor());
-        visitors.add(new MapJoinVisitor());
-        visitors.add(new ProjectVisitor());
-        visitors.add(new SortVisitor());
-        visitors.add(new ExtractVisitor());
-        visitors.add(new TableScanWriteVisitor(aliasToPathMap));
+	/**
+	 * translate from hive operator tree to asterix operator tree
+	 * 
+	 * @param hive
+	 *            roots
+	 * @return Algebricks roots
+	 */
+	public void translate(List<Operator> hiveRoot,
+			ILogicalOperator parentOperator,
+			HashMap<String, PartitionDesc> aliasToPathMap)
+			throws AlgebricksException {
+		/**
+		 * register visitors
+		 */
+		visitors.add(new FilterVisitor());
+		visitors.add(new GroupByVisitor());
+		visitors.add(new JoinVisitor());
+		visitors.add(new LateralViewJoinVisitor());
+		visitors.add(new UnionVisitor());
+		visitors.add(new LimitVisitor());
+		visitors.add(new MapJoinVisitor());
+		visitors.add(new ProjectVisitor());
+		visitors.add(new SortVisitor());
+		visitors.add(new ExtractVisitor());
+		visitors.add(new TableScanWriteVisitor(aliasToPathMap));
 
-        List<Mutable<ILogicalOperator>> refList = translate(hiveRoot, new MutableObject<ILogicalOperator>(
-                parentOperator));
-        insertReplicateOperator(refList);
-        if (refList != null)
-            rootOperators.addAll(refList);
-    }
+		List<Mutable<ILogicalOperator>> refList = translate(hiveRoot,
+				new MutableObject<ILogicalOperator>(parentOperator));
+		insertReplicateOperator(refList);
+		if (refList != null)
+			rootOperators.addAll(refList);
+	}
 
-    /**
-     * translate operator DAG
-     * 
-     * @param hiveRoot
-     * @param AlgebricksParentOperator
-     * @return
-     */
-    private List<Mutable<ILogicalOperator>> translate(List<Operator> hiveRoot,
-            Mutable<ILogicalOperator> AlgebricksParentOperator) throws AlgebricksException {
+	/**
+	 * translate operator DAG
+	 * 
+	 * @param hiveRoot
+	 * @param AlgebricksParentOperator
+	 * @return
+	 */
+	private List<Mutable<ILogicalOperator>> translate(List<Operator> hiveRoot,
+			Mutable<ILogicalOperator> AlgebricksParentOperator)
+			throws AlgebricksException {
 
-        for (Operator hiveOperator : hiveRoot) {
-            continueTraverse = true;
-            Mutable<ILogicalOperator> currentOperatorRef = null;
-            if (hiveOperator.getType() == OperatorType.FILTER) {
-                FilterOperator fop = (FilterOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.REDUCESINK) {
-                ReduceSinkOperator fop = (ReduceSinkOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.JOIN) {
-                JoinOperator fop = (JoinOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null) {
-                        continueTraverse = true;
-                        break;
-                    } else
-                        continueTraverse = false;
-                }
-                if (currentOperatorRef == null)
-                    return null;
-            } else if (hiveOperator.getType() == OperatorType.LATERALVIEWJOIN) {
-                LateralViewJoinOperator fop = (LateralViewJoinOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-                if (currentOperatorRef == null)
-                    return null;
-            } else if (hiveOperator.getType() == OperatorType.MAPJOIN) {
-                MapJoinOperator fop = (MapJoinOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null) {
-                        continueTraverse = true;
-                        break;
-                    } else
-                        continueTraverse = false;
-                }
-                if (currentOperatorRef == null)
-                    return null;
-            } else if (hiveOperator.getType() == OperatorType.SELECT) {
-                SelectOperator fop = (SelectOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.EXTRACT) {
-                ExtractOperator fop = (ExtractOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.GROUPBY) {
-                GroupByOperator fop = (GroupByOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.TABLESCAN) {
-                TableScanOperator fop = (TableScanOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.FILESINK) {
-                FileSinkOperator fop = (FileSinkOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.LIMIT) {
-                LimitOperator lop = (LimitOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.UDTF) {
-                UDTFOperator lop = (UDTFOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null)
-                        break;
-                }
-            } else if (hiveOperator.getType() == OperatorType.UNION) {
-                UnionOperator lop = (UnionOperator) hiveOperator;
-                for (Visitor visitor : visitors) {
-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);
-                    if (currentOperatorRef != null) {
-                        continueTraverse = true;
-                        break;
-                    } else
-                        continueTraverse = false;
-                }
-            } else
-                ;
-            if (hiveOperator.getChildOperators() != null && hiveOperator.getChildOperators().size() > 0
-                    && continueTraverse) {
-                @SuppressWarnings("unchecked")
-                List<Operator> children = hiveOperator.getChildOperators();
-                if (currentOperatorRef == null)
-                    currentOperatorRef = AlgebricksParentOperator;
-                translate(children, currentOperatorRef);
-            }
-            if (hiveOperator.getChildOperators() == null || hiveOperator.getChildOperators().size() == 0)
-                logicalOp.add(currentOperatorRef);
-        }
-        return logicalOp;
-    }
+		for (Operator hiveOperator : hiveRoot) {
+			continueTraverse = true;
+			Mutable<ILogicalOperator> currentOperatorRef = null;
+			if (hiveOperator.getType() == OperatorType.FILTER) {
+				FilterOperator fop = (FilterOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.REDUCESINK) {
+				ReduceSinkOperator fop = (ReduceSinkOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.JOIN) {
+				JoinOperator fop = (JoinOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null) {
+						continueTraverse = true;
+						break;
+					} else
+						continueTraverse = false;
+				}
+				if (currentOperatorRef == null)
+					return null;
+			} else if (hiveOperator.getType() == OperatorType.LATERALVIEWJOIN) {
+				LateralViewJoinOperator fop = (LateralViewJoinOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+				if (currentOperatorRef == null)
+					return null;
+			} else if (hiveOperator.getType() == OperatorType.MAPJOIN) {
+				MapJoinOperator fop = (MapJoinOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null) {
+						continueTraverse = true;
+						break;
+					} else
+						continueTraverse = false;
+				}
+				if (currentOperatorRef == null)
+					return null;
+			} else if (hiveOperator.getType() == OperatorType.SELECT) {
+				SelectOperator fop = (SelectOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.EXTRACT) {
+				ExtractOperator fop = (ExtractOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.GROUPBY) {
+				GroupByOperator fop = (GroupByOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.TABLESCAN) {
+				TableScanOperator fop = (TableScanOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.FILESINK) {
+				FileSinkOperator fop = (FileSinkOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(fop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.LIMIT) {
+				LimitOperator lop = (LimitOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(lop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.UDTF) {
+				UDTFOperator lop = (UDTFOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(lop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null)
+						break;
+				}
+			} else if (hiveOperator.getType() == OperatorType.UNION) {
+				UnionOperator lop = (UnionOperator) hiveOperator;
+				for (Visitor visitor : visitors) {
+					currentOperatorRef = visitor.visit(lop,
+							AlgebricksParentOperator, this);
+					if (currentOperatorRef != null) {
+						continueTraverse = true;
+						break;
+					} else
+						continueTraverse = false;
+				}
+			} else
+				;
+			if (hiveOperator.getChildOperators() != null
+					&& hiveOperator.getChildOperators().size() > 0
+					&& continueTraverse) {
+				@SuppressWarnings("unchecked")
+				List<Operator> children = hiveOperator.getChildOperators();
+				if (currentOperatorRef == null)
+					currentOperatorRef = AlgebricksParentOperator;
+				translate(children, currentOperatorRef);
+			}
+			if (hiveOperator.getChildOperators() == null
+					|| hiveOperator.getChildOperators().size() == 0)
+				logicalOp.add(currentOperatorRef);
+		}
+		return logicalOp;
+	}
 
-    /**
-     * used in select, group by to get no-column-expression columns
-     * 
-     * @param cols
-     * @return
-     */
-    public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent, List<ExprNodeDesc> cols,
-            ArrayList<LogicalVariable> variables) {
+	/**
+	 * used in select, group by to get no-column-expression columns
+	 * 
+	 * @param cols
+	 * @return
+	 */
+	public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent,
+			List<ExprNodeDesc> cols, ArrayList<LogicalVariable> variables) {
 
-        ArrayList<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();
+		ArrayList<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();
 
-        /**
-         * variables to be appended in the assign operator
-         */
-        ArrayList<LogicalVariable> appendedVariables = new ArrayList<LogicalVariable>();
+		/**
+		 * variables to be appended in the assign operator
+		 */
+		ArrayList<LogicalVariable> appendedVariables = new ArrayList<LogicalVariable>();
 
-        // one variable can only be assigned once
-        for (ExprNodeDesc hiveExpr : cols) {
-            rewriteExpression(hiveExpr);
+		// one variable can only be assigned once
+		for (ExprNodeDesc hiveExpr : cols) {
+			rewriteExpression(hiveExpr);
 
-            if (hiveExpr instanceof ExprNodeColumnDesc) {
-                ExprNodeColumnDesc desc2 = (ExprNodeColumnDesc) hiveExpr;
-                String fieldName = desc2.getTabAlias() + "." + desc2.getColumn();
+			if (hiveExpr instanceof ExprNodeColumnDesc) {
+				ExprNodeColumnDesc desc2 = (ExprNodeColumnDesc) hiveExpr;
+				String fieldName = desc2.getTabAlias() + "."
+						+ desc2.getColumn();
 
-                // System.out.println("project expr: " + fieldName);
+				// System.out.println("project expr: " + fieldName);
 
-                if (fieldName.indexOf("$$") < 0) {
-                    LogicalVariable var = getVariable(fieldName, hiveExpr.getTypeInfo());
-                    desc2.setColumn(var.toString());
-                    desc2.setTabAlias("");
-                    variables.add(var);
-                } else {
-                    LogicalVariable var = nameToLogicalVariableMap.get(desc2.getColumn());
-                    String name = this.logicalVariableToFieldMap.get(var);
-                    var = this.getVariableOnly(name);
-                    variables.add(var);
-                }
-            } else {
-                Mutable<ILogicalExpression> asterixExpr = translateScalarFucntion(hiveExpr);
-                expressions.add(asterixExpr);
-                LogicalVariable var = getVariable(hiveExpr.getExprString() + asterixExpr.hashCode(),
-                        hiveExpr.getTypeInfo());
-                variables.add(var);
-                appendedVariables.add(var);
-            }
-        }
+				if (fieldName.indexOf("$$") < 0) {
+					LogicalVariable var = getVariable(fieldName,
+							hiveExpr.getTypeInfo());
+					desc2.setColumn(var.toString());
+					desc2.setTabAlias("");
+					variables.add(var);
+				} else {
+					LogicalVariable var = nameToLogicalVariableMap.get(desc2
+							.getColumn());
+					String name = this.logicalVariableToFieldMap.get(var);
+					var = this.getVariableOnly(name);
+					variables.add(var);
+				}
+			} else {
+				Mutable<ILogicalExpression> asterixExpr = translateScalarFucntion(hiveExpr);
+				expressions.add(asterixExpr);
+				LogicalVariable var = getVariable(hiveExpr.getExprString()
+						+ asterixExpr.hashCode(), hiveExpr.getTypeInfo());
+				variables.add(var);
+				appendedVariables.add(var);
+			}
+		}
 
-        /**
-         * create an assign operator to deal with appending
-         */
-        ILogicalOperator assignOp = null;
-        if (appendedVariables.size() > 0) {
-            assignOp = new AssignOperator(appendedVariables, expressions);
-            assignOp.getInputs().add(parent);
-        }
-        return assignOp;
-    }
+		/**
+		 * create an assign operator to deal with appending
+		 */
+		ILogicalOperator assignOp = null;
+		if (appendedVariables.size() > 0) {
+			assignOp = new AssignOperator(appendedVariables, expressions);
+			assignOp.getInputs().add(parent);
+		}
+		return assignOp;
+	}
 
-    private ILogicalPlan plan;
+	private ILogicalPlan plan;
 
-    public ILogicalPlan genLogicalPlan() {
-        plan = new ALogicalPlanImpl(rootOperators);
-        return plan;
-    }
+	public ILogicalPlan genLogicalPlan() {
+		plan = new ALogicalPlanImpl(rootOperators);
+		return plan;
+	}
 
-    public void printOperators() throws AlgebricksException {
-        LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();
-        StringBuilder buffer = new StringBuilder();
-        PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);
-        outputWriter.println(buffer);
-        outputWriter.println("rewritten variables: ");
-        outputWriter.flush();
-        printVariables();
+	public void printOperators() throws AlgebricksException {
+		LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();
+		StringBuilder buffer = new StringBuilder();
+		PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);
+		outputWriter.println(buffer);
+		outputWriter.println("rewritten variables: ");
+		outputWriter.flush();
+		printVariables();
 
-    }
+	}
 
-    public static void setOutputPrinter(PrintWriter writer) {
-        outputWriter = writer;
-    }
+	public static void setOutputPrinter(PrintWriter writer) {
+		outputWriter = writer;
+	}
 
-    private void printVariables() {
-        Set<Entry<String, LogicalVariable>> entries = fieldToLogicalVariableMap.entrySet();
+	private void printVariables() {
+		Set<Entry<String, LogicalVariable>> entries = fieldToLogicalVariableMap
+				.entrySet();
 
-        for (Entry<String, LogicalVariable> entry : entries) {
-            outputWriter.println(entry.getKey() + " -> " + entry.getValue());
-        }
-        outputWriter.flush();
-    }
+		for (Entry<String, LogicalVariable> entry : entries) {
+			outputWriter.println(entry.getKey() + " -> " + entry.getValue());
+		}
+		outputWriter.flush();
+	}
 
-    /**
-     * generate the object inspector for the output of an operator
-     * 
-     * @param operator
-     *            The Hive operator
-     * @return an ObjectInspector object
-     */
-    public Schema generateInputSchema(Operator operator) {
-        List<String> variableNames = new ArrayList<String>();
-        List<TypeInfo> typeList = new ArrayList<TypeInfo>();
-        List<ColumnInfo> columns = operator.getSchema().getSignature();
+	/**
+	 * generate the object inspector for the output of an operator
+	 * 
+	 * @param operator
+	 *            The Hive operator
+	 * @return an ObjectInspector object
+	 */
+	public Schema generateInputSchema(Operator operator) {
+		List<String> variableNames = new ArrayList<String>();
+		List<TypeInfo> typeList = new ArrayList<TypeInfo>();
+		List<ColumnInfo> columns = operator.getSchema().getSignature();
 
-        for (ColumnInfo col : columns) {
-            // typeList.add();
-            TypeInfo type = col.getType();
-            typeList.add(type);
+		for (ColumnInfo col : columns) {
+			// typeList.add();
+			TypeInfo type = col.getType();
+			typeList.add(type);
 
-            String fieldName = col.getInternalName();
-            variableNames.add(fieldName);
-        }
+			String fieldName = col.getInternalName();
+			variableNames.add(fieldName);
+		}
 
-        return new Schema(variableNames, typeList);
-    }
+		return new Schema(variableNames, typeList);
+	}
 
-    /**
-     * rewrite the names of output columns for feature expression evaluators to
-     * use
-     * 
-     * @param operator
-     */
-    public void rewriteOperatorOutputSchema(Operator operator) {
-        List<ColumnInfo> columns = operator.getSchema().getSignature();
+	/**
+	 * rewrite the names of output columns for feature expression evaluators to
+	 * use
+	 * 
+	 * @param operator
+	 */
+	public void rewriteOperatorOutputSchema(Operator operator) {
+		List<ColumnInfo> columns = operator.getSchema().getSignature();
 
-        for (ColumnInfo column : columns) {
-            String columnName = column.getTabAlias() + "." + column.getInternalName();
-            if (columnName.indexOf("$$") < 0) {
-                LogicalVariable var = getVariable(columnName, column.getType());
-                column.setInternalName(var.toString());
-            }
-        }
-    }
+		for (ColumnInfo column : columns) {
+			String columnName = column.getTabAlias() + "."
+					+ column.getInternalName();
+			if (columnName.indexOf("$$") < 0) {
+				LogicalVariable var = getVariable(columnName, column.getType());
+				column.setInternalName(var.toString());
+			}
+		}
+	}
 
-    @Override
-    public void rewriteOperatorOutputSchema(List<LogicalVariable> variables, Operator operator) {
+	@Override
+	public void rewriteOperatorOutputSchema(List<LogicalVariable> variables,
+			Operator operator) {
 
-        printOperatorSchema(operator);
-        List<ColumnInfo> columns = operator.getSchema().getSignature();
-        if (variables.size() != columns.size()) {
-            throw new IllegalStateException("output cardinality error " + operator.getName() + " variable size: "
-                    + variables.size() + " expected " + columns.size());
-        }
+		//printOperatorSchema(operator);
+		List<ColumnInfo> columns = operator.getSchema().getSignature();
+		if (variables.size() != columns.size()) {
+			throw new IllegalStateException("output cardinality error "
+					+ operator.getName() + " variable size: "
+					+ variables.size() + " expected " + columns.size());
+		}
 
-        for (int i = 0; i < variables.size(); i++) {
-            LogicalVariable var = variables.get(i);
-            ColumnInfo column = columns.get(i);
-            String fieldName = column.getTabAlias() + "." + column.getInternalName();
-            if (fieldName.indexOf("$$") < 0) {
-                updateVariable(fieldName, var);
-                column.setInternalName(var.toString());
-            }
-        }
-        printOperatorSchema(operator);
-    }
+		for (int i = 0; i < variables.size(); i++) {
+			LogicalVariable var = variables.get(i);
+			ColumnInfo column = columns.get(i);
+			String fieldName = column.getTabAlias() + "."
+					+ column.getInternalName();
+			if (fieldName.indexOf("$$") < 0) {
+				updateVariable(fieldName, var);
+				column.setInternalName(var.toString());
+			}
+		}
+		//printOperatorSchema(operator);
+	}
 
-    /**
-     * rewrite an expression and substitute variables
-     * 
-     * @param expr
-     *            hive expression
-     */
-    public void rewriteExpression(ExprNodeDesc expr) {
-        if (expr instanceof ExprNodeColumnDesc) {
-            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
-            String fieldName = desc.getTabAlias() + "." + desc.getColumn();
-            if (fieldName.indexOf("$$") < 0) {
-                LogicalVariable var = getVariableOnly(fieldName);
-                if (var == null) {
-                    fieldName = "." + desc.getColumn();
-                    var = getVariableOnly(fieldName);
-                    if (var == null) {
-                        fieldName = "null." + desc.getColumn();
-                        var = getVariableOnly(fieldName);
-                        if (var == null) {
-                            throw new IllegalStateException(fieldName + " is wrong!!! ");
-                        }
-                    }
-                }
-                String name = this.logicalVariableToFieldMap.get(var);
-                var = getVariableOnly(name);
-                desc.setColumn(var.toString());
-            }
-        } else {
-            if (expr.getChildren() != null && expr.getChildren().size() > 0) {
-                List<ExprNodeDesc> children = expr.getChildren();
-                for (ExprNodeDesc desc : children)
-                    rewriteExpression(desc);
-            }
-        }
-    }
+	/**
+	 * rewrite an expression and substitute variables
+	 * 
+	 * @param expr
+	 *            hive expression
+	 */
+	public void rewriteExpression(ExprNodeDesc expr) {
+		if (expr instanceof ExprNodeColumnDesc) {
+			ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
+			String fieldName = desc.getTabAlias() + "." + desc.getColumn();
+			if (fieldName.indexOf("$$") < 0) {
+				LogicalVariable var = getVariableOnly(fieldName);
+				if (var == null) {
+					fieldName = "." + desc.getColumn();
+					var = getVariableOnly(fieldName);
+					if (var == null) {
+						fieldName = "null." + desc.getColumn();
+						var = getVariableOnly(fieldName);
+						if (var == null) {
+							throw new IllegalStateException(fieldName
+									+ " is wrong!!! ");
+						}
+					}
+				}
+				String name = this.logicalVariableToFieldMap.get(var);
+				var = getVariableOnly(name);
+				desc.setColumn(var.toString());
+			}
+		} else {
+			if (expr.getChildren() != null && expr.getChildren().size() > 0) {
+				List<ExprNodeDesc> children = expr.getChildren();
+				for (ExprNodeDesc desc : children)
+					rewriteExpression(desc);
+			}
+		}
+	}
 
-    /**
-     * rewrite an expression and substitute variables
-     * 
-     * @param expr
-     *            hive expression
-     */
-    public void rewriteExpressionPartial(ExprNodeDesc expr) {
-        if (expr instanceof ExprNodeColumnDesc) {
-            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
-            String fieldName = desc.getTabAlias() + "." + desc.getColumn();
-            if (fieldName.indexOf("$$") < 0) {
-                LogicalVariable var = getVariableOnly(fieldName);
-                desc.setColumn(var.toString());
-            }
-        } else {
-            if (expr.getChildren() != null && expr.getChildren().size() > 0) {
-                List<ExprNodeDesc> children = expr.getChildren();
-                for (ExprNodeDesc desc : children)
-                    rewriteExpressionPartial(desc);
-            }
-        }
-    }
+	/**
+	 * rewrite an expression and substitute variables
+	 * 
+	 * @param expr
+	 *            hive expression
+	 */
+	public void rewriteExpressionPartial(ExprNodeDesc expr) {
+		if (expr instanceof ExprNodeColumnDesc) {
+			ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
+			String fieldName = desc.getTabAlias() + "." + desc.getColumn();
+			if (fieldName.indexOf("$$") < 0) {
+				LogicalVariable var = getVariableOnly(fieldName);
+				desc.setColumn(var.toString());
+			}
+		} else {
+			if (expr.getChildren() != null && expr.getChildren().size() > 0) {
+				List<ExprNodeDesc> children = expr.getChildren();
+				for (ExprNodeDesc desc : children)
+					rewriteExpressionPartial(desc);
+			}
+		}
+	}
 
-    private void printOperatorSchema(Operator operator) {
-        System.out.println(operator.getName());
-        List<ColumnInfo> columns = operator.getSchema().getSignature();
-        for (ColumnInfo column : columns) {
-            System.out.print(column.getTabAlias() + "." + column.getInternalName() + "  ");
-        }
-        System.out.println();
-    }
+	// private void printOperatorSchema(Operator operator) {
+	// // System.out.println(operator.getName());
+	// // List<ColumnInfo> columns = operator.getSchema().getSignature();
+	// // for (ColumnInfo column : columns) {
+	// // System.out.print(column.getTabAlias() + "." +
+	// // column.getInternalName() + "  ");
+	// // }
+	// // System.out.println();
+	// }
 
-    /**
-     * translate scalar function expression
-     * 
-     * @param hiveExpr
-     * @return
-     */
-    public Mutable<ILogicalExpression> translateScalarFucntion(ExprNodeDesc hiveExpr) {
-        ILogicalExpression AlgebricksExpr;
+	/**
+	 * translate scalar function expression
+	 * 
+	 * @param hiveExpr
+	 * @return
+	 */
+	public Mutable<ILogicalExpression> translateScalarFucntion(
+			ExprNodeDesc hiveExpr) {
+		ILogicalExpression AlgebricksExpr;
 
-        if (hiveExpr instanceof ExprNodeGenericFuncDesc) {
-            List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
-            List<ExprNodeDesc> children = hiveExpr.getChildren();
+		if (hiveExpr instanceof ExprNodeGenericFuncDesc) {
+			List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
+			List<ExprNodeDesc> children = hiveExpr.getChildren();
 
-            for (ExprNodeDesc child : children)
-                arguments.add(translateScalarFucntion(child));
+			for (ExprNodeDesc child : children)
+				arguments.add(translateScalarFucntion(child));
 
-            ExprNodeGenericFuncDesc funcExpr = (ExprNodeGenericFuncDesc) hiveExpr;
-            GenericUDF genericUdf = funcExpr.getGenericUDF();
-            UDF udf = null;
-            if (genericUdf instanceof GenericUDFBridge) {
-                GenericUDFBridge bridge = (GenericUDFBridge) genericUdf;
-                try {
-                    udf = bridge.getUdfClass().newInstance();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
+			ExprNodeGenericFuncDesc funcExpr = (ExprNodeGenericFuncDesc) hiveExpr;
+			GenericUDF genericUdf = funcExpr.getGenericUDF();
+			UDF udf = null;
+			if (genericUdf instanceof GenericUDFBridge) {
+				GenericUDFBridge bridge = (GenericUDFBridge) genericUdf;
+				try {
+					udf = bridge.getUdfClass().newInstance();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
 
-            /**
-             * set up the hive function
-             */
-            Object hiveFunction = genericUdf;
-            if (udf != null)
-                hiveFunction = udf;
+			/**
+			 * set up the hive function
+			 */
+			Object hiveFunction = genericUdf;
+			if (udf != null)
+				hiveFunction = udf;
 
-            FunctionIdentifier funcId = HiveAlgebricksBuiltInFunctionMap.INSTANCE.getAlgebricksFunctionId(hiveFunction
-                    .getClass());
-            if (funcId == null) {
-                funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, hiveFunction.getClass().getName());
-            }
+			FunctionIdentifier funcId = HiveAlgebricksBuiltInFunctionMap.INSTANCE
+					.getAlgebricksFunctionId(hiveFunction.getClass());
+			if (funcId == null) {
+				funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,
+						hiveFunction.getClass().getName());
+			}
 
-            Object functionInfo = null;
-            if (genericUdf instanceof GenericUDFBridge) {
-                functionInfo = funcExpr;
-            }
+			Object functionInfo = null;
+			if (genericUdf instanceof GenericUDFBridge) {
+				functionInfo = funcExpr;
+			}
 
-            /**
-             * generate the function call expression
-             */
-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
-                    funcId, functionInfo), arguments);
-            AlgebricksExpr = AlgebricksFuncExpr;
+			/**
+			 * generate the function call expression
+			 */
+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(
+					new HiveFunctionInfo(funcId, functionInfo), arguments);
+			AlgebricksExpr = AlgebricksFuncExpr;
 
-        } else if (hiveExpr instanceof ExprNodeColumnDesc) {
-            ExprNodeColumnDesc column = (ExprNodeColumnDesc) hiveExpr;
-            LogicalVariable var = this.getVariable(column.getColumn());
-            AlgebricksExpr = new VariableReferenceExpression(var);
+		} else if (hiveExpr instanceof ExprNodeColumnDesc) {
+			ExprNodeColumnDesc column = (ExprNodeColumnDesc) hiveExpr;
+			LogicalVariable var = this.getVariable(column.getColumn());
+			AlgebricksExpr = new VariableReferenceExpression(var);
 
-        } else if (hiveExpr instanceof ExprNodeFieldDesc) {
-            FunctionIdentifier funcId;
-            funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, ExpressionConstant.FIELDACCESS);
+		} else if (hiveExpr instanceof ExprNodeFieldDesc) {
+			FunctionIdentifier funcId;
+			funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,
+					ExpressionConstant.FIELDACCESS);
 
-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
-                    funcId, hiveExpr));
-            AlgebricksExpr = AlgebricksFuncExpr;
-        } else if (hiveExpr instanceof ExprNodeConstantDesc) {
-            ExprNodeConstantDesc hiveConst = (ExprNodeConstantDesc) hiveExpr;
-            Object value = hiveConst.getValue();
-            AlgebricksExpr = new ConstantExpression(new HivesterixConstantValue(value));
-        } else if (hiveExpr instanceof ExprNodeNullDesc) {
-            FunctionIdentifier funcId;
-            funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, ExpressionConstant.NULL);
+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(
+					new HiveFunctionInfo(funcId, hiveExpr));
+			AlgebricksExpr = AlgebricksFuncExpr;
+		} else if (hiveExpr instanceof ExprNodeConstantDesc) {
+			ExprNodeConstantDesc hiveConst = (ExprNodeConstantDesc) hiveExpr;
+			Object value = hiveConst.getValue();
+			AlgebricksExpr = new ConstantExpression(
+					new HivesterixConstantValue(value));
+		} else if (hiveExpr instanceof ExprNodeNullDesc) {
+			FunctionIdentifier funcId;
+			funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,
+					ExpressionConstant.NULL);
 
-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
-                    funcId, hiveExpr));
+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(
+					new HiveFunctionInfo(funcId, hiveExpr));
 
-            AlgebricksExpr = AlgebricksFuncExpr;
-        } else {
-            throw new IllegalStateException("unknown hive expression");
-        }
-        return new MutableObject<ILogicalExpression>(AlgebricksExpr);
-    }
+			AlgebricksExpr = AlgebricksFuncExpr;
+		} else {
+			throw new IllegalStateException("unknown hive expression");
+		}
+		return new MutableObject<ILogicalExpression>(AlgebricksExpr);
+	}
 
-    /**
-     * translate aggregation function expression
-     * 
-     * @param aggregateDesc
-     * @return
-     */
-    public Mutable<ILogicalExpression> translateAggregation(AggregationDesc aggregateDesc) {
+	/**
+	 * translate aggregation function expression
+	 * 
+	 * @param aggregateDesc
+	 * @return
+	 */
+	public Mutable<ILogicalExpression> translateAggregation(
+			AggregationDesc aggregateDesc) {
 
-        String UDAFName = aggregateDesc.getGenericUDAFName();
+		String UDAFName = aggregateDesc.getGenericUDAFName();
 
-        List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
-        List<ExprNodeDesc> children = aggregateDesc.getParameters();
+		List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
+		List<ExprNodeDesc> children = aggregateDesc.getParameters();
 
-        for (ExprNodeDesc child : children)
-            arguments.add(translateScalarFucntion(child));
+		for (ExprNodeDesc child : children)
+			arguments.add(translateScalarFucntion(child));
 
-        FunctionIdentifier funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, UDAFName + "("
-                + aggregateDesc.getMode() + ")");
-        HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, aggregateDesc);
-        AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(funcInfo, false,
-                arguments);
-        return new MutableObject<ILogicalExpression>(aggregationExpression);
-    }
+		FunctionIdentifier funcId = new FunctionIdentifier(
+				ExpressionConstant.NAMESPACE, UDAFName + "("
+						+ aggregateDesc.getMode() + ")");
+		HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, aggregateDesc);
+		AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(
+				funcInfo, false, arguments);
+		return new MutableObject<ILogicalExpression>(aggregationExpression);
+	}
 
-    /**
-     * translate aggregation function expression
-     * 
-     * @param aggregator
-     * @return
-     */
-    public Mutable<ILogicalExpression> translateUnnestFunction(UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument) {
+	/**
+	 * translate aggregation function expression
+	 * 
+	 * @param aggregator
+	 * @return
+	 */
+	public Mutable<ILogicalExpression> translateUnnestFunction(
+			UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument) {
 
-        String UDTFName = udtfDesc.getUDTFName();
+		String UDTFName = udtfDesc.getUDTFName();
 
-        FunctionIdentifier funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, UDTFName);
-        UnnestingFunctionCallExpression unnestingExpression = new UnnestingFunctionCallExpression(new HiveFunctionInfo(
-                funcId, udtfDesc));
-        unnestingExpression.getArguments().add(argument);
-        return new MutableObject<ILogicalExpression>(unnestingExpression);
-    }
+		FunctionIdentifier funcId = new FunctionIdentifier(
+				ExpressionConstant.NAMESPACE, UDTFName);
+		UnnestingFunctionCallExpression unnestingExpression = new UnnestingFunctionCallExpression(
+				new HiveFunctionInfo(funcId, udtfDesc));
+		unnestingExpression.getArguments().add(argument);
+		return new MutableObject<ILogicalExpression>(unnestingExpression);
+	}
 
-    /**
-     * get typeinfo
-     */
-    @Override
-    public TypeInfo getType(LogicalVariable var) {
-        return variableToType.get(var);
-    }
+	/**
+	 * get typeinfo
+	 */
+	@Override
+	public TypeInfo getType(LogicalVariable var) {
+		return variableToType.get(var);
+	}
 
-    /**
-     * get variable from variable name
-     */
-    @Override
-    public LogicalVariable getVariable(String name) {
-        return nameToLogicalVariableMap.get(name);
-    }
+	/**
+	 * get variable from variable name
+	 */
+	@Override
+	public LogicalVariable getVariable(String name) {
+		return nameToLogicalVariableMap.get(name);
+	}
 
-    @Override
-    public LogicalVariable getVariableFromFieldName(String fieldName) {
-        return this.getVariableOnly(fieldName);
-    }
+	@Override
+	public LogicalVariable getVariableFromFieldName(String fieldName) {
+		return this.getVariableOnly(fieldName);
+	}
 
-    /**
-     * set the metadata provider
-     */
-    @Override
-    public void setMetadataProvider(IMetadataProvider<PartitionDesc, Object> metadata) {
-        this.metaData = metadata;
-    }
+	/**
+	 * set the metadata provider
+	 */
+	@Override
+	public void setMetadataProvider(
+			IMetadataProvider<PartitionDesc, Object> metadata) {
+		this.metaData = metadata;
+	}
 
-    /**
-     * insert ReplicateOperator when necessary
-     */
-    private void insertReplicateOperator(List<Mutable<ILogicalOperator>> roots) {
-        Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childToParentsMap = new HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>>();
-        buildChildToParentsMapping(roots, childToParentsMap);
-        for (Entry<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> entry : childToParentsMap.entrySet()) {
-            List<Mutable<ILogicalOperator>> pList = entry.getValue();
-            if (pList.size() > 1) {
-                ILogicalOperator rop = new ReplicateOperator(pList.size());
-                Mutable<ILogicalOperator> ropRef = new MutableObject<ILogicalOperator>(rop);
-                Mutable<ILogicalOperator> childRef = entry.getKey();
-                rop.getInputs().add(childRef);
-                for (Mutable<ILogicalOperator> parentRef : pList) {
-                    ILogicalOperator parentOp = parentRef.getValue();
-                    int index = parentOp.getInputs().indexOf(childRef);
-                    parentOp.getInputs().set(index, ropRef);
-                }
-            }
-        }
-    }
+	/**
+	 * insert ReplicateOperator when necessary
+	 */
+	private void insertReplicateOperator(List<Mutable<ILogicalOperator>> roots) {
+		Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childToParentsMap = new HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>>();
+		buildChildToParentsMapping(roots, childToParentsMap);
+		for (Entry<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> entry : childToParentsMap
+				.entrySet()) {
+			List<Mutable<ILogicalOperator>> pList = entry.getValue();
+			if (pList.size() > 1) {
+				ILogicalOperator rop = new ReplicateOperator(pList.size());
+				Mutable<ILogicalOperator> ropRef = new MutableObject<ILogicalOperator>(
+						rop);
+				Mutable<ILogicalOperator> childRef = entry.getKey();
+				rop.getInputs().add(childRef);
+				for (Mutable<ILogicalOperator> parentRef : pList) {
+					ILogicalOperator parentOp = parentRef.getValue();
+					int index = parentOp.getInputs().indexOf(childRef);
+					parentOp.getInputs().set(index, ropRef);
+				}
+			}
+		}
+	}
 
-    /**
-     * build the mapping from child to Parents
-     * 
-     * @param roots
-     * @param childToParentsMap
-     */
-    private void buildChildToParentsMapping(List<Mutable<ILogicalOperator>> roots,
-            Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> map) {
-        for (Mutable<ILogicalOperator> opRef : roots) {
-            List<Mutable<ILogicalOperator>> childRefs = opRef.getValue().getInputs();
-            for (Mutable<ILogicalOperator> childRef : childRefs) {
-                List<Mutable<ILogicalOperator>> parentList = map.get(childRef);
-                if (parentList == null) {
-                    parentList = new ArrayList<Mutable<ILogicalOperator>>();
-                    map.put(childRef, parentList);
-                }
-                if (!parentList.contains(opRef))
-                    parentList.add(opRef);
-            }
-            buildChildToParentsMapping(childRefs, map);
-        }
-    }
+	/**
+	 * build the mapping from child to Parents
+	 * 
+	 * @param roots
+	 * @param childToParentsMap
+	 */
+	private void buildChildToParentsMapping(
+			List<Mutable<ILogicalOperator>> roots,
+			Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> map) {
+		for (Mutable<ILogicalOperator> opRef : roots) {
+			List<Mutable<ILogicalOperator>> childRefs = opRef.getValue()
+					.getInputs();
+			for (Mutable<ILogicalOperator> childRef : childRefs) {
+				List<Mutable<ILogicalOperator>> parentList = map.get(childRef);
+				if (parentList == null) {
+					parentList = new ArrayList<Mutable<ILogicalOperator>>();
+					map.put(childRef, parentList);
+				}
+				if (!parentList.contains(opRef))
+					parentList.add(opRef);
+			}
+			buildChildToParentsMapping(childRefs, map);
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
index 6c1ac72..ed5ab70 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
@@ -74,8 +74,6 @@
 
     private static final Log LOG = LogFactory.getLog(HyracksExecutionEngine.class.getName());
 
-    // private static final String[] locConstraints = {}
-
     private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_LOGICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();
     private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_PHYSICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();
     static {
@@ -273,7 +271,6 @@
              * list of map-reduce tasks
              */
             Task<? extends Serializable> task = rootTasks.get(i);
-            // System.out.println("!" + task.getName());
 
             if (task instanceof MapRedTask) {
                 List<Operator> mapRootOps = articulateMapReduceOperators(task, rootOps, aliasToPath, rootTasks);
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
index d248486..9e62c73 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
@@ -110,7 +110,7 @@
 			if (returnedSplits[i] != null)
 				splits[i] = returnedSplits[i];
 
-		System.out.println("!!! number of splits: " + splits.length);
+		System.out.println("number of splits: " + splits.length);
 		constraintsByHostNames = new String[splits.length];
 		for (int i = 0; i < splits.length; i++) {
 			try {
