You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/27 11:12:12 UTC

[GitHub] [doris] ZhangYiXi-dev opened a new pull request, #13737: [feature](running_difference) support running_difference function

ZhangYiXi-dev opened a new pull request, #13737:
URL: https://github.com/apache/doris/pull/13737

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Calculates the difference between successive row values ​​in the data block. Returns 0 for the first row and the difference from the previous row for each subsequent row.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [x] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [x] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [x] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [x] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [x] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


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


[GitHub] [doris] zhangstar333 commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
zhangstar333 commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1007548972


##########
be/src/vec/functions/function_running_difference.h:
##########
@@ -0,0 +1,188 @@
+#pragma once
+
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/number_traits.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_time_v2.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "common/status.h"
+#include "vec/common/assert_cast.h"
+#include "vec/functions/function.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_string.h"
+#include "vec/columns/columns_number.h"
+#include "vec/common/typeid_cast.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized{
+class FunctionRunningDifference : public IFunction
+{
+private:
+    /// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented.
+    //NO_SANITIZE_UNDEFINED
+    template <typename Src, typename Dst>
+    static void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
+    {
+        size_t size = src.size();
+        dst.resize(size);
+
+        if (size == 0)
+            return;
+
+        /// It is possible to SIMD optimize this loop. By no need for that in practice.
+
+        Src prev{};
+        bool has_prev_value = false;
+
+        for (size_t i = 0; i < size; ++i)
+        {
+            if (null_map && (*null_map)[i])
+            {
+                dst[i] = Dst{};
+                continue;
+            }
+
+            if (!has_prev_value)
+            {
+                dst[i] = 0;
+                prev = src[i];
+                has_prev_value = true;
+            }
+            else
+            {
+                auto cur = src[i];
+                /// Overflow is Ok.
+                dst[i] = static_cast<Dst>(cur) - prev;
+                prev = cur;
+            }
+        }
+    }
+
+    /// Result type is same as result of subtraction of argument types.
+    template <typename SrcFieldType>
+    using DstFieldType = typename NumberTraits::ResultOfSubtraction<SrcFieldType, SrcFieldType>::Type;
+
+    /// Call polymorphic lambda with tag argument of concrete field type of src_type.
+    template <typename F>
+    void dispatchForSourceType(const IDataType & src_type, F && f) const
+    {
+        WhichDataType which(src_type);
+
+        if (which.is_uint8())
+            f(UInt8());
+        else if (which.is_uint16())
+            f(UInt16());
+        else if (which.is_uint32())
+            f(UInt32());
+        else if (which.is_uint64())
+            f(UInt64());
+        else if (which.is_int8())
+            f(Int8());
+        else if (which.is_int16())
+            f(Int16());
+        else if (which.is_int32())
+            f(Int32());
+        else if (which.is_int64())
+            f(Int64());
+        else if (which.is_float32())
+            f(Float32());
+        else if (which.is_float64())
+            f(Float64());
+        else if (which.is_date())
+            f(DataTypeDate::FieldType());
+        else if (which.is_date_v2())
+            f(DataTypeDateV2::FieldType());
+        else if (which.is_date_time())
+            f(DataTypeDateTime::FieldType());
+        else
+            throw Exception("Argument for function " + get_name() + " must have numeric type.", 1/*ErrorCode::ILLEGAL_TYPE_OF_ARGUMENT*/);
+    }
+
+public:
+    static constexpr auto name = "running_difference";
+
+    static FunctionPtr create(){
+        return std::make_shared<FunctionRunningDifference>();
+    }
+
+    String get_name() const override {
+        return name;
+    }
+
+    bool is_stateful() const override{
+        return true;
+    } 
+
+    size_t get_number_of_arguments() const override
+    {
+        return 1;
+    }
+
+    bool is_deterministic() const override { return false; }
+    bool is_deterministic_in_scope_of_query() const override
+    {
+         return false;
+    } 
+
+   // bool is_suitable_for_short_circuit_arguments_execution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    DataTypePtr get_return_type_impl(const DataTypes & arguments) const override
+    {
+        DataTypePtr res;
+        dispatchForSourceType(*remove_nullable(arguments[0]), [&](auto field_type_tag)
+        {
+            res = std::make_shared<DataTypeNumber<DstFieldType<decltype(field_type_tag)>>>();
+        });
+
+        if (arguments[0]->is_nullable())
+            res = make_nullable(res);
+

Review Comment:
   I see in ...functions.py file, you set return type is ALWAYS_NOT_NULLABLE, but here make_nullable



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


[GitHub] [doris] zhangstar333 commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
zhangstar333 commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1007548140


##########
be/src/vec/functions/function_running_difference.h:
##########
@@ -0,0 +1,188 @@
+#pragma once
+
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/number_traits.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_time_v2.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "common/status.h"
+#include "vec/common/assert_cast.h"
+#include "vec/functions/function.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_string.h"
+#include "vec/columns/columns_number.h"
+#include "vec/common/typeid_cast.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized{
+class FunctionRunningDifference : public IFunction
+{
+private:
+    /// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented.
+    //NO_SANITIZE_UNDEFINED
+    template <typename Src, typename Dst>
+    static void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
+    {
+        size_t size = src.size();
+        dst.resize(size);
+
+        if (size == 0)
+            return;
+
+        /// It is possible to SIMD optimize this loop. By no need for that in practice.
+
+        Src prev{};
+        bool has_prev_value = false;
+
+        for (size_t i = 0; i < size; ++i)
+        {
+            if (null_map && (*null_map)[i])
+            {
+                dst[i] = Dst{};
+                continue;
+            }
+
+            if (!has_prev_value)
+            {
+                dst[i] = 0;
+                prev = src[i];
+                has_prev_value = true;
+            }
+            else
+            {
+                auto cur = src[i];
+                /// Overflow is Ok.
+                dst[i] = static_cast<Dst>(cur) - prev;
+                prev = cur;
+            }
+        }
+    }
+
+    /// Result type is same as result of subtraction of argument types.
+    template <typename SrcFieldType>
+    using DstFieldType = typename NumberTraits::ResultOfSubtraction<SrcFieldType, SrcFieldType>::Type;
+
+    /// Call polymorphic lambda with tag argument of concrete field type of src_type.
+    template <typename F>
+    void dispatchForSourceType(const IDataType & src_type, F && f) const
+    {
+        WhichDataType which(src_type);
+
+        if (which.is_uint8())
+            f(UInt8());
+        else if (which.is_uint16())
+            f(UInt16());
+        else if (which.is_uint32())
+            f(UInt32());
+        else if (which.is_uint64())
+            f(UInt64());
+        else if (which.is_int8())
+            f(Int8());
+        else if (which.is_int16())
+            f(Int16());
+        else if (which.is_int32())
+            f(Int32());
+        else if (which.is_int64())
+            f(Int64());
+        else if (which.is_float32())
+            f(Float32());
+        else if (which.is_float64())
+            f(Float64());
+        else if (which.is_date())
+            f(DataTypeDate::FieldType());
+        else if (which.is_date_v2())
+            f(DataTypeDateV2::FieldType());
+        else if (which.is_date_time())
+            f(DataTypeDateTime::FieldType());
+        else
+            throw Exception("Argument for function " + get_name() + " must have numeric type.", 1/*ErrorCode::ILLEGAL_TYPE_OF_ARGUMENT*/);
+    }
+
+public:
+    static constexpr auto name = "running_difference";
+
+    static FunctionPtr create(){
+        return std::make_shared<FunctionRunningDifference>();
+    }
+
+    String get_name() const override {
+        return name;
+    }
+
+    bool is_stateful() const override{
+        return true;
+    } 
+
+    size_t get_number_of_arguments() const override
+    {
+        return 1;
+    }
+
+    bool is_deterministic() const override { return false; }
+    bool is_deterministic_in_scope_of_query() const override
+    {
+         return false;
+    } 
+
+   // bool is_suitable_for_short_circuit_arguments_execution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+

Review Comment:
   maybe it's better to return true



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


[GitHub] [doris] dataroaring commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
dataroaring commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1008992843


##########
regression-test/suites/query_p0/sql_functions/math_functions/test_running_difference.sql:
##########
@@ -0,0 +1,55 @@
+DROP TABLE IF EXISTS running_difference_test;
+
+CREATE TABLE running_difference_test (
+                 `id` int NULL COMMENT 'id' ,
+                `day` date COMMENT 'day', 
+	`time_val` datetime COMMENT 'time_val',
+ 	`doublenum` double NULL COMMENT 'doublenum'
+                )

Review Comment:
   add a column not nullale.



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


[GitHub] [doris] zhangstar333 commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
zhangstar333 commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1009133812


##########
be/src/vec/functions/function_running_difference.h:
##########
@@ -0,0 +1,124 @@
+#pragma once
+
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/number_traits.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_time_v2.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "common/status.h"
+#include "vec/common/assert_cast.h"
+#include "vec/functions/function.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_string.h"
+#include "vec/columns/columns_number.h"
+#include "vec/common/typeid_cast.h"
+#include "vec/functions/simple_function_factory.h"
+#include "vec/columns/column.h"
+#include "vec/data_types/data_type_nullable.h"
+
+namespace doris::vectorized {
+
+class FunctionRunningDifference : public IFunction {
+public:
+    static constexpr auto name = "running_difference";
+
+    static FunctionPtr create() { return std::make_shared<FunctionRunningDifference>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    bool use_default_implementation_for_constants() const override { return true; }
+
+    template <typename SrcFieldType>
+    using DstFieldType = typename NumberTraits::ResultOfSubtraction<SrcFieldType, SrcFieldType>::Type;

Review Comment:
   now seems it's could remove
    



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


[GitHub] [doris] HappenLee commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
HappenLee commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1020864738


##########
be/src/vec/functions/function_running_difference.h:
##########
@@ -0,0 +1,138 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "common/status.h"
+#include "vec/columns/column.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_string.h"
+#include "vec/columns/columns_number.h"
+#include "vec/common/assert_cast.h"
+#include "vec/common/typeid_cast.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_nullable.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_time_v2.h"
+#include "vec/data_types/number_traits.h"
+#include "vec/functions/function.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+class FunctionRunningDifference : public IFunction {
+public:
+    static constexpr auto name = "running_difference";
+
+    static FunctionPtr create() { return std::make_shared<FunctionRunningDifference>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    bool use_default_implementation_for_constants() const override { return true; }

Review Comment:
   `use_default_implementation_for_constants` should be false.



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


[GitHub] [doris] dataroaring commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
dataroaring commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1008988110


##########
be/src/vec/functions/function_running_difference.cpp:
##########
@@ -0,0 +1,13 @@
+#include "vec/functions/function_running_difference.h"
+
+namespace doris::vectorized {
+
+void register_function_running_difference(SimpleFunctionFactory& factory) {
+    //factory.register_function<FunctionRunningDifferenceImpl<false>>();
+    factory.register_function<FunctionRunningDifference>();
+    //factory.register_function<FunctionCase<false, true>>();
+    //factory.register_function<FunctionCase<true, false>>();
+    //factory.register_function<FunctionCase<true, true>>();

Review Comment:
   Please remove useless comment.



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


[GitHub] [doris] hello-stephen commented on pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13737:
URL: https://github.com/apache/doris/pull/13737#issuecomment-1294463034

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 38.77 seconds
    load time: 559 seconds
    storage size: 17154644859 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221028050643_clickbench_pr_35136.html


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


[GitHub] [doris] zhangstar333 commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
zhangstar333 commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1007548140


##########
be/src/vec/functions/function_running_difference.h:
##########
@@ -0,0 +1,188 @@
+#pragma once
+
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/number_traits.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_time_v2.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "common/status.h"
+#include "vec/common/assert_cast.h"
+#include "vec/functions/function.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_string.h"
+#include "vec/columns/columns_number.h"
+#include "vec/common/typeid_cast.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized{
+class FunctionRunningDifference : public IFunction
+{
+private:
+    /// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented.
+    //NO_SANITIZE_UNDEFINED
+    template <typename Src, typename Dst>
+    static void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
+    {
+        size_t size = src.size();
+        dst.resize(size);
+
+        if (size == 0)
+            return;
+
+        /// It is possible to SIMD optimize this loop. By no need for that in practice.
+
+        Src prev{};
+        bool has_prev_value = false;
+
+        for (size_t i = 0; i < size; ++i)
+        {
+            if (null_map && (*null_map)[i])
+            {
+                dst[i] = Dst{};
+                continue;
+            }
+
+            if (!has_prev_value)
+            {
+                dst[i] = 0;
+                prev = src[i];
+                has_prev_value = true;
+            }
+            else
+            {
+                auto cur = src[i];
+                /// Overflow is Ok.
+                dst[i] = static_cast<Dst>(cur) - prev;
+                prev = cur;
+            }
+        }
+    }
+
+    /// Result type is same as result of subtraction of argument types.
+    template <typename SrcFieldType>
+    using DstFieldType = typename NumberTraits::ResultOfSubtraction<SrcFieldType, SrcFieldType>::Type;
+
+    /// Call polymorphic lambda with tag argument of concrete field type of src_type.
+    template <typename F>
+    void dispatchForSourceType(const IDataType & src_type, F && f) const
+    {
+        WhichDataType which(src_type);
+
+        if (which.is_uint8())
+            f(UInt8());
+        else if (which.is_uint16())
+            f(UInt16());
+        else if (which.is_uint32())
+            f(UInt32());
+        else if (which.is_uint64())
+            f(UInt64());
+        else if (which.is_int8())
+            f(Int8());
+        else if (which.is_int16())
+            f(Int16());
+        else if (which.is_int32())
+            f(Int32());
+        else if (which.is_int64())
+            f(Int64());
+        else if (which.is_float32())
+            f(Float32());
+        else if (which.is_float64())
+            f(Float64());
+        else if (which.is_date())
+            f(DataTypeDate::FieldType());
+        else if (which.is_date_v2())
+            f(DataTypeDateV2::FieldType());
+        else if (which.is_date_time())
+            f(DataTypeDateTime::FieldType());
+        else
+            throw Exception("Argument for function " + get_name() + " must have numeric type.", 1/*ErrorCode::ILLEGAL_TYPE_OF_ARGUMENT*/);
+    }
+
+public:
+    static constexpr auto name = "running_difference";
+
+    static FunctionPtr create(){
+        return std::make_shared<FunctionRunningDifference>();
+    }
+
+    String get_name() const override {
+        return name;
+    }
+
+    bool is_stateful() const override{
+        return true;
+    } 
+
+    size_t get_number_of_arguments() const override
+    {
+        return 1;
+    }
+
+    bool is_deterministic() const override { return false; }
+    bool is_deterministic_in_scope_of_query() const override
+    {
+         return false;
+    } 
+
+   // bool is_suitable_for_short_circuit_arguments_execution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+

Review Comment:
   maybe it's better to return true



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


[GitHub] [doris] dataroaring merged pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
dataroaring merged PR #13737:
URL: https://github.com/apache/doris/pull/13737


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


[GitHub] [doris] hello-stephen commented on pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13737:
URL: https://github.com/apache/doris/pull/13737#issuecomment-1294390969

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 39.02 seconds
    load time: 555 seconds
    storage size: 17154699331 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221028030844_clickbench_pr_35046.html


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


[GitHub] [doris] dataroaring commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
dataroaring commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1008992623


##########
regression-test/suites/query_p0/sql_functions/math_functions/test_running_difference.sql:
##########
@@ -0,0 +1,55 @@
+DROP TABLE IF EXISTS running_difference_test;
+
+CREATE TABLE running_difference_test (
+                 `id` int NULL COMMENT 'id' ,
+                `day` date COMMENT 'day', 
+	`time_val` datetime COMMENT 'time_val',
+ 	`doublenum` double NULL COMMENT 'doublenum'
+                )
+DUPLICATE KEY(id) 
+DISTRIBUTED BY HASH(id) BUCKETS 3 
+PROPERTIES ( 
+    "replication_num" = "1"
+); 
+
+INSERT into running_difference_test (id,day, time_val,doublenum) values ('1', '2022-11-08', '2022-03-12 11:05:04', 4.7),
+                                                   ('1', '2022-10-31', '2022-03-12 10:42:01', 3.3),
+                                                    ('1', '2022-10-27', '2022-03-12 10:41:02', 2.6),
+                                                   ('1', '2022-10-28', '2022-03-12 10:41:00', 1.4); 

Review Comment:
   add null for test.



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


[GitHub] [doris] hello-stephen commented on pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13737:
URL: https://github.com/apache/doris/pull/13737#issuecomment-1293693915

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 38.34 seconds
    load time: 589 seconds
    storage size: 17154821198 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221027151845_clickbench_pr_34884.html


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


[GitHub] [doris] Yukang-Lian commented on a diff in pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
Yukang-Lian commented on code in PR #13737:
URL: https://github.com/apache/doris/pull/13737#discussion_r1007547644


##########
be/src/vec/functions/function_running_difference.cpp:
##########
@@ -0,0 +1,13 @@
+#include "vec/functions/function_running_difference.h"
+
+namespace doris::vectorized {
+
+void register_function_running_difference(SimpleFunctionFactory& factory) {
+    //factory.register_function<FunctionRunningDifferenceImpl<false>>();
+    factory.register_function<FunctionRunningDifference>();
+    //factory.register_function<FunctionCase<false, true>>();
+    //factory.register_function<FunctionCase<true, false>>();
+    //factory.register_function<FunctionCase<true, true>>();
+}

Review Comment:
   plz remove redundant code.



##########
gensrc/script/doris_builtins_functions.py:
##########
@@ -2180,8 +2180,14 @@
     [['split_part'], 'VARCHAR', ['VARCHAR', 'VARCHAR', 'INT'],
         '_ZN5doris15StringFunctions10split_partEPN9doris_udf15FunctionContextERKNS1_9StringValES6_RKNS1_6IntValE',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
+
      [['extract_url_parameter'], 'VARCHAR', ['VARCHAR', 'VARCHAR'],'','', '', 'vec', ''],
 
+    # runningdifference
+    [['running_difference'], 'INT', ['INT'],
+        '',
+        '', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
+

Review Comment:
   we need to register other data types. As follows
   ```suggestion
   [['running_difference'], 'FLOAT', ['FLOAT'],
           '',
           '', '', 'vec', 'ALWAYS_NOT_NULLABLE'],```



##########
be/test/vec/function/function_running_difference_test.cpp:
##########
@@ -0,0 +1,26 @@
+#include <gtest/gtest.h>
+#include <time.h>
+
+#include <any>
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "function_test_util.h"
+namespace doris::vectorized {
+    using namespace ut_type;
+    TEST(function_running_test, function_running_difference_test) {
+    std::string func_name = "running_difference"; 
+
+    InputTypeSet input_types = {TypeIndex::Int64};
+
+    DataSet data_set = {
+                        {{(int64_t)1}, (int64_t)0},
+                        {{(int64_t)2}, (int64_t)1},
+                        {{(int64_t)3}, (int64_t)1},
+                        {{(int64_t)5}, (int64_t)2}};
+
+    check_function<DataTypeInt64, true>(func_name, input_types, data_set);
+}
+

Review Comment:
   We need to add more ut to test different data types such as `float` and `date`.



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


[GitHub] [doris] github-actions[bot] commented on pull request #13737: [feature](running_difference) support running_difference function

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13737:
URL: https://github.com/apache/doris/pull/13737#issuecomment-1297971666

   PR approved by anyone and no changes requested.


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