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/08/17 16:27:27 UTC

[GitHub] [superset] kgabryje opened a new pull request, #21114: fix(explore): Filters with custom SQL disappearing

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

   
   ### SUMMARY
   When user added more than 1 filter with custom SQL and saved the chart, all filters with custom SQL except for the first one disappeared. This PR fixes that issue.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Before:
   
   https://user-images.githubusercontent.com/15073128/185192610-40a9c076-7540-4818-a6b2-b89d1b20c84f.mov
   
   After:
   
   https://user-images.githubusercontent.com/15073128/185192803-44626ed7-e1c6-42e6-ab09-41a7b464c44a.mov
   
   ### TESTING INSTRUCTIONS
   1. Open explore and add a few filters with custom sql
   2. Save chart
   3. All added filters should still be there
   
   ### 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] michael-s-molina commented on a diff in pull request #21114: fix(explore): Filters with custom SQL disappearing

Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on code in PR #21114:
URL: https://github.com/apache/superset/pull/21114#discussion_r948263505


##########
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:
##########
@@ -51,28 +54,34 @@ const simpleFilterToAdhoc = (
   return result;
 };
 
-const removeAdhocFilterDuplicates = (filters: SimpleAdhocFilter[]) => {
+const removeAdhocFilterDuplicates = (filters: AdhocFilter[]) => {
   const isDuplicate = (
-    adhocFilter: SimpleAdhocFilter,
-    existingFilters: SimpleAdhocFilter[],
+    adhocFilter: AdhocFilter,
+    existingFilters: AdhocFilter[],
   ) =>
     existingFilters.some(
-      (existingFilter: SimpleAdhocFilter) =>
-        existingFilter.operator === adhocFilter.operator &&
-        existingFilter.subject === adhocFilter.subject &&
-        ((!('comparator' in existingFilter) &&
-          !('comparator' in adhocFilter)) ||
-          ('comparator' in existingFilter &&
-            'comparator' in adhocFilter &&
-            isEqual(existingFilter.comparator, adhocFilter.comparator))),
+      (existingFilter: AdhocFilter) =>

Review Comment:
   Can we split this code into equality functions for each filter type to improve readability? You can do it in a follow-up 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


[GitHub] [superset] kgabryje merged pull request #21114: fix(explore): Filters with custom SQL disappearing

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


-- 
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] michael-s-molina commented on a diff in pull request #21114: fix(explore): Filters with custom SQL disappearing

Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on code in PR #21114:
URL: https://github.com/apache/superset/pull/21114#discussion_r948263505


##########
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:
##########
@@ -51,28 +54,34 @@ const simpleFilterToAdhoc = (
   return result;
 };
 
-const removeAdhocFilterDuplicates = (filters: SimpleAdhocFilter[]) => {
+const removeAdhocFilterDuplicates = (filters: AdhocFilter[]) => {
   const isDuplicate = (
-    adhocFilter: SimpleAdhocFilter,
-    existingFilters: SimpleAdhocFilter[],
+    adhocFilter: AdhocFilter,
+    existingFilters: AdhocFilter[],
   ) =>
     existingFilters.some(
-      (existingFilter: SimpleAdhocFilter) =>
-        existingFilter.operator === adhocFilter.operator &&
-        existingFilter.subject === adhocFilter.subject &&
-        ((!('comparator' in existingFilter) &&
-          !('comparator' in adhocFilter)) ||
-          ('comparator' in existingFilter &&
-            'comparator' in adhocFilter &&
-            isEqual(existingFilter.comparator, adhocFilter.comparator))),
+      (existingFilter: AdhocFilter) =>

Review Comment:
   Can we split this code into equality functions for each filter type to improve readability?



-- 
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] github-actions[bot] commented on pull request #21114: fix(explore): Filters with custom SQL disappearing

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

   @kgabryje Ephemeral environment spinning up at http://54.190.201.200:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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 #21114: fix(explore): Filters with custom SQL disappearing

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/21114?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 [#21114](https://codecov.io/gh/apache/superset/pull/21114?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (74835d6) into [master](https://codecov.io/gh/apache/superset/commit/94e8fd3b3512ef9553fe29a8f71831cfdad455bd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (94e8fd3) will **increase** coverage by `0.03%`.
   > The diff coverage is `67.56%`.
   
   > :exclamation: Current head 74835d6 differs from pull request most recent head 567bd02. Consider uploading reports for the commit 567bd02 to get more accurate results
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #21114      +/-   ##
   ==========================================
   + Coverage   66.27%   66.30%   +0.03%     
   ==========================================
     Files        1770     1772       +2     
     Lines       67543    67612      +69     
     Branches     7185     7204      +19     
   ==========================================
   + Hits        44764    44832      +68     
   + Misses      20940    20938       -2     
   - Partials     1839     1842       +3     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `52.08% <90.90%> (+0.08%)` | :arrow_up: |
   
   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/21114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...dashboard/components/AddSliceCard/AddSliceCard.tsx](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0FkZFNsaWNlQ2FyZC9BZGRTbGljZUNhcmQudHN4) | `65.90% <0.00%> (ø)` | |
   | [superset/config.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvY29uZmlnLnB5) | `91.47% <ø> (ø)` | |
   | [superset/examples/bart\_lines.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvYmFydF9saW5lcy5weQ==) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/birth\_names.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvYmlydGhfbmFtZXMucHk=) | `71.42% <0.00%> (-0.65%)` | :arrow_down: |
   | [superset/examples/country\_map.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvY291bnRyeV9tYXAucHk=) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/energy.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvZW5lcmd5LnB5) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/flights.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvZmxpZ2h0cy5weQ==) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/long\_lat.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvbG9uZ19sYXQucHk=) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/multiformat\_time\_series.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvbXVsdGlmb3JtYXRfdGltZV9zZXJpZXMucHk=) | `0.00% <0.00%> (ø)` | |
   | [superset/examples/paris.py](https://codecov.io/gh/apache/superset/pull/21114/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-c3VwZXJzZXQvZXhhbXBsZXMvcGFyaXMucHk=) | `0.00% <0.00%> (ø)` | |
   | ... and [11 more](https://codecov.io/gh/apache/superset/pull/21114/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?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] geido commented on pull request #21114: fix(explore): Filters with custom SQL disappearing

Posted by GitBox <gi...@apache.org>.
geido commented on PR #21114:
URL: https://github.com/apache/superset/pull/21114#issuecomment-1218290280

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


[GitHub] [superset] github-actions[bot] commented on pull request #21114: fix(explore): Filters with custom SQL disappearing

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

   @geido Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
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] github-actions[bot] commented on pull request #21114: fix(explore): Filters with custom SQL disappearing

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

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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] michael-s-molina commented on a diff in pull request #21114: fix(explore): Filters with custom SQL disappearing

Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on code in PR #21114:
URL: https://github.com/apache/superset/pull/21114#discussion_r948263505


