[6/7] kylin git commit: KYLIN-2030 bug fix
KYLIN-2030 bug fix Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/324e4239 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/324e4239 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/324e4239 Branch: refs/heads/master Commit: 324e4239c308ba5b14a46eb3187dad3186489f92 Parents: 46284bd Author: Hongbin MaAuthored: Sun Oct 9 19:07:52 2016 +0800 Committer: Hongbin Ma Committed: Thu Oct 27 08:30:13 2016 +0800 -- .../kylin/cube/CubeCapabilityChecker.java | 23 ++-- .../kylin/query/relnode/OLAPAggregateRel.java | 22 +++ 2 files changed, 25 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/kylin/blob/324e4239/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java -- diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java index ee21b1c..e509d98 100644 --- a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java @@ -81,7 +81,7 @@ public class CubeCapabilityChecker { //1. dimension as measure if (!unmatchedAggregations.isEmpty()) { -tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, cube.getDescriptor().listDimensionColumnsIncludingDerived()); +tryDimensionAsMeasures(unmatchedAggregations, result, cube.getDescriptor().listDimensionColumnsIncludingDerived()); } } else { //for non query-on-facttable @@ -92,10 +92,18 @@ public class CubeCapabilityChecker { dimCols.add(columnDesc.getRef()); } -//1. dimension as measure, like max(cal_dt) or count( distinct col) from lookup +//1. all aggregations on lookup table can be done. For distinct count, mark them all DimensionAsMeasures +// so that the measure has a chance to be upgraded to DimCountDistinctMeasureType in org.apache.kylin.metadata.model.FunctionDesc#reInitMeasureType if (!unmatchedAggregations.isEmpty()) { -tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, dimCols); +Iterator itr = unmatchedAggregations.iterator(); +while (itr.hasNext()) { +FunctionDesc functionDesc = itr.next(); +if (dimCols.containsAll(functionDesc.getParameter().getColRefs())) { +itr.remove(); +} +} } +tryDimensionAsMeasures(Lists.newArrayList(aggrFunctions), result, dimCols); //2. more "dimensions" contributed by snapshot if (!unmatchedDimensions.isEmpty()) { @@ -159,19 +167,12 @@ public class CubeCapabilityChecker { return result; } -private static void tryDimensionAsMeasures(Collection unmatchedAggregations, SQLDigest digest, CubeInstance cube, CapabilityResult result, Set dimCols) { -CubeDesc cubeDesc = cube.getDescriptor(); -Collection cubeFuncs = cubeDesc.listAllFunctions(); +private static void tryDimensionAsMeasures(Collection unmatchedAggregations, CapabilityResult result, Set dimCols) { Iterator it = unmatchedAggregations.iterator(); while (it.hasNext()) { FunctionDesc functionDesc = it.next(); -if (cubeFuncs.contains(functionDesc)) { -it.remove(); -continue; -} - // let calcite handle count if (functionDesc.isCount()) { it.remove(); http://git-wip-us.apache.org/repos/asf/kylin/blob/324e4239/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java -- diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java index d73206a..62351d3 100644 --- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java +++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java @@ -296,16 +296,20 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel { } private void translateAggregation() { -// now the realization is known, replace aggregations with what's defined on MeasureDesc -List measures = this.context.realization.getMeasures(); -List newAggrs =
[6/7] kylin git commit: KYLIN-2030 bug fix
KYLIN-2030 bug fix Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/662bfe91 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/662bfe91 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/662bfe91 Branch: refs/heads/orderedbytes4 Commit: 662bfe918e0fa2f3f195acfda815330dbcb32f21 Parents: 55584c6 Author: Hongbin MaAuthored: Sun Oct 9 19:07:52 2016 +0800 Committer: Hongbin Ma Committed: Wed Oct 26 14:42:48 2016 +0800 -- .../kylin/cube/CubeCapabilityChecker.java | 23 ++-- .../kylin/query/relnode/OLAPAggregateRel.java | 22 +++ 2 files changed, 25 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/kylin/blob/662bfe91/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java -- diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java index ee21b1c..e509d98 100644 --- a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java @@ -81,7 +81,7 @@ public class CubeCapabilityChecker { //1. dimension as measure if (!unmatchedAggregations.isEmpty()) { -tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, cube.getDescriptor().listDimensionColumnsIncludingDerived()); +tryDimensionAsMeasures(unmatchedAggregations, result, cube.getDescriptor().listDimensionColumnsIncludingDerived()); } } else { //for non query-on-facttable @@ -92,10 +92,18 @@ public class CubeCapabilityChecker { dimCols.add(columnDesc.getRef()); } -//1. dimension as measure, like max(cal_dt) or count( distinct col) from lookup +//1. all aggregations on lookup table can be done. For distinct count, mark them all DimensionAsMeasures +// so that the measure has a chance to be upgraded to DimCountDistinctMeasureType in org.apache.kylin.metadata.model.FunctionDesc#reInitMeasureType if (!unmatchedAggregations.isEmpty()) { -tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, dimCols); +Iterator itr = unmatchedAggregations.iterator(); +while (itr.hasNext()) { +FunctionDesc functionDesc = itr.next(); +if (dimCols.containsAll(functionDesc.getParameter().getColRefs())) { +itr.remove(); +} +} } +tryDimensionAsMeasures(Lists.newArrayList(aggrFunctions), result, dimCols); //2. more "dimensions" contributed by snapshot if (!unmatchedDimensions.isEmpty()) { @@ -159,19 +167,12 @@ public class CubeCapabilityChecker { return result; } -private static void tryDimensionAsMeasures(Collection unmatchedAggregations, SQLDigest digest, CubeInstance cube, CapabilityResult result, Set dimCols) { -CubeDesc cubeDesc = cube.getDescriptor(); -Collection cubeFuncs = cubeDesc.listAllFunctions(); +private static void tryDimensionAsMeasures(Collection unmatchedAggregations, CapabilityResult result, Set dimCols) { Iterator it = unmatchedAggregations.iterator(); while (it.hasNext()) { FunctionDesc functionDesc = it.next(); -if (cubeFuncs.contains(functionDesc)) { -it.remove(); -continue; -} - // let calcite handle count if (functionDesc.isCount()) { it.remove(); http://git-wip-us.apache.org/repos/asf/kylin/blob/662bfe91/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java -- diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java index d73206a..62351d3 100644 --- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java +++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java @@ -296,16 +296,20 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel { } private void translateAggregation() { -// now the realization is known, replace aggregations with what's defined on MeasureDesc -List measures = this.context.realization.getMeasures(); -List newAggrs =