You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/18 12:47:19 UTC

[GitHub] [superset] zhaoyongjie opened a new pull request, #20109: refactor: decouple DataTablesPane

zhaoyongjie opened a new pull request, #20109:
URL: https://github.com/apache/superset/pull/20109

   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   In order to popup results pane in the Dashboard. the first stage decouple DataTablesPane.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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
   - [ ] 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


[GitHub] [superset] codecov[bot] commented on pull request #20109: refactor: decouple DataTablesPane

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #20109:
URL: https://github.com/apache/superset/pull/20109#issuecomment-1132956628

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20109](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (cde8b29) into [master](https://codecov.io/gh/apache/superset/commit/0bcc21bc45ac672d82674a325cc7e94a944e2bc3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0bcc21b) will **decrease** coverage by `0.00%`.
   > The diff coverage is `71.87%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #20109      +/-   ##
   ==========================================
   - Coverage   66.46%   66.45%   -0.01%     
   ==========================================
     Files        1721     1724       +3     
     Lines       64512    64498      -14     
     Branches     6806     6806              
   ==========================================
   - Hits        42875    42864      -11     
   + Misses      19905    19902       -3     
     Partials     1732     1732              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `51.32% <71.87%> (-0.02%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ntend/src/explore/components/ExploreChartPanel.jsx](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9FeHBsb3JlQ2hhcnRQYW5lbC5qc3g=) | `70.49% <ø> (ø)` | |
   | [...end/src/explore/components/DataTablesPane/utils.ts](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhVGFibGVzUGFuZS91dGlscy50cw==) | `41.93% <41.93%> (ø)` | |
   | [...rc/explore/components/DataTablesPane/DataTable.tsx](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhVGFibGVzUGFuZS9EYXRhVGFibGUudHN4) | `82.60% <82.60%> (ø)` | |
   | [...plore/components/DataTablesPane/DataTablesPane.tsx](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhVGFibGVzUGFuZS9EYXRhVGFibGVzUGFuZS50c3g=) | `85.29% <85.29%> (ø)` | |
   | [...re/components/DataTablesPane/DataTableControls.tsx](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhVGFibGVzUGFuZS9EYXRhVGFibGVDb250cm9scy50c3g=) | `100.00% <100.00%> (ø)` | |
   | [...lore/components/useOriginalFormattedTimeColumns.ts](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy91c2VPcmlnaW5hbEZvcm1hdHRlZFRpbWVDb2x1bW5zLnRz) | `75.00% <100.00%> (ø)` | |
   | [.../src/explore/components/DataTableControl/index.tsx](https://codecov.io/gh/apache/superset/pull/20109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhVGFibGVDb250cm9sL2luZGV4LnRzeA==) | `70.51% <0.00%> (-1.29%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [0bcc21b...cde8b29](https://codecov.io/gh/apache/superset/pull/20109?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20109: refactor: decouple DataTablesPane

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20109:
URL: https://github.com/apache/superset/pull/20109#discussion_r882304894


##########
superset-frontend/src/explore/components/DataTablesPane/useGetResultsOrSamples.ts:
##########
@@ -0,0 +1,122 @@
+/**
+ * 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 { useState, useEffect } from 'react';
+import { t, ensureIsArray } from '@superset-ui/core';
+import { getChartDataRequest } from 'src/components/Chart/chartAction';
+import { getClientErrorObject } from 'src/utils/getClientErrorObject';
+import { requestPayload, responseData } from './types';
+
+const cache = new WeakMap();
+
+export function useGetResultsOrSamples({
+  isRequest,
+  resultType,
+  queryFormData,
+  datasource,
+  queryForce,
+  ownState,
+  actions,
+}: requestPayload): responseData {
+  // todo: this hook should split into useGetResults and useGetSamples after change endpoint
+  const [response, setResponse] = useState<responseData>({

Review Comment:
   done, I have added a new `samples` endpoint and refactored this logic.



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


[GitHub] [superset] villebro commented on a diff in pull request #20109: refactor: decouple DataTablesPane

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #20109:
URL: https://github.com/apache/superset/pull/20109#discussion_r882481533


##########
superset-frontend/src/explore/components/DataTablesPane/components/ResultsPane.tsx:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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 React, { useState, useEffect } from 'react';
+import { ensureIsArray, GenericDataType, styled, t } from '@superset-ui/core';
+import Loading from 'src/components/Loading';
+import { EmptyStateMedium } from 'src/components/EmptyState';
+import TableView, { EmptyWrapperType } from 'src/components/TableView';
+import {
+  useFilteredTableData,
+  useTableColumns,
+} from 'src/explore/components/DataTableControl';
+import { useOriginalFormattedTimeColumns } from 'src/explore/components/useOriginalFormattedTimeColumns';
+import { getChartDataRequest } from 'src/components/Chart/chartAction';
+import { getClientErrorObject } from 'src/utils/getClientErrorObject';
+import { TableControls } from './DataTableControls';
+import { ResultsPaneProps } from '../types';
+
+const Error = styled.pre`
+  margin-top: ${({ theme }) => `${theme.gridUnit * 4}px`};
+`;
+
+const cache = new WeakSet();
+
+export const ResultsPane = ({
+  isRequest,
+  queryFormData,
+  queryForce,
+  ownState,
+  errorMessage,
+  actions,
+  dataSize = 50,
+}: ResultsPaneProps) => {
+  const [filterText, setFilterText] = useState('');
+  const [data, setData] = useState<Record<string, any>[][]>([]);
+  const [colnames, setColnames] = useState<string[]>([]);
+  const [coltypes, setColtypes] = useState<GenericDataType[]>([]);
+  const [isLoading, setIsLoading] = useState<boolean>(false);
+  const [responseError, setResponseError] = useState<string>('');
+
+  useEffect(() => {
+    // it's an invalid formData when gets a errorMessage
+    if (errorMessage) return;
+    if (isRequest && !cache.has(queryFormData)) {
+      setIsLoading(true);
+      getChartDataRequest({
+        formData: queryFormData,
+        force: queryForce,
+        resultFormat: 'json',
+        resultType: 'results',
+        ownState,
+      })
+        .then(({ json }) => {
+          const { colnames, coltypes } = json.result[0];
+          // Only displaying the first query is currently supported

Review Comment:
   Idea for follow-up: Now it should be fairly simple to add support for displaying the other queries data, too. We could have a dropdown next to the search field where you could choose the query if there are more than one available.



##########
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:
##########
@@ -0,0 +1,214 @@
+/**
+ * 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 React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useState,
+  MouseEvent,
+} from 'react';
+import { styled, t, useTheme } from '@superset-ui/core';
+import Icons from 'src/components/Icons';
+import Tabs from 'src/components/Tabs';
+import {
+  getItem,
+  setItem,
+  LocalStorageKeys,
+} from 'src/utils/localStorageHelpers';
+import { ResultsPane, SamplesPane, TableControlsWrapper } from './components';
+import { DataTablesPaneProps } from './types';
+
+enum ResultTypes {
+  results = 'results',
+  samples = 'samples',

Review Comment:
   nit, I believe this is the convention:
   ```suggestion
     Results = 'results',
     Samples = 'samples',
   ```



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


[GitHub] [superset] kgabryje commented on a diff in pull request #20109: refactor: decouple DataTablesPane

Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #20109:
URL: https://github.com/apache/superset/pull/20109#discussion_r880261863


##########
superset-frontend/src/explore/components/DataTablesPane/useGetResultsOrSamples.ts:
##########
@@ -0,0 +1,122 @@
+/**
+ * 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 { useState, useEffect } from 'react';
+import { t, ensureIsArray } from '@superset-ui/core';
+import { getChartDataRequest } from 'src/components/Chart/chartAction';
+import { getClientErrorObject } from 'src/utils/getClientErrorObject';
+import { requestPayload, responseData } from './types';
+
+const cache = new WeakMap();
+
+export function useGetResultsOrSamples({
+  isRequest,
+  resultType,
+  queryFormData,
+  datasource,
+  queryForce,
+  ownState,
+  actions,
+}: requestPayload): responseData {
+  // todo: this hook should split into useGetResults and useGetSamples after change endpoint
+  const [response, setResponse] = useState<responseData>({

Review Comment:
   I think `useReducer` is a better choice for handling complex objects in a state. Alternatively, we could split that state into 5 `useState`s



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


[GitHub] [superset] zhaoyongjie merged pull request #20109: refactor: decouple DataTablesPane

Posted by GitBox <gi...@apache.org>.
zhaoyongjie merged PR #20109:
URL: https://github.com/apache/superset/pull/20109


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