[Improvement](function) support decimalv3 for function least and greatest (#19931)
This commit is contained in:
@ -110,7 +110,7 @@ struct CompareMultiImpl {
|
||||
} \
|
||||
}
|
||||
NUMERIC_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
DISPATCH(Decimal128, ColumnDecimal<Decimal128>)
|
||||
DECIMAL_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
TIME_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
#undef DISPATCH
|
||||
}
|
||||
@ -136,6 +136,17 @@ private:
|
||||
? column_raw_data[index_check_const(i, ArgConst)]
|
||||
: result_raw_data[i];
|
||||
}
|
||||
} else if constexpr (std::is_same_v<ColumnType, ColumnDecimal32> ||
|
||||
std::is_same_v<ColumnType, ColumnDecimal64> ||
|
||||
std::is_same_v<ColumnType, ColumnDecimal128I>) {
|
||||
for (size_t i = 0; i < input_rows_count; ++i) {
|
||||
using type = std::decay_t<decltype(result_raw_data[0].value)>;
|
||||
result_raw_data[i] =
|
||||
Op<type, type>::apply(column_raw_data[index_check_const(i, ArgConst)].value,
|
||||
result_raw_data[i].value)
|
||||
? column_raw_data[index_check_const(i, ArgConst)]
|
||||
: result_raw_data[i];
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < input_rows_count; ++i) {
|
||||
using type = std::decay_t<decltype(result_raw_data[0])>;
|
||||
@ -204,7 +215,7 @@ struct FunctionFieldImpl {
|
||||
} \
|
||||
}
|
||||
NUMERIC_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
DISPATCH(Decimal128, ColumnDecimal<Decimal128>)
|
||||
DECIMAL_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
TIME_TYPE_TO_COLUMN_TYPE(DISPATCH)
|
||||
#undef DISPATCH
|
||||
}
|
||||
@ -230,6 +241,17 @@ private:
|
||||
first_raw_data[index_check_const(i, ArgConst)], arg_data)) *
|
||||
col);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<ColumnType, ColumnDecimal32> ||
|
||||
std::is_same_v<ColumnType, ColumnDecimal64> ||
|
||||
std::is_same_v<ColumnType, ColumnDecimal128I>) {
|
||||
for (size_t i = 0; i < input_rows_count; ++i) {
|
||||
using type = std::decay_t<decltype(first_raw_data[0].value)>;
|
||||
res_data[i] |= (!res_data[i] *
|
||||
(EqualsOp<type, type>::apply(
|
||||
first_raw_data[index_check_const(i, ArgConst)].value,
|
||||
arg_data.value)) *
|
||||
col);
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < input_rows_count; ++i) {
|
||||
using type = std::decay_t<decltype(first_raw_data[0])>;
|
||||
|
||||
@ -1403,7 +1403,9 @@ public class FunctionCallExpr extends Expr {
|
||||
}
|
||||
fn = getBuiltinFunction(fnName.getFunction(), childTypes,
|
||||
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
|
||||
} else if (fnName.getFunction().equalsIgnoreCase("coalesce") && children.size() > 1) {
|
||||
} else if ((fnName.getFunction().equalsIgnoreCase("coalesce")
|
||||
|| fnName.getFunction().equalsIgnoreCase("greatest")
|
||||
|| fnName.getFunction().equalsIgnoreCase("least")) && children.size() > 1) {
|
||||
Type[] childTypes = collectChildReturnTypes();
|
||||
Type assignmentCompatibleType = childTypes[0];
|
||||
for (int i = 1; i < childTypes.length && assignmentCompatibleType.isDecimalV3(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user