Open luizcapu opened 1 month ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 83.91%. Comparing base (
76d897e
) to head (ed26eb6
). Report is 835 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Marking this PR as ready for review. test-sqlite is the only test failing.
However, it's failing with sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: tables.table_name
, which is inherently opposed to the nature of this PR.
Furthermore, there are some signals that this constraint should be dropped:
SQLite Database support for metadata databases will be removed in a future version of Superset.
MySQLDialect
onlyI could use some guidance to decide whether or not dropping this constraint is the right decision. And if so, how to do it.
Thank you in advance.
SUMMARY
At Pinterest we were trying to use the
get_or_create
endpoint to automate the integration between our MetricsLayer and Superset. During our tests we've encountered the following issue: https://github.com/apache/superset/issues/30377The issue happens because at the moment the
get_or_create
code does not account for the payloadschema
attribute, doing a search bytable_name
only.This PR changes
get_or_create
to take theschema
into account:get_table_by_schema_and_name
was added to theDatasetDAO
classget_or_create
now checks if the dataset exists by callingDatasetDAO.get_table_by_schema_and_name
(instead ofDatasetDAO.get_table_by_name
)TESTING INSTRUCTIONS
Case 1 - False Positive
users
datasets)200
pointing to the new dataset. No false positives anymore.Case 2 - Internal Server Error
table_name
and differentschemas
(either via UI or create dataset API)table_name
but a different schema. Payload example:200
pointing to the new dataset. No 500 errors anymore.Backward Compatibility
200
with the response body pointing to the existing dataset.ADDITIONAL INFORMATION