Repository: lens Updated Branches: refs/heads/master 908530f58 -> 9c03c76e6
LENS-851 : Fix aliasing for non-aggregate functions in multi fact union query in where clause Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/9c03c76e Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/9c03c76e Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/9c03c76e Branch: refs/heads/master Commit: 9c03c76e6d79b1b45d79512b28bf021c52a007b3 Parents: 908530f Author: Rajat Khandelwal <[email protected]> Authored: Tue Jan 12 09:58:27 2016 +0530 Committer: Amareshwari Sriramadasu <[email protected]> Committed: Tue Jan 12 09:58:27 2016 +0530 ---------------------------------------------------------------------- .../lens/cube/parse/SingleFactMultiStorageHQLContext.java | 2 +- .../test/java/org/apache/lens/cube/parse/TestCubeRewriter.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lens/blob/9c03c76e/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactMultiStorageHQLContext.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactMultiStorageHQLContext.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactMultiStorageHQLContext.java index ac56328..7e3a0bf 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactMultiStorageHQLContext.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/SingleFactMultiStorageHQLContext.java @@ -220,7 +220,7 @@ public class SingleFactMultiStorageHQLContext extends UnionHQLContext { if (astNode == null) { return null; } - if (isAggregateAST(astNode) || isTableColumnAST(astNode)) { + if (isAggregateAST(astNode) || isTableColumnAST(astNode) || isNonAggregateFunctionAST(astNode)) { if (innerToOuterASTs.containsKey(new HashableASTNode(astNode))) { ASTNode ret = innerToOuterASTs.get(new HashableASTNode(astNode)); // Set parent null for quicker GC http://git-wip-us.apache.org/repos/asf/lens/blob/9c03c76e/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java index 4810559..698f36c 100644 --- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java +++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java @@ -419,7 +419,8 @@ public class TestCubeRewriter extends TestQueryRewrite { conf.setBoolean(CubeQueryConfUtil.ENABLE_STORAGES_UNION, true); hqlQuery = rewrite("select ascii(cityid) as `City ID`, msr8, msr7 as `Third measure` " - + "from testCube where cityid = 'a' and zipcode = 'b' and " + TWO_MONTHS_RANGE_UPTO_HOURS, conf); + + "from testCube where ascii(cityid) = 'c' and cityid = 'a' and zipcode = 'b' and " + + TWO_MONTHS_RANGE_UPTO_HOURS, conf); expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider, "SELECT testcube.alias0 as `City ID`, sum(testcube.alias1) + max(testcube.alias2), " @@ -429,7 +430,8 @@ public class TestCubeRewriter extends TestQueryRewrite { "select ascii(testcube.cityid) as `alias0`, sum(testcube.msr2) as `alias1`, " + "max(testcube.msr3) as `alias2`, " + "sum(case when testcube.cityid = 'x' then testcube.msr21 else testcube.msr22 end) as `alias3`", - "testcube.cityid = 'a' and testcube.zipcode = 'b'", "group by ascii(testcube.cityid)"); + "testcube.alias0 = 'c' and testcube.cityid = 'a' and testcube.zipcode = 'b'", + "group by ascii(testcube.cityid)"); compareQueries(hqlQuery, expected);
