You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by gu...@apache.org on 2014/09/23 21:03:13 UTC

svn commit: r1627116 - in /hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql: optimizer/optiq/ optimizer/optiq/cost/ optimizer/optiq/reloperators/ optimizer/optiq/rules/ optimizer/optiq/stats/ optimizer/optiq/translator/ parse/

Author: gunther
Date: Tue Sep 23 19:03:12 2014
New Revision: 1627116

URL: http://svn.apache.org/r1627116
Log:
HIVE-8232: CBO Trunk Merge: Address Review Comments (Laljo John Pullokkaran via Gunther Hagleitner)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/HiveOptiqUtil.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCost.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCostUtil.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveJoinRel.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveSortRel.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HiveMergeProjectRule.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HivePartitionPrunerRule.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/DerivedTableInjector.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/HiveOptiqUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/HiveOptiqUtil.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/HiveOptiqUtil.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/HiveOptiqUtil.java Tue Sep 23 19:03:12 2014
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
 
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveJoinRel;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
-import org.apache.hadoop.hive.ql.parse.HiveParser;
 import org.eigenbase.rel.RelFactories.ProjectFactory;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.relopt.RelOptUtil;
@@ -74,12 +73,12 @@ public class HiveOptiqUtil {
     return vCols;
   }
 
