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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java:
##########
@@ -1108,4 +1102,34 @@ public static Expression boolor(BooleanLiteral first) {
     public static Expression boolxor(BooleanLiteral first) {
         return first;
     }
+
+    /**
+     * interval
+     */
+    @ExecFunction(name = "interval")
+    public static Expression interval(NullLiteral compareValue, Literal... 
thresholds) {
+        return new IntegerLiteral(-1);
+    }
+
+    /**
+     * interval
+     */
+    @ExecFunction(name = "interval")
+    public static Expression interval(BigIntLiteral compareValue, 
BigIntLiteral... thresholds) {
+        long value = compareValue.getValue();
+        if (value < thresholds[0].getValue()) {
+            return new IntegerLiteral(0);
+        }
+        int l = 0;

Review Comment:
   java有没有类似upper_bound的标准库函数?



##########
be/src/vec/functions/function_interval.cpp:
##########
@@ -0,0 +1,145 @@
+// 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.
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <limits>
+#include <memory>
+#include <vector>
+
+#include "common/status.h"
+#include "runtime/define_primitive_type.h"
+#include "runtime/primitive_type.h"
+#include "vec/columns/column.h"
+#include "vec/columns/column_const.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_vector.h"
+#include "vec/common/assert_cast.h"
+#include "vec/core/block.h"
+#include "vec/core/column_numbers.h"
+#include "vec/core/column_with_type_and_name.h"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/functions/function.h"
+#include "vec/functions/function_needs_to_handle_null.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+class FunctionIntervalImpl {
+public:
+    static constexpr auto name = "interval";
+    static size_t get_number_of_arguments() { return 0; }
+    static bool is_variadic() { return true; }
+    static DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) {
+        return std::make_shared<DataTypeInt32>();
+    }
+
+    static bool is_return_nullable(bool has_nullable,
+                                   const 
std::vector<ColumnWithConstAndNullMap>& cols_info) {
+        return false;
+    }
+
+    static bool execute_const_null(ColumnInt32::MutablePtr& res_col,
+                                   PaddedPODArray<UInt8>& res_null_map_data,
+                                   size_t input_rows_count, size_t null_index) 
{
+        if (null_index == 0) {
+            res_col->insert_many_vals(-1, input_rows_count);
+            return true;
+        }
+        return false;
+    }
+
+    static void collect_columns_info(std::vector<ColumnWithConstAndNullMap>& 
columns_info,

Review Comment:
   利用这一套似乎并没有怎么简化代码。就自己手工处理下const和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: [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