Ver código fonte

HUE-9000 [editor] Add the optimizer enabled flag to the executor

Johan Ahlen 6 anos atrás
pai
commit
86449967d9

+ 3 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/executable.js

@@ -197,6 +197,7 @@ export default class Executable {
 
         throw err;
       }
+
       if (this.handle.has_result_set && this.handle.sync) {
         this.result = new ExecutionResult(this);
         if (this.handle.sync) {
@@ -206,7 +207,8 @@ export default class Executable {
           this.result.fetchRows();
         }
       }
-      if (true || this.isOptimizerEnabled()) {
+
+      if (this.executor.isOptimizerEnabled) {
         huePubSub.publish('editor.upload.query', this.history.id);
       }
 

+ 2 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/executor.js

@@ -29,6 +29,7 @@ class Executor {
    * @param {ContextNamespace} options.namespace
    * @param {string} options.statement
    * @param {string} [options.database]
+   * @param {boolean} [options.isOptimizerEnabled] - Default false
    * @param {Snippet} [options.snippet] - Optional snippet for history
    */
   constructor(options) {
@@ -37,6 +38,7 @@ class Executor {
     this.namespace = options.namespace;
     this.database = options.database;
     this.isSqlEngine = options.isSqlEngine;
+    this.isOptimizerEnabled = options.isOptimizerEnabled;
     this.executables = [];
 
     this.snippet = options.snippet;

+ 1 - 0
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -1006,6 +1006,7 @@ export default class Snippet {
       database: this.database,
       sourceType: this.type,
       namespace: this.namespace,
+      isOptimizerEnabled: this.parentVm.isOptimizerEnabled(),
       snippet: this,
       isSqlEngine: this.isSqlDialect
     });

+ 2 - 1
desktop/core/src/desktop/js/apps/notebook2/spec/notebookSpec.js

@@ -23,7 +23,8 @@ describe('notebook.js', () => {
     selectedNotebook: () => undefined,
     availableSnippets: () => ({}),
     editorMode: () => false,
-    getSnippetViewSettings: () => ({ sqlDialect: true })
+    getSnippetViewSettings: () => ({ sqlDialect: true }),
+    isOptimizerEnabled: () => false
   };
 
   window.HUE_CHARTS = {

+ 2 - 1
desktop/core/src/desktop/js/apps/notebook2/spec/snippetSpec.js

@@ -23,7 +23,8 @@ describe('snippet.js', () => {
     selectedNotebook: () => undefined,
     availableSnippets: () => ({}),
     editorMode: () => false,
-    getSnippetViewSettings: () => ({ sqlDialect: true })
+    getSnippetViewSettings: () => ({ sqlDialect: true }),
+    isOptimizerEnabled: () => false
   };
 
   window.HUE_CHARTS = {