-  public static boolean validateASTForCBO (ASTNode ast) {
+  public static boolean validateASTForCBO(ASTNode ast) {
     String astTree = ast.toStringTree();
-    String [] tokens = {"TOK_CHARSETLITERAL"};
+    String[] tokens = { "TOK_CHARSETLITERAL" };
     for (String token : tokens) {
       if (astTree.contains(token)) {
-         return false;
+        return false;
       }
     }
     return true;
@@ -459,9 +458,8 @@ public class HiveOptiqUtil {
       int rightOffSet = j.getLeft().getRowType().getFieldCount();
 
       // 1. Split leaf join predicate to expressions from left, right
-      @SuppressWarnings("unused")
-      RexNode nonEquiPredicate = RelOptUtil.splitJoinCondition(j.getSystemFieldList(), j.getLeft(),
-          j.getRight(), pe, joinKeyExprsFromLeft, joinKeyExprsFromRight, filterNulls, null);
+      RelOptUtil.splitJoinCondition(j.getSystemFieldList(), j.getLeft(), j.getRight(), pe,
+          joinKeyExprsFromLeft, joinKeyExprsFromRight, filterNulls, null);
 
       // 2. For left expressions, collect child projection indexes used
       InputReferencedVisitor irvLeft = new InputReferencedVisitor();

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCost.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCost.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCost.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCost.java Tue Sep 23 19:03:12 2014
@@ -123,6 +123,7 @@ public class HiveCost implements RelOptC
 
   public boolean isEqWithEpsilon(RelOptCost other) {
     return (this == other) || (Math.abs((this.rowCount) - (other.getRows())) < RelOptUtil.EPSILON);
+    // Turn this one once we do the Algorithm selection in CBO
     /*
      * return (this == other) || (Math.abs((this.dCpu + this.dIo) -
      * (other.getCpu() + other.getIo())) < RelOptUtil.EPSILON);

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCostUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCostUtil.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCostUtil.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/cost/HiveCostUtil.java Tue Sep 23 19:03:12 2014
@@ -21,6 +21,7 @@ import org.apache.hadoop.hive.ql.optimiz
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveTableScanRel;
 import org.eigenbase.relopt.RelOptCost;
 
+// Use this once we have Join Algorithm selection
 public class HiveCostUtil {
   private static final double cpuCostInNanoSec          = 1.0;
   private static final double netCostInNanoSec          = 150 * cpuCostInNanoSec;
@@ -28,6 +29,7 @@ public class HiveCostUtil {
   private static final double localFSReadCostInNanoSec  = 4 * netCostInNanoSec;
   private static final double hDFSWriteCostInNanoSec    = 10 * localFSWriteCostInNanoSec;
   @SuppressWarnings("unused")
+//Use this once we have Join Algorithm selection
   private static final double hDFSReadCostInNanoSec     = 1.5 * localFSReadCostInNanoSec;
 
   public static RelOptCost computCardinalityBasedCost(HiveRel hr) {

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveJoinRel.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveJoinRel.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveJoinRel.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveJoinRel.java Tue Sep 23 19:03:12 2014
@@ -55,6 +55,7 @@ public class HiveJoinRel extends JoinRel
 
   private final boolean leftSemiJoin;
   private final JoinAlgorithm      joinAlgorithm;
+  //This will be used once we do Join Algorithm selection
   @SuppressWarnings("unused")
   private final MapJoinStreamingRelation mapJoinStreamingSide = MapJoinStreamingRelation.NONE;
 

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveSortRel.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveSortRel.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveSortRel.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveSortRel.java Tue Sep 23 19:03:12 2014
@@ -34,8 +34,6 @@ public class HiveSortRel extends SortRel
       RelCollation collation, RexNode offset, RexNode fetch) {
     super(cluster, TraitsUtil.getSortTraitSet(cluster, traitSet, collation), child, collation,
         offset, fetch);
-
-    assert getConvention() == child.getConvention();
   }
 
   @Override

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HiveMergeProjectRule.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HiveMergeProjectRule.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HiveMergeProjectRule.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HiveMergeProjectRule.java Tue Sep 23 19:03:12 2014
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.ql.optimi
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveProjectRel;
 import org.eigenbase.rel.rules.MergeProjectRule;
 
+//Currently not used, turn this on later
 public class HiveMergeProjectRule extends MergeProjectRule {
   public static final HiveMergeProjectRule INSTANCE = new HiveMergeProjectRule();
 

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HivePartitionPrunerRule.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HivePartitionPrunerRule.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HivePartitionPrunerRule.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/rules/HivePartitionPrunerRule.java Tue Sep 23 19:03:12 2014
@@ -52,9 +52,6 @@ public class HivePartitionPrunerRule ext
     Pair<RexNode, RexNode> predicates = PartitionPruner
         .extractPartitionPredicates(filter.getCluster(), hiveTable, predicate);
     RexNode partColExpr = predicates.left;
-    RexNode remainingExpr = predicates.right;
-    remainingExpr = remainingExpr == null ? filter.getCluster().getRexBuilder()
-        .makeLiteral(true) : remainingExpr;
     hiveTable.computePartitionList(conf, partColExpr);
   }
 }

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java Tue Sep 23 19:03:12 2014
@@ -217,7 +217,7 @@ public class FilterSelectivityEstimator 
       expr = RelOptUtil.pushFilterPastProject(expr, (ProjectRelBase) r);
       return isPartitionPredicate(expr, ((ProjectRelBase) r).getChild());
     } else if ( r instanceof FilterRelBase ) {
-      isPartitionPredicate(expr, ((ProjectRelBase) r).getChild());
+      return isPartitionPredicate(expr, ((FilterRelBase) r).getChild());
     } else if ( r instanceof HiveTableScanRel ) {
       RelOptHiveTable table = (RelOptHiveTable)
           ((HiveTableScanRel)r).getTable();

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/DerivedTableInjector.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/DerivedTableInjector.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/DerivedTableInjector.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/DerivedTableInjector.java Tue Sep 23 19:03:12 2014
@@ -103,12 +103,6 @@ public class DerivedTableInjector {
           introduceDerivedTable(rel, parent);
         }
       }
-    } else if (rel instanceof TableAccessRelBase) {
-
-    } else if (rel instanceof TableFunctionRelBase) {
-
-    } else if (rel instanceof ValuesRelBase) {
-
     }
 
     List<RelNode> childNodes = rel.getInputs();

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java Tue Sep 23 19:03:12 2014
@@ -134,13 +134,12 @@ public class RexNodeConverter {
     RexNode rexNode = convert(fieldDesc.getDesc());
     if (rexNode instanceof RexCall) {
       // regular case of accessing nested field in a column
-      return m_cluster.getRexBuilder().makeFieldAccess(rexNode,
-          fieldDesc.getFieldName(), true);
+      return m_cluster.getRexBuilder().makeFieldAccess(rexNode, fieldDesc.getFieldName(), true);
     } else {
       // This may happen for schema-less tables, where columns are dynamically
       // supplied by serdes.
-      throw new OptiqSemanticException("Unexpected rexnode : " +
-        rexNode.getClass().getCanonicalName());
+      throw new OptiqSemanticException("Unexpected rexnode : "
+          + rexNode.getClass().getCanonicalName());
     }
   }
 
@@ -152,7 +151,8 @@ public class RexNodeConverter {
     List<RexNode> childRexNodeLst = new LinkedList<RexNode>();
     Builder<RelDataType> argTypeBldr = ImmutableList.<RelDataType> builder();
 
-    // TODO: 1) Expand to other functions as needed 2) What about types other than primitive.
+    // TODO: 1) Expand to other functions as needed 2) What about types other
+    // than primitive.
     if (func.getGenericUDF() instanceof GenericUDFBaseNumeric) {
       tgtDT = func.getTypeInfo();
     } else if (func.getGenericUDF() instanceof GenericUDFBaseCompare) {
@@ -179,10 +179,9 @@ public class RexNodeConverter {
     expr = handleExplicitCast(func, childRexNodeLst);
 
     if (expr == null) {
-      retType = (expr != null) ? expr.getType() : TypeConverter.convert(func.getTypeInfo(),
-          m_cluster.getTypeFactory());
-      SqlOperator optiqOp = SqlFunctionConverter.getOptiqOperator(
-          func.getFuncText(), func.getGenericUDF(), argTypeBldr.build(), retType);
+      retType = TypeConverter.convert(func.getTypeInfo(), m_cluster.getTypeFactory());
+      SqlOperator optiqOp = SqlFunctionConverter.getOptiqOperator(func.getFuncText(),
+          func.getGenericUDF(), argTypeBldr.build(), retType);
       expr = m_cluster.getRexBuilder().makeCall(optiqOp, childRexNodeLst);
     } else {
       retType = expr.getType();
@@ -221,8 +220,8 @@ public class RexNodeConverter {
     return castExpr;
   }
 
-  private RexNode handleExplicitCast(ExprNodeGenericFuncDesc func,
-    List<RexNode> childRexNodeLst) throws OptiqSemanticException {
+  private RexNode handleExplicitCast(ExprNodeGenericFuncDesc func, List<RexNode> childRexNodeLst)
+      throws OptiqSemanticException {
     RexNode castExpr = null;
 
     if (childRexNodeLst != null && childRexNodeLst.size() == 1) {
@@ -230,8 +229,6 @@ public class RexNodeConverter {
       if ((udf instanceof GenericUDFToChar) || (udf instanceof GenericUDFToVarchar)
           || (udf instanceof GenericUDFToDecimal) || (udf instanceof GenericUDFToDate)
           || (udf instanceof GenericUDFToBinary) || castExprUsingUDFBridge(udf)) {
-        // || (udf instanceof GenericUDFToUnixTimeStamp) || (udf instanceof
-        // GenericUDFTimestamp) || castExprUsingUDFBridge(udf)) {
         castExpr = m_cluster.getRexBuilder().makeAbstractCast(
             TypeConverter.convert(func.getTypeInfo(), m_cluster.getTypeFactory()),
             childRexNodeLst.get(0));
@@ -285,8 +282,8 @@ public class RexNodeConverter {
     PrimitiveCategory hiveTypeCategory = hiveType.getPrimitiveCategory();
 
     ConstantObjectInspector coi = literal.getWritableObjectInspector();
-    Object value = ObjectInspectorUtils.copyToStandardJavaObject(
-        coi.getWritableConstantValue(), coi);
+    Object value = ObjectInspectorUtils.copyToStandardJavaObject(coi.getWritableConstantValue(),
+        coi);
 
     RexNode optiqLiteral = null;
     // TODO: Verify if we need to use ConstantObjectInspector to unwrap data
@@ -295,7 +292,7 @@ public class RexNodeConverter {
       optiqLiteral = rexBuilder.makeLiteral(((Boolean) value).booleanValue());
       break;
     case BYTE:
-      byte[] byteArray = new byte[] { (Byte) value};
+      byte[] byteArray = new byte[] { (Byte) value };
       ByteString bs = new ByteString(byteArray);
       optiqLiteral = rexBuilder.makeBinaryLiteral(bs);
       break;
@@ -316,24 +313,31 @@ public class RexNodeConverter {
         value = ((Decimal128) value).toBigDecimal();
       }
       if (value == null) {
-        // We have found an invalid decimal value while enforcing precision and scale. Ideally,
-        // we would replace it with null here, which is what Hive does. However, we need to plumb
-        // this thru up somehow, because otherwise having different expression type in AST causes
-        // the plan generation to fail after CBO, probably due to some residual state in SA/QB.
-        // For now, we will not run CBO in the presence of invalid decimal literals.
-        throw new OptiqSemanticException("Expression "
-          + literal.getExprString() + " is not a valid decimal");
+        // We have found an invalid decimal value while enforcing precision and
+        // scale. Ideally,
+        // we would replace it with null here, which is what Hive does. However,
+        // we need to plumb
+        // this thru up somehow, because otherwise having different expression
+        // type in AST causes
+        // the plan generation to fail after CBO, probably due to some residual
+        // state in SA/QB.
+        // For now, we will not run CBO in the presence of invalid decimal
+        // literals.
+        throw new OptiqSemanticException("Expression " + literal.getExprString()
+            + " is not a valid decimal");
         // TODO: return createNullLiteral(literal);
       }
-      BigDecimal bd = (BigDecimal)value;
+      BigDecimal bd = (BigDecimal) value;
       BigInteger unscaled = bd.unscaledValue();
       if (unscaled.compareTo(MIN_LONG_BI) >= 0 && unscaled.compareTo(MAX_LONG_BI) <= 0) {
         optiqLiteral = rexBuilder.makeExactLiteral(bd);
       } else {
-        // CBO doesn't support unlimited precision decimals. In practice, this will work...
-        // An alternative would be to throw CboSemanticException and fall back to no CBO.
-        RelDataType relType = m_cluster.getTypeFactory().createSqlType(
-                SqlTypeName.DECIMAL, bd.scale(), unscaled.toString().length());
+        // CBO doesn't support unlimited precision decimals. In practice, this
+        // will work...
+        // An alternative would be to throw CboSemanticException and fall back
+        // to no CBO.
+        RelDataType relType = m_cluster.getTypeFactory().createSqlType(SqlTypeName.DECIMAL,
+            bd.scale(), unscaled.toString().length());
         optiqLiteral = rexBuilder.makeExactLiteral(bd, relType);
       }
       break;
@@ -376,8 +380,8 @@ public class RexNodeConverter {
   }
 
   private RexNode createNullLiteral(ExprNodeDesc expr) throws OptiqSemanticException {
-    return m_cluster.getRexBuilder().makeNullLiteral(TypeConverter.convert(
-        expr.getTypeInfo(), m_cluster.getTypeFactory()).getSqlTypeName());
+    return m_cluster.getRexBuilder().makeNullLiteral(
+        TypeConverter.convert(expr.getTypeInfo(), m_cluster.getTypeFactory()).getSqlTypeName());
   }
 
   public static RexNode convert(RelOptCluster cluster, ExprNodeDesc joinCondnExprNode,

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1627116&r1=1627115&r2=1627116&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Tue Sep 23 19:03:12 2014
@@ -249,7 +249,6 @@ import org.eigenbase.rel.rules.LoptOptim
 import org.eigenbase.rel.rules.MergeFilterRule;
 import org.eigenbase.rel.rules.PushFilterPastProjectRule;
 import org.eigenbase.rel.rules.PushFilterPastSetOpRule;
-import org.eigenbase.rel.rules.RemoveTrivialProjectRule;
 import org.eigenbase.rel.rules.SemiJoinRel;
 import org.eigenbase.rel.rules.TransitivePredicatesOnJoinRule;
 import org.eigenbase.relopt.RelOptCluster;
@@ -284,7 +283,6 @@ import org.eigenbase.sql.SqlLiteral;
 import org.eigenbase.util.CompositeList;
 import org.eigenbase.util.ImmutableIntList;
 import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
@@ -12642,7 +12640,7 @@ public class SemanticAnalyzer extends Ba
 
       try {
 
-        // 0. If the table has a Sample specified, bail from Optiq path.
+        // 1. If the table has a Sample specified, bail from Optiq path.
         if ( qb.getParseInfo().getTabSample(tableAlias) != null ||
             SemanticAnalyzer.this.nameToSplitSample.containsKey(tableAlias)) {
           String msg = String.format("Table Sample specified for %s." +
@@ -12652,9 +12650,6 @@ public class SemanticAnalyzer extends Ba
           throw new OptiqSemanticException(msg);
         }
 
-        // 1. Get Table Alias
-        String alias_id = getAliasId(tableAlias, qb);
-
         // 2. Get Table Metadata
         Table tab = qb.getMetaData().getSrcForAlias(tableAlias);
 
@@ -12984,7 +12979,6 @@ public class SemanticAnalyzer extends Ba
     private RelNode genGBRelNode(List<ExprNodeDesc> gbExprs, List<AggInfo> aggInfoLst,
         RelNode srcRel) throws SemanticException {
       RowResolver gbInputRR = this.relToHiveRR.get(srcRel);
-      ArrayList<ColumnInfo> signature = gbInputRR.getRowSchema().getSignature();
       ImmutableMap<String, Integer> posMap = this.relToHiveColNameOptiqPosMap.get(srcRel);
       RexNodeConverter converter = new RexNodeConverter(this.cluster, srcRel.getRowType(),
           posMap, 0, false);
@@ -13194,7 +13188,6 @@ public class SemanticAnalyzer extends Ba
       if (hasGrpByAstExprs || hasAggregationTrees) {
         ArrayList<ExprNodeDesc> gbExprNDescLst = new ArrayList<ExprNodeDesc>();
         ArrayList<String> outputColumnNames = new ArrayList<String>();
-        int numDistinctUDFs = 0;
 
         // 2. Input, Output Row Resolvers
         RowResolver groupByInputRowResolver = this.relToHiveRR.get(srcRel);
@@ -13226,9 +13219,6 @@ public class SemanticAnalyzer extends Ba
             String aggName = unescapeIdentifier(value.getChild(0).getText());
             boolean isDistinct = value.getType() == HiveParser.TOK_FUNCTIONDI;
             boolean isAllColumns = value.getType() == HiveParser.TOK_FUNCTIONSTAR;
-            if (isDistinct) {
-              numDistinctUDFs++;
-            }
 
             // 4.2 Convert UDAF Params to ExprNodeDesc
             ArrayList<ExprNodeDesc> aggParameters = new ArrayList<ExprNodeDesc>();
@@ -13593,7 +13583,6 @@ public class SemanticAnalyzer extends Ba
               // 6.2.2 Update Output Row Schema
               ColumnInfo oColInfo = new ColumnInfo(
                   getColumnInternalName(projsForWindowSelOp.size()), wtp.getValue(), null, false);
-              String colAlias = wExprSpec.getAlias();
               if (false) {
                 out_rwsch.checkColumn(null, wExprSpec.getAlias());
                 out_rwsch.put(null, wExprSpec.getAlias(), oColInfo);