github-actions[bot] commented on code in PR #45265:
URL: https://github.com/apache/doris/pull/45265#discussion_r1880786196
##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -753,48 +419,160 @@ class FunctionDateOrDateTimeComputation : public
IFunction {
WhichDataType which1(remove_nullable(first_arg_type));
WhichDataType which2(remove_nullable(second_arg_type));
+ /// now dispatch with the two arguments' type. no need to consider
return type because the same arguments decide a
+ /// unique return type which could be extracted from Transform.
+
+ // for all `xxx_add/sub`, the second arg is int32.
+ // for `week/yearweek`, if it has the second arg, it's int32.
+ // in these situations, the first would be any datelike type.
+ if (which2.is_int32()) {
+ switch (which1.idx) {
+ case TypeIndex::Date:
+ return execute_inner<DataTypeDate::FieldType, Int32>(block,
arguments, result,
+
input_rows_count);
+ break;
+ case TypeIndex::DateTime:
+ return execute_inner<DataTypeDateTime::FieldType,
Int32>(block, arguments, result,
+
input_rows_count);
+ break;
+ case TypeIndex::DateV2:
+ return execute_inner<DataTypeDateV2::FieldType, Int32>(block,
arguments, result,
+
input_rows_count);
+ break;
+ case TypeIndex::DateTimeV2:
+ return execute_inner<DataTypeDateTimeV2::FieldType,
Int32>(block, arguments, result,
+
input_rows_count);
+ break;
+ default:
+ return Status::InternalError("Illegal argument {} and {} of
function {}",
+
block.get_by_position(arguments[0]).type->get_name(),
+
block.get_by_position(arguments[1]).type->get_name(),
+ get_name());
+ }
+ }
+ // then consider datelike - datelike. everything is possible here as
well.
+ // for `xxx_diff`, every combination of V2 is possible. but for V1 we
only support Datetime - Datetime
if (which1.is_date_v2() && which2.is_date_v2()) {
- return DateTimeAddIntervalImpl<DataTypeDateV2::FieldType,
Transform,
-
DataTypeDateV2::FieldType>::execute(block, arguments,
-
result,
-
input_rows_count);
+ return execute_inner<DataTypeDateV2::FieldType,
DataTypeDateV2::FieldType>(
+ block, arguments, result, input_rows_count);
} else if (which1.is_date_time_v2() && which2.is_date_time_v2()) {
- return DateTimeAddIntervalImpl<
- DataTypeDateTimeV2::FieldType, Transform,
- DataTypeDateTimeV2::FieldType>::execute(block, arguments,
result,
- input_rows_count);
- } else if (which1.is_date_time() && which2.is_date_time()) {
- return DateTimeAddIntervalImpl<DataTypeDateTime::FieldType,
Transform,
-
DataTypeDateTime::FieldType>::execute(block, arguments,
-
result,
-
input_rows_count);
- } else if (which1.is_date_v2() && which2.is_date_time_v2()) {
- return DateTimeAddIntervalImpl<
- DataTypeDateV2::FieldType, Transform,
- DataTypeDateTimeV2::FieldType>::execute(block, arguments,
result,
- input_rows_count);
- } else if (which1.is_date_time_v2() && which2.is_date_v2()) {
- return DateTimeAddIntervalImpl<DataTypeDateTimeV2::FieldType,
Transform,
-
DataTypeDateV2::FieldType>::execute(block, arguments,
-
result,
-
input_rows_count);
- } else if (which1.is_date()) {
- return DateTimeAddIntervalImpl<DataTypeDate::FieldType,
Transform>::execute(
+ return execute_inner<DataTypeDateTimeV2::FieldType,
DataTypeDateTimeV2::FieldType>(
block, arguments, result, input_rows_count);
- } else if (which1.is_date_time()) {
- return DateTimeAddIntervalImpl<DataTypeDateTime::FieldType,
Transform>::execute(
+ } else if (which1.is_date_v2() && which2.is_date_time_v2()) {
+ return execute_inner<DataTypeDateV2::FieldType,
DataTypeDateTimeV2::FieldType>(
block, arguments, result, input_rows_count);
- } else if (which1.is_date_v2()) {
- return DateTimeAddIntervalImpl<DataTypeDateV2::FieldType,
Transform>::execute(
+ } else if (which1.is_date_time_v2() && which2.is_date_v2()) {
+ return execute_inner<DataTypeDateTimeV2::FieldType,
DataTypeDateV2::FieldType>(
block, arguments, result, input_rows_count);
- } else if (which1.is_date_time_v2()) {
- return DateTimeAddIntervalImpl<DataTypeDateTimeV2::FieldType,
Transform>::execute(
+ } else if (which1.is_date_time() && which2.is_date_time()) {
+ return execute_inner<DataTypeDateTime::FieldType,
DataTypeDateTime::FieldType>(
block, arguments, result, input_rows_count);
- } else {
- return Status::RuntimeError("Illegal type {} of argument of
function {}",
-
block.get_by_position(arguments[0]).type->get_name(),
- get_name());
}
+ return Status::InternalError("Illegal argument {} and {} of function
{}",
+
block.get_by_position(arguments[0]).type->get_name(),
+
block.get_by_position(arguments[1]).type->get_name(),
+ get_name());
+ }
+
+ template <typename FromType0, typename FromType1> // are native types
+ static Status execute_inner(Block& block, const ColumnNumbers& arguments,
uint32_t result,
Review Comment:
warning: function 'execute_inner' exceeds recommended size/complexity
thresholds [readability-function-size]
```cpp
static Status execute_inner(Block& block, const ColumnNumbers&
arguments, uint32_t result,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/functions/function_date_or_datetime_computation.h:477:** 97
lines including whitespace and comments (threshold 80)
```cpp
static Status execute_inner(Block& block, const ColumnNumbers&
arguments, uint32_t result,
^
```
</details>
##########
be/src/vec/functions/array/function_array_range.cpp:
##########
@@ -16,10 +16,10 @@
// under the License.
#include <glog/logging.h>
Review Comment:
warning: 'glog/logging.h' file not found [clang-diagnostic-error]
```cpp
#include <glog/logging.h>
^
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]