-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add timediff function #1505
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 timediff function #1505
Conversation
|
I think that you need't import a new udf type to implement timediff. |
gensrc/script/gen_functions.py
Outdated
| 'VARCHAR': 'string_val', | ||
| 'DATE': 'datetime_val', | ||
| 'DATETIME': 'datetime_val', | ||
| 'TIME': 'datetime_val', |
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.
I think it's better to use bigint_val
| } | ||
| // no need to check upper bound | ||
| break; | ||
| case TIME: |
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.
I think it is not fit to add type TIME in IntLiteral
| case TYPE_DATETIME: | ||
| case TYPE_TIME: { | ||
| char buf[64]; | ||
| const DateTimeValue* time_val = (const DateTimeValue*)(item); |
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.
I think use bigint to represent time in memory?
403f208 to
4fb06b4
Compare
be/src/exprs/literal.cpp
Outdated
| _value.datetime_val.from_date_str( | ||
| node.date_literal.value.c_str(), node.date_literal.value.size()); | ||
| break; | ||
| case TYPE_TIME: |
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.
reuse TYPE_DOUBLE
| public: | ||
| static void init(); | ||
|
|
||
| static BooleanVal cast_to_boolean_val(FunctionContext*, const DoubleVal&); |
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.
I think we can only support time to double and to string
be/src/runtime/raw_value.cpp
Outdated
| break; | ||
| } | ||
|
|
||
| case TYPE_TIME: |
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.
I think this should be the same as TYPE_DOUBLE
| buf_ret = _row_buffer->push_double(*static_cast<double*>(item)); | ||
| break; | ||
|
|
||
| case TYPE_TIME: { |
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.
you can write a function to do this to avoid write this many times
| case INT: | ||
| return "IntVal"; | ||
| case BIGINT: | ||
| case TIME: |
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.
why BIGINT?
| compatibilityMatrix[DECIMALV2.ordinal()][DECIMAL.ordinal()] = DECIMALV2; | ||
|
|
||
| compatibilityMatrix[HLL.ordinal()][HLL.ordinal()] = HLL; | ||
| compatibilityMatrix[TIME.ordinal()][TIME.ordinal()] = TIME; |
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.
you should add more relation between time and other types
e649d62 to
92d7b85
Compare
92d7b85 to
7118a60
Compare
imay
left a comment
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
merge to apache-doris 0694b6a
Add timediff function
#1428