Pārlūkot izejas kodu

HUE-9456 [editor] Include the raw statement when executing in editor v2

With this change it's possible to read the query without the automatically added limit
Johan Ahlen 5 gadi atpakaļ
vecāks
revīzija
866cf29236

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

@@ -348,6 +348,8 @@ export default abstract class Executable {
 
   abstract getKey(): string;
 
+  abstract getRawStatement(): string;
+
   abstract getStatement(): string;
 
   abstract toJson(): string;
@@ -426,7 +428,6 @@ export default abstract class Executable {
 
   async toContext(id?: string): Promise<ExecutableContext> {
     const session = await sessionManager.getSession({ type: this.executor.connector().id });
-    const statement = this.getStatement();
     const snippet = {
       type: this.executor.connector().id,
       result: {
@@ -435,8 +436,8 @@ export default abstract class Executable {
       executor: this.executor.toJs(),
       status: this.status,
       id: id || UUID(),
-      statement_raw: statement,
-      statement: statement,
+      statement_raw: this.getRawStatement(),
+      statement: this.getStatement(),
       lastExecuted: this.executeStarted,
       variables: [],
       compute: this.executor.compute(),

+ 6 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/sqlExecutable.ts

@@ -43,8 +43,12 @@ export default class SqlExecutable extends Executable {
     this.parsedStatement = options.parsedStatement;
   }
 
+  getRawStatement(): string {
+    return this.parsedStatement.statement;
+  }
+
   getStatement(): string {
-    let statement = this.parsedStatement.statement;
+    let statement = this.getRawStatement();
     if (
       this.parsedStatement.firstToken &&
       this.parsedStatement.firstToken.toLowerCase() === 'select' &&
@@ -116,6 +120,7 @@ export default class SqlExecutable extends Executable {
   toJson(): string {
     return JSON.stringify({
       id: this.id,
+      parsedStatement: this.parsedStatement,
       statement: this.getStatement(),
       database: this.database
     });