zclllyybb commented on code in PR #26827:
URL: https://github.com/apache/doris/pull/26827#discussion_r1403416523


##########
be/src/vec/functions/function_timestamp.cpp:
##########
@@ -570,6 +576,100 @@ template <typename DateType>
 struct UnixTimeStampDateImpl {
     static DataTypes get_variadic_argument_types() { return 
{std::make_shared<DateType>()}; }
 
+    static DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& 
arguments) {
+        if constexpr (std::is_same_v<DateType, DataTypeDateTimeV2>) {
+            if (arguments[0].type->is_nullable()) {
+                UInt32 scale = static_cast<const 
DataTypeNullable*>(arguments[0].type.get())
+                                       ->get_nested_type()
+                                       ->get_scale();
+                return make_nullable(
+                        std::make_shared<DataTypeDecimal<Decimal64>>(10 + 
scale, scale));
+            }
+            UInt32 scale = arguments[0].type->get_scale();
+            return std::make_shared<DataTypeDecimal<Decimal64>>(10 + scale, 
scale);
+        } else {
+            if (arguments[0].type->is_nullable()) {
+                return make_nullable(std::make_shared<DataTypeInt32>());
+            }
+            return std::make_shared<DataTypeInt32>();
+        }
+    }
+
+    static Status execute_impl(FunctionContext* context, Block& block,
+                               const ColumnNumbers& arguments, size_t result,
+                               size_t input_rows_count) {
+        const ColumnPtr& col_source = 
block.get_by_position(arguments[0]).column;
+        DCHECK(!col_source->is_nullable());
+
+        if constexpr (std::is_same_v<DateType, DataTypeDate> ||
+                      std::is_same_v<DateType, DataTypeDateTime>) {
+            auto col_result = ColumnVector<Int32>::create();
+            auto& col_result_data = col_result->get_data();
+            col_result->resize(input_rows_count);
+
+            for (int i = 0; i < input_rows_count; i++) {
+                StringRef source = col_source->get_data_at(i);

Review Comment:
   done



-- 
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-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to