Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sqllab): SQLEditor Extension #24205

Merged

Conversation

Antonio-RiveroMartnez
Copy link
Member

SUMMARY

In order to extend capabilities in our SQLEditor we need to provide an extension. This PR is adding such extension and adding tests for it.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Merging #24205 (72b14fe) into master (8375baa) will decrease coverage by 1.54%.
The diff coverage is 40.90%.

❗ Current head 72b14fe differs from pull request most recent head b51fe1f. Consider uploading reports for the commit b51fe1f to get more accurate results

@@            Coverage Diff             @@
##           master   #24205      +/-   ##
==========================================
- Coverage   68.22%   66.69%   -1.54%     
==========================================
  Files        1957     1957              
  Lines       75594    75600       +6     
  Branches     8224     8223       -1     
==========================================
- Hits        51572    50418    -1154     
- Misses      21914    23074    +1160     
  Partials     2108     2108              
Flag Coverage Δ
javascript 54.73% <38.09%> (+<0.01%) ⬆️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nd/src/components/ErrorMessage/BasicErrorAlert.tsx 93.75% <ø> (ø)
superset-frontend/src/components/Table/index.tsx 75.29% <ø> (ø)
...veFilters/FilterBar/FilterControls/FilterValue.tsx 5.66% <0.00%> (-0.06%) ⬇️
superset-frontend/src/dashboard/types.ts 100.00% <ø> (ø)
...perset-frontend/src/hooks/apiResources/queryApi.ts 100.00% <ø> (ø)
...onfigModal/FiltersConfigForm/FiltersConfigForm.tsx 55.36% <28.57%> (+0.19%) ⬆️
...frontend/src/SqlLab/components/SqlEditor/index.jsx 59.25% <100.00%> (+0.65%) ⬆️
...onents/ErrorMessage/ErrorMessageWithStackTrace.tsx 83.33% <100.00%> (+3.33%) ⬆️
...set-frontend/src/dashboard/util/permissionUtils.ts 86.66% <100.00%> (ø)
superset/config.py 92.02% <100.00%> (+0.02%) ⬆️

... and 93 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines 128 to 130
tables: TTables[];
queryEditor: TQueryEditor;
database: TDatabase;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Antonio-RiveroMartnez
Not all custom extension requires all these properties such like tables and database
Therefore, I think it's not a good idea passing these specified properties because you can access these values from redux. (you can also access the queryEditor object by useQueryEditor hook)
Only thing you need to pass is queryEditorId and then each custom extension component should use a hook to retrieve the properties that needed.

Suggested change
tables: TTables[];
queryEditor: TQueryEditor;
database: TDatabase;
queryEditorId: string;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @justinpark ! Good call, I will change this. I am working a bit more on this extension feature so I'll move this PR to be a DRAFT until I get everything in place and final props etc are figured out. ILYK. Thanks for the input as always 👏

@michael-s-molina
Copy link
Member

@Antonio-RiveroMartnez could you help me review #24214 and rebase your PR on top of that one?

@Antonio-RiveroMartnez
Copy link
Member Author

@Antonio-RiveroMartnez could you help me review #24214 and rebase your PR on top of that one?

Oh nice! Yes I will do so.

    - Add a new extension so our SQLEditor can make use of it if provided extend SQLLab.
    - Add tests for the new extension
- Rebase using the refactored branch
- Use queryEditor Id instead of passing tables and database and add two additional props needed for triggering queries
{SqlFormExtension && (
<SqlFormExtension
queryEditorId={queryEditor.id}
setQueryEditorAndSaveSqlWithDebounce={
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Antonio-RiveroMartnez I am thinking if we need to pass setQueryEditorAndSaveSqlWithDebounce and startQuery or if those can be implemented by hooking into the state?

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @geido good call! I understand we want to keep the extension with as little props/dependencies as possible, but for example in the case of startQuery, it needs to dispatch two actions in the main component, so, right now I don't see a clearer way than passing the whole callback, like we do on other extensions like SSHTunneling, etc. But If anyone has an idea on how this might work, I'm more than happy to discuss. Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geido @Antonio-RiveroMartnez similar to the previous comment, this action props doesn't make sense since your custom component only needs these actions. You can hook up these actions in your custom component by combining of existing action helpers

For example you can build startQuery in your component by combining of runQueryFromSqlEditor and setActiveSouthPaneTab

      dispatch(
        runQueryFromSqlEditor(
          database,
          queryEditor,
          defaultQueryLimit,
          ctasArg ? ctas : '',
          ctasArg,
          ctas_method,
        ),
      );
      dispatch(setActiveSouthPaneTab('Results'));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @justinpark sure, I can recreate all those with the helpers, but since we are not changing how they work, just invoking them, I treated them like other props our existing extensions are using. IMHO I see no major benefit by forcing a duplication of code in the extension. However, if you truly see this like an scenario we should force such duplication, I can work on it in a follow up PR. Thanks as always for the input.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Antonio-RiveroMartnez Antonio-RiveroMartnez merged commit 1d9a761 into apache:master Jun 1, 2023
Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants