Mryange commented on code in PR #51475:
URL: https://github.com/apache/doris/pull/51475#discussion_r2163473685


##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -1207,4 +1209,33 @@ class FunctionNextDay : public IFunction {
     }
 };
 
+class FunctionTime : public IFunction {
+public:
+    static constexpr auto name = "time";
+    static FunctionPtr create() { return std::make_shared<FunctionTime>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeTimeV2>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        uint32_t result, size_t input_rows_count) const 
override {
+        DCHECK_EQ(arguments.size(), 1);
+        ColumnPtr col = block.get_by_position(arguments[0]).column;
+        const auto* arg = assert_cast<const ColumnDateTimeV2*>(col.get());
+        ColumnTimeV2::MutablePtr res = ColumnTimeV2::create(input_rows_count);
+        auto& res_data = res->get_data();
+        for (int i = 0; i < arg->size(); i++) {
+            const auto* v =
+                    reinterpret_cast<const 
DateV2Value<DateTimeV2ValueType>*>(&arg->get_element(i));

Review Comment:
    const auto* arg = assert_cast<const ColumnDateTimeV2*>(col.get());
    可以换成
     const auto& arg = assert_cast<const ColumnDateTimeV2&>(col.get());
     
     这里这个reinterpret_cast也可以把指针换成引用。



-- 
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]

Reply via email to