You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2015/02/05 06:58:10 UTC

[6/9] incubator-lens git commit: LENS-50 : Fix checkstyle issues in lens-cube module (Rajat Khandelwal via amareshwari)

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/JoinResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/JoinResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/JoinResolver.java
index d864d8f..b2c2572 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/JoinResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/JoinResolver.java
@@ -18,20 +18,14 @@
  */
 package org.apache.lens.cube.parse;
 
-import static org.apache.hadoop.hive.ql.parse.HiveParser.Identifier;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_FULLOUTERJOIN;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_JOIN;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_LEFTOUTERJOIN;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_LEFTSEMIJOIN;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_RIGHTOUTERJOIN;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_SUBQUERY;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_TABNAME;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_TABREF;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_UNIQUEJOIN;
+import static org.apache.hadoop.hive.ql.parse.HiveParser.*;
 
 import java.util.*;
 
-import lombok.*;
+import org.apache.lens.cube.metadata.*;
+import org.apache.lens.cube.metadata.SchemaGraph.TableRelationship;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
+import org.apache.lens.cube.parse.CubeQueryContext.OptionalDimCtx;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -40,22 +34,12 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.parse.ASTNode;
-import org.apache.hadoop.hive.ql.parse.JoinCond;
-import org.apache.hadoop.hive.ql.parse.JoinType;
-import org.apache.hadoop.hive.ql.parse.QB;
-import org.apache.hadoop.hive.ql.parse.QBJoinTree;
-import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer;
-import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.metadata.*;
-import org.apache.lens.cube.metadata.SchemaGraph.TableRelationship;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
-import org.apache.lens.cube.parse.CubeQueryContext.OptionalDimCtx;
+import org.apache.hadoop.hive.ql.parse.*;
+
+import lombok.*;
 
 /**
- *
  * JoinResolver.
- *
  */
 class JoinResolver implements ContextRewriter {
 
@@ -71,7 +55,8 @@ class JoinResolver implements ContextRewriter {
     private final JoinTree joinTree;
     transient Map<AbstractCubeTable, Set<String>> chainColumns = new HashMap<AbstractCubeTable, Set<String>>();
 
-    public JoinClause(CubeQueryContext cubeql, Map<Aliased<Dimension>, List<TableRelationship>> chain, Set<Dimension> dimsInPath) {
+    public JoinClause(CubeQueryContext cubeql, Map<Aliased<Dimension>,
+      List<TableRelationship>> chain, Set<Dimension> dimsInPath) {
       this.cubeql = cubeql;
       this.chain = chain;
       this.joinTree = mergeJoinChains(chain);
@@ -109,48 +94,47 @@ class JoinResolver implements ContextRewriter {
     }
 
     /**
-     * Takes chains and merges them in the form of a tree. If two chains have some common path
-     * till some table and bifurcate from there, then in the chain, both paths will have the common
-     * path but the resultant tree will have single path from root(cube) to that table and paths
-     * will bifurcate from there.
-     *
-     * For example, citystate = [basecube.cityid=citydim.id], [citydim.stateid=statedim.id]
-     *              cityzip   = [basecube.cityid=citydim.id], [citydim.zipcode=zipdim.code]
-     *
+     * Takes chains and merges them in the form of a tree. If two chains have some common path till some table and
+     * bifurcate from there, then in the chain, both paths will have the common path but the resultant tree will have
+     * single path from root(cube) to that table and paths will bifurcate from there.
+     * <p/>
+     * For example, citystate   =   [basecube.cityid=citydim.id], [citydim.stateid=statedim.id]
+     *              cityzip     =   [basecube.cityid=citydim.id], [citydim.zipcode=zipdim.code]
+     * <p/>
      * Without merging, the behaviour is like this:
+     * <p/>
+     * <p/>
+     *                  (basecube.cityid=citydim.id)          (citydim.stateid=statedim.id)
+     *                  _____________________________citydim____________________________________statedim
+     *                 |
+     *   basecube------|
+     *                 |_____________________________citydim____________________________________zipdim
      *
+     *                  (basecube.cityid=citydim.id)          (citydim.zipcode=zipdim.code)
      *
-     *                              (basecube.cityid=citydim.id)          (citydim.stateid=statedim.id)
-     *                              ____________________________citydim-------------------------------------statedim
-     *                             |
-     *                basecube-----
-     *                             |____________________________citydim-------------------------------------zipdim
-     *                              (basecube.cityid=citydim.id)         (citydim.zipcode=zipdim.code)
-     *
-     *
-     *
+     * <p/>
      * Merging will result in a tree like following
+     * <p/>                                                  (citydim.stateid=statedim.id)
+     * <p/>                                                ________________________________ statedim
+     *             (basecube.cityid=citydim.id)           |
+     * basecube-------------------------------citydim---- |
+     *                                                    |________________________________  zipdim
      *
+     *                                                       (citydim.zipcode=zipdim.code)
      *
-     *                                                                   (citydim.stateid=statedim.id)
-     *                                                                   ________________________________ statedim
-     *                          (basecube.cityid=citydim.id)            |
-     *                basecube-------------------------------citydim----
-     *                                                                  |________________________________  zipdim
-     *                                                                   (citydim.zipcode=zipdim.code)
-     *
-     * Doing this will reduce the number of joins whereever possible.
+     * <p/>
+     * Doing this will reduce the number of joins wherever possible.
      *
      * @param chain Joins in Linear format.
-     * @return      Joins in Tree format
+     * @return Joins in Tree format
      */
     public JoinTree mergeJoinChains(Map<Aliased<Dimension>, List<TableRelationship>> chain) {
       Map<String, Integer> aliasUsage = new HashMap<String, Integer>();
       JoinTree root = JoinTree.createRoot();
-      for(Map.Entry<Aliased<Dimension>, List<TableRelationship>> entry: chain.entrySet()) {
+      for (Map.Entry<Aliased<Dimension>, List<TableRelationship>> entry : chain.entrySet()) {
         JoinTree current = root;
         // Last element in this list is link from cube to first dimension
-        for(int i = entry.getValue().size() - 1; i >= 0; i--) {
+        for (int i = entry.getValue().size() - 1; i >= 0; i--) {
           // Adds a child if needed, or returns a child already existing corresponding to the given link.
           current = current.addChild(entry.getValue().get(i), cubeql, aliasUsage);
           if (cubeql.getAutoJoinCtx().partialJoinChains) {
@@ -161,16 +145,18 @@ class JoinResolver implements ContextRewriter {
         }
         // This is a destination table. Decide alias separately. e.g. chainname
         // nullcheck is necessary because dimensions can be destinations too. In that case getAlias() == null
-        if(entry.getKey().getAlias() != null) {
+        if (entry.getKey().getAlias() != null) {
           current.setAlias(entry.getKey().getAlias());
         }
       }
-      if(root.subtrees.size() > 0) {
-        root.setAlias(cubeql.getAliasForTabName(root.subtrees.keySet().iterator().next().getFromTable().getName()));
+      if (root.getSubtrees().size() > 0) {
+        root.setAlias(cubeql.getAliasForTabName(
+          root.getSubtrees().keySet().iterator().next().getFromTable().getName()));
       }
       return root;
     }
   }
+
   @Data
   @ToString(exclude = "parent")
   @EqualsAndHashCode(exclude = "parent")
@@ -181,7 +167,7 @@ class JoinResolver implements ContextRewriter {
     TableRelationship parentRelationship;
     // Alias for the join clause
     String alias;
-    public Map<TableRelationship, JoinTree> subtrees = new LinkedHashMap<TableRelationship, JoinTree>();
+    private Map<TableRelationship, JoinTree> subtrees = new LinkedHashMap<TableRelationship, JoinTree>();
     // Number of nodes from root to this node. depth of root is 0. Unused for now.
     private int depthFromRoot;
     // join type of the current table.
@@ -190,6 +176,7 @@ class JoinResolver implements ContextRewriter {
     public static JoinTree createRoot() {
       return new JoinTree(null, null, 0);
     }
+
     public JoinTree(JoinTree parent, TableRelationship tableRelationship,
       int depthFromRoot) {
       this.parent = parent;
@@ -197,9 +184,9 @@ class JoinResolver implements ContextRewriter {
       this.depthFromRoot = depthFromRoot;
     }
 
-    public JoinTree addChild
-      (TableRelationship tableRelationship, CubeQueryContext cubeql, Map<String, Integer> aliasUsage) {
-      if(subtrees.get(tableRelationship) == null) {
+    public JoinTree addChild(TableRelationship tableRelationship,
+      CubeQueryContext cubeql, Map<String, Integer> aliasUsage) {
+      if (getSubtrees().get(tableRelationship) == null) {
         JoinTree current = new JoinTree(this, tableRelationship,
           this.depthFromRoot + 1);
         // Set alias. Need to compute only when new node is being created.
@@ -209,37 +196,40 @@ class JoinResolver implements ContextRewriter {
         // overridden outside this function.
         AbstractCubeTable destTable = tableRelationship.getToTable();
         current.setAlias(cubeql.getAliasForTabName(destTable.getName()));
-        if(aliasUsage.get(current.getAlias()) == null) {
+        if (aliasUsage.get(current.getAlias()) == null) {
           aliasUsage.put(current.getAlias(), 0);
         } else {
           aliasUsage.put(current.getAlias(), aliasUsage.get(current.getAlias()) + 1);
           current.setAlias(current.getAlias() + "_" + (aliasUsage.get(current.getAlias()) - 1));
         }
-        subtrees.put(tableRelationship, current);
+        getSubtrees().put(tableRelationship, current);
       }
-      return subtrees.get(tableRelationship);
+      return getSubtrees().get(tableRelationship);
     }
 
     // Recursive computation of number of edges.
     public int getNumEdges() {
       int ret = 0;
-      for(JoinTree tree: subtrees.values()) {
+      for (JoinTree tree : getSubtrees().values()) {
         ret += 1;
         ret += tree.getNumEdges();
       }
       return ret;
     }
+
     public boolean isLeaf() {
-      return this.subtrees.isEmpty();
+      return getSubtrees().isEmpty();
     }
+
     // Breadth First Traversal. Unused currently.
     public Iterator<JoinTree> bft() {
       return new Iterator<JoinTree>() {
-        List<JoinTree> remaining = new ArrayList<JoinTree>(){
+        List<JoinTree> remaining = new ArrayList<JoinTree>() {
           {
-            addAll(subtrees.values());
+            addAll(getSubtrees().values());
           }
         };
+
         @Override
         public boolean hasNext() {
           return remaining.isEmpty();
@@ -248,7 +238,7 @@ class JoinResolver implements ContextRewriter {
         @Override
         public JoinTree next() {
           JoinTree retval = remaining.remove(0);
-          remaining.addAll(retval.subtrees.values());
+          remaining.addAll(retval.getSubtrees().values());
           return retval;
         }
 
@@ -264,9 +254,10 @@ class JoinResolver implements ContextRewriter {
       return new Iterator<JoinTree>() {
         Stack<JoinTree> joinTreeStack = new Stack<JoinTree>() {
           {
-            addAll(subtrees.values());
+            addAll(getSubtrees().values());
           }
         };
+
         @Override
         public boolean hasNext() {
           return !joinTreeStack.isEmpty();
@@ -275,7 +266,7 @@ class JoinResolver implements ContextRewriter {
         @Override
         public JoinTree next() {
           JoinTree retval = joinTreeStack.pop();
-          joinTreeStack.addAll(retval.subtrees.values());
+          joinTreeStack.addAll(retval.getSubtrees().values());
           return retval;
         }
 
@@ -289,9 +280,9 @@ class JoinResolver implements ContextRewriter {
     public Set<JoinTree> leaves() {
       Set<JoinTree> leaves = new HashSet<JoinTree>();
       Iterator<JoinTree> dft = dft();
-      while(dft.hasNext()) {
+      while (dft.hasNext()) {
         JoinTree cur = dft.next();
-        if(cur.isLeaf()) {
+        if (cur.isLeaf()) {
           leaves.add(cur);
         }
       }
@@ -322,15 +313,21 @@ class JoinResolver implements ContextRewriter {
 
     // Map of a joined table to its columns which are part of any of the join
     // paths. This is used in candidate table resolver
-    @Getter private Map<Dimension, Map<AbstractCubeTable, List<String>>> joinPathFromColumns =
-        new HashMap<Dimension, Map<AbstractCubeTable, List<String>>>();
+    @Getter
+    private Map<Dimension, Map<AbstractCubeTable, List<String>>> joinPathFromColumns =
+      new HashMap<Dimension, Map<AbstractCubeTable, List<String>>>();
 
-    @Getter private Map<Dimension, Map<AbstractCubeTable, List<String>>> joinPathToColumns =
-        new HashMap<Dimension, Map<AbstractCubeTable, List<String>>>();
+    @Getter
+    private Map<Dimension, Map<AbstractCubeTable, List<String>>> joinPathToColumns =
+      new HashMap<Dimension, Map<AbstractCubeTable, List<String>>>();
 
     // there can be separate join clause for each fact incase of multi fact queries
-    @Getter Map<CandidateFact, JoinClause> factClauses = new HashMap<CandidateFact, JoinClause>();
-    @Getter @Setter JoinClause minCostClause;
+    @Getter
+    Map<CandidateFact, JoinClause> factClauses = new HashMap<CandidateFact, JoinClause>();
+    @Getter
+    @Setter
+    JoinClause minCostClause;
+
     public AutoJoinContext(Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> allPaths,
       Map<Dimension, OptionalDimCtx> optionalDimensions, Map<AbstractCubeTable, String> partialJoinConditions,
       boolean partialJoinChains, Map<AbstractCubeTable, JoinType> tableJoinTypeMap, AbstractCubeTable autoJoinTarget,
@@ -358,6 +355,7 @@ class JoinResolver implements ContextRewriter {
       }
       return factClauses.get(fact);
     }
+
     // Populate map of tables to their columns which are present in any of the
     // join paths
     private void initJoinPathColumns() {
@@ -391,7 +389,7 @@ class JoinResolver implements ContextRewriter {
     }
 
     private void populateJoinPathCols(List<SchemaGraph.JoinPath> joinPaths,
-        Map<AbstractCubeTable, List<String>> fromPathColumns, Map<AbstractCubeTable, List<String>> toPathColumns) {
+      Map<AbstractCubeTable, List<String>> fromPathColumns, Map<AbstractCubeTable, List<String>> toPathColumns) {
       for (SchemaGraph.JoinPath path : joinPaths) {
         for (TableRelationship edge : path.getEdges()) {
           AbstractCubeTable fromTable = edge.getFromTable();
@@ -419,6 +417,7 @@ class JoinResolver implements ContextRewriter {
     public void printAllPaths(String src) {
       LOG.info(src + " All paths" + allPaths);
     }
+
     public void removeJoinedTable(Dimension dim) {
       allPaths.remove(Aliased.create(dim));
       joinPathFromColumns.remove(dim);
@@ -429,7 +428,7 @@ class JoinResolver implements ContextRewriter {
     }
 
     public String getFromString(String fromTable, CandidateFact fact, Set<Dimension> qdims,
-        Map<Dimension, CandidateDim> dimsToQuery, CubeQueryContext cubeql) throws SemanticException {
+      Map<Dimension, CandidateDim> dimsToQuery, CubeQueryContext cubeql) throws SemanticException {
       String fromString = fromTable;
       LOG.info("All paths dump:" + cubeql.getAutoJoinCtx().getAllPaths());
       if (qdims == null || qdims.isEmpty()) {
@@ -555,8 +554,8 @@ class JoinResolver implements ContextRewriter {
       return StringUtils.join(clauses, "");
     }
 
-    public Set<Dimension> getDimsOnPath
-      (Map<Aliased<Dimension>, List<TableRelationship>> joinChain, Set<Dimension> qdims) {
+    public Set<Dimension> getDimsOnPath(Map<Aliased<Dimension>, List<TableRelationship>> joinChain,
+      Set<Dimension> qdims) {
       Set<Dimension> dimsOnPath = new HashSet<Dimension>();
       for (Map.Entry<Aliased<Dimension>, List<TableRelationship>> entry : joinChain.entrySet()) {
         List<TableRelationship> chain = entry.getValue();
@@ -569,7 +568,7 @@ class JoinResolver implements ContextRewriter {
 
         for (int i = chain.size() - 1; i >= 0; i--) {
           TableRelationship rel = chain.get(i);
-          dimsOnPath.add((Dimension)rel.getToTable());
+          dimsOnPath.add((Dimension) rel.getToTable());
         }
       }
       return dimsOnPath;
@@ -580,7 +579,7 @@ class JoinResolver implements ContextRewriter {
       if (dimsToQuery != null && dimsToQuery.get(table) != null) {
         if (StringUtils.isNotBlank(dimsToQuery.get(table).whereClause)) {
           whereClause = dimsToQuery.get(table).whereClause;
-          if(alias != null) {
+          if (alias != null) {
             whereClause = StorageUtil.getWhereClause(whereClause, alias);
           }
         }
@@ -614,7 +613,7 @@ class JoinResolver implements ContextRewriter {
     }
 
     public void pruneAllPaths(CubeInterface cube, final Set<CandidateFact> cfacts,
-        final Map<Dimension, CandidateDim> dimsToQuery) {
+      final Map<Dimension, CandidateDim> dimsToQuery) {
       // Remove join paths which cannot be satisfied by the resolved candidate
       // fact and dimension tables
       if (cfacts != null) {
@@ -690,9 +689,10 @@ class JoinResolver implements ContextRewriter {
       }
     }
 
-    private Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> pruneFactPaths
-      (CubeInterface cube, final CandidateFact cfact) {
-      Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> prunedPaths = new HashMap<Aliased<Dimension>, List<SchemaGraph.JoinPath>>();
+    private Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> pruneFactPaths(CubeInterface cube,
+      final CandidateFact cfact) {
+      Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> prunedPaths
+        = new HashMap<Aliased<Dimension>, List<SchemaGraph.JoinPath>>();
       // Remove join paths which cannot be satisfied by the candidate fact
       for (Map.Entry<Aliased<Dimension>, List<SchemaGraph.JoinPath>> ppaths : allPaths.entrySet()) {
         prunedPaths.put(ppaths.getKey(), new ArrayList<SchemaGraph.JoinPath>(ppaths.getValue()));
@@ -740,12 +740,11 @@ class JoinResolver implements ContextRewriter {
     }
 
     /**
-     * There can be multiple join paths between a dimension and the target. Set
-     * of all possible join clauses is the cartesian product of join paths of
-     * all dimensions
+     * There can be multiple join paths between a dimension and the target. Set of all possible join clauses is the
+     * cartesian product of join paths of all dimensions
      */
     private Iterator<JoinClause> getJoinClausesForAllPaths(final CandidateFact fact,
-        final Set<Dimension> qdims, final CubeQueryContext cubeql) {
+      final Set<Dimension> qdims, final CubeQueryContext cubeql) {
       Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> allPaths;
       // if fact is passed only look at paths possible from fact to dims
       if (fact != null) {
@@ -760,7 +759,7 @@ class JoinResolver implements ContextRewriter {
       pruneAllPathsWithQueriedDims(allPaths, qdims);
 
       // Number of paths in each path set
-      final int groupSizes[] = new int[allPaths.values().size()];
+      final int[] groupSizes = new int[allPaths.values().size()];
       // Total number of elements in the cartesian product
       int numSamples = 1;
       // All path sets
@@ -778,7 +777,7 @@ class JoinResolver implements ContextRewriter {
         i++;
       }
 
-      final int selection[] = new int[groupSizes.length];
+      final int[] selection = new int[groupSizes.length];
       final int MAX_SAMPLE_COUNT = numSamples;
 
       // Return a lazy iterator over all possible join chains
@@ -792,9 +791,10 @@ class JoinResolver implements ContextRewriter {
 
         @Override
         public JoinClause next() {
-          Map<Aliased<Dimension>, List<TableRelationship>> chain = new LinkedHashMap<Aliased<Dimension>, List<TableRelationship>>();
+          Map<Aliased<Dimension>, List<TableRelationship>> chain
+            = new LinkedHashMap<Aliased<Dimension>, List<TableRelationship>>();
           //generate next permutation.
-          for(int i = groupSizes.length - 1, base=sample; i >= 0; base /= groupSizes[i], i--) {
+          for (int i = groupSizes.length - 1, base = sample; i >= 0; base /= groupSizes[i], i--) {
             selection[i] = base % groupSizes[i];
           }
           for (int i = 0; i < selection.length; i++) {
@@ -818,13 +818,13 @@ class JoinResolver implements ContextRewriter {
     }
 
     /**
-     * Given allPaths, it will remove entries where key is a non-join chain dimension and not contained
-     * in qdims
+     * Given allPaths, it will remove entries where key is a non-join chain dimension and not contained in qdims
+     *
      * @param allPaths
      * @param qdims
      */
-    private void pruneAllPathsWithQueriedDims
-      (Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> allPaths, Set<Dimension> qdims) {
+    private void pruneAllPathsWithQueriedDims(Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> allPaths,
+      Set<Dimension> qdims) {
       Iterator<Map.Entry<Aliased<Dimension>, List<SchemaGraph.JoinPath>>> iter = allPaths.entrySet().iterator();
       while (iter.hasNext()) {
         Map.Entry<Aliased<Dimension>, List<SchemaGraph.JoinPath>> cur = iter.next();
@@ -836,7 +836,7 @@ class JoinResolver implements ContextRewriter {
     }
 
     public Set<Dimension> pickOptionalTables(final CandidateFact fact,
-        Set<Dimension> qdims, CubeQueryContext cubeql) throws SemanticException {
+      Set<Dimension> qdims, CubeQueryContext cubeql) throws SemanticException {
       // Find the min cost join clause and add dimensions in the clause as optional dimensions
       Set<Dimension> joiningOptionalTables = new HashSet<Dimension>();
       if (qdims == null) {
@@ -877,7 +877,7 @@ class JoinResolver implements ContextRewriter {
           if (!cdim.getColumns().containsAll(minCostClause.chainColumns.get(dim))) {
             i.remove();
             LOG.info("Not considering dimtable:" + dimtable + " as its columns are"
-                + " not part of any join paths. Join columns:" + minCostClause.chainColumns.get(dim));
+              + " not part of any join paths. Join columns:" + minCostClause.chainColumns.get(dim));
             cubeql.addDimPruningMsgs(dim, cdim.dimtable,
               CandidateTablePruneCause.noColumnPartOfAJoinPath(minCostClause.chainColumns.get(dim)));
             break;
@@ -885,7 +885,7 @@ class JoinResolver implements ContextRewriter {
         }
         if (cubeql.getCandidateDimTables().get(dim).size() == 0) {
           throw new SemanticException(ErrorMsg.NO_DIM_HAS_COLUMN, dim.getName(),
-              minCostClause.chainColumns.get(dim).toString());
+            minCostClause.chainColumns.get(dim).toString());
         }
       }
 
@@ -951,7 +951,7 @@ class JoinResolver implements ContextRewriter {
   private void resolveJoins(CubeQueryContext cubeql) throws HiveException {
     QB cubeQB = cubeql.getQB();
     boolean joinResolverDisabled =
-        conf.getBoolean(CubeQueryConfUtil.DISABLE_AUTO_JOINS, CubeQueryConfUtil.DEFAULT_DISABLE_AUTO_JOINS);
+      conf.getBoolean(CubeQueryConfUtil.DISABLE_AUTO_JOINS, CubeQueryConfUtil.DEFAULT_DISABLE_AUTO_JOINS);
     if (joinResolverDisabled) {
       if (cubeql.getJoinTree() != null) {
         cubeQB.setQbJoinTree(genJoinTree(cubeQB, cubeql.getJoinTree(), cubeql));
@@ -966,9 +966,9 @@ class JoinResolver implements ContextRewriter {
       Set<String> dims = chain.getIntermediateDimensions();
 
       dims.add(chain.getDestTable());
-      for(String dim: dims) {
+      for (String dim : dims) {
         Dimension dimension = cubeql.getMetastoreClient().getDimension(dim);
-        if(dimensionInJoinChain.get(dimension) == null) {
+        if (dimensionInJoinChain.get(dimension) == null) {
           dimensionInJoinChain.put(dimension, new ArrayList<JoinChain>());
         }
         dimensionInJoinChain.get(dimension).add(chain);
@@ -1030,7 +1030,6 @@ class JoinResolver implements ContextRewriter {
     }
 
 
-
     SchemaGraph graph = cubeql.getMetastoreClient().getSchemaGraph();
     Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> multipleJoinPaths =
       new LinkedHashMap<Aliased<Dimension>, List<SchemaGraph.JoinPath>>();
@@ -1038,7 +1037,7 @@ class JoinResolver implements ContextRewriter {
 
     // Resolve join path for each dimension accessed in the query
     for (Dimension joinee : dimTables) {
-      if(dimensionInJoinChain.get(joinee) == null) {
+      if (dimensionInJoinChain.get(joinee) == null) {
         // Find all possible join paths
         SchemaGraph.GraphSearch search = new SchemaGraph.GraphSearch(joinee, target, graph);
         List<SchemaGraph.JoinPath> joinPaths = search.findAllPathsToTarget();
@@ -1070,22 +1069,22 @@ class JoinResolver implements ContextRewriter {
                 cubeql.getCandidateDimTables().get(((CandidateDim) candidate).getBaseTable()).remove(candidate);
                 cubeql.addDimPruningMsgs(
                   (Dimension) candidate.getBaseTable(), (CubeDimensionTable) candidate.getTable(),
-                    new CandidateTablePruneCause(CandidateTablePruneCode.COLUMN_NOT_FOUND)
+                  new CandidateTablePruneCause(CandidateTablePruneCode.COLUMN_NOT_FOUND)
                 );
               }
             }
           }
         }
-      } else if(dimensionInJoinChain.get(joinee).size() > 1) {
-        throw new SemanticException("Table " + joinee.getName() + " has " +
-          dimensionInJoinChain.get(joinee).size() + " different paths through joinchains " +
-          "(" + dimensionInJoinChain.get(joinee) + ")" +
-          " used in query. Couldn't determine which one to use");
+      } else if (dimensionInJoinChain.get(joinee).size() > 1) {
+        throw new SemanticException("Table " + joinee.getName() + " has "
+          +dimensionInJoinChain.get(joinee).size() + " different paths through joinchains "
+          +"(" + dimensionInJoinChain.get(joinee) + ")"
+          +" used in query. Couldn't determine which one to use");
       } else {
         // the case when dimension is used only once in all joinchains.
-        if(isJoinchainDestination(cubeql, joinee)) {
+        if (isJoinchainDestination(cubeql, joinee)) {
           throw new SemanticException("Table " + joinee.getName() + " is getting accessed via two different names: "
-          + "[" + dimensionInJoinChain.get(joinee).get(0).getName() + ", " + joinee.getName() + "]");
+            + "[" + dimensionInJoinChain.get(joinee).get(0).getName() + ", " + joinee.getName() + "]");
         }
       }
     }
@@ -1093,7 +1092,7 @@ class JoinResolver implements ContextRewriter {
     for (JoinChain chain : cubeql.getJoinchains().values()) {
       Dimension dimension = cubeql.getMetastoreClient().getDimension(chain.getDestTable());
       Aliased<Dimension> aliasedDimension = Aliased.create(dimension, chain.getName());
-      if(multipleJoinPaths.get(aliasedDimension) == null) {
+      if (multipleJoinPaths.get(aliasedDimension) == null) {
         multipleJoinPaths.put(aliasedDimension, new ArrayList<SchemaGraph.JoinPath>());
       }
       multipleJoinPaths.get(aliasedDimension).addAll(
@@ -1104,6 +1103,7 @@ class JoinResolver implements ContextRewriter {
         tableJoinTypeMap, target, conf.get(CubeQueryConfUtil.JOIN_TYPE_KEY), true);
     cubeql.setAutoJoinCtx(joinCtx);
   }
+
   private boolean isJoinchainDestination(CubeQueryContext cubeql, Dimension dimension) {
     for (JoinChain chain : cubeql.getJoinchains().values()) {
       if (chain.getDestTable().equalsIgnoreCase(dimension.getName())) {
@@ -1112,8 +1112,9 @@ class JoinResolver implements ContextRewriter {
     }
     return false;
   }
+
   private void addOptionalTables(CubeQueryContext cubeql, List<SchemaGraph.JoinPath> joinPathList, boolean required)
-      throws SemanticException {
+    throws SemanticException {
     for (SchemaGraph.JoinPath joinPath : joinPathList) {
       for (TableRelationship rel : joinPath.getEdges()) {
         // Add the joined tables to the queries table sets so that they are
@@ -1226,8 +1227,8 @@ class JoinResolver implements ContextRewriter {
     if ((left.getToken().getType() == TOK_TABREF) || (left.getToken().getType() == TOK_SUBQUERY)) {
       String tableName = SemanticAnalyzer.getUnescapedUnqualifiedTableName((ASTNode) left.getChild(0)).toLowerCase();
       String alias =
-          left.getChildCount() == 1 ? tableName : SemanticAnalyzer.unescapeIdentifier(left
-              .getChild(left.getChildCount() - 1).getText().toLowerCase());
+        left.getChildCount() == 1 ? tableName : SemanticAnalyzer.unescapeIdentifier(left
+          .getChild(left.getChildCount() - 1).getText().toLowerCase());
 
       joinTree.setLeftAlias(alias);
 
@@ -1246,7 +1247,7 @@ class JoinResolver implements ContextRewriter {
       joinTree.setJoinSrc(leftTree);
 
       String[] leftChildAliases = leftTree.getLeftAliases();
-      String leftAliases[] = new String[leftChildAliases.length + 1];
+      String[] leftAliases = new String[leftChildAliases.length + 1];
       for (int i = 0; i < leftChildAliases.length; i++) {
         leftAliases[i] = leftChildAliases[i];
       }
@@ -1260,8 +1261,8 @@ class JoinResolver implements ContextRewriter {
     if ((right.getToken().getType() == TOK_TABREF) || (right.getToken().getType() == TOK_SUBQUERY)) {
       String tableName = SemanticAnalyzer.getUnescapedUnqualifiedTableName((ASTNode) right.getChild(0)).toLowerCase();
       String alias =
-          right.getChildCount() == 1 ? tableName : SemanticAnalyzer.unescapeIdentifier(right
-              .getChild(right.getChildCount() - 1).getText().toLowerCase());
+        right.getChildCount() == 1 ? tableName : SemanticAnalyzer.unescapeIdentifier(right
+          .getChild(right.getChildCount() - 1).getText().toLowerCase());
       String[] rightAliases = new String[1];
       rightAliases[0] = alias;
       joinTree.setRightAliases(rightAliases);
@@ -1272,7 +1273,7 @@ class JoinResolver implements ContextRewriter {
       children[1] = alias;
       joinTree.setBaseSrc(children);
       // remember rhs table for semijoin
-      if (joinTree.getNoSemiJoin() == false) {
+      if (!joinTree.getNoSemiJoin()) {
         joinTree.addRHSSemijoin(alias);
       }
     } else {
@@ -1291,8 +1292,8 @@ class JoinResolver implements ContextRewriter {
 
   private boolean isJoinToken(ASTNode node) {
     if ((node.getToken().getType() == TOK_JOIN) || (node.getToken().getType() == TOK_LEFTOUTERJOIN)
-        || (node.getToken().getType() == TOK_RIGHTOUTERJOIN) || (node.getToken().getType() == TOK_FULLOUTERJOIN)
-        || (node.getToken().getType() == TOK_LEFTSEMIJOIN) || (node.getToken().getType() == TOK_UNIQUEJOIN)) {
+      || (node.getToken().getType() == TOK_RIGHTOUTERJOIN) || (node.getToken().getType() == TOK_FULLOUTERJOIN)
+      || (node.getToken().getType() == TOK_LEFTSEMIJOIN) || (node.getToken().getType() == TOK_UNIQUEJOIN)) {
       return true;
     }
     return false;

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/LeastPartitionResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/LeastPartitionResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/LeastPartitionResolver.java
index 1abb243..0514ecf 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/LeastPartitionResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/LeastPartitionResolver.java
@@ -18,17 +18,14 @@
  */
 package org.apache.lens.cube.parse;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 /**
  * Prune candidate fact sets which require more partitions than minimum parts.
@@ -54,7 +51,7 @@ class LeastPartitionResolver implements ContextRewriter {
         Set<CandidateFact> facts = i.next();
         if (factPartCount.get(facts) > minPartitions) {
           LOG.info("Not considering facts:" + facts + " from candidate fact tables as it requires more partitions to"
-              + " be queried:" + factPartCount.get(facts) + " minimum:" + minPartitions);
+            + " be queried:" + factPartCount.get(facts) + " minimum:" + minPartitions);
           i.remove();
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestDimensionResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestDimensionResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestDimensionResolver.java
index 426fe6d..b4c603b 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestDimensionResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestDimensionResolver.java
@@ -18,18 +18,15 @@
  */
 package org.apache.lens.cube.parse;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+
+import org.apache.lens.cube.metadata.Dimension;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.metadata.Dimension;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 /**
  * Prune dimension tables having more weight than minimum
@@ -59,7 +56,7 @@ class LightestDimensionResolver implements ContextRewriter {
           CandidateDim dim = i.next();
           if (dimWeightMap.get(dim) > minWeight) {
             LOG.info("Not considering dimtable:" + dim + " from candidate dimension tables as it has more weight:"
-                + dimWeightMap.get(dim) + " minimum:" + minWeight);
+              + dimWeightMap.get(dim) + " minimum:" + minWeight);
             cubeql.addDimPruningMsgs(entry.getKey(), dim.dimtable, new CandidateTablePruneCause(
               CandidateTablePruneCode.MORE_WEIGHT));
             i.remove();

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestFactResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestFactResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestFactResolver.java
index 9216998..fc06f08 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestFactResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/LightestFactResolver.java
@@ -19,17 +19,14 @@
 
 package org.apache.lens.cube.parse;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
 
 /**
  * Prune fact tables having more weight than minimum.
@@ -55,7 +52,7 @@ public class LightestFactResolver implements ContextRewriter {
         Set<CandidateFact> facts = i.next();
         if (factWeightMap.get(facts) > minWeight) {
           LOG.info("Not considering facts:" + facts + " from candidate fact tables as it has more fact weight:"
-              + factWeightMap.get(facts) + " minimum:" + minWeight);
+            + factWeightMap.get(facts) + " minimum:" + minWeight);
           i.remove();
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/MultiFactHQLContext.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/MultiFactHQLContext.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/MultiFactHQLContext.java
index 7afe82e..ca680e1 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/MultiFactHQLContext.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/MultiFactHQLContext.java
@@ -23,20 +23,21 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.lens.cube.metadata.Dimension;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.metadata.Dimension;
 
 /**
- * Writes a join query with all the facts involved, with where, groupby and
- * having expressions pushed down to the fact queries.
+ * Writes a join query with all the facts involved, with where, groupby and having expressions pushed down to the fact
+ * queries.
  */
 class MultiFactHQLContext extends SimpleHQLContext {
 
-  public static Log LOG = LogFactory.getLog(MultiFactHQLContext.class.getName());
+  public static final Log LOG = LogFactory.getLog(MultiFactHQLContext.class.getName());
 
   private Map<Dimension, CandidateDim> dimsToQuery;
   private Set<CandidateFact> facts;
@@ -44,7 +45,7 @@ class MultiFactHQLContext extends SimpleHQLContext {
   private Map<CandidateFact, Set<Dimension>> factDimMap;
 
   MultiFactHQLContext(Set<CandidateFact> facts, Map<Dimension, CandidateDim> dimsToQuery,
-      Map<CandidateFact, Set<Dimension>> factDimMap, CubeQueryContext query) throws SemanticException {
+    Map<CandidateFact, Set<Dimension>> factDimMap, CubeQueryContext query) throws SemanticException {
     super();
     this.query = query;
     this.facts = facts;
@@ -96,10 +97,10 @@ class MultiFactHQLContext extends SimpleHQLContext {
     for (int i = 0; i < query.getSelectAST().getChildCount(); i++) {
       if (selectToFactIndex.get(i) == null) {
         throw new SemanticException(ErrorMsg.EXPRESSION_NOT_IN_ANY_FACT, HQLParser.getString((ASTNode) query
-            .getSelectAST().getChild(i)));
+          .getSelectAST().getChild(i)));
       }
       select.append("mq").append(selectToFactIndex.get(i)).append(".").append(query.getSelectAlias(i)).append(" ")
-          .append(query.getSelectFinalAlias(i));
+        .append(query.getSelectFinalAlias(i));
       if (i != query.getSelectAST().getChildCount() - 1) {
         select.append(", ");
       }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/ORTimeRangeWriter.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/ORTimeRangeWriter.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/ORTimeRangeWriter.java
index 4893b77..722230b 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/ORTimeRangeWriter.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/ORTimeRangeWriter.java
@@ -29,7 +29,7 @@ public class ORTimeRangeWriter implements TimeRangeWriter {
 
   @Override
   public String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext, String tableName,
-      Set<FactPartition> rangeParts) {
+    Set<FactPartition> rangeParts) {
     if (rangeParts.size() == 0) {
       return "";
     }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/PruneCauses.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/PruneCauses.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/PruneCauses.java
index 2bc3721..ae9e013 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/PruneCauses.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/PruneCauses.java
@@ -18,11 +18,15 @@
  */
 package org.apache.lens.cube.parse;
 
-import java.util.*;
-
-import org.apache.commons.lang.StringUtils;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.lens.cube.metadata.AbstractCubeTable;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
+
+import org.apache.commons.lang.StringUtils;
 
 import org.codehaus.jackson.annotate.JsonWriteNullProperties;
 
@@ -32,8 +36,11 @@ import lombok.Getter;
 import lombok.NoArgsConstructor;
 
 public class PruneCauses<T extends AbstractCubeTable> extends HashMap<T, List<CandidateTablePruneCause>> {
-  @Getter(lazy=true) private final HashMap<CandidateTablePruneCause, List<T>> reversed = reverse();
-  @Getter(lazy=true) private final BriefAndDetailedError jsonObject = toJsonObject();
+  @Getter(lazy = true)
+  private final HashMap<CandidateTablePruneCause, List<T>> reversed = reverse();
+  @Getter(lazy = true)
+  private final BriefAndDetailedError jsonObject = toJsonObject();
+
   public void addPruningMsg(T table, CandidateTablePruneCause msg) {
     if (get(table) == null) {
       put(table, new ArrayList<CandidateTablePruneCause>());
@@ -43,9 +50,9 @@ public class PruneCauses<T extends AbstractCubeTable> extends HashMap<T, List<Ca
 
   public HashMap<CandidateTablePruneCause, List<T>> reverse() {
     HashMap<CandidateTablePruneCause, List<T>> result = new HashMap<CandidateTablePruneCause, List<T>>();
-    for(T key: keySet()) {
-      for(CandidateTablePruneCause value: get(key)) {
-        if(result.get(value) == null) {
+    for (T key : keySet()) {
+      for (CandidateTablePruneCause value : get(key)) {
+        if (result.get(value) == null) {
           result.put(value, new ArrayList<T>());
         }
         result.get(value).add(key);
@@ -57,9 +64,9 @@ public class PruneCauses<T extends AbstractCubeTable> extends HashMap<T, List<Ca
   public BriefAndDetailedError toJsonObject() {
     final HashMap<String, List<CandidateTablePruneCause>> detailedMessage
       = new HashMap<String, List<CandidateTablePruneCause>>();
-    for(Map.Entry<CandidateTablePruneCause, List<T>> entry: getReversed().entrySet()) {
+    for (Map.Entry<CandidateTablePruneCause, List<T>> entry : getReversed().entrySet()) {
       String key = StringUtils.join(entry.getValue(), ",");
-      if(detailedMessage.get(key) == null) {
+      if (detailedMessage.get(key) == null) {
         detailedMessage.put(key, new ArrayList<CandidateTablePruneCause>());
       }
       detailedMessage.get(key).add(entry.getKey());
@@ -68,15 +75,15 @@ public class PruneCauses<T extends AbstractCubeTable> extends HashMap<T, List<Ca
   }
 
   public String getBriefCause() {
-    CandidateTablePruneCause.CandidateTablePruneCode maxCause = CandidateTablePruneCause.CandidateTablePruneCode.values()[0];
-    for(CandidateTablePruneCause cause: getReversed().keySet()) {
-      if(cause.getCause().compareTo(maxCause) > 0) {
+    CandidateTablePruneCode maxCause = CandidateTablePruneCode.values()[0];
+    for (CandidateTablePruneCause cause : getReversed().keySet()) {
+      if (cause.getCause().compareTo(maxCause) > 0) {
         maxCause = cause.getCause();
       }
     }
     Map<CandidateTablePruneCause, List<T>> maxCauseMap = new HashMap<CandidateTablePruneCause, List<T>>();
-    for(Map.Entry<CandidateTablePruneCause, List<T>> entry: getReversed().entrySet()) {
-      if(entry.getKey().getCause().compareTo(maxCause) == 0) {
+    for (Map.Entry<CandidateTablePruneCause, List<T>> entry : getReversed().entrySet()) {
+      if (entry.getKey().getCause().compareTo(maxCause) == 0) {
         maxCauseMap.put(entry.getKey(), entry.getValue());
       }
     }
@@ -92,7 +99,7 @@ public class PruneCauses<T extends AbstractCubeTable> extends HashMap<T, List<Ca
   @AllArgsConstructor
   @NoArgsConstructor
   public static final class BriefAndDetailedError {
-    public String brief;
-    public HashMap<String, List<CandidateTablePruneCause>> details;
+    private String brief;
+    private HashMap<String, List<CandidateTablePruneCause>> details;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/SimpleHQLContext.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/SimpleHQLContext.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/SimpleHQLContext.java
index f067d0a..c251e61 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/SimpleHQLContext.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/SimpleHQLContext.java
@@ -29,13 +29,12 @@ import org.apache.hadoop.hive.ql.parse.SemanticException;
 
 /**
  * Accepts strings of all expressions and constructs HQL query.
- * 
- * Making this as an abstract class because it provides constructors without all
- * expressions being set.
+ * <p/>
+ * Making this as an abstract class because it provides constructors without all expressions being set.
  */
 public abstract class SimpleHQLContext implements HQLContextInterface {
 
-  public static Log LOG = LogFactory.getLog(SimpleHQLContext.class.getName());
+  public static final Log LOG = LogFactory.getLog(SimpleHQLContext.class.getName());
 
   private String select;
   private String from;
@@ -49,7 +48,7 @@ public abstract class SimpleHQLContext implements HQLContextInterface {
   }
 
   SimpleHQLContext(String select, String from, String where, String groupby, String orderby, String having,
-      Integer limit) {
+    Integer limit) {
     this.select = select;
     this.from = from;
     this.where = where;
@@ -69,10 +68,9 @@ public abstract class SimpleHQLContext implements HQLContextInterface {
 
   /**
    * Set all missing expressions of HQL context.
-   * 
-   * Leaving this empty implementation for the case of all expressions being
-   * passed in constructor. If other constructors are used the missing
-   * expressions should be set here
+   * <p/>
+   * Leaving this empty implementation for the case of all expressions being passed in constructor. If other
+   * constructors are used the missing expressions should be set here
    */
   protected void setMissingExpressions() throws SemanticException {
   }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactHQLContext.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactHQLContext.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactHQLContext.java
index 3a5f296..017c836 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactHQLContext.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactHQLContext.java
@@ -20,29 +20,29 @@ package org.apache.lens.cube.parse;
 
 import java.util.Map;
 
+import org.apache.lens.cube.metadata.Dimension;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.ParseException;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.lens.cube.metadata.Dimension;
 
 /**
- * HQL context class which passes down all query strings to come from
- * DimOnlyHQLContext and works with fact being queried.
- * 
+ * HQL context class which passes down all query strings to come from DimOnlyHQLContext and works with fact being
+ * queried.
+ * <p/>
  * Updates from string with join clause expanded
- * 
  */
 class SingleFactHQLContext extends DimOnlyHQLContext {
 
-  public static Log LOG = LogFactory.getLog(SingleFactHQLContext.class.getName());
+  public static final Log LOG = LogFactory.getLog(SingleFactHQLContext.class.getName());
 
   private CandidateFact fact;
 
   SingleFactHQLContext(CandidateFact fact, Map<Dimension, CandidateDim> dimsToQuery, CubeQueryContext query)
-      throws SemanticException {
+    throws SemanticException {
     super(dimsToQuery, query);
     this.fact = fact;
   }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageTableResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageTableResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageTableResolver.java
index 6381ba3..64b835e 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageTableResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageTableResolver.java
@@ -20,20 +20,13 @@ package org.apache.lens.cube.parse;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import java.util.*;
+
+import org.apache.lens.cube.metadata.*;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipStorageCause;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipStorageCode;
+import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipUpdatePeriodCode;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -43,24 +36,13 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.lens.cube.metadata.CubeDimensionTable;
-import org.apache.lens.cube.metadata.CubeFactTable;
-import org.apache.lens.cube.metadata.CubeMetastoreClient;
-import org.apache.lens.cube.metadata.Dimension;
-import org.apache.lens.cube.metadata.MetastoreUtil;
-import org.apache.lens.cube.metadata.StorageConstants;
-import org.apache.lens.cube.metadata.UpdatePeriod;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipStorageCode;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipStorageCause;
-import org.apache.lens.cube.parse.CandidateTablePruneCause.SkipUpdatePeriodCode;
 
 /**
- * Resolve storages and partitions of all candidate tables and prunes candidate
- * tables with missing storages or partitions.
+ * Resolve storages and partitions of all candidate tables and prunes candidate tables with missing storages or
+ * partitions.
  */
 class StorageTableResolver implements ContextRewriter {
-  private static Log LOG = LogFactory.getLog(StorageTableResolver.class.getName());
+  public static final Log LOG = LogFactory.getLog(StorageTableResolver.class.getName());
 
   private final Configuration conf;
   private final List<String> supportedStorages;
@@ -69,7 +51,7 @@ class StorageTableResolver implements ContextRewriter {
   private final boolean failOnPartialData;
   private final List<String> validDimTables;
   private final Map<CubeFactTable, Map<UpdatePeriod, Set<String>>> validStorageMap =
-      new HashMap<CubeFactTable, Map<UpdatePeriod, Set<String>>>();
+    new HashMap<CubeFactTable, Map<UpdatePeriod, Set<String>>>();
   private String processTimePartCol = null;
   private final UpdatePeriod maxInterval;
   private final boolean populateNonExistingParts;
@@ -80,12 +62,15 @@ class StorageTableResolver implements ContextRewriter {
 
   static enum PHASE {
     FACT_TABLES, FACT_PARTITIONS, DIM_TABLE_AND_PARTITIONS;
+
     static PHASE first() {
       return values()[0];
     }
+
     static PHASE last() {
       return values()[values().length - 1];
     }
+
     PHASE next() {
       return values()[(this.ordinal() + 1) % values().length];
     }
@@ -100,8 +85,8 @@ class StorageTableResolver implements ContextRewriter {
       this.populateNonExistingParts = true;
     } else {
       this.populateNonExistingParts =
-          conf.getBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,
-              CubeQueryConfUtil.DEFAULT_ADD_NON_EXISTING_PARTITIONS);
+        conf.getBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,
+          CubeQueryConfUtil.DEFAULT_ADD_NON_EXISTING_PARTITIONS);
     }
     String str = conf.get(CubeQueryConfUtil.VALID_STORAGE_DIM_TABLES);
     validDimTables = StringUtils.isBlank(str) ? null : Arrays.asList(StringUtils.split(str.toLowerCase(), ","));
@@ -113,8 +98,8 @@ class StorageTableResolver implements ContextRewriter {
       this.maxInterval = null;
     }
     rangeWriter =
-        ReflectionUtils.newInstance(conf.getClass(CubeQueryConfUtil.TIME_RANGE_WRITER_CLASS,
-            CubeQueryConfUtil.DEFAULT_TIME_RANGE_WRITER, TimeRangeWriter.class), this.conf);
+      ReflectionUtils.newInstance(conf.getClass(CubeQueryConfUtil.TIME_RANGE_WRITER_CLASS,
+        CubeQueryConfUtil.DEFAULT_TIME_RANGE_WRITER, TimeRangeWriter.class), this.conf);
     String formatStr = conf.get(CubeQueryConfUtil.PART_WHERE_CLAUSE_DATE_FORMAT);
     if (formatStr != null) {
       partWhereClauseFormat = new SimpleDateFormat(formatStr);
@@ -131,8 +116,7 @@ class StorageTableResolver implements ContextRewriter {
   }
 
   public boolean isStorageSupported(String storage) {
-    return allStoragesSupported ||
-      supportedStorages.contains(storage);
+    return allStoragesSupported || supportedStorages.contains(storage);
   }
 
   Map<String, List<String>> storagePartMap = new HashMap<String, List<String>>();
@@ -141,30 +125,30 @@ class StorageTableResolver implements ContextRewriter {
   public void rewriteContext(CubeQueryContext cubeql) throws SemanticException {
     client = cubeql.getMetastoreClient();
 
-    switch(phase) {
-      case FACT_TABLES:
-        if (!cubeql.getCandidateFactTables().isEmpty()) {
-          // resolve storage table names
-          resolveFactStorageTableNames(cubeql);
-        }
-        cubeql.pruneCandidateFactSet(CandidateTablePruneCode.NO_CANDIDATE_STORAGES);
-        break;
-      case FACT_PARTITIONS:
-        if (!cubeql.getCandidateFactTables().isEmpty()) {
-          // resolve storage partitions
-          resolveFactStoragePartitions(cubeql);
-        }
-        cubeql.pruneCandidateFactSet(CandidateTablePruneCode.NO_CANDIDATE_STORAGES);
-        break;
-      case DIM_TABLE_AND_PARTITIONS:
-        resolveDimStorageTablesAndPartitions(cubeql);
-        if (cubeql.getAutoJoinCtx() != null) {
-          // After all candidates are pruned after storage resolver, prune join paths.
-          cubeql.getAutoJoinCtx().pruneAllPaths(cubeql.getCube(), cubeql.getCandidateFactTables(), null);
-          cubeql.getAutoJoinCtx().pruneAllPathsForCandidateDims(cubeql.getCandidateDimTables());
-          cubeql.getAutoJoinCtx().refreshJoinPathColumns();
-        }
-        break;
+    switch (phase) {
+    case FACT_TABLES:
+      if (!cubeql.getCandidateFactTables().isEmpty()) {
+        // resolve storage table names
+        resolveFactStorageTableNames(cubeql);
+      }
+      cubeql.pruneCandidateFactSet(CandidateTablePruneCode.NO_CANDIDATE_STORAGES);
+      break;
+    case FACT_PARTITIONS:
+      if (!cubeql.getCandidateFactTables().isEmpty()) {
+        // resolve storage partitions
+        resolveFactStoragePartitions(cubeql);
+      }
+      cubeql.pruneCandidateFactSet(CandidateTablePruneCode.NO_CANDIDATE_STORAGES);
+      break;
+    case DIM_TABLE_AND_PARTITIONS:
+      resolveDimStorageTablesAndPartitions(cubeql);
+      if (cubeql.getAutoJoinCtx() != null) {
+        // After all candidates are pruned after storage resolver, prune join paths.
+        cubeql.getAutoJoinCtx().pruneAllPaths(cubeql.getCube(), cubeql.getCandidateFactTables(), null);
+        cubeql.getAutoJoinCtx().pruneAllPathsForCandidateDims(cubeql.getCandidateDimTables());
+        cubeql.getAutoJoinCtx().refreshJoinPathColumns();
+      }
+      break;
     }
     //Doing this on all three phases. Keep updating cubeql with the current identified missing partitions.
     cubeql.setNonexistingParts(nonExistingPartitions);
@@ -215,8 +199,8 @@ class StorageTableResolver implements ContextRewriter {
               int numParts;
               try {
                 numParts =
-                    client.getNumPartitionsByFilter(tableName,
-                        getDimFilter(dim.getTimedDimension(), StorageConstants.LATEST_PARTITION_VALUE));
+                  client.getNumPartitionsByFilter(tableName,
+                    getDimFilter(dim.getTimedDimension(), StorageConstants.LATEST_PARTITION_VALUE));
               } catch (Exception e) {
                 e.printStackTrace();
                 throw new SemanticException("Could not check if partition exists on " + dim, e);
@@ -282,7 +266,7 @@ class StorageTableResolver implements ContextRewriter {
       validStorageMap.put(fact, storageTableMap);
       String str = conf.get(CubeQueryConfUtil.getValidStorageTablesKey(fact.getName()));
       List<String> validFactStorageTables =
-          StringUtils.isBlank(str) ? null : Arrays.asList(StringUtils.split(str.toLowerCase(), ","));
+        StringUtils.isBlank(str) ? null : Arrays.asList(StringUtils.split(str.toLowerCase(), ","));
       Map<String, SkipStorageCause> skipStorageCauses = new HashMap<String, SkipStorageCause>();
 
       for (Map.Entry<String, Set<UpdatePeriod>> entry : fact.getUpdatePeriods().entrySet()) {
@@ -293,14 +277,14 @@ class StorageTableResolver implements ContextRewriter {
           skipStorageCauses.put(storage, new SkipStorageCause(SkipStorageCode.UNSUPPORTED));
           continue;
         }
-        String tableName;
+        String tableName = getStorageTableName(fact, storage, validFactStorageTables);
         // skip the update period if the storage is not valid
-        if ((tableName = getStorageTableName(fact, storage, validFactStorageTables)) == null) {
+        if (tableName == null) {
           skipStorageCauses.put(storage, new SkipStorageCause(SkipStorageCode.INVALID));
           continue;
         }
         List<String> validUpdatePeriods =
-            CubeQueryConfUtil.getStringList(conf, CubeQueryConfUtil.getValidUpdatePeriodsKey(fact.getName(), storage));
+          CubeQueryConfUtil.getStringList(conf, CubeQueryConfUtil.getValidUpdatePeriodsKey(fact.getName(), storage));
 
         boolean isStorageAdded = false;
         Map<String, SkipUpdatePeriodCode> skipUpdatePeriodCauses = new HashMap<String, SkipUpdatePeriodCode>();
@@ -376,7 +360,7 @@ class StorageTableResolver implements ContextRewriter {
       }
       if (cfact.numQueriedParts == 0 || (failOnPartialData && (noPartsForRange || !nonExistingParts.isEmpty()))) {
         LOG.info("Not considering fact table:" + cfact.fact + " as it could" + " not find partition for given ranges: "
-            + cubeql.getTimeRanges());
+          + cubeql.getTimeRanges());
         if (!skipStorageCauses.isEmpty()) {
           CandidateTablePruneCause cause = CandidateTablePruneCause.noCandidateStorages(skipStorageCauses);
           cubeql.addFactPruningMsgs(cfact.fact, cause);
@@ -420,18 +404,18 @@ class StorageTableResolver implements ContextRewriter {
     HashMap<String, SkipStorageCause> skipStorageCauses, List<String> nonExistingParts) throws SemanticException {
     try {
       return getPartitions(fact, range, getValidUpdatePeriods(fact), this.populateNonExistingParts, skipStorageCauses,
-          nonExistingParts);
+        nonExistingParts);
     } catch (Exception e) {
       throw new SemanticException(e);
     }
   }
 
   private Set<FactPartition> getPartitions(CubeFactTable fact, TimeRange range, TreeSet<UpdatePeriod> updatePeriods,
-      boolean addNonExistingParts, HashMap<String, SkipStorageCause> skipStorageCauses, List<String> nonExistingParts)
-      throws Exception {
+    boolean addNonExistingParts, HashMap<String, SkipStorageCause> skipStorageCauses, List<String> nonExistingParts)
+    throws Exception {
     Set<FactPartition> partitions = new TreeSet<FactPartition>();
     if (getPartitions(fact, range.getFromDate(), range.getToDate(), range.getPartitionColumn(), null, partitions,
-        updatePeriods, addNonExistingParts, skipStorageCauses, nonExistingParts)) {
+      updatePeriods, addNonExistingParts, skipStorageCauses, nonExistingParts)) {
       return partitions;
     } else {
       return null;
@@ -439,9 +423,9 @@ class StorageTableResolver implements ContextRewriter {
   }
 
   private boolean getPartitions(CubeFactTable fact, Date fromDate, Date toDate, String partCol,
-      FactPartition containingPart, Set<FactPartition> partitions, TreeSet<UpdatePeriod> updatePeriods,
-      boolean addNonExistingParts, Map<String, SkipStorageCause> skipStorageCauses, List<String> nonExistingParts)
-      throws Exception {
+    FactPartition containingPart, Set<FactPartition> partitions, TreeSet<UpdatePeriod> updatePeriods,
+    boolean addNonExistingParts, Map<String, SkipStorageCause> skipStorageCauses, List<String> nonExistingParts)
+    throws Exception {
     LOG.info("getPartitions for " + fact + " from fromDate:" + fromDate + " toDate:" + toDate);
     if (fromDate.equals(toDate) || fromDate.after(toDate)) {
       return true;
@@ -488,7 +472,7 @@ class StorageTableResolver implements ContextRewriter {
     long numIters = DateUtil.getTimeDiff(ceilFromDate, floorToDate, interval);
     int i = 1;
     int lookAheadNumParts =
-        conf.getInt(CubeQueryConfUtil.getLookAheadPTPartsKey(interval), CubeQueryConfUtil.DEFAULT_LOOK_AHEAD_PT_PARTS);
+      conf.getInt(CubeQueryConfUtil.getLookAheadPTPartsKey(interval), CubeQueryConfUtil.DEFAULT_LOOK_AHEAD_PT_PARTS);
     boolean leastInterval = updatePeriods.first().equals(interval);
     while (dt.compareTo(floorToDate) < 0) {
       cal.add(interval.calendarField(), 1);
@@ -522,7 +506,7 @@ class StorageTableResolver implements ContextRewriter {
           newset.addAll(updatePeriods);
           newset.remove(interval);
           if (!getPartitions(fact, dt, cal.getTime(), partCol, null, partitions, newset, false, skipStorageCauses,
-              nonExistingParts)) {
+            nonExistingParts)) {
             if (addNonExistingParts) {
               LOG.info("Adding non existing partition" + part);
               if (!failOnPartialData) {
@@ -582,12 +566,12 @@ class StorageTableResolver implements ContextRewriter {
                       Set<FactPartition> processTimeParts = new TreeSet<FactPartition>();
                       LOG.info("Looking for process time partitions between " + pdt + " and " + temp.getTime());
                       getPartitions(fact, pdt, temp.getTime(), processTimePartCol, null, processTimeParts, newset,
-                          false, skipStorageCauses, nonExistingParts);
+                        false, skipStorageCauses, nonExistingParts);
                       if (!processTimeParts.isEmpty()) {
                         for (FactPartition pPart : processTimeParts) {
                           LOG.info("Looking for finer partitions in pPart" + pPart);
                           if (!getPartitions(fact, dt, cal.getTime(), partCol, pPart, partitions, newset, false,
-                              skipStorageCauses, nonExistingParts)) {
+                            skipStorageCauses, nonExistingParts)) {
                             LOG.info("No partitions found in look ahead range");
                           }
                         }
@@ -614,9 +598,10 @@ class StorageTableResolver implements ContextRewriter {
       i++;
     }
     if (containingPart == null) {
-      return (getPartitions(fact, fromDate, ceilFromDate, partCol, null, partitions, updatePeriods,
-          addNonExistingParts, skipStorageCauses, nonExistingParts) && getPartitions(fact, floorToDate, toDate,
-          partCol, null, partitions, updatePeriods, addNonExistingParts, skipStorageCauses, nonExistingParts));
+      return getPartitions(fact, fromDate, ceilFromDate, partCol, null, partitions,
+          updatePeriods, addNonExistingParts, skipStorageCauses, nonExistingParts)
+        && getPartitions(fact, floorToDate, toDate, partCol, null, partitions,
+          updatePeriods, addNonExistingParts, skipStorageCauses, nonExistingParts);
     } else {
       return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageUtil.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageUtil.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageUtil.java
index 6d724ea..14feb24 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageUtil.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageUtil.java
@@ -18,13 +18,17 @@
  */
 package org.apache.lens.cube.parse;
 
+import java.util.*;
+
+import org.apache.lens.cube.metadata.StorageConstants;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.lens.cube.metadata.StorageConstants;
 
-import java.util.*;
+public final class StorageUtil {
+  private StorageUtil() {
 
-class StorageUtil {
+  }
   private static final Log LOG = LogFactory.getLog(StorageUtil.class.getName());
 
   public static String getWherePartClause(String timeDimName, String tableName, List<String> parts) {
@@ -52,7 +56,7 @@ class StorageUtil {
     StringBuilder sb = new StringBuilder();
     String sep = "";
     for (String timePartCol : timedDimensions) {
-      if(!timePartCol.equals(partCol)) {
+      if (!timePartCol.equals(partCol)) {
         sb.append(sep).append(alias).append(".").append(timePartCol)
           .append(" != '").append(StorageConstants.LATEST_PARTITION_VALUE).append("'");
         sep = " AND ";
@@ -142,9 +146,11 @@ class StorageUtil {
     }
     return Collections.singletonMap(maxCoveringStorage, maxCoveringSet);
   }
+
   public static String getWhereClause(String clause, String alias) {
     return String.format(clause, alias);
   }
+
   public static String getWhereClause(CandidateDim dim, String alias) {
     return getWhereClause(dim.whereClause, alias);
   }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeUtils.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeUtils.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeUtils.java
index 8e9ac13..27c3b89 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeUtils.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeUtils.java
@@ -18,9 +18,12 @@
  */
 package org.apache.lens.cube.parse;
 
-class TimeRangeUtils {
+public final class TimeRangeUtils {
+  private TimeRangeUtils() {
+
+  }
   public static String getTimeRangePartitionFilter(FactPartition partition, CubeQueryContext cubeQueryContext,
-      String tableName) {
+    String tableName) {
     String partCol = partition.getPartCol();
     String partFilter;
 

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeWriter.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeWriter.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeWriter.java
index 4ac2151..c6e275f 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeWriter.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimeRangeWriter.java
@@ -22,7 +22,7 @@ import java.util.Set;
 
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 
-interface TimeRangeWriter {
-  public String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext, String tableName, Set<FactPartition> parts)
-      throws SemanticException;
+public interface TimeRangeWriter {
+  String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext, String tableName, Set<FactPartition> parts)
+    throws SemanticException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/cube/parse/TimerangeResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimerangeResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimerangeResolver.java
index 43dece3..418ebe4 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/TimerangeResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/TimerangeResolver.java
@@ -18,16 +18,15 @@
  */
 package org.apache.lens.cube.parse;
 
-import static org.apache.hadoop.hive.ql.parse.HiveParser.DOT;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.Identifier;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_FUNCTION;
-import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_TABLE_OR_COL;
+import static org.apache.hadoop.hive.ql.parse.HiveParser.*;
 
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+
+import org.apache.lens.cube.metadata.AbstractCubeTable;
+import org.apache.lens.cube.metadata.CubeColumn;
+import org.apache.lens.cube.metadata.Dimension;
+import org.apache.lens.cube.metadata.SchemaGraph;
+import org.apache.lens.cube.parse.DenormalizationResolver.ReferencedQueriedColumn;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -37,19 +36,12 @@ import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.hadoop.hive.ql.plan.PlanUtils;
-import org.apache.lens.cube.metadata.AbstractCubeTable;
-import org.apache.lens.cube.metadata.CubeColumn;
-import org.apache.lens.cube.metadata.Dimension;
-import org.apache.lens.cube.metadata.SchemaGraph;
-import org.apache.lens.cube.parse.DenormalizationResolver.ReferencedQueriedColumn;
 
 /**
- * Finds all timeranges in the query and does validation wrt the queried field's
- * life and the range queried
- * 
+ * Finds all timeranges in the query and does validation wrt the queried field's life and the range queried
  */
 class TimerangeResolver implements ContextRewriter {
-  private static Log LOG = LogFactory.getLog(TimerangeResolver.class.getName());
+  public static final Log LOG = LogFactory.getLog(TimerangeResolver.class.getName());
 
   public TimerangeResolver(Configuration conf) {
   }
@@ -75,7 +67,7 @@ class TimerangeResolver implements ContextRewriter {
   }
 
   private void searchTimeRanges(ASTNode root, CubeQueryContext cubeql, ASTNode parent, int childIndex)
-      throws SemanticException {
+    throws SemanticException {
     if (root == null) {
       return;
     } else if (root.getToken().getType() == TOK_FUNCTION) {
@@ -105,7 +97,7 @@ class TimerangeResolver implements ContextRewriter {
   }
 
   private void processTimeRangeFunction(CubeQueryContext cubeql, ASTNode timenode, ASTNode parent, int childIndex)
-      throws SemanticException {
+    throws SemanticException {
     TimeRange.TimeRangeBuilder builder = TimeRange.getBuilder();
     builder.astNode(timenode);
     builder.parent(parent);
@@ -163,8 +155,8 @@ class TimerangeResolver implements ContextRewriter {
         }
         if (isColumnLifeInvalid(column, range)) {
           throw new SemanticException(ErrorMsg.NOT_AVAILABLE_IN_RANGE, col, range.toString(),
-              (column.getStartTime() == null ? "" : " from:" + column.getStartTime()), (column.getEndTime() == null
-                  ? "" : " upto:" + column.getEndTime()));
+            (column.getStartTime() == null ? "" : " from:" + column.getStartTime()), (column.getEndTime() == null
+            ? "" : " upto:" + column.getEndTime()));
         }
       }
     }
@@ -203,7 +195,7 @@ class TimerangeResolver implements ContextRewriter {
       for (TimeRange range : cubeql.getTimeRanges()) {
         if (isColumnLifeInvalid(column, range)) {
           LOG.info("Timerange queried is not in column life for " + column
-              + ", Removing join paths containing the column");
+            + ", Removing join paths containing the column");
           // Remove join paths containing this column
           Map<Aliased<Dimension>, List<SchemaGraph.JoinPath>> allPaths = joinContext.getAllPaths();
 
@@ -219,7 +211,7 @@ class TimerangeResolver implements ContextRewriter {
                 if (joinPaths.isEmpty()) {
                   // This dimension doesn't have any paths left
                   throw new SemanticException(ErrorMsg.NO_JOIN_PATH, "No valid join path available for dimension "
-                      + dimension + " which would satisfy time range " + range.getFromDate() + "-" + range.getToDate());
+                    + dimension + " which would satisfy time range " + range.getFromDate() + "-" + range.getToDate());
                 }
               }
             } // End loop to remove path
@@ -233,6 +225,6 @@ class TimerangeResolver implements ContextRewriter {
 
   private boolean isColumnLifeInvalid(CubeColumn column, TimeRange range) {
     return (column.getStartTime() != null && column.getStartTime().after(range.getFromDate()))
-        || (column.getEndTime() != null && column.getEndTime().before(range.getToDate()));
+      || (column.getEndTime() != null && column.getEndTime().before(range.getToDate()));
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/be5ee379/lens-cube/src/main/java/org/apache/lens/driver/cube/RewriteUtil.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/driver/cube/RewriteUtil.java b/lens-cube/src/main/java/org/apache/lens/driver/cube/RewriteUtil.java
index 16b18cf..4f284a7 100644
--- a/lens-cube/src/main/java/org/apache/lens/driver/cube/RewriteUtil.java
+++ b/lens-cube/src/main/java/org/apache/lens/driver/cube/RewriteUtil.java
@@ -19,35 +19,37 @@
 package org.apache.lens.driver.cube;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.ql.parse.ASTNode;
-import org.apache.hadoop.hive.ql.parse.HiveParser;
-import org.apache.hadoop.hive.ql.parse.ParseException;
-import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.lens.api.LensException;
 import org.apache.lens.cube.parse.CubeQueryRewriter;
 import org.apache.lens.cube.parse.HQLParser;
 import org.apache.lens.server.api.driver.LensDriver;
-
 import org.apache.lens.server.api.query.AbstractQueryContext;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.ParseException;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.log4j.Logger;
 
 /**
  * The Class RewriteUtil.
  */
-public class RewriteUtil {
+public final class RewriteUtil {
+  private RewriteUtil() {
+
+  }
   public static final Logger LOG = Logger.getLogger(RewriteUtil.class);
 
   /** The cube pattern. */
   static Pattern cubePattern = Pattern.compile(".*CUBE(.*)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE
-      | Pattern.DOTALL);
+    | Pattern.DOTALL);
 
   /** The matcher. */
   static Matcher matcher = null;
@@ -73,13 +75,10 @@ public class RewriteUtil {
   /**
    * Find cube positions.
    *
-   * @param query
-   *          the query
+   * @param query the query
    * @return the list
-   * @throws SemanticException
-   *           the semantic exception
-   * @throws ParseException
-   *           the parse exception
+   * @throws SemanticException the semantic exception
+   * @throws ParseException    the parse exception
    */
   static List<CubeQueryInfo> findCubePositions(String query) throws SemanticException, ParseException {
     ASTNode ast = HQLParser.parseHQL(query);
@@ -95,25 +94,21 @@ public class RewriteUtil {
   /**
    * Find cube positions.
    *
-   * @param ast
-   *          the ast
-   * @param cubeQueries
-   *          the cube queries
-   * @param originalQuery
-   *          the original query
-   * @throws SemanticException
-   *           the semantic exception
+   * @param ast           the ast
+   * @param cubeQueries   the cube queries
+   * @param originalQuery the original query
+   * @throws SemanticException the semantic exception
    */
   private static void findCubePositions(ASTNode ast, List<CubeQueryInfo> cubeQueries, String originalQuery)
-      throws SemanticException {
-    int child_count = ast.getChildCount();
+    throws SemanticException {
+    int childCount = ast.getChildCount();
     if (ast.getToken() != null) {
       if (ast.getChild(0) != null) {
         LOG.debug("First child:" + ast.getChild(0) + " Type:"
-            + ((ASTNode) ast.getChild(0)).getToken().getType());
+          + ((ASTNode) ast.getChild(0)).getToken().getType());
       }
       if (ast.getToken().getType() == HiveParser.TOK_QUERY
-          && ((ASTNode) ast.getChild(0)).getToken().getType() == HiveParser.KW_CUBE) {
+        && ((ASTNode) ast.getChild(0)).getToken().getType() == HiveParser.KW_CUBE) {
         LOG.debug("Inside cube clause");
         CubeQueryInfo cqi = new CubeQueryInfo();
         cqi.cubeAST = ast;
@@ -122,7 +117,7 @@ public class RewriteUtil {
           cqi.startPos = ast.getCharPositionInLine();
           int ci = ast.getChildIndex();
           if (parent.getToken() == null || parent.getToken().getType() == HiveParser.TOK_EXPLAIN
-              || parent.getToken().getType() == HiveParser.TOK_CREATETABLE) {
+            || parent.getToken().getType() == HiveParser.TOK_CREATETABLE) {
             // Not a sub query
             cqi.endPos = originalQuery.length();
           } else if (parent.getChildCount() > ci + 1) {
@@ -144,14 +139,14 @@ public class RewriteUtil {
             // or one for the string 'UNION ALL' if there are more union all
             LOG.debug("Child of union all");
             cqi.endPos = getEndPos(originalQuery, parent.getParent().getChild(1).getCharPositionInLine(), ")",
-                "UNION ALL");
+              "UNION ALL");
           }
         }
         LOG.debug("Adding cqi " + cqi + " query:" + originalQuery.substring(cqi.startPos, cqi.endPos));
         cubeQueries.add(cqi);
       } else {
-        for (int child_pos = 0; child_pos < child_count; ++child_pos) {
-          findCubePositions((ASTNode) ast.getChild(child_pos), cubeQueries, originalQuery);
+        for (int childPos = 0; childPos < childCount; ++childPos) {
+          findCubePositions((ASTNode) ast.getChild(childPos), cubeQueries, originalQuery);
         }
       }
     } else {
@@ -162,12 +157,9 @@ public class RewriteUtil {
   /**
    * Gets the end pos.
    *
-   * @param query
-   *          the query
-   * @param backTrackIndex
-   *          the back track index
-   * @param backTrackStr
-   *          the back track str
+   * @param query          the query
+   * @param backTrackIndex the back track index
+   * @param backTrackStr   the back track str
    * @return the end pos
    */
   private static int getEndPos(String query, int backTrackIndex, String... backTrackStr) {
@@ -189,11 +181,9 @@ public class RewriteUtil {
   /**
    * Gets the rewriter.
    *
-   * @param queryConf
-   *          the query conf
+   * @param queryConf the query conf
    * @return the rewriter
-   * @throws SemanticException
-   *           the semantic exception
+   * @throws SemanticException the semantic exception
    */
   static CubeQueryRewriter getCubeRewriter(Configuration queryConf) throws SemanticException {
     return new CubeQueryRewriter(queryConf);
@@ -203,8 +193,7 @@ public class RewriteUtil {
    * Replaces new lines with spaces; '&&' with AND; '||' with OR // these two can be removed once HIVE-5326 gets
    * resolved.
    *
-   * @param query
-   *          the query
+   * @param query the query
    * @return the replaced query
    */
   static String getReplacedQuery(final String query) {
@@ -214,11 +203,9 @@ public class RewriteUtil {
   /**
    * Rewrite query.
    *
-   * @param ctx
-   *          the query context
+   * @param ctx the query context
    * @return the map
-   * @throws LensException
-   *           the lens exception
+   * @throws LensException the lens exception
    */
   public static Map<LensDriver, String> rewriteQuery(AbstractQueryContext ctx) throws LensException {
     try {
@@ -270,7 +257,7 @@ public class RewriteUtil {
       }
       if (driverQueries.isEmpty()) {
         throw new LensException("No driver accepted the query, because "
-            + (useBuilder ? rewriteFailure.toString() : failureCause));
+          + (useBuilder ? rewriteFailure.toString() : failureCause));
       }
       return driverQueries;
     } catch (Exception e) {
@@ -281,8 +268,7 @@ public class RewriteUtil {
   /**
    * Checks if is cube query.
    *
-   * @param query
-   *          the query
+   * @param query the query
    * @return true, if is cube query
    */
   public static boolean isCubeQuery(String query) {