[Improvement](window funnel) restrict timestamp to datetime type in window funnel (#12123)
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include "vec/aggregate_functions/aggregate_function_window_funnel.h"
|
||||
|
||||
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
|
||||
#include "vec/data_types/data_type_nullable.h"
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
@ -29,19 +30,15 @@ AggregateFunctionPtr create_aggregate_function_window_funnel(const std::string&
|
||||
LOG(WARNING) << "window_funnel's argument less than 3.";
|
||||
return nullptr;
|
||||
}
|
||||
if (WhichDataType(argument_types[2]).is_date_time_v2()) {
|
||||
if (WhichDataType(remove_nullable(argument_types[2])).is_date_time_v2()) {
|
||||
return std::make_shared<
|
||||
AggregateFunctionWindowFunnel<DateV2Value<DateTimeV2ValueType>, UInt64>>(
|
||||
argument_types);
|
||||
} else if (WhichDataType(argument_types[2]).is_date_v2()) {
|
||||
return std::make_shared<
|
||||
AggregateFunctionWindowFunnel<DateV2Value<DateV2ValueType>, UInt32>>(
|
||||
argument_types);
|
||||
} else if (WhichDataType(argument_types[2]).is_date_or_datetime()) {
|
||||
} else if (WhichDataType(remove_nullable(argument_types[2])).is_date_time()) {
|
||||
return std::make_shared<AggregateFunctionWindowFunnel<VecDateTimeValue, Int64>>(
|
||||
argument_types);
|
||||
} else {
|
||||
LOG(FATAL) << "Only support Date/DateTime type as window argument!";
|
||||
LOG(FATAL) << "Only support DateTime type as window argument!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -946,6 +946,18 @@ public class FunctionCallExpr extends Expr {
|
||||
}
|
||||
fn = getBuiltinFunction(fnName.getFunction(), childTypes,
|
||||
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
|
||||
if (fn != null && fn.getArgs()[2].isDatetime() && childTypes[2].isDatetimeV2()) {
|
||||
fn.setArgType(childTypes[2], 2);
|
||||
} else if (fn != null && fn.getArgs()[2].isDatetime() && childTypes[2].isDateV2()) {
|
||||
fn.setArgType(ScalarType.DATETIMEV2, 2);
|
||||
}
|
||||
if (fn != null && childTypes[2].isDate()) {
|
||||
// cast date to datetime
|
||||
uncheckedCastChild(ScalarType.DATETIME, 2);
|
||||
} else if (fn != null && childTypes[2].isDateV2()) {
|
||||
// cast date to datetime
|
||||
uncheckedCastChild(ScalarType.DATETIMEV2, 2);
|
||||
}
|
||||
} else if (fnName.getFunction().equalsIgnoreCase("if")) {
|
||||
Type[] childTypes = collectChildReturnTypes();
|
||||
Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType(childTypes[1], childTypes[2], true);
|
||||
|
||||
Reference in New Issue
Block a user