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

fix: feature flags typing #15254

Merged
merged 7 commits into from
Nov 19, 2021
Merged

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Jun 18, 2021

SUMMARY

Adds type annotations to feature flags, clearly stating that all feature flags are booleans. Because of that QUERY_COST_FORMATTERS_BY_ENGINE, SCHEDULED_QUERIES and SQL_VALIDATORS_BY_ENGINE are no longer feature flags but config keys. Note that currently on master, SQL_VALIDATORS_BY_ENGINE is defined as a top level key on config.py, but is erroneously being read from the feature flag object on the frontend. This fixes the issue and adds a note to UPDATING.md.

Testing instructions

  1. Go to SQL Lab and open a Postgres database
  2. Write a query that's incorrect and verify that the error shows up in the gutter (see below)

image

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@villebro villebro marked this pull request as ready for review November 17, 2021 06:58
@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #15254 (345d01b) into master (c829614) will decrease coverage by 0.20%.
The diff coverage is 55.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15254      +/-   ##
==========================================
- Coverage   76.94%   76.74%   -0.21%     
==========================================
  Files        1042     1043       +1     
  Lines       56254    56371     +117     
  Branches     7785     7794       +9     
==========================================
- Hits        43286    43260      -26     
- Misses      12710    12855     +145     
+ Partials      258      256       -2     
Flag Coverage Δ
hive ?
mysql 81.96% <83.33%> (+<0.01%) ⬆️
postgres 81.96% <83.33%> (-0.01%) ⬇️
presto ?
python 82.04% <83.33%> (-0.43%) ⬇️
sqlite 81.64% <83.33%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/showSavedQuery/index.jsx 0.00% <0.00%> (ø)
superset/views/base.py 74.91% <ø> (ø)
...rc/SqlLab/components/ScheduleQueryButton/index.tsx 28.12% <12.50%> (ø)
superset/views/core.py 76.97% <50.00%> (ø)
...frontend/src/SqlLab/components/SqlEditor/index.jsx 54.97% <100.00%> (+0.82%) ⬆️
...et-frontend/src/dashboard/components/Dashboard.jsx 78.09% <100.00%> (ø)
superset/config.py 91.53% <100.00%> (+0.02%) ⬆️
superset/utils/feature_flag_manager.py 96.29% <100.00%> (ø)
superset/db_engines/hive.py 0.00% <0.00%> (-85.19%) ⬇️
superset/db_engine_specs/hive.py 69.49% <0.00%> (-16.99%) ⬇️
... and 109 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c829614...345d01b. Read the comment docs.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM. I contributed some code to this PR, so leaving this to be stamped by @betodealmeida

@@ -2414,7 +2413,7 @@ def validate_sql_json(
)

spec = mydb.db_engine_spec
validators_by_engine = get_feature_flags().get("SQL_VALIDATORS_BY_ENGINE")
validators_by_engine = app.config["SQL_VALIDATORS_BY_ENGINE"]
Copy link
Member

Choose a reason for hiding this comment

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

It appears that SQL validation has never worked based on the SQL_VALIDATORS_BY_ENGINE top level config parameter, as this was referencing the feature flag map.

@@ -392,8 +397,7 @@ class SqlEditor extends React.PureComponent {
canValidateQuery() {
// Check whether or not we can validate the current query based on whether
// or not the backend has a validator configured for it.
const validatorMap = window.featureFlags.SQL_VALIDATORS_BY_ENGINE;
Copy link
Member

Choose a reason for hiding this comment

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

Same here - instead of checking the featureFlags map, we should check bootstrap data.

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.

LGTM. We also have SCHEDULED_QUERIES which is non-boolean:

const jsonSchema = window.featureFlags.SCHEDULED_QUERIES?.JSONSCHEMA;

const getUISchema = () => window.featureFlags.SCHEDULED_QUERIES?.UISCHEMA;

@villebro
Copy link
Member

LGTM. We also have SCHEDULED_QUERIES which is non-boolean:

const jsonSchema = window.featureFlags.SCHEDULED_QUERIES?.JSONSCHEMA;

const getUISchema = () => window.featureFlags.SCHEDULED_QUERIES?.UISCHEMA;

Thanks @betodealmeida , let's get that one fixed, too!

Comment on lines +85 to +88
const appContainer = document.getElementById('app');
const bootstrapData = JSON.parse(
appContainer.getAttribute('data-bootstrap') || '{}',
);
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to move this boilerplate into a util, but I'd prefer to do that in a follow up

@dpgaspar dpgaspar merged commit 69f9ee8 into apache:master Nov 19, 2021
@dpgaspar dpgaspar deleted the fix/feature-flag-typing branch November 19, 2021 15:56
@michellethomas
Copy link
Contributor

@dpgaspar Hi, can you clarify in UPDATING that this turns on SQL_VALIDATORS_BY_ENGINE for presto and postgres when it was not on previously. Do we want this feature to be on by default?

AAfghahi pushed a commit that referenced this pull request Jan 10, 2022
* fix: feature flags typing

* fix tests

* add note in UPDATING.md

* fix frontend

* also move SCHEDULED_QUERIES to top level

* fix test

Co-authored-by: Ville Brofeldt <[email protected]>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 12, 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 preset-io size/M 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants