github-actions[bot] commented on code in PR #26810:
URL: https://github.com/apache/doris/pull/26810#discussion_r1390206273
##########
be/src/vec/functions/function_convert_tz.h:
##########
@@ -57,23 +58,93 @@
#include "vec/runtime/vdatetime_value.h"
namespace doris::vectorized {
-template <typename DateValueType, typename ArgType>
-struct ConvertTZImpl {
- using ColumnType = std::conditional_t<
- std::is_same_v<DateV2Value<DateV2ValueType>, DateValueType>,
ColumnDateV2,
-
std::conditional_t<std::is_same_v<DateV2Value<DateTimeV2ValueType>,
DateValueType>,
- ColumnDateTimeV2, ColumnDateTime>>;
- using NativeType = std::conditional_t<
- std::is_same_v<DateV2Value<DateV2ValueType>, DateValueType>,
UInt32,
-
std::conditional_t<std::is_same_v<DateV2Value<DateTimeV2ValueType>,
DateValueType>,
- UInt64, Int64>>;
- using ReturnDateType = std::conditional_t<std::is_same_v<VecDateTimeValue,
DateValueType>,
- VecDateTimeValue,
DateV2Value<DateTimeV2ValueType>>;
- using ReturnNativeType =
- std::conditional_t<std::is_same_v<VecDateTimeValue,
DateValueType>, Int64, UInt64>;
- using ReturnColumnType =
std::conditional_t<std::is_same_v<VecDateTimeValue, DateValueType>,
- ColumnDateTime,
ColumnDateTimeV2>;
+template <typename ArgDateType>
+class FunctionConvertTZ : public IFunction {
+ using DateValueType = date_cast::TypeToValueTypeV<ArgDateType>;
+ using ColumnType = date_cast::TypeToColumnV<ArgDateType>;
+ using NativeType = date_cast::ValueTypeOfColumnV<ColumnType>;
+ constexpr static bool is_v1 = date_cast::IsV1<ArgDateType>();
+ using ReturnDateType =
+ std::conditional_t<is_v1, DataTypeDateTime, ArgDateType>;
+ using ReturnDateValueType = date_cast::TypeToValueTypeV<ReturnDateType>;
+ using ReturnColumnType = date_cast::TypeToColumnV<ReturnDateType>;
+ using ReturnNativeType = date_cast::ValueTypeOfColumnV<ReturnColumnType>;
+
+public:
+ static constexpr auto name = "convert_tz";
+
+ static FunctionPtr create() { return
std::make_shared<FunctionConvertTZ>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 3; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ if constexpr (is_v1) {
+ return make_nullable(std::make_shared<DataTypeDateTime>());
+ } else {
+ return make_nullable(std::make_shared<DataTypeDateTimeV2>());
+ }
+ }
+
+ bool is_variadic() const override { return true; }
+
+ DataTypes get_variadic_argument_types_impl() const override {
+ return {std::make_shared<ArgDateType>(),
std::make_shared<DataTypeString>(),
+ std::make_shared<DataTypeString>()};
+ }
+
+ bool use_default_implementation_for_nulls() const override { return false;
}
+
+ Status close(FunctionContext* context, FunctionContext::FunctionStateScope
scope) override {
+ return Status::OK();
+ }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) const override
{
+ auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
+
+ bool col_const[3];
Review Comment:
warning: do not declare C-style arrays, use std::array<> instead
[modernize-avoid-c-arrays]
```cpp
bool col_const[3];
^
```
--
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]