You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "jessie-ross (via GitHub)" <gi...@apache.org> on 2024/01/02 10:13:32 UTC

[PR] feat: [SIP TBD] Google Sheets Export [WIP] [superset]

jessie-ross opened a new pull request, #26391:
URL: https://github.com/apache/superset/pull/26391

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   This PR implements https://github.com/apache/superset/issues/26390
   
   I've marked this as a WIP but it's a fully working implementation, missing is:
   - [ ] Testing.
   - [ ] Need to look into the documentation system.
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   **Before:**
   ![Screenshot 2024-01-02 at 5 08 30 pm](https://github.com/apache/superset/assets/971886/ad16668e-4176-4a73-b56b-d818752e85eb)
   
   **After**
   ![Screenshot 2024-01-02 at 5 08 43 pm](https://github.com/apache/superset/assets/971886/62910e16-c3ad-4f5d-a85f-7a0bd2505689)
   
   **Video Demo**
   
   https://github.com/apache/superset/assets/971886/78504a9f-727e-4a9e-a278-bb58a547f025
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   See the added docs:
   1. Follow setup instructions in the docs.
   2. Run a query in SqlLab.
   3. Click the "Google Sheets" button under the new "Export" dropdown.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: https://github.com/apache/superset/issues/26390
   - [x] Required feature flags:
      - `GOOGLE_SHEETS_EXPORT`
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-2294013792

   It's taken me a while to get back round to this but I've successfully tested this change in our work environment, I've fixed bugs around serialization of data, and I've improved the handling of permissions in the front-end to match other changes to the codebase.
   
   This PR is now ready for review :)


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "sivankumar86 (via GitHub)" <gi...@apache.org>.
sivankumar86 commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-2257404318

   Could you add support in report creation as well ? export the report to google sheet from schedule 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP TBD] Google Sheets Export [WIP] [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1440104920


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   > A more complex alternative would be to perform the export on the backend, and provide a notification to the user when it's done. I'm not sure if Superset has this kind of thing set up.
   
   I guess I could do this in the front-end with toasts actually, that would be a viable alternative to me.
   
   But I still prefer the UX and simplicity of the separate page.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1548916998


##########
superset/sqllab/api.py:
##########
@@ -236,6 +240,7 @@ def format_sql(self) -> FlaskResponse:
             return self.response_400(message=error.messages)
 
     @expose("/export/<string:client_id>/")

Review Comment:
   I'm happy to go either way on the url format, the two are equivalent:
   ```
   /export/<client-id>/?format=csv
   /export/<client-id>/?format=google-sheets
   /export/<client-id>/   (csv, deprecated)
   ```
   
   ```
   /export/<client-id>/csv/
   /export/<client-id>/google-sheets/
   /export/<client-id>/   (csv, deprecated)
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross closed pull request #26391: feat: [SIP-114] Google Sheets Export (part 1)
URL: https://github.com/apache/superset/pull/26391


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1550739140


##########
superset/sqllab/api.py:
##########
@@ -236,6 +240,7 @@ def format_sql(self) -> FlaskResponse:
             return self.response_400(message=error.messages)
 
     @expose("/export/<string:client_id>/")

Review Comment:
   I'm happy to do that too, it is really an overall API design point, and I'm not sure how Superset does things.
   
   In my mind deprecated doesn't mean it has to ever be removed, so it never has to be a breaking change.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-2294010043

   > Could you add support in report creation as well
   
   @sivankumar86 Something like this is in the SIP, I plan to add it in after this PR.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1440104082


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   My reasoning is that using an separate page provides a better user experience, and helps decouple the code.
   
   It prevents popup blocker issues, but more importantly, this process can take some time, especially as the backend might need to rerun a query for export:
   https://github.com/apache/superset/blob/9033e72679fad7efdabc0f5b28607d974a7b5e1f/superset/commands/sql_lab/export.py?plain=1#L112-L126
   
   Our databases (SparkSQL mainly) are particularly slow, and then adding on top of that expensive queries and large amounts of data that need to be moved, we're looking at a 1m average wait time, with the upper bounds being around 15m.
   
   By having this process occur on a separate page it allows the export to happen asynchronously, and for the user to continue their use of Superset while the export occurs.
   Notably the CSV export already behaves like this - the download starts asynchronously to the UI.
   
   Simple alternatives would be a modal, or hover popup, suffering from the long loading time issue.
   
   A more complex alternative would be to perform the export on the backend, and provide a notification to the user when it's done. I'm not sure if Superset has this kind of thing set up.
   
   



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1719437838


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -316,6 +326,37 @@ const ResultSet = ({
         user?.roles,
       );

Review Comment:
   I'm not sure if we missed an upgrade step in our installation but the view was named `SqlLab` instead of `SQLLab` in our database and we had to run `flask fab security-converge`.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1723161198


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { SupersetClient, t } from '@superset-ui/core';
+import { useEffect, useState } from 'react';
+import { useDispatch } from 'react-redux';
+import { useParams } from 'react-router-dom';
+import Loading from 'src/components/Loading';
+import {
+  addDangerToast,
+  addInfoToast,
+} from 'src/components/MessageToasts/actions';
+
+export default function ExportGoogleSheets() {
+  const { clientId }: any = useParams();
+  const dispatch = useDispatch();
+  const [{ isLoading, data, error }, setState] = useState<{
+    isLoading: boolean;
+    data: any;
+    error: any;
+  }>({ isLoading: true, data: null, error: null });
+  useEffect(() => {
+    if (!dispatch || !clientId) {
+      return;
+    }
+    dispatch(
+      addInfoToast(t('Exporting results to Google Sheets'), { duration: 0 }),
+    );
+    SupersetClient.get({
+      endpoint: `/api/v1/sqllab/export/${clientId}/google-sheets/`,
+    })
+      .then(res => setState({ data: res.json, isLoading: false, error: null }))
+      .catch(e => setState({ data: null, isLoading: false, error: e }));

Review Comment:
   Addressed in https://github.com/apache/superset/pull/26391/commits/b537fcbc175ee18ff75284a373e9c93ad24dae16



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP TBD] Google Sheets Export [WIP] [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1439663162


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   This blank page appears to be superfluous. It might be more efficient to incorporate this logic within the SQL Lab page and only display the page for the Google Sheets link if the operation is successful.



##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -283,10 +320,15 @@ const ResultSet = ({
                 onClick={createExploreResultsOnClick}
               />
             )}
-            {csv && (
-              <Button buttonSize="small" href={getExportCsvUrl(query.id)}>
-                <i className="fa fa-file-text-o" /> {t('Download to CSV')}
-              </Button>
+            {hasExports && (
+              <AntdDropdown overlay={ExportMenu}>
+                <Button>
+                  <Space>
+                    Export

Review Comment:
   ```suggestion
                       {t('Export')}
   ```



##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { SupersetClient, t } from '@superset-ui/core';
+import React, { useEffect, useState } from 'react';
+import { useDispatch } from 'react-redux';
+import { useParams } from 'react-router-dom';
+import Loading from 'src/components/Loading';
+import {
+  addDangerToast,
+  addInfoToast,
+} from 'src/components/MessageToasts/actions';
+
+export default function ExportGoogleSheets() {
+  const { clientId }: any = useParams();
+  const dispatch = useDispatch();
+  const [{ isLoading, data, error }, setState] = useState<{
+    isLoading: boolean;
+    data: any;
+    error: any;
+  }>({ isLoading: true, data: null, error: null });
+  useEffect(() => {
+    if (!dispatch || !clientId) {
+      return;
+    }
+    dispatch(
+      addInfoToast(t('Exporting results to Google Sheets'), { duration: 0 }),
+    );
+    SupersetClient.get({
+      endpoint: `/api/v1/sqllab/export/${clientId}/google-sheets/`,
+    })
+      .then(res => setState({ data: res.json, isLoading: false, error: null }))
+      .catch(e => setState({ data: null, isLoading: false, error: e }));
+  }, [dispatch, clientId]);

Review Comment:
   You can simplify this logic by using [rdk-query](https://redux-toolkit.js.org/tutorials/rtk-query).
   
   ```suggestion
   const gSheetApi = api.injectEndpoints({
     endpoints: builder => ({
       export: builder.query({
         query: ({ clientId }) => ({
           endpoint: `/api/v1/sqllab/export/${clientId}/google-sheets/`,
           transformResponse: ({ json }) => json,
         })
       }),
     }),
   });
   export const { useExportQuery } = gSheetApi;
   
   ```



##########
superset-frontend/src/views/routes.tsx:
##########
@@ -245,6 +252,12 @@ if (isFeatureEnabled(FeatureFlag.TAGGING_SYSTEM)) {
     Component: Tags,
   });
 }
+if (isFeatureEnabled(FeatureFlag.GOOGLE_SHEETS_EXPORT)) {
+  routes.push({
+    path: '/export/:clientId/google-sheets/',
+    Component: ExportGoogleSheets,
+  });
+}

Review Comment:
   ```suggestion
   ```



##########
superset-frontend/src/views/routes.tsx:
##########
@@ -127,6 +127,13 @@ const Profile = lazy(
   () => import(/* webpackChunkName: "Profile" */ 'src/pages/Profile'),
 );
 
+const ExportGoogleSheets = lazy(
+  () =>
+    import(
+      /* webpackChunkName: "ExportGoogleSheets" */ 'src/pages/ExportGoogleSheets'
+    ),
+);
+

Review Comment:
   ```suggestion
   ```



##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -264,6 +272,35 @@ const ResultSet = ({
         schema: query?.schema,
       };
 
+      // Antd >= 4.24.0 format:
+      const exportMenuItems = [];
+      exportMenuItems.push({
+        label: t('CSV'),
+        key: 'csv',
+        icon: <Icons.FileOutlined />,
+        onClick: () =>
+          window.open(getExportCsvUrl(query.id), '_blank')?.focus(),
+      });
+      if (isFeatureEnabled(FeatureFlag.GOOGLE_SHEETS_EXPORT)) {
+        exportMenuItems.push({
+          label: t('Google Sheets'),
+          key: 'google-sheets',
+          icon: <Icons.GoogleOutlined />,
+          onClick: () =>
+            window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),

Review Comment:
   This onClick handler should have the logic for gSheetApi request.
   ```suggestion
        const [trigger, { data, isLoading, isError }] = useLazyExportQuery();
        ---
        onClick: () => trigger({ clientId: getExportGoogleSheetsUrl(query.id) }),
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1721737106


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -310,12 +320,50 @@ const ResultSet = ({
         schema: query?.schema,
       };
 
-      const canExportData = findPermission(
+      const canExportCsv = findPermission(
         'can_export_csv',
-        'SQLLab',
+        'SqlLab',
+        user?.roles,
+      );
+      const canExportGoogleSheets = findPermission(
+        'can_export_google_sheets',
+        'SqlLab',
         user?.roles,
       );
 
+      // Antd >= 4.24.0 format:
+      const exportMenuItems = [];
+      if (canExportCsv) {
+        exportMenuItems.push({
+          label: t('CSV'),
+          key: 'csv',
+          icon: <Icons.FileOutlined />,
+          onClick: () => {
+            logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV, {});
+            window.open(getExportCsvUrl(query.id), '_blank')?.focus();
+          },
+        });
+      }
+      if (isFeatureEnabled(FeatureFlag.GoogleSheetsExport) && canExportGoogleSheets) {
+        exportMenuItems.push({
+          label: t('Google Sheets'),
+          key: 'google-sheets',
+          icon: <Icons.GoogleOutlined />,
+          onClick: () =>
+            window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),

Review Comment:
   I hope to add the action logging like the above export csv.
   
   ```
   ```
   ```suggestion
               logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_GSHEET, {});
               window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1721737106


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -310,12 +320,50 @@ const ResultSet = ({
         schema: query?.schema,
       };
 
-      const canExportData = findPermission(
+      const canExportCsv = findPermission(
         'can_export_csv',
-        'SQLLab',
+        'SqlLab',
+        user?.roles,
+      );
+      const canExportGoogleSheets = findPermission(
+        'can_export_google_sheets',
+        'SqlLab',
         user?.roles,
       );
 
+      // Antd >= 4.24.0 format:
+      const exportMenuItems = [];
+      if (canExportCsv) {
+        exportMenuItems.push({
+          label: t('CSV'),
+          key: 'csv',
+          icon: <Icons.FileOutlined />,
+          onClick: () => {
+            logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV, {});
+            window.open(getExportCsvUrl(query.id), '_blank')?.focus();
+          },
+        });
+      }
+      if (isFeatureEnabled(FeatureFlag.GoogleSheetsExport) && canExportGoogleSheets) {
+        exportMenuItems.push({
+          label: t('Google Sheets'),
+          key: 'google-sheets',
+          icon: <Icons.GoogleOutlined />,
+          onClick: () =>
+            window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),

Review Comment:
   I hope to add the action logging like the above export csv.
   
   
   ```suggestion
               logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_GSHEET, {});
               window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1550724261


##########
superset/sqllab/api.py:
##########
@@ -236,6 +240,7 @@ def format_sql(self) -> FlaskResponse:
             return self.response_400(message=error.messages)
 
     @expose("/export/<string:client_id>/")

Review Comment:
   Great. Maybe another option is to make csv the default format if none is passed. Then we wouldn't need to deprecate the existing api. 



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "sivankumar86 (via GitHub)" <gi...@apache.org>.
sivankumar86 commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-2257405706

   https://github.com/apache/superset/discussions/29660 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1723151120


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -310,12 +320,50 @@ const ResultSet = ({
         schema: query?.schema,
       };
 
-      const canExportData = findPermission(
+      const canExportCsv = findPermission(
         'can_export_csv',
-        'SQLLab',
+        'SqlLab',
+        user?.roles,
+      );
+      const canExportGoogleSheets = findPermission(
+        'can_export_google_sheets',
+        'SqlLab',
         user?.roles,
       );
 
+      // Antd >= 4.24.0 format:
+      const exportMenuItems = [];
+      if (canExportCsv) {
+        exportMenuItems.push({
+          label: t('CSV'),
+          key: 'csv',
+          icon: <Icons.FileOutlined />,
+          onClick: () => {
+            logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV, {});
+            window.open(getExportCsvUrl(query.id), '_blank')?.focus();
+          },
+        });
+      }
+      if (isFeatureEnabled(FeatureFlag.GoogleSheetsExport) && canExportGoogleSheets) {
+        exportMenuItems.push({
+          label: t('Google Sheets'),
+          key: 'google-sheets',
+          icon: <Icons.GoogleOutlined />,
+          onClick: () =>
+            window.open(getExportGoogleSheetsUrl(query.id), '_blank')?.focus(),

Review Comment:
   Added in https://github.com/apache/superset/pull/26391/commits/92857562ee4c1c091e25def8c34e1f3042c6705d



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] Google Sheets Export (part 1) [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-2410384139

   @justinpark @rusackas Hi, this is still waiting on review.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export (part 1) [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1721720334


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { SupersetClient, t } from '@superset-ui/core';
+import { useEffect, useState } from 'react';
+import { useDispatch } from 'react-redux';
+import { useParams } from 'react-router-dom';
+import Loading from 'src/components/Loading';
+import {
+  addDangerToast,
+  addInfoToast,
+} from 'src/components/MessageToasts/actions';
+
+export default function ExportGoogleSheets() {
+  const { clientId }: any = useParams();
+  const dispatch = useDispatch();
+  const [{ isLoading, data, error }, setState] = useState<{
+    isLoading: boolean;
+    data: any;
+    error: any;
+  }>({ isLoading: true, data: null, error: null });
+  useEffect(() => {
+    if (!dispatch || !clientId) {
+      return;
+    }
+    dispatch(
+      addInfoToast(t('Exporting results to Google Sheets'), { duration: 0 }),
+    );
+    SupersetClient.get({
+      endpoint: `/api/v1/sqllab/export/${clientId}/google-sheets/`,
+    })
+      .then(res => setState({ data: res.json, isLoading: false, error: null }))
+      .catch(e => setState({ data: null, isLoading: false, error: e }));

Review Comment:
   The below process of parsing the error message can be standarized through getClientErrorObject.
   
   ```suggestion
         .catch(response => {
           getClientErrorObject(response).then(
             ({ error, message }: { error: any; message: string }) => {
               const errorMessage = error
                 ? error.error || error.statusText || error
                 : message;
               dispatch(addDangerToast(errorMessage));
             },
           );
         });
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1635831084


##########
superset/sqllab/api.py:
##########
@@ -236,6 +240,7 @@ def format_sql(self) -> FlaskResponse:
             return self.response_400(message=error.messages)
 
     @expose("/export/<string:client_id>/")

Review Comment:
   Since csv is default if none is passed (meaning no breaking changes,) and the SIP includes the current format, I'm going to go with that.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1548305032


##########
superset/sqllab/api.py:
##########
@@ -236,6 +240,7 @@ def format_sql(self) -> FlaskResponse:
             return self.response_400(message=error.messages)
 
     @expose("/export/<string:client_id>/")

Review Comment:
   @jessie-ross Thanks for the great feature proposal. I was reading through the SIP, and thought I might suggest another option here which would be to use the existing api "/export/<string:client_id>/" and pass the export type with a query string `?format=csv` for example. That could potentially simplify this. It seems like the request/response schemas should be fairly similar, with just a switch in the command that is run. 



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP TBD] Google Sheets Export [WIP] [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1440104082


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   My reasoning is that using an separate page provides a better user experience, and helps decouple the code.
   
   It prevents popup blocker issues, but importantly, this process can take some time, especially as the backend might need to rerun a query for export:
   https://github.com/apache/superset/blob/9033e72679fad7efdabc0f5b28607d974a7b5e1f/superset/commands/sql_lab/export.py?plain=1#L112-L126
   
   Our databases (SparkSQL mainly) are particularly slow, and then adding on top of that expensive queries and large amounts of data that need to be moved, we're looking at a 1m average wait time, with the upper bounds being around 15m.
   
   By having this process occur on a separate page it allows the export to happen asynchronously, and for the user to continue their use of Superset while the export occurs.
   Notably the CSV export already behaves like this - the download starts asynchronously to the UI.
   
   Simple alternatives would be a modal, or hover popup, suffering from the long loading time issue.
   
   A more complex alternative would be to perform the export on the backend, and provide a notification to the user when it's done. I'm not sure if Superset has this kind of thing set up.
   
   



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP TBD] Google Sheets Export [WIP] [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1440109990


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   > I guess I could do this in the front-end with toasts actually, that would be a viable alternative to me.
   
   After experimenting with this I've found that Superset navigation can unintuitively trigger a full page reload, e.g. navigating from "SQL Lab" to "Datasets", meaning that the front-end export process would be lost.
   
   This could be mitigated by a prevent-navigate-away alert, but I don't think that would be preferable UX, and we're heading further away from simplicity.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on PR #26391:
URL: https://github.com/apache/superset/pull/26391#issuecomment-1929268789

   Hi @justinpark, just wondering if there was any feedback on this?


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat: [SIP-114] [WIP] Google Sheets Export [superset]

Posted by "jessie-ross (via GitHub)" <gi...@apache.org>.
jessie-ross commented on code in PR #26391:
URL: https://github.com/apache/superset/pull/26391#discussion_r1635829543


##########
superset-frontend/src/pages/ExportGoogleSheets/index.tsx:
##########
@@ -0,0 +1,76 @@
+/**

Review Comment:
   @justinpark Since there has been no feedback on this, I'm going to go with the loading page as it seems to be the best option.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org