##########
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:
##########
@@ -51,28 +54,34 @@ const simpleFilterToAdhoc = (
   return result;
 };
 
-const removeAdhocFilterDuplicates = (filters: SimpleAdhocFilter[]) => {
+const removeAdhocFilterDuplicates = (filters: AdhocFilter[]) => {
   const isDuplicate = (
-    adhocFilter: SimpleAdhocFilter,
-    existingFilters: SimpleAdhocFilter[],
+    adhocFilter: AdhocFilter,
+    existingFilters: AdhocFilter[],
   ) =>
     existingFilters.some(
-      (existingFilter: SimpleAdhocFilter) =>
-        existingFilter.operator === adhocFilter.operator &&
-        existingFilter.subject === adhocFilter.subject &&
-        ((!('comparator' in existingFilter) &&
-          !('comparator' in adhocFilter)) ||
-          ('comparator' in existingFilter &&
-            'comparator' in adhocFilter &&
-            isEqual(existingFilter.comparator, adhocFilter.comparator))),
+      (existingFilter: AdhocFilter) =>

Review Comment:
   Can we split this code into equality functions for each filter type to improve readability? A follow-up is ok.



-- 
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] github-actions[bot] commented on pull request #21114: fix(explore): Filters with custom SQL disappearing

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

   @geido Container image not yet published for this PR. Please try again when build is complete.


-- 
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 pull request #21114: fix(explore): Filters with custom SQL disappearing

Posted by GitBox <gi...@apache.org>.
kgabryje commented on PR #21114:
URL: https://github.com/apache/superset/pull/21114#issuecomment-1218422401

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


[GitHub] [superset] kgabryje commented on a diff in pull request #21114: fix(explore): Filters with custom SQL disappearing

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


##########
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:
##########
@@ -176,16 +185,28 @@ export const getFormDataWithDashboardContext = (
     exploreFormData,
     dashboardContextFormData,
   );
-  const adhocFilters = removeAdhocFilterDuplicates([
-    ...ensureIsArray(exploreFormData.adhoc_filters),
-    ...ensureIsArray(filterBoxData.adhoc_filters),
-    ...ensureIsArray(nativeFiltersData.adhoc_filters),
-  ]);
+  const adhocFilters = [
+    ...Object.keys(exploreFormData),
+    ...Object.keys(filterBoxData),
+    ...Object.keys(nativeFiltersData),
+  ]
+    .filter(key => key.match(/adhoc_filter.*/))

Review Comment:
   handles the case of fields like `adhoc_filters_b` in mixed chart. Logic similar to `superset/utils/core.py`, line 1121



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