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: Errors when saving dataset #24113

Conversation

jfrag1
Copy link
Member

@jfrag1 jfrag1 commented May 18, 2023

SUMMARY

Recently, a PR changed the endpoint used to update datasets to PUT /api/v1/dataset/{id}: #23678

The old endpoint did not have a lot of the validation the new endpoint had. As a result, some existing datasets would then fail validation once we switched over to the stricter one, making them unable to be updated unless you knew exactly what to change. It was also discovered that the custom validation for a column's python_date_format did not allow slashes in the date format, only hyphens, which was confusing since the UI placeholder uses slashes.

This PR changes the validation to allow for either slashes or hyphens and makes a few other tweaks to reduce false-alarm validation errors.

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

@@ -150,7 +150,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
groupby: column.groupby,
is_active: column.is_active,
is_dttm: column.is_dttm,
python_date_format: column.python_date_format,
python_date_format: column.python_date_format || null,
Copy link
Member Author

Choose a reason for hiding this comment

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

Allows for the field to be cleared, before an empty string was failing a Length(1, 255) validation

)$
""",
re.VERBOSE,
)
match = regex.match(value or "")
if not match:
raise ValidationError(_("Invalid date/timestamp format"))
raise ValidationError([_("Invalid date/timestamp format")])
Copy link
Member Author

Choose a reason for hiding this comment

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

The API error response was malformed without this, was giving ["I", "n", "v", ...]. This fixes it

@@ -56,7 +56,7 @@ class DatasetColumnsPutSchema(Schema):
filterable = fields.Boolean()
groupby = fields.Boolean()
is_active = fields.Boolean(allow_none=True)
is_dttm = fields.Boolean(dump_default=False)
is_dttm = fields.Boolean(allow_none=True, dump_default=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

Columns can have is_dttm being null, this allows datasets with such columns to be updated without error

@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Merging #24113 (9e53b85) into master (2222073) will increase coverage by 0.00%.
The diff coverage is 66.66%.

❗ Current head 9e53b85 differs from pull request most recent head 53f89f3. Consider uploading reports for the commit 53f89f3 to get more accurate results

@@           Coverage Diff           @@
##           master   #24113   +/-   ##
=======================================
  Coverage   68.30%   68.30%           
=======================================
  Files        1952     1952           
  Lines       75432    75433    +1     
  Branches     8191     8192    +1     
=======================================
+ Hits        51521    51522    +1     
  Misses      21807    21807           
  Partials     2104     2104           
Flag Coverage Δ
hive 53.17% <50.00%> (ø)
javascript 54.70% <100.00%> (+<0.01%) ⬆️
mysql 78.94% <50.00%> (ø)
postgres 79.01% <50.00%> (ø)
presto 53.10% <50.00%> (ø)
python 82.81% <50.00%> (ø)
sqlite 77.54% <50.00%> (ø)
unit 53.09% <50.00%> (ø)

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

Impacted Files Coverage Δ
superset/datasets/schemas.py 97.48% <50.00%> (ø)
...tend/src/components/Datasource/DatasourceModal.tsx 74.00% <100.00%> (+0.53%) ⬆️

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

Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

LGTM

@Antonio-RiveroMartnez Antonio-RiveroMartnez merged commit 2b236cb into apache:master May 22, 2023
29 checks passed
@Antonio-RiveroMartnez Antonio-RiveroMartnez deleted the jack/fix-dataset-saving-edge-cases branch May 22, 2023 17:21
@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/XS 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants