diff --git a/dbms/src/DataTypes/getLeastSupertype.cpp b/dbms/src/DataTypes/getLeastSupertype.cpp index c7b68e3bf89..cbbd87d2534 100644 --- a/dbms/src/DataTypes/getLeastSupertype.cpp +++ b/dbms/src/DataTypes/getLeastSupertype.cpp @@ -100,36 +100,6 @@ DataTypePtr getLeastSupertype(const DataTypes & types) return getLeastSupertype(non_nothing_types); } - /// For Arrays - { - bool have_array = false; - bool all_arrays = true; - - DataTypes nested_types; - nested_types.reserve(types.size()); - - for (const auto & type : types) - { - if (const DataTypeArray * type_array = typeid_cast(type.get())) - { - have_array = true; - nested_types.emplace_back(type_array->getNestedType()); - } - else - all_arrays = false; - } - - if (have_array) - { - if (!all_arrays) - throw Exception( - getExceptionMessagePrefix(types) + " because some of them are Array and some of them are not", - ErrorCodes::NO_COMMON_TYPE); - - return std::make_shared(getLeastSupertype(nested_types)); - } - } - /// For tuples { bool have_tuple = false; @@ -204,6 +174,36 @@ DataTypePtr getLeastSupertype(const DataTypes & types) } } + /// For Arrays, canBeInsideNullable = true, should check it after handling Nullable + { + bool have_array = false; + bool all_arrays = true; + + DataTypes nested_types; + nested_types.reserve(types.size()); + + for (const auto & type : types) + { + if (const DataTypeArray * type_array = typeid_cast(type.get())) + { + have_array = true; + nested_types.emplace_back(type_array->getNestedType()); + } + else + all_arrays = false; + } + + if (have_array) + { + if (!all_arrays) + throw Exception( + getExceptionMessagePrefix(types) + " because some of them are Array and some of them are not", + ErrorCodes::NO_COMMON_TYPE); + + return std::make_shared(getLeastSupertype(nested_types)); + } + } + /// Non-recursive rules std::unordered_set type_ids; diff --git a/dbms/src/DataTypes/getMostSubtype.cpp b/dbms/src/DataTypes/getMostSubtype.cpp index 4429a4f26f6..9b7c63170e6 100644 --- a/dbms/src/DataTypes/getMostSubtype.cpp +++ b/dbms/src/DataTypes/getMostSubtype.cpp @@ -105,34 +105,6 @@ DataTypePtr getMostSubtype(const DataTypes & types, bool throw_if_result_is_noth return get_nothing_or_throw(" because some of them are Nothing"); } - /// For Arrays - { - bool have_array = false; - bool all_arrays = true; - - DataTypes nested_types; - nested_types.reserve(types.size()); - - for (const auto & type : types) - { - if (const auto * const type_array = typeid_cast(type.get())) - { - have_array = true; - nested_types.emplace_back(type_array->getNestedType()); - } - else - all_arrays = false; - } - - if (have_array) - { - if (!all_arrays) - return get_nothing_or_throw(" because some of them are Array and some of them are not"); - - return std::make_shared(getMostSubtype(nested_types, false, force_support_conversion)); - } - } - /// For tuples { bool have_tuple = false; @@ -210,6 +182,34 @@ DataTypePtr getMostSubtype(const DataTypes & types, bool throw_if_result_is_noth } } + /// For Arrays, canBeInsideNullable = true, should check it after handling Nullable + { + bool have_array = false; + bool all_arrays = true; + + DataTypes nested_types; + nested_types.reserve(types.size()); + + for (const auto & type : types) + { + if (const auto * const type_array = typeid_cast(type.get())) + { + have_array = true; + nested_types.emplace_back(type_array->getNestedType()); + } + else + all_arrays = false; + } + + if (have_array) + { + if (!all_arrays) + return get_nothing_or_throw(" because some of them are Array and some of them are not"); + + return std::make_shared(getMostSubtype(nested_types, false, force_support_conversion)); + } + } + /// Non-recursive rules /// For String and FixedString, the common type is FixedString. diff --git a/dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp b/dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp index 946819fd893..5a91ba5af80 100644 --- a/dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp +++ b/dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp @@ -150,10 +150,14 @@ try ->equals(*typeFromString("Array(Array(UInt8))"))); ASSERT_TRUE(getLeastSupertype(typesFromString("Array(Array(UInt8)) Array(Array(Int8))")) ->equals(*typeFromString("Array(Array(Int16))"))); - ASSERT_TRUE( - getLeastSupertype(typesFromString("Array(Date) Array(DateTime)"))->equals(*typeFromString("Array(DateTime)"))); + ASSERT_TRUE(getLeastSupertype(typesFromString("Array(Date) Array(DateTime)")) // + ->equals(*typeFromString("Array(DateTime)"))); ASSERT_TRUE(getLeastSupertype(typesFromString("Array(String) Array(FixedString(32))")) ->equals(*typeFromString("Array(String)"))); + ASSERT_TRUE(getLeastSupertype(typesFromString("Array(Float32) Array(Float32)")) // + ->equals(*typeFromString("Array(Float32)"))); + ASSERT_TRUE(getLeastSupertype(typesFromString("Array(Float32) Nullable(Array(Float32))")) // + ->equals(*typeFromString("Nullable(Array(Float32))"))); ASSERT_TRUE( getLeastSupertype(typesFromString("Nullable(Nothing) Nothing"))->equals(*typeFromString("Nullable(Nothing)"))); @@ -214,11 +218,16 @@ try ->equals(*typeFromString("Array(Array(UInt8))"))); ASSERT_TRUE(getMostSubtype(typesFromString("Array(Array(UInt8)) Array(Array(Int8))")) ->equals(*typeFromString("Array(Array(UInt8))"))); - ASSERT_TRUE(getMostSubtype(typesFromString("Array(Date) Array(DateTime)"))->equals(*typeFromString("Array(Date)"))); + ASSERT_TRUE(getMostSubtype(typesFromString("Array(Date) Array(DateTime)")) // + ->equals(*typeFromString("Array(Date)"))); ASSERT_TRUE(getMostSubtype(typesFromString("Array(String) Array(FixedString(32))")) ->equals(*typeFromString("Array(FixedString(32))"))); ASSERT_TRUE(getMostSubtype(typesFromString("Array(String) Array(FixedString(32))")) ->equals(*typeFromString("Array(FixedString(32))"))); + ASSERT_TRUE(getMostSubtype(typesFromString("Array(Float32) Array(Float32)")) // + ->equals(*typeFromString("Array(Float32)"))); + ASSERT_TRUE(getMostSubtype(typesFromString("Array(Float32) Nullable(Array(Float32))")) // + ->equals(*typeFromString("Array(Float32)"))); ASSERT_TRUE(getMostSubtype(typesFromString("Nullable(Nothing) Nothing"))->equals(*typeFromString("Nothing"))); ASSERT_TRUE(getMostSubtype(typesFromString("Nullable(UInt8) Int8"))->equals(*typeFromString("UInt8"))); diff --git a/dbms/src/Flash/Mpp/MPPTaskScheduleEntry.cpp b/dbms/src/Flash/Mpp/MPPTaskScheduleEntry.cpp index 9c86bde57c0..53dcea99446 100644 --- a/dbms/src/Flash/Mpp/MPPTaskScheduleEntry.cpp +++ b/dbms/src/Flash/Mpp/MPPTaskScheduleEntry.cpp @@ -42,11 +42,7 @@ bool MPPTaskScheduleEntry::schedule(ScheduleState state) if (schedule_state == ScheduleState::WAITING) { auto log_level = state == ScheduleState::SCHEDULED ? Poco::Message::PRIO_DEBUG : Poco::Message::PRIO_WARNING; - LOG_IMPL( - log, - log_level, - "task is {}.", - state == ScheduleState::SCHEDULED ? "scheduled" : " failed to schedule"); + LOG_IMPL(log, log_level, "task is {}.", state == ScheduleState::SCHEDULED ? "scheduled" : "failed to schedule"); schedule_state = state; schedule_cv.notify_one(); return true; diff --git a/dbms/src/Storages/DeltaMerge/ColumnStat.h b/dbms/src/Storages/DeltaMerge/ColumnStat.h index 04365781ab6..1ab69ed8af4 100644 --- a/dbms/src/Storages/DeltaMerge/ColumnStat.h +++ b/dbms/src/Storages/DeltaMerge/ColumnStat.h @@ -178,7 +178,9 @@ readText(ColumnStats & column_sats, DMFileFormat::Version ver, ReadBuffer & buf) .serialized_bytes = serialized_bytes, // ... here ignore some fields with default initializers .vector_index = {}, +#ifndef NDEBUG .additional_data_for_test = {}, +#endif }); } }