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: Faulty datetime parser regex #20290

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

reesercollins
Copy link
Contributor

SUMMARY

As it currently stands, the regex for the datetime parser will incorrectly recognize things like "todayblahblah" and "snow" as datetime constants.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Try running "snow" through the dateTime parser before the changes. It should give erroneous results. After this change, it should behave as expected.

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 Jun 7, 2022

Codecov Report

Merging #20290 (c2b861d) into master (77e326f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head c2b861d differs from pull request most recent head 8af4cf3. Consider uploading reports for the commit 8af4cf3 to get more accurate results

@@           Coverage Diff           @@
##           master   #20290   +/-   ##
=======================================
  Coverage   66.65%   66.65%           
=======================================
  Files        1729     1729           
  Lines       64904    64906    +2     
  Branches     6842     6842           
=======================================
+ Hits        43262    43266    +4     
+ Misses      19893    19891    -2     
  Partials     1749     1749           
Flag Coverage Δ
javascript 51.57% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...nts/controls/DateFilterControl/utils/dateParser.ts 92.30% <100.00%> (ø)
...uperset-frontend/src/explore/exploreUtils/index.js 80.59% <100.00%> (+0.88%) ⬆️
...perset-frontend/src/views/CRUD/alert/AlertList.tsx 65.65% <100.00%> (+0.35%) ⬆️
superset/reports/api.py 90.22% <100.00%> (+0.38%) ⬆️
superset/utils/csv.py 97.91% <100.00%> (ø)

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 77e326f...8af4cf3. Read the comment docs.

@zhaoyongjie
Copy link
Member

zhaoyongjie commented Jun 8, 2022

@reesercollins do you mind giving me an example of this? the error input, for example, the snow/todayblabla. the backend should return a parse exception.

image

@reesercollins
Copy link
Contributor Author

This may just be our organization's changes to the dateparser which added a third option to the datetimeConstant regex which meant now would be parsed anywhere in the string, including in the string DATEADD(DATETIME("now"), -7, day). Either way, by making this fix, it prevents further errors down the line should more datetime constants be added upstream.

@zhaoyongjie zhaoyongjie self-requested a review June 8, 2022 14:02
Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

@reesercollins make sense. the change is safe, and approved! Thanks!

@zhaoyongjie zhaoyongjie merged commit a57ed76 into apache:master Jun 8, 2022
@reesercollins reesercollins deleted the fix/dateparser-regex branch June 8, 2022 14:08
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 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 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants