You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/11/23 04:27:59 UTC

ambari git commit: AMBARI-13879. The Explain button sometimes re-writes the query and puts EXPLAIN at the start. (Pallav Kulshreshtha via Jaimin)

Repository: ambari
Updated Branches:
  refs/heads/trunk 6c53c254d -> 3b1e5c5d8


AMBARI-13879. The Explain button sometimes re-writes the query and puts EXPLAIN at the start. (Pallav Kulshreshtha via Jaimin)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3b1e5c5d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3b1e5c5d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3b1e5c5d

Branch: refs/heads/trunk
Commit: 3b1e5c5d8ead67622f48ef010cbeace397e08526
Parents: 6c53c25
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Sun Nov 22 19:25:02 2015 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Sun Nov 22 19:26:39 2015 -0800

----------------------------------------------------------------------
 .../ui/hive-web/app/components/query-editor.js  | 11 +----
 .../ui/hive-web/app/controllers/index.js        | 10 +++-
 .../tests/unit/components/query-editor-test.js  | 15 ------
 .../tests/unit/controllers/index-test.js        | 50 ++++++++++++++++++++
 4 files changed, 60 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3b1e5c5d/contrib/views/hive/src/main/resources/ui/hive-web/app/components/query-editor.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/query-editor.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/query-editor.js
index f119fc8..814262a 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/query-editor.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/query-editor.js
@@ -108,14 +108,5 @@ export default Ember.Component.extend({
     }).find('.ui-resizable-s').addClass('grip fa fa-reorder');
 
     this.tablesChanged();
-  }.on('didInsertElement'),
-
-  updateValue: function () {
-    var query = this.get('query');
-    var editor = this.get('editor');
-
-    if (editor.getValue() !== query) {
-      editor.setValue(query || '');
-    }
-  }.observes('query')
+  }.on('didInsertElement')
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b1e5c5d/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
index 735d2c5..a056759 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
@@ -294,7 +294,7 @@ export default Ember.Controller.extend({
           return constants.namingConventions.explainPrefix + query;
         }
       } else {
-        return query.replace(/explain formatted|explain/gi, '');
+        return query;
       }
     });
 
@@ -660,6 +660,14 @@ export default Ember.Controller.extend({
 
     executeQuery: function (referrer, query) {
       var self = this;
+
+      var isExplainQuery = (self.get('openQueries.currentQuery.fileContent').toUpperCase().trim().indexOf(constants.namingConventions.explainPrefix) === 0);
+
+      if(isExplainQuery){
+        self.send('explainQuery');
+        return;
+      }
+
       var subroute;
 
       if (query) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b1e5c5d/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js
index e70b5ee..91dc96f 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js
@@ -35,18 +35,3 @@ test('initEditor sets the editor on didInsertElement', function () {
   ok(component.get('editor'), 'element rendered. Editor set.');
 });
 
-test('updateValue sets the query value on the editor.', function () {
-  expect(1);
-
-  var component = this.subject();
-
-  var query = 'select something';
-
-  this.$();
-
-  Ember.run(function () {
-    component.set(('query'), query);
-  });
-
-  equal(component.get('editor').getValue(), query, 'set query property. Updated editor value property.');
-});

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b1e5c5d/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js
index d66c899..290f61e 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js
@@ -18,6 +18,7 @@
 
 import Ember from 'ember';
 import { moduleFor, test } from 'ember-qunit';
+import constants from 'hive/utils/constants';
 
 moduleFor('controller:index', 'IndexController', {
   needs: [
@@ -186,6 +187,55 @@ test('canExecute return false if queryParams doesnt\'t have values', function()
   ok(controller.get('canExecute'), 'Params with values => canExecute return true');
 });
 
+test('Execute EXPLAIN type query', function() {
+  expect(1);
+
+  var query = Ember.Object.create({
+    id: 1,
+    fileContent: "explain select 1" // explain type query
+  });
+
+  var controller = this.subject({
+    model: query,
+    _executeQuery: function (referer) {
+      equal(referer, constants.jobReferrer.explain, 'Explain type query successful.');
+      return {then: function() {}};
+    }
+  });
+
+  Ember.run(function() {
+      controller.set('openQueries.queryTabs', [query]);
+      controller.set('openQueries.currentQuery', query);
+      controller.send('executeQuery');
+  });
+
+});
+
+test('Execute non EXPLAIN type query', function() {
+  expect(1);
+
+  var query = Ember.Object.create({
+    id: 1,
+    fileContent: "select 1" //non explain type query
+  });
+
+  var controller = this.subject({
+    model: query,
+    _executeQuery: function (referer) {
+      equal(referer, constants.jobReferrer.job , 'non Explain type query successful.');
+      return {then: function() {}};
+    }
+  });
+
+  Ember.run(function() {
+      controller.set('openQueries.queryTabs', [query]);
+      controller.set('openQueries.currentQuery', query);
+      controller.send('executeQuery');
+  });
+
+});
+
+
 test('csvUrl returns if the current query is not a job', function() {
   expect(1);
   var content = Ember.Object.create({