zhaoyongjie opened a new pull request, #27368: URL: https://github.com/apache/superset/pull/27368
### SUMMARY The PR introduced a new function in date time expression that is `datediff(<from>, <to>, [time unit],)`, it return a integer, so the return value should apply in the `dateadd` function. The basic form is: ``` # return value is 9 datediff(datetime('2018-01-01T00:00:00'), datetime('2018-01-10T00:00:00')) # return value is -9 datediff(datetime('2018-01-10T00:00:00'), datetime('2018-01-01T00:00:00')) ``` The `from` and `to` parameter is able to be set any date time expression: ``` # return value is -365 datediff(dateadd(datetime('2018-01-01T00:00:00'), 1, year), datetime('2018-01-10T00:00:00')) ``` The `datediff` also be in `dateadd` as a time delta ``` # return value is "datetime(2017, 12, 23, 0, 0, 0)" dateadd( datetime('2018-01-01T00:00:00'), datediff(datetime('2018-01-10T00:00:00'), datetime('2018-01-01T00:00:00')), day, ) ``` ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> N/A ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> The unit test was covered 100% cases. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] 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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org