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

Add timestampadd/timestampdiff function #2725

Merged
merged 5 commits into from
Jan 15, 2020
Merged

Conversation

HangyuanLiu
Copy link
Contributor

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

Copy link
Contributor

@imay imay left a 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

# Conflicts:
#	be/src/exprs/timestamp_functions.cpp
#	be/test/exprs/timestamp_functions_test.cpp
;

unit ::=
KW_YEAR
Copy link
Contributor

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

Comment on lines 131 to 140
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);
}
Copy link
Contributor

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?

Copy link
Contributor

@imay imay left a comment

Choose a reason for hiding this comment

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

LGTM

@imay imay merged commit 0ddca59 into apache:master Jan 15, 2020
yangzhg added a commit to yangzhg/doris that referenced this pull request Feb 14, 2020
yangzhg added a commit to yangzhg/doris that referenced this pull request Feb 14, 2020
morningman pushed a commit that referenced this pull request Feb 14, 2020
Fix a sqlparser conflict imported by pr #2725, in that pr add some time unit to keyword
I have moved those to time_unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants