Explorar o código

HUE-8768 [editor] Send websocket channel in v2

Small comments to help differentiate where is the actual query context
Romain %!s(int64=5) %!d(string=hai) anos
pai
achega
5d9f15deff

+ 1 - 1
desktop/core/src/desktop/js/api/apiHelper.js

@@ -1870,7 +1870,7 @@ class ApiHelper {
 
     const promise = new Promise(async (resolve, reject) => {
       let data = {};
-      if (executable.executor.snippet) {
+      if (executable.executor.snippet) {  // V1
         // TODO: Refactor away the snippet, it currently works because snippet.statement is a computed from
         // the active executable, but we n
         data = {

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

@@ -376,7 +376,7 @@ export default class Executable {
   }
 
   async toContext(id) {
-    if (this.snippet) {
+    if (this.snippet) {  // V1
       return {
         operationId: this.operationId,
         snippet: this.snippet.toContextJson(),
@@ -410,7 +410,8 @@ export default class Executable {
       uuid: hueUtils.UUID(),
       name: '',
       isSaved: false,
-      sessions: [session]
+      sessions: [session],
+      editorWsChannel: window.WS_CHANNEL
     };
 
     return {

+ 8 - 4
desktop/libs/notebook/src/notebook/connectors/ksql.py

@@ -56,7 +56,7 @@ class KSqlApi(Api):
 
     data, description = self.db.query(
         snippet['statement'],
-        channel_name=snippet.get('editorWsChannel')
+        channel_name=notebook.get('editorWsChannel')
     )
     has_result_set = data is not None
 
@@ -94,8 +94,11 @@ class KSqlApi(Api):
         elif database == 'topics':
           response['tables_meta'] = self.db.show_topics()
         elif database == 'streams':
-          response['tables_meta'] = [
-            {'name': t['name'], 'type': t['type'], 'comment': 'Topic: %(topic)s Format: %(format)s' % t}
+          response['tables_meta'] = [{
+              'name': t['name'],
+              'type': t['type'],
+              'comment': 'Topic: %(topic)s Format: %(format)s' % t
+            }
             for t in self.db.show_streams()
           ]
       elif column is None:
@@ -105,7 +108,8 @@ class KSqlApi(Api):
             'comment': col.get('comment'),
             'name': col.get('name'),
             'type': str(col['schema'].get('type'))
-          } for col in columns
+          }
+          for col in columns
         ]
       else:
         response = {}