Skip to content

Commit

Permalink
[Fix](Nereids) fix fold const be return type (#41164)
Browse files Browse the repository at this point in the history
remove windowframe in window expression to avoid folding constant on be
  • Loading branch information
LiBinfeng-01 authored Sep 27, 2024
1 parent 3c3a028 commit 0ef9ecd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public WindowExpression(Expression function, List<Expression> partitionKeys, Lis
.add(function)
.addAll(partitionKeys)
.addAll(orderKeys)
.add(windowFrame)
.build());
this.function = function;
this.partitionKeys = ImmutableList.copyOf(partitionKeys);
Expand Down Expand Up @@ -153,6 +152,9 @@ public WindowExpression withChildren(List<Expression> children) {
if (index < children.size()) {
return new WindowExpression(func, partitionKeys, orderKeys, (WindowFrame) children.get(index));
}
if (windowFrame.isPresent()) {
return new WindowExpression(func, partitionKeys, orderKeys, windowFrame.get());
}
return new WindowExpression(func, partitionKeys, orderKeys);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,29 @@ suite("fold_constant_by_be") {
sql("verbose select substring('123456', 1, 3)")
contains "varchar(3)"
}

sql "drop table if exists table_200_undef_partitions2_keys3_properties4_distributed_by53"
sql """create table table_200_undef_partitions2_keys3_properties4_distributed_by53 (
pk int,
col_char_255__undef_signed char(255) null ,
col_char_100__undef_signed char(100) null ,
col_char_255__undef_signed_not_null char(255) not null ,
col_char_100__undef_signed_not_null char(100) not null ,
col_varchar_255__undef_signed varchar(255) null ,
col_varchar_255__undef_signed_not_null varchar(255) not null ,
col_varchar_1000__undef_signed varchar(1000) null ,
col_varchar_1000__undef_signed_not_null varchar(1000) not null ,
col_varchar_1001__undef_signed varchar(1001) null ,
col_varchar_1001__undef_signed_not_null varchar(1001) not null
) engine=olap
DUPLICATE KEY(pk, col_char_255__undef_signed, col_char_100__undef_signed)
distributed by hash(pk) buckets 10
properties("replication_num" = "1");"""
explain {
sql("select LAST_VALUE(col_char_255__undef_signed_not_null, false) over (partition by " +
"concat('GkIPbzAZSu', col_char_100__undef_signed), mask('JrqFkEDqeA') " +
"order by pk rows between unbounded preceding and 6 following) AS col_alias26947 " +
"from table_200_undef_partitions2_keys3_properties4_distributed_by53;")
notContains("mask")
}
}

0 comments on commit 0ef9ecd

Please sign in to comment.