ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-15346. Hive view: Visual Explain does not work when there are multiple statements in the query editor (pallavkul)
Date Fri, 18 Mar 2016 07:28:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk bec76707f -> 795fac68f


AMBARI-15346. Hive view: Visual Explain does not work when there are multiple statements in
the query editor (pallavkul)


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

Branch: refs/heads/trunk
Commit: 795fac68f5b963ed6437d3bf902e7ce033f8b987
Parents: bec7670
Author: Pallav Kulshreshtha <pallav.kul@gmail.com>
Authored: Fri Mar 18 12:56:59 2016 +0530
Committer: Pallav Kulshreshtha <pallav.kul@gmail.com>
Committed: Fri Mar 18 12:58:19 2016 +0530

----------------------------------------------------------------------
 .../ui/hive-web/app/components/query-editor.js  | 16 ++++--------
 .../ui/hive-web/app/controllers/index.js        | 27 +++++++++++---------
 2 files changed, 20 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/795fac68/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 10c6bb3..34b293c 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
@@ -114,21 +114,15 @@ export default Ember.Component.extend({
     var query = this.get('query');
     var editor = this.get('editor');
 
-    var isEditorExplainQuery = (editor.getValue().toUpperCase().trim().indexOf('EXPLAIN')
=== 0);
-    var isFinalExplainQuery = (query.toUpperCase().trim().indexOf('EXPLAIN') === 0);
+    var isFinalExplainQuery = (query.toUpperCase().trim().indexOf('EXPLAIN') > -1);
+    var editorQuery = editor.getValue();
 
     if (editor.getValue() !== query) {
-
-      if(!isEditorExplainQuery && !isFinalExplainQuery){
-        editor.setValue(query || '');
-      } else if(!isEditorExplainQuery && isFinalExplainQuery){
-        editor.setValue(editor.getValue() || '');
-      } else if(isEditorExplainQuery && isFinalExplainQuery){
-        editor.setValue(editor.getValue() || '');
-      } else{
+      if(isFinalExplainQuery){
+        editor.setValue(editorQuery || '')
+      }else {
         editor.setValue(query || '');
       }
-
     }
 
   }.observes('query')

http://git-wip-us.apache.org/repos/asf/ambari/blob/795fac68/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 c6f50f4..9584508 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
@@ -284,19 +284,23 @@ export default Ember.Controller.extend({
     queries = queryComponents.queryString.split(';');
     queries = queries.filter(Boolean);
 
-    queries = queries.map(function (query) {
-      if (shouldExplain) {
-        query = query.replace(/explain formatted|explain/gi, '');
+    var queriesLength = queries.length;
 
-        if (shouldGetVisualExplain) {
-          return constants.namingConventions.explainFormattedPrefix + query;
-        } else {
-          return constants.namingConventions.explainPrefix + query;
-        }
+    queries = queries.map(function (q, index) {
+      var newQuery = q.replace(/explain formatted|explain/gi, '');
+      return newQuery;
+    });
+
+    var lastQuery = queries[queriesLength - 1];
+
+    if(!Ember.isNone(lastQuery) && shouldExplain) {
+      if (shouldGetVisualExplain) {
+        lastQuery = constants.namingConventions.explainFormattedPrefix + lastQuery;
       } else {
-        return query;
+        lastQuery = constants.namingConventions.explainPrefix + lastQuery;
       }
-    });
+      queries[queriesLength - 1] = lastQuery;
+    }
 
     if (queryComponents.files.length) {
       finalQuery += queryComponents.files.join("\n") + "\n\n";
@@ -306,8 +310,7 @@ export default Ember.Controller.extend({
       finalQuery += queryComponents.udfs.join("\n") + "\n\n";
     }
 
-    finalQuery += queries.join(";");
-    finalQuery += ";";
+    finalQuery += queries.join(";") + ";";
     return finalQuery.trim();
   },
 


Mime
View raw message