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

chore: Migrate /superset/estimate_query_cost/<database_id>/<schema>/ to API v1 #22910

Closed
wants to merge 5 commits into from

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

Continuing the effort on deprecating all /superset/ REST API endpoints
Deprecates /superset/estimate_query_cost for /api/v1/sqllab/estimate/

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

@diegomedina248 diegomedina248 force-pushed the dm/migrate-estimate_query_cost-to-v1 branch from 7c4cceb to 99ce414 Compare January 30, 2023 16:51
@diegomedina248 diegomedina248 force-pushed the dm/migrate-estimate_query_cost-to-v1 branch 2 times, most recently from 492488c to ee7d1d3 Compare January 30, 2023 16:59
@diegomedina248 diegomedina248 force-pushed the dm/migrate-estimate_query_cost-to-v1 branch from ee7d1d3 to a4ec247 Compare January 30, 2023 17:07
@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Merging #22910 (3f0c20b) into master (efe6d22) will decrease coverage by 11.25%.
The diff coverage is 54.79%.

❗ Current head 3f0c20b differs from pull request most recent head c660773. Consider uploading reports for the commit c660773 to get more accurate results

@@             Coverage Diff             @@
##           master   #22910       +/-   ##
===========================================
- Coverage   67.45%   56.21%   -11.25%     
===========================================
  Files        1878     1878               
  Lines       72140    72218       +78     
  Branches     7866     7872        +6     
===========================================
- Hits        48663    40595     -8068     
- Misses      21458    29603     +8145     
- Partials     2019     2020        +1     
Flag Coverage Δ
hive ?
mysql ?
postgres ?
presto 52.62% <55.55%> (+<0.01%) ⬆️
python 58.85% <55.55%> (-23.32%) ⬇️
sqlite ?
unit 52.51% <55.55%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/actions/sqlLab.js 63.49% <0.00%> (-0.56%) ⬇️
superset-frontend/src/SqlLab/reducers/sqlLab.js 36.87% <ø> (ø)
superset/sqllab/commands/estimate.py 50.00% <50.00%> (ø)
superset/sqllab/api.py 84.84% <56.25%> (-15.16%) ⬇️
superset/sqllab/schemas.py 100.00% <100.00%> (ø)
superset/views/core.py 36.08% <100.00%> (-38.56%) ⬇️
superset/utils/dashboard_import_export.py 0.00% <0.00%> (-100.00%) ⬇️
superset/tags/core.py 4.54% <0.00%> (-95.46%) ⬇️
superset/key_value/commands/update.py 0.00% <0.00%> (-90.91%) ⬇️
superset/key_value/commands/delete.py 0.00% <0.00%> (-87.88%) ⬇️
... and 343 more

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

self._schema = params.get("schema", "")

def validate(self) -> None:
self._database = db.session.query(Database).get(self._database_id)
Copy link
Member

Choose a reason for hiding this comment

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

this should go to the DAO to get all possible security constraints applied to it

ExecutePayloadSchema,
QueryExecutionResponseSchema,
)

@expose("/estimate/", methods=["POST"])
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about placing this one on /api/v1/database/ instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a balancing act here, I agree.
I think the database resource is bloated already, and while I could see usages outside SQL lab, we don't at the moment nor in the medium term (afaik).
I could see arguments on both sides and I don't feel particularly strong about either of them

_schema: str
_database: Database

def __init__(self, params: EstimateQueryCostSchema) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

user should be passed in, because there are some security constraints that should be applied

@@ -25,6 +25,13 @@
}


class EstimateQueryCostSchema(Schema):
database_id = fields.Integer(required=True)
sql = fields.String(required=True)
Copy link
Member

Choose a reason for hiding this comment

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

let's add some nice descriptions here

sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
)

def test_run_success(self) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

add some tests for users that don't have access to the database (missing database access on [some-db.id])

@diegomedina248 diegomedina248 force-pushed the dm/migrate-estimate_query_cost-to-v1 branch from 8e262dd to 7ab30e8 Compare February 7, 2023 01:48
@diegomedina248 diegomedina248 force-pushed the dm/migrate-estimate_query_cost-to-v1 branch from 7ab30e8 to c660773 Compare February 7, 2023 01:49
@diegomedina248
Copy link
Contributor Author

@dpgaspar the remaining comments here I believe will be addressed by you as a follow up right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants