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


##########
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:
   Yes. useMemo will reduce the cost of `schemaWords` mapping from 
schemaOptions.
   (For example, airbnb has > 10,000 schema options so `useMemo` should be 
needed)



-- 
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