-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Feature](function) Support more INTERVAL time-unit #60347
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
1820ba3 to
8785708
Compare
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run nonConcurrent |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for all MySQL-compatible compound time units for INTERVAL operations in DATE_ADD/SUB and EXTRACT functions. It also fixes incorrect behavior introduced in PR #57253 where invalid format exceptions were expected but now the functions handle partial or malformed inputs more gracefully (similar to MySQL).
Changes:
- Added support for 11 new compound time units: YEAR_MONTH, DAY_HOUR, DAY_MINUTE, DAY_SECOND, DAY_MICROSECOND, HOUR_MINUTE, HOUR_SECOND, HOUR_MICROSECOND, MINUTE_SECOND, MINUTE_MICROSECOND, SECOND_MICROSECOND
- Refactored interval parsing logic in C++ backend to handle flexible input formats with better MySQL compatibility
- Changed error handling from exceptions to best-effort parsing for malformed interval strings
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test_dateadd_with_other_timeunit.groovy | Converts exception tests to query tests with expected outputs for malformed inputs |
| test_date_function.groovy | Removes exception test for invalid hour format |
| doc_date_functions_test.groovy | Renames alias from 'year_month' to 'year_and_month' for clarity |
| test_dateadd_with_other_timeunit.out | Adds expected outputs for new query tests |
| test_add_sub_union_type.out | Complete new test output file with 810 lines of test results |
| ScalarFunctionVisitor.java | Adds visitor methods for all new time unit functions |
| Interval.java | Reorders TimeUnit enum and adds new compound time units |
| YearMonth*.java, DayHour*.java, etc. | New scalar function classes for extract and add/sub operations |
| DateTimeExtractAndTransform.java | Adds extract implementations for all new time units |
| DateTimeArithmetic.java | Complete rewrite of interval parsing with unified approach |
| DatetimeFunctionBinder.java | Binds new time units to function implementations |
| BuiltinScalarFunctions.java | Registers all new scalar functions |
| DorisParser.g4 | Updates grammar for EXTRACT and unitIdentifier |
| DorisLexer.g4 | Adds new keywords for compound time units |
| function_time_test.cpp | Adds comprehensive C++ unit tests (670+ lines) |
| vdatetime_value.cpp | Adds template instantiations for new time units |
| function_date_or_datetime_to_string.cpp | Registers new extract functions |
| function_date_or_datetime_computation.h | Major refactoring to unified AddUnionTypeImpl template |
| function_date_or_datetime_computation.cpp | Updates function registrations with macros |
| datetime_errors.h | Adds error helpers and time unit name mapping |
| date_time_transforms.h | Adds format implementations for extract |
| date_format_type.h | Adds low-level format structs for string conversion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What problem does this PR solve?
Issue Number: close #xxx
Related PR: Fix the wrong behavior introduced in: #57253
Problem Summary:
Release note
doc: apache/doris-website#3315
Support all time unit in Mysql: https://dev.mysql.com/doc/refman/8.4/en/expressions.html#temporal-intervals
Affected function:
DATE_ADD/SUB,EXTRACTCheck List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)