lens git commit: LENS-1208 : Fix join condition for outer join of multi fact queries for expression attributes
Repository: lens Updated Branches: refs/heads/master 42c4dfcb6 -> a736f4697 LENS-1208 : Fix join condition for outer join of multi fact queries for expression attributes Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/a736f469 Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/a736f469 Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/a736f469 Branch: refs/heads/master Commit: a736f4697ee91fa7949e4e895407dbcbf3d5e62b Parents: 42c4dfc Author: Amareshwari Sriramadasu Authored: Tue Jul 5 15:04:05 2016 +0530 Committer: Rajat Khandelwal Committed: Tue Jul 5 15:04:05 2016 +0530 -- .../apache/lens/cube/parse/CandidateFact.java | 19 +-- .../lens/cube/parse/ExpressionResolver.java | 2 ++ .../apache/lens/cube/parse/CubeTestSetup.java | 34 +++- .../lens/cube/parse/TestBaseCubeQueries.java| 30 +++-- 4 files changed, 79 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java -- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java index 187d98d..01265a5 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java @@ -180,8 +180,6 @@ public class CandidateFact implements CandidateTable, QueryAST { * @throws LensException */ public void updateASTs(CubeQueryContext cubeql) throws LensException { -Set cubeCols = cubeql.getCube().getAllFieldNames(); - // update select AST with selected fields int currentChild = 0; for (int i = 0; i < cubeql.getSelectAST().getChildCount(); i++) { @@ -189,7 +187,9 @@ public class CandidateFact implements CandidateTable, QueryAST { Set exprCols = HQLParser.getColsInExpr(cubeql.getAliasForTableName(cubeql.getCube()), selectExpr); if (getColumns().containsAll(exprCols)) { selectIndices.add(i); -if (cubeql.getCube().getDimAttributeNames().containsAll(exprCols)) { +if (exprCols.isEmpty() // no direct fact columns + // does not have measure names + || (!containsAny(cubeql.getCube().getMeasureNames(), exprCols))) { dimFieldIndices.add(i); } ASTNode aliasNode = HQLParser.findNodeByPath(selectExpr, Identifier); @@ -220,6 +220,19 @@ public class CandidateFact implements CandidateTable, QueryAST { // push down of having clauses happens just after this call in cubequerycontext } + // The source set contains atleast one column in the colSet + static boolean containsAny(Collection srcSet, Collection colSet) { +if (colSet == null || colSet.isEmpty()) { + return true; +} +for (String column : colSet) { + if (srcSet.contains(column)) { +return true; + } +} +return false; + } + @Override public String getStorageString(String alias) { return StringUtils.join(storageTables, ",") + " " + alias; http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java -- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java index 898c438..5adea6c 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java @@ -356,7 +356,9 @@ class ExpressionResolver implements ContextRewriter { ExpressionContext ec = getExpressionContext(expr, alias); if (cTable.getColumns().contains(expr)) { // expression is directly materialized in candidate table +log.debug("{} is directly evaluable in {}", expr, cTable); ec.addDirectlyAvailable(cTable); +return; } for (ExprSpecContext esc : ec.allExprs) { if (esc.getTblAliasToColumns().get(alias) == null) { http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java -- diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java index ea6b4a1..48652f2 100644 --- a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java +++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java @@ -1302,10 +130
[18/50] [abbrv] lens git commit: LENS-1208 : Fix join condition for outer join of multi fact queries for expression attributes
LENS-1208 : Fix join condition for outer join of multi fact queries for expression attributes Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/a736f469 Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/a736f469 Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/a736f469 Branch: refs/heads/current-release-line Commit: a736f4697ee91fa7949e4e895407dbcbf3d5e62b Parents: 42c4dfc Author: Amareshwari Sriramadasu Authored: Tue Jul 5 15:04:05 2016 +0530 Committer: Rajat Khandelwal Committed: Tue Jul 5 15:04:05 2016 +0530 -- .../apache/lens/cube/parse/CandidateFact.java | 19 +-- .../lens/cube/parse/ExpressionResolver.java | 2 ++ .../apache/lens/cube/parse/CubeTestSetup.java | 34 +++- .../lens/cube/parse/TestBaseCubeQueries.java| 30 +++-- 4 files changed, 79 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java -- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java index 187d98d..01265a5 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateFact.java @@ -180,8 +180,6 @@ public class CandidateFact implements CandidateTable, QueryAST { * @throws LensException */ public void updateASTs(CubeQueryContext cubeql) throws LensException { -Set cubeCols = cubeql.getCube().getAllFieldNames(); - // update select AST with selected fields int currentChild = 0; for (int i = 0; i < cubeql.getSelectAST().getChildCount(); i++) { @@ -189,7 +187,9 @@ public class CandidateFact implements CandidateTable, QueryAST { Set exprCols = HQLParser.getColsInExpr(cubeql.getAliasForTableName(cubeql.getCube()), selectExpr); if (getColumns().containsAll(exprCols)) { selectIndices.add(i); -if (cubeql.getCube().getDimAttributeNames().containsAll(exprCols)) { +if (exprCols.isEmpty() // no direct fact columns + // does not have measure names + || (!containsAny(cubeql.getCube().getMeasureNames(), exprCols))) { dimFieldIndices.add(i); } ASTNode aliasNode = HQLParser.findNodeByPath(selectExpr, Identifier); @@ -220,6 +220,19 @@ public class CandidateFact implements CandidateTable, QueryAST { // push down of having clauses happens just after this call in cubequerycontext } + // The source set contains atleast one column in the colSet + static boolean containsAny(Collection srcSet, Collection colSet) { +if (colSet == null || colSet.isEmpty()) { + return true; +} +for (String column : colSet) { + if (srcSet.contains(column)) { +return true; + } +} +return false; + } + @Override public String getStorageString(String alias) { return StringUtils.join(storageTables, ",") + " " + alias; http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java -- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java index 898c438..5adea6c 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/ExpressionResolver.java @@ -356,7 +356,9 @@ class ExpressionResolver implements ContextRewriter { ExpressionContext ec = getExpressionContext(expr, alias); if (cTable.getColumns().contains(expr)) { // expression is directly materialized in candidate table +log.debug("{} is directly evaluable in {}", expr, cTable); ec.addDirectlyAvailable(cTable); +return; } for (ExprSpecContext esc : ec.allExprs) { if (esc.getTblAliasToColumns().get(alias) == null) { http://git-wip-us.apache.org/repos/asf/lens/blob/a736f469/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java -- diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java index ea6b4a1..48652f2 100644 --- a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java +++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java @@ -1302,10 +1302,26 @@ public class CubeTestSetup { factColumns.add(new Fiel