ktmud commented on code in PR #23257:
URL: https://github.com/apache/superset/pull/23257#discussion_r1123648439


##########
superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx:
##########
@@ -98,14 +100,27 @@ const AceEditorWrapper = ({
     'dbId',
     'sql',
     'functionNames',
-    'schemaOptions',
     'tableOptions',
     'validationResult',
     'schema',
   ]);
+  const { data: schemaOptions } = useSchemas({ dbId: queryEditor.dbId });
   const currentSql = queryEditor.sql ?? '';
   const functionNames = queryEditor.functionNames ?? [];
-  const schemas = queryEditor.schemaOptions ?? [];
+
+  // Loading schema, table and column names as auto-completable words
+  const { schemas, schemaWords } = useMemo(
+    () => ({
+      schemas: schemaOptions ?? [],
+      schemaWords: (schemaOptions ?? []).map(s => ({
+        name: s.label,
+        value: s.value,
+        score: SCHEMA_AUTOCOMPLETE_SCORE,
+        meta: 'schema',
+      })),
+    }),
+    [schemaOptions],
+  );

Review Comment:
   Do we really need a `useMemo` here? It may look cleaner to keep the words 
logic with other autocomplete words.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to