浏览代码

[editor] Fix issue with missing handle on a failed query in Editor v2

Johan Ahlen 5 年之前
父节点
当前提交
835d78dc58

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.executableLogs.js

@@ -136,7 +136,7 @@ class ExecutableLogs extends DisposableComponent {
   }
   }
 
 
   updateFromExecutable(executable) {
   updateFromExecutable(executable) {
-    this.hasResultset(executable.handle.has_result_set);
+    this.hasResultset(executable.handle && executable.handle.has_result_set);
     this.status(executable.status);
     this.status(executable.status);
     this.sourceType(executable.sourceType);
     this.sourceType(executable.sourceType);
     if (!this.compute) {
     if (!this.compute) {

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.snippetResults.js

@@ -275,7 +275,7 @@ class SnippetResults extends DisposableComponent {
 
 
   updateFromExecutable(executable) {
   updateFromExecutable(executable) {
     this.status(executable.status);
     this.status(executable.status);
-    this.hasResultSet(executable.handle.has_result_set);
+    this.hasResultSet(executable.handle && executable.handle.has_result_set);
     if (!this.hasResultSet) {
     if (!this.hasResultSet) {
       this.resetResultData();
       this.resetResultData();
     }
     }

+ 12 - 10
desktop/core/src/desktop/js/apps/notebook2/execution/executable.ts

@@ -58,7 +58,7 @@ export const EXECUTABLE_STATUS_TRANSITION_EVENT = 'hue.executable.status.transit
 export interface ExecutableRaw {
 export interface ExecutableRaw {
   executeEnded: number;
   executeEnded: number;
   executeStarted: number;
   executeStarted: number;
-  handle: ExecutionHandle;
+  handle?: ExecutionHandle;
   history?: ExecutionHistory;
   history?: ExecutionHistory;
   id: string;
   id: string;
   logs: ExecutionLogsRaw;
   logs: ExecutionLogsRaw;
@@ -69,15 +69,15 @@ export interface ExecutableRaw {
   type: string;
   type: string;
 }
 }
 
 
-const INITIAL_HANDLE: ExecutionHandle = {
-  statement_id: 0
-};
+// const INITIAL_HANDLE: ExecutionHandle = {
+//   statement_id: 0
+// };
 
 
 export default abstract class Executable {
 export default abstract class Executable {
   id: string = UUID();
   id: string = UUID();
   database?: string;
   database?: string;
   executor: Executor;
   executor: Executor;
-  handle: ExecutionHandle;
+  handle?: ExecutionHandle;
   operationId?: string;
   operationId?: string;
   history?: ExecutionHistory;
   history?: ExecutionHistory;
   status = EXECUTION_STATUS.ready;
   status = EXECUTION_STATUS.ready;
@@ -95,8 +95,6 @@ export default abstract class Executable {
 
 
   protected constructor(options: { executor: Executor }) {
   protected constructor(options: { executor: Executor }) {
     this.executor = options.executor;
     this.executor = options.executor;
-
-    this.handle = INITIAL_HANDLE;
     this.logs = new ExecutionLogs(this);
     this.logs = new ExecutionLogs(this);
   }
   }
 
 
@@ -231,7 +229,7 @@ export default abstract class Executable {
         throw err;
         throw err;
       }
       }
 
 
-      if (this.handle.has_result_set && this.handle.sync) {
+      if (this.handle && this.handle.has_result_set && this.handle.sync) {
         this.result = new ExecutionResult(this);
         this.result = new ExecutionResult(this);
         if (this.handle.sync) {
         if (this.handle.sync) {
           if (this.handle.result) {
           if (this.handle.result) {
@@ -253,6 +251,10 @@ export default abstract class Executable {
   }
   }
 
 
   async checkStatus(statusCheckCount?: number): Promise<void> {
   async checkStatus(statusCheckCount?: number): Promise<void> {
+    if (!this.handle) {
+      return;
+    }
+
     let checkStatusTimeout = -1;
     let checkStatusTimeout = -1;
 
 
     let actualCheckCount = statusCheckCount || 0;
     let actualCheckCount = statusCheckCount || 0;
@@ -277,7 +279,7 @@ export default abstract class Executable {
         this.executeEnded = Date.now();
         this.executeEnded = Date.now();
         this.setStatus(queryStatus.status);
         this.setStatus(queryStatus.status);
         this.setProgress(100);
         this.setProgress(100);
-        if (!this.result && this.handle.has_result_set) {
+        if (!this.result && this.handle && this.handle.has_result_set) {
           this.result = new ExecutionResult(this);
           this.result = new ExecutionResult(this);
           this.result.fetchRows();
           this.result.fetchRows();
         }
         }
@@ -378,7 +380,7 @@ export default abstract class Executable {
         await this.close();
         await this.close();
       } catch (err) {}
       } catch (err) {}
     }
     }
-    this.handle = INITIAL_HANDLE;
+    this.handle = undefined;
     this.setProgress(0);
     this.setProgress(0);
     this.setStatus(EXECUTION_STATUS.ready);
     this.setStatus(EXECUTION_STATUS.ready);
   }
   }