-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add timestampadd/timestampdiff function #2725
Conversation
fe/src/main/java/org/apache/doris/analysis/TimestampArithmeticExpr.java
Outdated
Show resolved
Hide resolved
f5bd079
to
c02ed75
Compare
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.
please add some comment for the new added function
c02ed75
to
d2ea231
Compare
# Conflicts: # be/src/exprs/timestamp_functions.cpp # be/test/exprs/timestamp_functions_test.cpp
fe/src/main/cup/sql_parser.cup
Outdated
; | ||
|
||
unit ::= | ||
KW_YEAR |
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.
should add this new keyword to keywords rule
docs/documentation/cn/sql-reference/sql-functions/date-time-functions/timestampadd.md
Outdated
Show resolved
Hide resolved
docs/documentation/cn/sql-reference/sql-functions/date-time-functions/timestampdiff.md
Outdated
Show resolved
Hide resolved
149b1c7
to
afeaba2
Compare
Type dateType = fixType(); | ||
if (dateType.isDate() && timeUnit.isDateTime()) { | ||
dateType = Type.DATETIME; | ||
} | ||
// The first child must return a timestamp or null. | ||
if (!getChild(0).getType().isDateType() && !getChild(0).getType().isNull()) { | ||
if (!dateType.isValid()) { | ||
throw new AnalysisException("Operand '" + getChild(0).toSql() | ||
+ "' of timestamp arithmetic expression '" + toSql() + "' returns type '" | ||
+ getChild(0).getType() + "'. Expected type 'TIMESTAMP/DATE/DATETIME'."); | ||
} | ||
castChild(dateType, 0); | ||
} |
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.
seems that these codes are the same with others.
Could you try to reduce these same code?
afeaba2
to
8b478b4
Compare
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.
LGTM
1.Support timestampdiff function
2.Support timestampadd function
3.Add Doris keyword (YRAR,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND)
4.Fix some cup format
#2703