You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/06/24 03:44:07 UTC
[1/2] incubator-kylin git commit: KYLIN-849 Couldn't query metrics on
lookup table PK
Repository: incubator-kylin
Updated Branches:
refs/heads/0.8 d02016944 -> c40fac8d9
KYLIN-849 Couldn't query metrics on lookup table PK
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/76644fef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/76644fef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/76644fef
Branch: refs/heads/0.8
Commit: 76644fef7a86cfe93aa41e54f20af959931411bc
Parents: d020169
Author: shaofengshi <sh...@apache.org>
Authored: Wed Jun 24 09:34:48 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Jun 24 09:35:07 2015 +0800
----------------------------------------------------------------------
.../kylin/cube/CubeCapabilityChecker.java | 5 +++-
.../kylin/query/relnode/OLAPAggregateRel.java | 8 ++----
.../AdjustForWeaklyMatchedRealization.java | 2 +-
query/src/test/resources/query/sql/query80.sql | 27 ++++++++++++++++++++
4 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/76644fef/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
----------------------------------------------------------------------
diff --git a/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
index 52a57b0..21e2737 100644
--- a/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
+++ b/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
@@ -134,7 +134,10 @@ public class CubeCapabilityChecker {
if (functionDesc.isCountDistinct()) // calcite can not handle distinct count
matched = false;
- TblColRef col = functionDesc.selectTblColRef(metricColumns, cubeDesc.getFactTable());
+ TblColRef col = null;
+ if (functionDesc.getParameter().getColRefs().size() > 0)
+ col = functionDesc.getParameter().getColRefs().get(0);
+
if (col == null || !cubeDesc.listDimensionColumnsIncludingDerived().contains(col)) {
matched = false;
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/76644fef/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 e228d82..054a74e 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
@@ -18,12 +18,7 @@
package org.apache.kylin.query.relnode;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import net.hydromatic.optiq.AggregateFunction;
import net.hydromatic.optiq.FunctionParameter;
@@ -214,6 +209,7 @@ public class OLAPAggregateRel extends AggregateRelBase implements OLAPRel, Enume
parameter = new ParameterDesc();
parameter.setValue(column.getName());
parameter.setType("column");
+ parameter.setColRefs(Arrays.asList(column));
}
}
FunctionDesc aggFunc = new FunctionDesc();
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/76644fef/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeaklyMatchedRealization.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeaklyMatchedRealization.java b/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeaklyMatchedRealization.java
index eba309a..0840d06 100644
--- a/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeaklyMatchedRealization.java
+++ b/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeaklyMatchedRealization.java
@@ -86,7 +86,7 @@ public class AdjustForWeaklyMatchedRealization extends RoutingRule {
FunctionDesc functionDesc = it.next();
if (!availableAggregations.contains(functionDesc)) {
// try to convert the metric to dimension to see if it works
- TblColRef col = functionDesc.selectTblColRef(olapContext.metricsColumns, factTableName);
+ TblColRef col = functionDesc.getParameter().getColRefs().get(0);
functionDesc.setDimensionAsMetric(true);
olapContext.rewriteFields.remove(functionDesc.getRewriteFieldName());
if (col != null) {
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/76644fef/query/src/test/resources/query/sql/query80.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql/query80.sql b/query/src/test/resources/query/sql/query80.sql
new file mode 100644
index 0000000..1bcc90b
--- /dev/null
+++ b/query/src/test/resources/query/sql/query80.sql
@@ -0,0 +1,27 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+SELECT
+ min(test_cal_dt.cal_dt) as mmin
+ ,max(test_cal_dt.cal_dt) as mmax
+ FROM test_kylin_fact
+ inner JOIN edw.test_cal_dt as test_cal_dt
+ ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt
+ inner JOIN test_category_groupings
+ ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id
+ AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id
[2/2] incubator-kylin git commit: KYLIN-848 Couldn't resume or
discard a cube job as a normal user
Posted by sh...@apache.org.
KYLIN-848 Couldn't resume or discard a cube job as a normal user
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/c40fac8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/c40fac8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/c40fac8d
Branch: refs/heads/0.8
Commit: c40fac8d93bef72ca3f8820e18ca06894b77b72f
Parents: 76644fe
Author: shaofengshi <sh...@apache.org>
Authored: Wed Jun 24 09:43:22 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Jun 24 09:43:22 2015 +0800
----------------------------------------------------------------------
.../kylin/rest/controller/JobController.java | 6 +++--
.../apache/kylin/rest/service/JobService.java | 26 +++++++++++++-------
2 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/c40fac8d/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
index ed0901e..6427a98 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
@@ -168,7 +168,8 @@ public class JobController extends BasicController implements InitializingBean {
@ResponseBody
public JobInstance resume(@PathVariable String jobId) {
try {
- jobService.resumeJob(jobId);
+ final JobInstance jobInstance = jobService.getJobInstance(jobId);
+ jobService.resumeJob(jobInstance);
return jobService.getJobInstance(jobId);
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
@@ -187,7 +188,8 @@ public class JobController extends BasicController implements InitializingBean {
public JobInstance cancel(@PathVariable String jobId) {
try {
- return jobService.cancelJob(jobId);
+ final JobInstance jobInstance = jobService.getJobInstance(jobId);
+ return jobService.cancelJob(jobInstance);
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
throw new InternalErrorException(e);
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/c40fac8d/server/src/main/java/org/apache/kylin/rest/service/JobService.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/service/JobService.java b/server/src/main/java/org/apache/kylin/rest/service/JobService.java
index b671383..02e0527 100644
--- a/server/src/main/java/org/apache/kylin/rest/service/JobService.java
+++ b/server/src/main/java/org/apache/kylin/rest/service/JobService.java
@@ -45,6 +45,7 @@ import org.apache.kylin.metadata.model.SegmentStatusEnum;
import org.apache.kylin.rest.constant.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
@@ -60,6 +61,9 @@ public class JobService extends BasicService {
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(JobService.class);
+ @Autowired
+ private AccessService accessService;
+
public List<JobInstance> listAllJobs(final String cubeName, final String projectName, final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue) throws IOException, JobException {
Integer limit = (null == limitValue) ? 30 : limitValue;
Integer offset = (null == offsetValue) ? 0 : offsetValue;
@@ -151,7 +155,12 @@ public class JobService extends BasicService {
throw new JobException("invalid build type:" + buildType);
}
getExecutableManager().addJob(job);
- return getSingleJobInstance(job);
+ JobInstance jobInstance = getSingleJobInstance(job);
+
+ accessService.init(jobInstance, null);
+ accessService.inherit(jobInstance, cube);
+
+ return jobInstance;
}
public JobInstance getJobInstance(String uuid) throws IOException, JobException {
@@ -275,19 +284,18 @@ public class JobService extends BasicService {
}
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION') or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
- public void resumeJob(String jobId) throws IOException, JobException {
- getExecutableManager().resumeJob(jobId);
+ public void resumeJob(JobInstance job) throws IOException, JobException {
+ getExecutableManager().resumeJob(job.getId());
}
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION') or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
- public JobInstance cancelJob(String jobId) throws IOException, JobException {
+ public JobInstance cancelJob(JobInstance job) throws IOException, JobException {
// CubeInstance cube = this.getCubeManager().getCube(job.getRelatedCube());
// for (BuildCubeJob cubeJob: listAllCubingJobs(cube.getName(), null, EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING))) {
// getExecutableManager().stopJob(cubeJob.getId());
// }
- final JobInstance jobInstance = getJobInstance(jobId);
- final String segmentId = jobInstance.getRelatedSegment();
- CubeInstance cubeInstance = getCubeManager().getCube(jobInstance.getRelatedCube());
+ final String segmentId = job.getRelatedSegment();
+ CubeInstance cubeInstance = getCubeManager().getCube(job.getRelatedCube());
final CubeSegment segment = cubeInstance.getSegmentById(segmentId);
if (segment != null && segment.getStatus() == SegmentStatusEnum.NEW) {
// Remove this segments
@@ -296,8 +304,8 @@ public class JobService extends BasicService {
getCubeManager().updateCube(cubeBuilder);
}
- getExecutableManager().discardJob(jobId);
- return jobInstance;
+ getExecutableManager().discardJob(job.getId());
+ return job;
}
}