LENS-927 : Fix intermittent test failure due to alias look up in JoinTree
Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/7035de9d Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/7035de9d Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/7035de9d Branch: refs/heads/current-release-line Commit: 7035de9d73f2df1e72111d43875b0e21d82feaf5 Parents: 27a0cad Author: Amareshwari Sriramadasu <amareshw...@gmail.com> Authored: Mon Jan 25 14:00:31 2016 +0530 Committer: Rajat Khandelwal <rajatgupt...@gmail.com> Committed: Mon Jan 25 14:00:31 2016 +0530 ---------------------------------------------------------------------- .../main/java/org/apache/lens/cube/parse/join/JoinClause.java | 7 ++----- .../main/java/org/apache/lens/cube/parse/join/JoinTree.java | 6 ++---- .../apache/lens/cube/parse/TestDenormalizationResolver.java | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lens/blob/7035de9d/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinClause.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinClause.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinClause.java index acc9d5c..4325252 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinClause.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinClause.java @@ -122,13 +122,10 @@ public class JoinClause implements Comparable<JoinClause> { // Last element in this list is link from cube to first dimension 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); + current = current.addChild(entry.getValue().get(i), aliasUsage); } // 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) { - current.setAlias(entry.getKey().getAlias()); - } + current.setAlias(entry.getKey().getAlias()); } if (root.getSubtrees().size() > 0) { root.setAlias(cubeql.getAliasForTableName( http://git-wip-us.apache.org/repos/asf/lens/blob/7035de9d/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinTree.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinTree.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinTree.java index 197847c..bcbfed5 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinTree.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/join/JoinTree.java @@ -22,7 +22,6 @@ import java.util.*; import org.apache.lens.cube.metadata.AbstractCubeTable; import org.apache.lens.cube.metadata.join.TableRelationship; -import org.apache.lens.cube.parse.CubeQueryContext; import org.apache.hadoop.hive.ql.parse.JoinType; @@ -57,8 +56,7 @@ public class JoinTree { this.depthFromRoot = depthFromRoot; } - public JoinTree addChild(TableRelationship tableRelationship, - CubeQueryContext query, Map<String, Integer> aliasUsage) { + public JoinTree addChild(TableRelationship tableRelationship, Map<String, Integer> aliasUsage) { if (getSubtrees().get(tableRelationship) == null) { JoinTree current = new JoinTree(this, tableRelationship, this.depthFromRoot + 1); @@ -68,7 +66,7 @@ public class JoinTree { // And for destination tables, an alias will be decided from here but might be // overridden outside this function. AbstractCubeTable destTable = tableRelationship.getToTable(); - current.setAlias(query.getAliasForTableName(destTable.getName())); + current.setAlias(destTable.getName()); if (aliasUsage.get(current.getAlias()) == null) { aliasUsage.put(current.getAlias(), 0); } else { http://git-wip-us.apache.org/repos/asf/lens/blob/7035de9d/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDenormalizationResolver.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDenormalizationResolver.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDenormalizationResolver.java index d7707a9..51ba636 100644 --- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDenormalizationResolver.java +++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDenormalizationResolver.java @@ -89,8 +89,8 @@ public class TestDenormalizationResolver extends TestQueryRewrite { String expected = getExpectedQuery(cubeName, "select dim3chain.name, testcube.dim2big1, max(testcube.msr3), sum(testcube.msr2) FROM ", " JOIN " - + getDbName() + "c2_testdim2tbl3 dim2chain " + "on testcube.dim2big1 = dim2chain.bigid1" + " join " - + getDbName() + "c2_testdim3tbl dim3chain on " + "dim2chain.testdim3id = dim3chain.id", null, + + getDbName() + "c2_testdim2tbl3 testdim2 " + "on testcube.dim2big1 = testdim2.bigid1" + " join " + + getDbName() + "c2_testdim3tbl dim3chain on " + "testdim2.testdim3id = dim3chain.id", null, " group by dim3chain.name, (testcube.dim2big1)", null, getWhereForDailyAndHourly2daysWithTimeDim(cubeName, "it", "C2_summary4"), null);