dpgaspar commented on a change in pull request #10442:
URL: 
https://github.com/apache/incubator-superset/pull/10442#discussion_r462167421



##########
File path: superset-frontend/src/views/CRUD/dataset/AddDatasetModal.tsx
##########
@@ -97,8 +97,13 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
         onHide();
       })
       .catch(
-        createErrorHandler(errMsg =>
-          addDangerToast(t('Error while saving dataset: %s', errMsg)),
+        createErrorHandler((errMsg: unknown) =>
+          addDangerToast(
+            t(
+              'Error while saving dataset: %s',
+              (errMsg as { table_name?: string }).table_name,

Review comment:
       Exactly!

##########
File path: superset-frontend/src/views/CRUD/dataset/DatasetList.tsx
##########
@@ -66,78 +66,40 @@ interface DatasetListProps {
   addDangerToast: (msg: string) => void;
   addSuccessToast: (msg: string) => void;
 }
-interface Database {
-  allow_csv_upload: boolean;
-  allow_ctas: boolean;
-  allow_cvas: null | boolean;
-  allow_dml: boolean;
-  allow_multi_schema_metadata_fetch: boolean;
-  allow_run_async: boolean;
-  allows_cost_estimate: boolean;
-  allows_subquery: boolean;
-  allows_virtual_table_explore: boolean;
-  backend: string;
-  database_name: string;
-  explore_database_id: number;
-  expose_in_sqllab: boolean;
-  force_ctas_schema: null | boolean;
-  function_names: string[];
-  id: number;
-}
-
-const createFetchDatabases = (handleError: (err: Response) => void) => async (
-  filterValue = '',
-  pageIndex?: number,
-  pageSize?: number,
-) => {
-  try {
-    const queryParams = rison.encode({
-      columns: ['database_name', 'id'],
-      keys: ['none'],
-      ...(pageIndex ? { page: pageIndex } : {}),
-      ...(pageSize ? { page_size: pageSize } : {}),
-      ...(filterValue ? { filter: filterValue } : {}),
-    });
-    const { json = {} } = await SupersetClient.get({
-      endpoint: `/api/v1/database/?q=${queryParams}`,
-    });
-
-    return json?.result?.map(
-      ({ database_name: label, id: value }: Database) => ({
-        label,
-        value,
-      }),
-    );
-  } catch (e) {
-    handleError(e);
-  }
-  return [];
-};
 
 export const createFetchSchemas = (
   handleError: (error: Response) => void,
 ) => async (filterValue = '', pageIndex?: number, pageSize?: number) => {
+  // add filters if filterValue
+  const filters = filterValue
+    ? { filters: [{ col: 'schema', opr: 'sw', value: filterValue }] }
+    : {};
   try {
     const queryParams = rison.encode({
+      columns: ['schema'],
+      keys: ['none'],
       ...(pageIndex ? { page: pageIndex } : {}),
       ...(pageSize ? { page_size: pageSize } : {}),
-      ...(filterValue ? { filter: filterValue } : {}),
+      ...filters,
     });
     const { json = {} } = await SupersetClient.get({
-      endpoint: `/api/v1/database/schemas/?q=${queryParams}`,
+      endpoint: `/api/v1/dataset/?q=${queryParams}`,
     });
 
-    return json?.result?.map(
-      ({ text: label, value }: { text: string; value: any }) => ({
-        label,
-        value,
-      }),
+    const schemas: string[] = json?.result?.map(
+      ({ schema }: { schema: string }) => schema,
     );
+
+    // uniqueify schema values and create options

Review comment:
       yes, good point we probably need to do it




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

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