KYLIN-1122 fixed SQLDigest.isRawQuery derive logic
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/b487f407 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/b487f407 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/b487f407 Branch: refs/heads/1.3.x Commit: b487f40760dd610477c83e1e4afa6d57c418c7ba Parents: 97b2786 Author: wangxiaoyu <romansew...@gmail.com> Authored: Sun Mar 20 21:57:08 2016 +0800 Committer: Xiaoyu Wang <wangxia...@apache.org> Committed: Mon Mar 21 20:01:04 2016 +0800 ---------------------------------------------------------------------- .../java/org/apache/kylin/measure/raw/RawMeasureType.java | 4 ++-- .../java/org/apache/kylin/metadata/realization/SQLDigest.java | 7 ++++++- .../org/apache/kylin/query/enumerator/CubeEnumerator.java | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/b487f407/metadata/src/main/java/org/apache/kylin/measure/raw/RawMeasureType.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/kylin/measure/raw/RawMeasureType.java b/metadata/src/main/java/org/apache/kylin/measure/raw/RawMeasureType.java index c6b1637..e67ca9b 100644 --- a/metadata/src/main/java/org/apache/kylin/measure/raw/RawMeasureType.java +++ b/metadata/src/main/java/org/apache/kylin/measure/raw/RawMeasureType.java @@ -160,7 +160,7 @@ public class RawMeasureType extends MeasureType<List<ByteArray>> { public CapabilityResult.CapabilityInfluence influenceCapabilityCheck(Collection<TblColRef> unmatchedDimensions, Collection<FunctionDesc> unmatchedAggregations, SQLDigest digest, MeasureDesc measureDesc) { //is raw query - if (digest.aggregations.size() != 0 || digest.metricColumns.size() != 0) + if (!digest.isRawQuery()) return null; TblColRef rawColumn = getRawColumn(measureDesc.getFunction()); @@ -191,7 +191,7 @@ public class RawMeasureType extends MeasureType<List<ByteArray>> { @Override public void adjustSqlDigest(MeasureDesc measureDesc, SQLDigest sqlDigest) { - if (sqlDigest.isRawQuery) { + if (sqlDigest.isRawQuery()) { TblColRef col = this.getRawColumn(measureDesc.getFunction()); ParameterDesc colParameter = new ParameterDesc(); colParameter.setType("column"); http://git-wip-us.apache.org/repos/asf/kylin/blob/b487f407/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java index 3e124ba..16e268e 100644 --- a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java +++ b/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java @@ -37,7 +37,7 @@ public class SQLDigest { public Collection<TblColRef> filterColumns; public Collection<TblColRef> metricColumns; public Collection<FunctionDesc> aggregations; - public boolean isRawQuery = false; + private boolean isRawQuery = false; public SQLDigest(String factTable, TupleFilter filter, Collection<JoinDesc> joinDescs, Collection<TblColRef> allColumns, // Collection<TblColRef> groupbyColumns, Collection<TblColRef> filterColumns, Collection<TblColRef> aggregatedColumns, Collection<FunctionDesc> aggregateFunnc) { @@ -49,6 +49,11 @@ public class SQLDigest { this.filterColumns = filterColumns; this.metricColumns = aggregatedColumns; this.aggregations = aggregateFunnc; + this.isRawQuery = this.groupbyColumns.isEmpty() && this.metricColumns.isEmpty(); + } + + public boolean isRawQuery() { + return isRawQuery; } @Override http://git-wip-us.apache.org/repos/asf/kylin/blob/b487f407/query/src/main/java/org/apache/kylin/query/enumerator/CubeEnumerator.java ---------------------------------------------------------------------- diff --git a/query/src/main/java/org/apache/kylin/query/enumerator/CubeEnumerator.java b/query/src/main/java/org/apache/kylin/query/enumerator/CubeEnumerator.java index a556847..66a4035 100644 --- a/query/src/main/java/org/apache/kylin/query/enumerator/CubeEnumerator.java +++ b/query/src/main/java/org/apache/kylin/query/enumerator/CubeEnumerator.java @@ -192,7 +192,6 @@ public class CubeEnumerator implements Enumerator<Object[]> { if (!sqlDigest.groupbyColumns.isEmpty() || !sqlDigest.metricColumns.isEmpty()) return; - sqlDigest.isRawQuery = true; // If no group by and metric found, then it's simple query like select ... from ... where ..., // But we have no raw data stored, in order to return better results, we hack to output sum of metric column logger.info("No group by and aggregation found in this query, will hack some result for better look of output...");