Skip to content

Commit a45677c

Browse files
vsiskoakuznetsov-os
authored andcommitted
IGNITE-6287 Web Console: Improved DDL support: added checkbox "Use selected cache as default schema name".
1 parent dc514c7 commit a45677c

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,7 @@ private VisorQueryJob(VisorQueryTaskArg arg, boolean debug) {
9999
if (c == null)
100100
throw new SQLException("Fail to execute query. Cache not found: " + cacheName);
101101

102-
try {
103-
qryCursor = c.withKeepBinary().query(qry);
104-
}
105-
catch (CacheException e) {
106-
// Work around for DDL without explicit schema name.
107-
if (X.hasCause(e, IgniteSQLException.class)
108-
&& e.getMessage().contains("can only be executed on PUBLIC schema")) {
109-
qry.setSchema("PUBLIC");
110-
111-
qryCursor = c.withKeepBinary().query(qry);
112-
}
113-
else
114-
throw e;
115-
}
102+
qryCursor = c.withKeepBinary().query(qry);
116103
}
117104

118105
VisorQueryCursor<List<?>> cur = new VisorQueryCursor<>(qryCursor);

modules/web-console/backend/app/mongo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ module.exports.factory = function(passportMongo, settings, pluginMongo, mongoose
10361036
maxPages: Number,
10371037
hideSystemColumns: Boolean,
10381038
cacheName: String,
1039+
useAsDefaultSchema: Boolean,
10391040
chartsOptions: {barChart: {stacked: Boolean}, areaChart: {style: String}},
10401041
rate: {
10411042
value: Number,

modules/web-console/frontend/app/modules/sql/sql.controller.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const ENFORCE_JOIN_SINCE = [['1.7.9', '1.8.0'], ['1.8.4', '1.9.0'], '1.9.1'];
3232

3333
const LAZY_QUERY_SINCE = [['2.1.4-p1', '2.2.0'], '2.2.1'];
3434

35+
const DDL_SINCE = [['2.1.6', '2.2.0'], '2.3.0'];
36+
3537
const _fullColName = (col) => {
3638
const res = [];
3739

@@ -56,6 +58,7 @@ class Paragraph {
5658
self.qryType = paragraph.qryType || 'query';
5759
self.maxPages = 0;
5860
self.filter = '';
61+
self.useAsDefaultSchema = false;
5962

6063
_.assign(this, paragraph);
6164

@@ -1381,6 +1384,15 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
13811384
return false;
13821385
};
13831386

1387+
$scope.ddlAvailable = (paragraph) => {
1388+
const cache = _.find($scope.caches, {name: paragraph.cacheName});
1389+
1390+
if (cache)
1391+
return !!_.find(cache.nodes, (node) => Version.since(node.version, ...DDL_SINCE));
1392+
1393+
return false;
1394+
};
1395+
13841396
$scope.execute = (paragraph, local = false) => {
13851397
const nonCollocatedJoins = !!paragraph.nonCollocatedJoins;
13861398
const enforceJoinOrder = !!paragraph.enforceJoinOrder;
@@ -1399,7 +1411,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
13991411
.then(() => {
14001412
const args = paragraph.queryArgs = {
14011413
type: 'QUERY',
1402-
cacheName: paragraph.cacheName,
1414+
cacheName: ($scope.ddlAvailable(paragraph) && !paragraph.useAsDefaultSchema) ? null : paragraph.cacheName,
14031415
query: paragraph.query,
14041416
pageSize: paragraph.pageSize,
14051417
maxPages: paragraph.maxPages,

modules/web-console/frontend/public/stylesheets/style.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ body > .wrapper > ui-view {
304304
}
305305
}
306306

307+
.use-cache {
308+
display: flex;
309+
310+
input[type="checkbox"] {
311+
width: 20px;
312+
}
313+
}
314+
307315
.group-section {
308316
margin-top: 20px;
309317
}

modules/web-console/frontend/views/sql/sql.tpl.pug

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ mixin paragraph-query
240240
td(style='width: 100%')
241241
input.labelField(id='cache_{{ [paragraph.id, $index].join("_") }}' type='radio' value='{{cache.name}}' ng-model='paragraph.cacheName')
242242
label(for='cache_{{ [paragraph.id, $index].join("_") }} ' ng-bind-html='cache.label')
243+
.settings-row
244+
.row(ng-if='ddlAvailable(paragraph)')
245+
label.tipLabel.use-cache(bs-tooltip data-placement='bottom'
246+
data-title=
247+
'Use selected cache as default schema name.<br/>\
248+
This will allow to execute query on specified cache without specify schema name.<br/>\
249+
<b>NOTE:</b> In future version of Ignite this feature will be removed.'
250+
data-trigger='hover')
251+
input(type='checkbox' ng-model='paragraph.useAsDefaultSchema')
252+
span Use selected cache as default schema name
243253
.empty-caches(ng-show='displayedCaches.length == 0 && caches.length != 0')
244254
label Wrong caches filter
245255
.empty-caches(ng-show='caches.length == 0')

0 commit comments

Comments
 (0)