Skip to content

Commit

Permalink
Merge 5bd802d into 43b248d
Browse files Browse the repository at this point in the history
  • Loading branch information
hit-lacus committed Jan 20, 2020
2 parents 43b248d + 5bd802d commit f136965
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public static String getToggle(String key) {
return map.get(key);
}

public static String getForceHitCube(){
return getString(DEBUG_TOGGLE_HIT_CUBE);
}

public static String getCoprocessorBehavior() {
return getString(DEBUG_TOGGLE_COPROCESSOR_BEHAVIOR);
}
Expand Down Expand Up @@ -383,4 +387,12 @@ public static Properties getJdbcDriverClientCalciteProps() {
}
*/
public final static String DEBUG_TOGGLE_STREAMING_DETAIL_PROFILE = "DEBUG_TOGGLE_STREAMING_DETAIL_PROFILE";


/**
* The cube chosen by Kylin may not be enough correct, user should have
* the right to choose which cube he want to query in some case, please
* check https://issues.apache.org/jira/browse/KYLIN-4312 for information.
*/
public final static String DEBUG_TOGGLE_HIT_CUBE = "DEBUG_TOGGLE_HIT_CUBE";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.debug.BackdoorToggles;
import org.apache.kylin.metadata.model.FunctionDesc;
import org.apache.kylin.metadata.realization.CapabilityResult;
import org.apache.kylin.metadata.realization.CapabilityResult.CapabilityInfluence;
Expand Down Expand Up @@ -53,6 +54,10 @@ public static IRealization selectRealization(OLAPContext olapContext, Set<IReali
for (IRealization real : realizations) {
if (real.isReady())
candidates.add(new Candidate(real, sqlDigest));
if (BackdoorToggles.getForceHitCube() != null && BackdoorToggles.getForceHitCube().equalsIgnoreCase(real.getName())) {
logger.info("Force choose {} as selected cube for specific purpose.", real.getName());
return real;
}
}

logger.info("Find candidates by table " + factTableName + " and project=" + projectName + " : "
Expand Down
28 changes: 26 additions & 2 deletions webapp/app/js/controllers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

KylinApp
.controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, $modal, MessageService, $domUtilityService, $timeout, TableService, SweetAlert, VdmUtil) {
.controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, CubeService, $modal, MessageService, $domUtilityService, $timeout, TableService, SweetAlert, VdmUtil) {
$scope.mainPanel = 'query';
if ($routeParams.queryPanel) {
$scope.mainPanel = $routeParams.queryPanel;
Expand Down Expand Up @@ -57,6 +57,8 @@ KylinApp
};

$scope.locationChangeConfirmed = false;
$scope.selectDirective = null;
$scope.cubeItems = [];

var Query = {
createNew: function (sql, project) {
Expand Down Expand Up @@ -250,7 +252,11 @@ KylinApp

$scope.query = function (query) {
scrollToButton();
QueryService.query({}, {sql: query.sql, offset: 0, limit: $scope.rowsPerPage, acceptPartial: query.acceptPartial, project: query.project}, function (result) {
var backdoorToggles = null;
if ($scope.selectDirective.selected != null && $scope.selectDirective.selected !== "-- All cubes in current project --") {
backdoorToggles = {"DEBUG_TOGGLE_HIT_CUBE": $scope.selectDirective.selected};
}
QueryService.query({}, {sql: query.sql, offset: 0, limit: $scope.rowsPerPage, acceptPartial: query.acceptPartial, project: query.project, backdoorToggles: backdoorToggles}, function (result) {
scrollToButton();
$scope.parseQueryResult(query, result, (!result || result.isException) ? 'failed' : 'success');
$scope.curQuery.result.hasMore = (query.result.results && query.result.results.length == $scope.rowsPerPage);
Expand Down Expand Up @@ -397,6 +403,10 @@ KylinApp
});
}

$scope.getSelected = function (selected) {
$scope.selectDirective = selected;
}

var saveQueryController = function ($scope, $modalInstance, curQuery, QueryService) {
$scope.curQuery = curQuery;

Expand All @@ -415,6 +425,20 @@ KylinApp
$scope.$watch('projectModel.selectedProject', function (newValue, oldValue) {
$scope.listCachedQueries();
$scope.listSavedQueries();
$scope.cubeItems = [];
$scope.cubeItems.push("-- All cubes in current project --")
if ($scope.selectDirective != null) {
$scope.selectDirective.clearSelected();
}
CubeService.list({projectName:newValue}, function (_cubes) {
if (_cubes !== 0) {
angular.forEach(_cubes,function(cube){
if (cube.status==="READY"){
$scope.cubeItems.push(cube.name);
}
})
}
})
});

$scope.$on('$locationChangeStart', function (event, next, current) {
Expand Down
4 changes: 4 additions & 0 deletions webapp/app/js/directives/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ uis.controller('uiSelectCtrl',
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '' || (ctrl.multiple && ctrl.selected.length === 0);
};

ctrl.clearSelected = function() {
ctrl.selected = undefined;
}

function _findIndex(collection, predicate, thisArg){
if (collection.findIndex){
return collection.findIndex(predicate, thisArg);
Expand Down
12 changes: 12 additions & 0 deletions webapp/app/partials/query/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
<div class="pull-left">
<h4>
Project: <span class="label label-info">{{projectModel.getSelectedProject()}}</span>
&nbsp&nbsp Cube:
<ui-select style="display: inline-flex; width: 250px" ng-model="mandatary_cube" ng-init="getSelected($select)">
<ui-select-match placeholder="Filter ..." style="overflow: auto;width: 250px">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="cube in cubeItems | filter:$select.search" style="word-break:break-all;">
<span ng-bind-html="cube | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
<i class="fa fa-info-circle" title="Specify cube to query" kylinpopover template="specifyCubeTip.html" placement="right"></i>
</h4>
</div>
<div class="pull-right">
Expand Down Expand Up @@ -229,3 +237,7 @@ <h3 class="kylin_title">
</div>

<div ng-include="'partials/projects/project_create.html'"></div>

<script type="text/ng-template" id="specifyCubeTip.html">
<p style="font-size: 8px;">Specify the cube to query, other cubes in current project won't be queried.</p>
</script>

0 comments on commit f136965

Please sign in to comment.