You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by github-actions on 2023/01/28 12:03:22 UTC
[GitHub] [doris] github-actions[bot] commented on a diff in pull request #16159: [datev2](function) make function nullable DEPEND_ON_ARGUMENT
github-actions[bot] commented on code in PR #16159:
URL: https://github.com/apache/doris/pull/16159#discussion_r1089723206
##########
be/src/vec/functions/function_timestamp.cpp:
##########
@@ -721,37 +837,59 @@
static Status execute_impl(FunctionContext* context, Block& block,
const ColumnNumbers& arguments, size_t result,
size_t input_rows_count) {
- auto null_map = ColumnUInt8::create(input_rows_count, 0);
- ColumnPtr res_column;
+ const auto is_nullable = block.get_by_position(result).type->is_nullable();
ColumnPtr argument_column =
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
- if constexpr (std::is_same_v<DateType, DataTypeDateTime> ||
- std::is_same_v<DateType, DataTypeDate>) {
- auto data_col = assert_cast<const ColumnVector<Int64>*>(argument_column.get());
- res_column = ColumnInt64::create(input_rows_count);
- execute_straight<VecDateTimeValue, Int64, Int64>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<Int64>*>(res_column->assume_mutable().get())
- ->get_data());
-
- } else if constexpr (std::is_same_v<DateType, DataTypeDateV2>) {
- auto data_col = assert_cast<const ColumnVector<UInt32>*>(argument_column.get());
- res_column = ColumnVector<UInt32>::create(input_rows_count);
- execute_straight<DateV2Value<DateV2ValueType>, UInt32, UInt32>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
- ->get_data());
+ ColumnPtr res_column;
+ if (is_nullable) {
+ auto null_map = ColumnUInt8::create(input_rows_count, 0);
+ if constexpr (std::is_same_v<DateType, DataTypeDateTime> ||
+ std::is_same_v<DateType, DataTypeDate>) {
+ auto data_col = assert_cast<const ColumnVector<Int64>*>(argument_column.get());
+ res_column = ColumnInt64::create(input_rows_count);
+ execute_straight<VecDateTimeValue, Int64, Int64>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<Int64>*>(res_column->assume_mutable().get())
+ ->get_data());
- } else if constexpr (std::is_same_v<DateType, DataTypeDateTimeV2>) {
- auto data_col = assert_cast<const ColumnVector<UInt64>*>(argument_column.get());
- res_column = ColumnVector<UInt32>::create(input_rows_count);
- execute_straight<DateV2Value<DateTimeV2ValueType>, UInt32, UInt64>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
- ->get_data());
+ } else if constexpr (std::is_same_v<DateType, DataTypeDateV2>) {
+ auto data_col = assert_cast<const ColumnVector<UInt32>*>(argument_column.get());
+ res_column = ColumnVector<UInt32>::create(input_rows_count);
+ execute_straight<DateV2Value<DateV2ValueType>, UInt32, UInt32>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
+ ->get_data());
+
+ } else if constexpr (std::is_same_v<DateType, DataTypeDateTimeV2>) {
+ auto data_col = assert_cast<const ColumnVector<UInt64>*>(argument_column.get());
+ res_column = ColumnVector<UInt32>::create(input_rows_count);
+ execute_straight<DateV2Value<DateTimeV2ValueType>, UInt32, UInt64>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
+ ->get_data());
+ }
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(res_column), std::move(null_map)));
Review Comment:
warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
```suggestion
result, ColumnNullable::create(res_column, std::move(null_map)));
```
##########
be/src/vec/functions/function_timestamp.cpp:
##########
@@ -620,38 +690,59 @@ struct LastDayImpl {
static Status execute_impl(FunctionContext* context, Block& block,
const ColumnNumbers& arguments, size_t result,
size_t input_rows_count) {
- auto null_map = ColumnUInt8::create(input_rows_count, 0);
+ const auto is_nullable = block.get_by_position(result).type->is_nullable();
+ auto null_map = ColumnUInt8::create();
ColumnPtr res_column;
ColumnPtr argument_column =
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
- if constexpr (std::is_same_v<DateType, DataTypeDateTime> ||
- std::is_same_v<DateType, DataTypeDate>) {
- auto data_col = assert_cast<const ColumnVector<Int64>*>(argument_column.get());
- res_column = ColumnInt64::create(input_rows_count);
- execute_straight<VecDateTimeValue, Int64, Int64>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<Int64>*>(res_column->assume_mutable().get())
- ->get_data());
+ if (is_nullable) {
+ null_map->resize(input_rows_count);
+ if constexpr (std::is_same_v<DateType, DataTypeDateTime> ||
+ std::is_same_v<DateType, DataTypeDate>) {
+ auto data_col = assert_cast<const ColumnVector<Int64>*>(argument_column.get());
+ res_column = ColumnInt64::create(input_rows_count);
+ execute_straight<VecDateTimeValue, Int64, Int64>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<Int64>*>(res_column->assume_mutable().get())
+ ->get_data());
- } else if constexpr (std::is_same_v<DateType, DataTypeDateV2>) {
- auto data_col = assert_cast<const ColumnVector<UInt32>*>(argument_column.get());
- res_column = ColumnVector<UInt32>::create(input_rows_count);
- execute_straight<DateV2Value<DateV2ValueType>, UInt32, UInt32>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
- ->get_data());
-
- } else if constexpr (std::is_same_v<DateType, DataTypeDateTimeV2>) {
- auto data_col = assert_cast<const ColumnVector<UInt64>*>(argument_column.get());
- res_column = ColumnVector<UInt32>::create(input_rows_count);
- execute_straight<DateV2Value<DateTimeV2ValueType>, UInt32, UInt64>(
- input_rows_count, null_map->get_data(), data_col->get_data(),
- static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
- ->get_data());
+ } else if constexpr (std::is_same_v<DateType, DataTypeDateV2>) {
+ auto data_col = assert_cast<const ColumnVector<UInt32>*>(argument_column.get());
+ res_column = ColumnVector<UInt32>::create(input_rows_count);
+ execute_straight<DateV2Value<DateV2ValueType>, UInt32, UInt32>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
+ ->get_data());
+
+ } else if constexpr (std::is_same_v<DateType, DataTypeDateTimeV2>) {
+ auto data_col = assert_cast<const ColumnVector<UInt64>*>(argument_column.get());
+ res_column = ColumnVector<UInt32>::create(input_rows_count);
+ execute_straight<DateV2Value<DateTimeV2ValueType>, UInt32, UInt64>(
+ input_rows_count, null_map->get_data(), data_col->get_data(),
+ static_cast<ColumnVector<UInt32>*>(res_column->assume_mutable().get())
+ ->get_data());
+ }
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(res_column), std::move(null_map)));
Review Comment:
warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
```suggestion
result, ColumnNullable::create(res_column, std::move(null_map)));
```
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org