Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]Remove be special handling of date types and bugs in registration functions #45159

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DataTypeDate final : public DataTypeNumberBase<Int64> {
doris::FieldType get_storage_field_type() const override {
return doris::FieldType::OLAP_FIELD_TYPE_DATE;
}
const char* get_family_name() const override { return "DateTime"; }
const char* get_family_name() const override { return "Date"; }
std::string do_get_name() const override { return "Date"; }

bool equals(const IDataType& rhs) const override;
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class FunctionArrayApply : public IFunction {
size_t get_number_of_arguments() const override { return 3; }
ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(is_array(arguments[0]))
<< "first argument for function: " << name << " should be DataTypeArray"
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class FunctionArrayBinary : public IFunction {
bool is_variadic() const override { return false; }
size_t get_number_of_arguments() const override { return 2; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(is_array(arguments[0])) << arguments[0]->get_name();
DCHECK(is_array(arguments[1])) << arguments[1]->get_name();
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_compact.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class FunctionArrayCompact : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class FunctionArrayConcat : public IFunction {
String get_name() const override { return name; }

bool is_variadic() const override { return true; }
bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class FunctionArrayConstructor : public IFunction {

size_t get_number_of_arguments() const override { return 0; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
// we accept with empty argument, like array(), which will be treated as array(UInt8)
if (arguments.empty()) {
Expand Down
20 changes: 13 additions & 7 deletions be/src/vec/functions/array/function_array_contains_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <type_traits>

#include "common/status.h"
#include "vec/aggregate_functions/aggregate_function.h"
#include "vec/common/assert_cast.h"
#include "vec/core/columns_with_type_and_name.h"
#include "vec/data_types/data_type_array.h"
#include "vec/data_types/data_type_number.h"
#include "vec/functions/array/function_array_utils.h"
Expand All @@ -42,18 +44,22 @@ class FunctionArrayContainsAll : public IFunction {

size_t get_number_of_arguments() const override { return 2; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
auto left_data_type = remove_nullable(arguments[0]);
auto right_data_type = remove_nullable(arguments[1]);
DCHECK(is_array(left_data_type)) << arguments[0]->get_name();
DCHECK(is_array(right_data_type)) << arguments[1]->get_name();
DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
auto left_data_type = remove_nullable(arguments[0].type);
auto right_data_type = remove_nullable(arguments[1].type);
DCHECK(is_array(left_data_type)) << arguments[0].type->get_name();
DCHECK(is_array(right_data_type)) << arguments[1].type->get_name();
auto left_nested_type = remove_nullable(
assert_cast<const DataTypeArray&>(*left_data_type).get_nested_type());
auto right_nested_type = remove_nullable(
assert_cast<const DataTypeArray&>(*right_data_type).get_nested_type());
DCHECK(left_nested_type->equals(*right_nested_type))
<< "data type " << arguments[0]->get_name() << " not equal with "
<< arguments[1]->get_name();
<< "data type " << arguments[0].type->get_name() << " not equal with "
<< arguments[1].type->get_name();
return std::make_shared<DataTypeUInt8>();
}

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
return std::make_shared<DataTypeUInt8>();
}

Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_cum_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class FunctionArrayCumSum : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_difference.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class FunctionArrayDifference : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

bool use_default_implementation_for_nulls() const override { return true; }
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_distinct.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class FunctionArrayDistinct : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class FunctionArrayElement : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

bool use_default_implementation_for_nulls() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_enumerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class FunctionArrayEnumerate : public IFunction {
static FunctionPtr create() { return std::make_shared<FunctionArrayEnumerate>(); }
String get_name() const override { return name; }
size_t get_number_of_arguments() const override { return 1; }

bool has_return_type_in_signature() const override { return false; }
DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
const DataTypeArray* array_type =
check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[0]).get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class FunctionArrayEnumerateUniq : public IFunction {
String get_name() const override { return name; }
bool is_variadic() const override { return true; }
size_t get_number_of_arguments() const override { return 1; }
bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
if (arguments.empty()) {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_exists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class FunctionArrayExists : public IFunction {

size_t get_number_of_arguments() const override { return 1; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(is_array(arguments[0]))
<< "first argument for function: " << name << " should be DataTypeArray"
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FunctionArrayFilter : public IFunction {
String get_name() const override { return name; }

bool is_variadic() const override { return false; }
bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }

Expand Down
9 changes: 7 additions & 2 deletions be/src/vec/functions/array/function_array_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "vec/core/block.h"
#include "vec/core/column_numbers.h"
#include "vec/core/column_with_type_and_name.h"
#include "vec/core/columns_with_type_and_name.h"
#include "vec/core/types.h"
#include "vec/data_types/data_type.h"
#include "vec/data_types/data_type_array.h"
Expand Down Expand Up @@ -182,14 +183,18 @@ class FunctionArrayIndex : public IFunction {
return Status::OK();
}

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
if (arguments[0]->is_nullable()) {
DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
if (arguments[0].type->is_nullable()) {
return make_nullable(std::make_shared<DataTypeNumber<ResultType>>());
} else {
return std::make_shared<DataTypeNumber<ResultType>>();
}
}

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
return std::make_shared<DataTypeNumber<ResultType>>();
}

Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) const override {
DBUG_EXECUTE_IF("array_func.array_contains", {
Expand Down
8 changes: 8 additions & 0 deletions be/src/vec/functions/array/function_array_join.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
// under the License.
#pragma once

#include <memory>

#include "vec/columns/column_array.h"
#include "vec/columns/column_const.h"
#include "vec/core/columns_with_type_and_name.h"
#include "vec/data_types/data_type.h"
#include "vec/data_types/data_type_array.h"
#include "vec/data_types/data_type_number.h"
#include "vec/data_types/data_type_string.h"
Expand Down Expand Up @@ -55,6 +59,10 @@ struct ArrayJoinImpl {
return std::make_shared<DataTypeString>();
}

static DataTypePtr get_return_type_impl(const DataTypes& arguments) {
return std::make_shared<DataTypeString>();
}

static Status execute(Block& block, const ColumnNumbers& arguments, uint32_t result,
const DataTypeArray* data_type_array, const ColumnArray& array) {
ColumnPtr src_column =
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_mapped.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class FunctionArrayMapped : public IFunction {
static constexpr auto name = Name::name;
static FunctionPtr create() { return std::make_shared<FunctionArrayMapped>(); }

bool has_return_type_in_signature() const override { return false; }

String get_name() const override { return name; }
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_nary.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class FunctionArrayNary : public IFunction {
bool is_variadic() const override { return true; }
size_t get_number_of_arguments() const override { return 0; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(arguments.size() >= 2)
<< "function: " << get_name() << ", arguments should large equals than 2";
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_pop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class FunctionArrayPop : public IFunction {
bool is_variadic() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }
bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(is_array(arguments[0]))
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_pushback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class FunctionArrayPushback : public IFunction {
String get_name() const override { return name; }

bool is_variadic() const override { return false; }
bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }

Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_pushfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class FunctionArrayPushfront : public IFunction {
bool is_variadic() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }
bool has_return_type_in_signature() const override { return false; }

bool use_default_implementation_for_nulls() const override { return false; }

Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_remove.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class FunctionArrayRemove : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_shuffle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class FunctionArrayShuffle : public IFunction {

bool is_variadic() const override { return true; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class FunctionArraySlice : public IFunction {

bool is_variadic() const override { return true; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 0; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class FunctionArraySort : public IFunction {

bool is_variadic() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

size_t get_number_of_arguments() const override { return 1; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/array/function_array_sortby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class FunctionArraySortBy : public IFunction {

bool use_default_implementation_for_nulls() const override { return false; }

bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
DCHECK(is_array(remove_nullable(arguments[0])))
<< "first argument for function: " << name << " should be DataTypeArray"
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class FunctionArraySplit : public IFunction {
String get_name() const override { return name; }

size_t get_number_of_arguments() const override { return 2; }
bool has_return_type_in_signature() const override { return false; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
return std::make_shared<DataTypeArray>(make_nullable(arguments[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class FunctionArrayWithConstant : public IFunction {
bool is_variadic() const override { return false; }

size_t get_number_of_arguments() const override { return 2; }
bool has_return_type_in_signature() const override { return false; }

// need handle null cases
bool use_default_implementation_for_nulls() const override { return false; }
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/functions/array/function_array_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class FunctionArrayZip : public IFunction {
public:
static constexpr auto name = "array_zip";
static FunctionPtr create() { return std::make_shared<FunctionArrayZip>(); }
bool has_return_type_in_signature() const override { return false; }

/// Get function name.
String get_name() const override { return name; }
Expand Down
19 changes: 12 additions & 7 deletions be/src/vec/functions/array/function_arrays_overlap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "vec/core/block.h"
#include "vec/core/column_numbers.h"
#include "vec/core/column_with_type_and_name.h"
#include "vec/core/columns_with_type_and_name.h"
#include "vec/core/types.h"
#include "vec/data_types/data_type.h"
#include "vec/data_types/data_type_array.h"
Expand Down Expand Up @@ -113,21 +114,25 @@ class FunctionArraysOverlap : public IFunction {

size_t get_number_of_arguments() const override { return 2; }

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
auto left_data_type = remove_nullable(arguments[0]);
auto right_data_type = remove_nullable(arguments[1]);
DCHECK(is_array(left_data_type)) << arguments[0]->get_name();
DCHECK(is_array(right_data_type)) << arguments[1]->get_name();
DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
auto left_data_type = remove_nullable(arguments[0].type);
auto right_data_type = remove_nullable(arguments[1].type);
DCHECK(is_array(left_data_type)) << arguments[0].type->get_name();
DCHECK(is_array(right_data_type)) << arguments[1].type->get_name();
auto left_nested_type = remove_nullable(
assert_cast<const DataTypeArray&>(*left_data_type).get_nested_type());
auto right_nested_type = remove_nullable(
assert_cast<const DataTypeArray&>(*right_data_type).get_nested_type());
DCHECK(left_nested_type->equals(*right_nested_type))
<< "data type " << arguments[0]->get_name() << " not equal with "
<< arguments[1]->get_name();
<< "data type " << arguments[0].type->get_name() << " not equal with "
<< arguments[1].type->get_name();
return make_nullable(std::make_shared<DataTypeUInt8>());
}

DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
return std::make_shared<DataTypeUInt8>();
}

/**
* eval inverted index. we can filter array rows with inverted index iter
* array_overlap(array, []) -> array_overlap(array, const value)
Expand Down
Loading
Loading