[fix](Nereids) make the type of the first parameter in window_funnel is intergerLike (#15810)
This commit is contained in:
@ -74,7 +74,7 @@ public class WindowFunnel extends AggregateFunction
|
||||
@Override
|
||||
public void checkLegalityBeforeTypeCoercion() {
|
||||
String functionName = getName();
|
||||
if (!getArgumentType(0).isIntegerType()) {
|
||||
if (!getArgumentType(0).isIntegerLikeType()) {
|
||||
throw new AnalysisException("The window params of " + functionName + " function must be integer");
|
||||
}
|
||||
if (!getArgumentType(1).isStringLikeType()) {
|
||||
|
||||
@ -29,6 +29,7 @@ import org.apache.doris.nereids.trees.expressions.literal.Literal;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral;
|
||||
import org.apache.doris.nereids.types.coercion.AbstractDataType;
|
||||
import org.apache.doris.nereids.types.coercion.CharacterType;
|
||||
import org.apache.doris.nereids.types.coercion.IntegralType;
|
||||
import org.apache.doris.nereids.types.coercion.NumericType;
|
||||
import org.apache.doris.nereids.types.coercion.PrimitiveType;
|
||||
|
||||
@ -433,6 +434,10 @@ public abstract class DataType implements AbstractDataType {
|
||||
return this instanceof BooleanType;
|
||||
}
|
||||
|
||||
public boolean isIntegerLikeType() {
|
||||
return this instanceof IntegralType;
|
||||
}
|
||||
|
||||
public boolean isTinyIntType() {
|
||||
return this instanceof TinyIntType;
|
||||
}
|
||||
|
||||
@ -53,3 +53,10 @@
|
||||
|
||||
-- !ceil --
|
||||
3
|
||||
|
||||
-- !window_funnel --
|
||||
1
|
||||
|
||||
-- !window_funnel --
|
||||
2
|
||||
|
||||
|
||||
@ -125,5 +125,48 @@ suite("nereids_function") {
|
||||
sql "select left('abcd', 3), right('abcd', 3)"
|
||||
result([['abc', 'bcd']])
|
||||
}
|
||||
|
||||
// test window_funnel function
|
||||
sql """ DROP TABLE IF EXISTS window_funnel_test """
|
||||
sql """
|
||||
CREATE TABLE IF NOT EXISTS window_funnel_test (
|
||||
xwho varchar(50) NULL COMMENT 'xwho',
|
||||
xwhen datetimev2(3) COMMENT 'xwhen',
|
||||
xwhat int NULL COMMENT 'xwhat'
|
||||
)
|
||||
DUPLICATE KEY(xwho)
|
||||
DISTRIBUTED BY HASH(xwho) BUCKETS 3
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
"""
|
||||
|
||||
sql "INSERT into window_funnel_test (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 10:41:00.111111', 1)"
|
||||
sql "INSERT INTO window_funnel_test (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 13:28:02.111111', 2)"
|
||||
sql "INSERT INTO window_funnel_test (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 16:15:01.111111', 3)"
|
||||
sql "INSERT INTO window_funnel_test (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 19:05:04.111111', 4)"
|
||||
|
||||
qt_window_funnel """
|
||||
select
|
||||
window_funnel(
|
||||
1,
|
||||
'default',
|
||||
t.xwhen,
|
||||
t.xwhat = 1,
|
||||
t.xwhat = 2
|
||||
) AS level
|
||||
from window_funnel_test t;
|
||||
"""
|
||||
qt_window_funnel """
|
||||
select
|
||||
window_funnel(
|
||||
20000,
|
||||
'default',
|
||||
t.xwhen,
|
||||
t.xwhat = 1,
|
||||
t.xwhat = 2
|
||||
) AS level
|
||||
from window_funnel_test t;
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user