[FIX](type) fix matchExactType for complex type (#28233)
fe matchExactType function should call type.matchTypes for its own logic, do not switch case to do special logic otherwise we may meet core in be like this.
```
F20231208 18:54:39.359673 680131 block.h:535] Check failed: _data_types[i]->is_nullable() target type: Struct(l_info:Nullable(Array(Nullable(String)))) src type: Struct(col:Nullable(Array(Nullable(UInt8))))
*** Check failure stack trace: ***
@ 0x5584e952b926 google::LogMessage::SendToLog()
@ 0x5584e9527ef0 google::LogMessage::Flush()
@ 0x5584e952c169 google::LogMessageFatal::~LogMessageFatal()
@ 0x5584cf17201e doris::vectorized::MutableBlock::merge_impl<>()
@ 0x5584ceac4b1d doris::vectorized::MutableBlock::merge<>()
@ 0x5584d4dd7de3 doris::vectorized::VUnionNode::get_next_const()
@ 0x5584d4dd9a45 doris::vectorized::VUnionNode::get_next()
@ 0x5584bce469bd std::__invoke_impl<>()
@ 0x5584bce466d0 std::__invoke<>()
@ 0x5584bce465c7 _ZNSt5_BindIFMN5doris8ExecNodeEFNS0_6StatusEPNS0_12RuntimeStateEPNS0_10vectorized5BlockEPbEPS1_St12_PlaceholderILi1EESC_ILi2EESC_ILi3EEEE6__callIS2_JOS4_OS7_OS8_EJLm0ELm1ELm2ELm3EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE
@ 0x5584bce46358 std::_Bind<>::operator()<>()
@ 0x5584bce46208 std::__invoke_impl<>()
@ 0x5584bce46178 _ZSt10__invoke_rIN5doris6StatusERSt5_BindIFMNS0_8ExecNodeEFS1_PNS0_12RuntimeStateEPNS0_10vectorized5BlockEPbEPS3_St12_PlaceholderILi1EESD_ILi2EESD_ILi3EEEEJS5_S8_S9_EENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESL_E4typeEOSM_DpOSN_
@ 0x5584bce45c18 std::_Function_handler<>::_M_invoke()
@ 0x5584bce6412f std::function<>::operator()()
@ 0x5584bce56382 doris::ExecNode::get_next_after_projects()
@ 0x5584bce26218 doris::PlanFragmentExecutor::get_vectorized_internal()
@ 0x5584bce2431b doris::PlanFragmentExecutor::open_vectorized_internal()
@ 0x5584bce22a96 doris::PlanFragmentExecutor::open()
@ 0x5584bce27c9d doris::PlanFragmentExecutor::execute()
@ 0x5584bcbdb3f8 doris::FragmentMgr::_exec_actual()
@ 0x5584bcbf982f doris::FragmentMgr::exec_plan_fragment()::$_0::operator()()
@ 0x5584bcbf9715 std::__invoke_impl<>()
@ 0x5584bcbf96b5 _ZSt10__invoke_rIvRZN5doris11FragmentMgr18exec_plan_fragmentERKNS0_23TExecPlanFragmentParamsERKSt8functionIFvPNS0_12RuntimeStateEPNS0_6StatusEEEE3$_0JEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESH_E4typeEOSI_DpOSJ_
@ 0x5584bcbf942d std::_Function_handler<>::_M_invoke()
@ 0x5584b9dfd883 std::function<>::operator()()
@ 0x5584bd6e3929 doris::FunctionRunnable::run()
@ 0x5584bd6cf8ce doris::ThreadPool::dispatch_thread()
```
This commit is contained in:
@ -88,13 +88,11 @@ public class ArrayType extends Type {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Array(Null) is a virtual Array type, can match any Array(...) type
|
||||
if (itemType.isNull() || ((ArrayType) t).getItemType().isNull()) {
|
||||
return true;
|
||||
if (((ArrayType) t).getContainsNull() != getContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemType.matchesType(((ArrayType) t).itemType)
|
||||
&& (((ArrayType) t).containsNull || !containsNull);
|
||||
return itemType.matchesType(((ArrayType) t).itemType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -126,9 +126,11 @@ public class MapType extends Type {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((keyType.isNull() || ((MapType) t).getKeyType().isNull())
|
||||
&& (valueType.isNull() || ((MapType) t).getKeyType().isNull())) {
|
||||
return true;
|
||||
if (((MapType) t).getIsKeyContainsNull() != getIsKeyContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
if (((MapType) t).getIsValueContainsNull() != getIsValueContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return keyType.matchesType(((MapType) t).keyType)
|
||||
|
||||
@ -95,6 +95,7 @@ public class TemplateType extends Type {
|
||||
}
|
||||
|
||||
if (specializedType != null
|
||||
&& !specializedType.isNull()
|
||||
&& !specificType.equals(specializedType)
|
||||
&& !specificType.matchesType(specializedType)
|
||||
&& !Type.isImplicitlyCastable(specificType, specializedType, true, enableDecimal256)
|
||||
@ -104,7 +105,7 @@ public class TemplateType extends Type {
|
||||
name, specificType, specializedType));
|
||||
}
|
||||
|
||||
if (specializedType == null) {
|
||||
if (specializedType == null || specializedType.isNull()) {
|
||||
specializedTypeMap.put(name, specificType);
|
||||
}
|
||||
return specializedTypeMap.get(name);
|
||||
|
||||
@ -2241,6 +2241,7 @@ public abstract class Type {
|
||||
}
|
||||
|
||||
public static boolean matchExactType(Type type1, Type type2, boolean ignorePrecision) {
|
||||
// we should make type decide to match other for itself to impl matchesType instead of switch case types
|
||||
if (type1.matchesType(type2)) {
|
||||
if (PrimitiveType.typeWithPrecision.contains(type2.getPrimitiveType())) {
|
||||
// For types which has precision and scale, we also need to check quality between precisions and scales
|
||||
@ -2253,22 +2254,6 @@ public abstract class Type {
|
||||
return isSameDecimalTypeWithDifferentPrecision(((ScalarType) type2).decimalPrecision(),
|
||||
((ScalarType) type1).decimalPrecision());
|
||||
}
|
||||
} else if (type2.isArrayType()) {
|
||||
// For types array, we also need to check contains null for case like
|
||||
// cast(array<not_null(int)> as array<int>)
|
||||
if (((ArrayType) type2).getContainsNull() != ((ArrayType) type1).getContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
return matchExactType(((ArrayType) type2).getItemType(), ((ArrayType) type1).getItemType());
|
||||
} else if (type2.isMapType()) {
|
||||
if (((MapType) type2).getIsKeyContainsNull() != ((MapType) type1).getIsKeyContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
if (((MapType) type2).getIsValueContainsNull() != ((MapType) type1).getIsValueContainsNull()) {
|
||||
return false;
|
||||
}
|
||||
return matchExactType(((MapType) type2).getKeyType(), ((MapType) type1).getKeyType())
|
||||
&& matchExactType(((MapType) type2).getValueType(), ((MapType) type1).getValueType());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user