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

feat: datediff in datetime_parser #27368

Merged
merged 2 commits into from
Mar 4, 2024
Merged

Conversation

zhaoyongjie
Copy link
Member

@zhaoyongjie zhaoyongjie commented Mar 3, 2024

SUMMARY

The PR introduced a new function in date time expression that is datediff(<from>, <to>, [time unit],), it returns 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

N/A

TESTING INSTRUCTIONS

The unit test was covered 100% cases.

ADDITIONAL INFORMATION

@@ -14,13 +14,14 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations
Copy link
Member Author

@zhaoyongjie zhaoyongjie Mar 3, 2024

Choose a reason for hiding this comment

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

By catch, to use "new typing" rather than the old one.

Copy link

codecov bot commented Mar 3, 2024

Codecov Report

Attention: Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.73%. Comparing base (f453d5d) to head (4b1bbf5).
Report is 1458 commits behind head on master.

Files with missing lines Patch % Lines
superset/utils/date_parser.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27368      +/-   ##
==========================================
+ Coverage   69.61%   69.73%   +0.12%     
==========================================
  Files        1908     1908              
  Lines       74543    74560      +17     
  Branches     8316     8316              
==========================================
+ Hits        51895    51998     +103     
+ Misses      20595    20509      -86     
  Partials     2053     2053              
Flag Coverage Δ
hive 53.77% <45.45%> (?)
mysql 77.98% <50.00%> (-0.03%) ⬇️
postgres 78.08% <50.00%> (-0.03%) ⬇️
presto 53.72% <45.45%> (?)
python 83.13% <95.45%> (+0.24%) ⬆️
sqlite 77.60% <50.00%> (-0.03%) ⬇️
unit 56.52% <95.45%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhaoyongjie zhaoyongjie merged commit e89ec4d into apache:master Mar 4, 2024
38 checks passed
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
qleroy pushed a commit to qleroy/superset that referenced this pull request Apr 28, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 27, 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/L 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants