Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ private Plan normalize(LogicalProject<Plan> project) {

// 1. handle bottom projects
Set<Alias> existedAlias = ExpressionUtils.collect(outputs, Alias.class::isInstance);
Set<Expression> toBePushedDown = collectExpressionsToBePushedDown(outputs);
Set<Expression> toBePushedDown = collectExpressionsToBePushedDown(
outputs.stream().filter(expr -> !expr.isConstant()).collect(Collectors.toList()));
NormalizeToSlotContext context = NormalizeToSlotContext.buildContext(existedAlias, toBePushedDown);
// set toBePushedDown exprs as NamedExpression, e.g. (a+1) -> Alias(a+1)
Set<NamedExpression> bottomProjects = context.pushDownToNamedExpression(toBePushedDown);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,18 @@ suite("agg_window_project") {
sql """select a, a aa, row_number() over (partition by b) from test_window_table2;"""

sql "DROP TABLE IF EXISTS test_window_table2;"

sql """DROP TABLE IF EXISTS test_window_union_t1;"""
sql """DROP TABLE IF EXISTS test_window_union_t2;"""
sql """create table test_window_union_t1 (item_code int) distributed by hash(item_code) properties("replication_num"="1");"""
sql """insert into test_window_union_t1 values(1), (11), (111);"""

sql """create table test_window_union_t2 (orderamount_lj_tq decimalv3(38,5)) distributed by hash(orderamount_lj_tq) properties("replication_num"="1");"""
sql """insert into test_window_union_t2 values(123456.12345), (223456.12345), (323456.12345);"""

sql """
SELECT 0 AS `amount_dh_real_tq`, (CASE WHEN `t`.`item_code` IS NOT NULL THEN (1.0 / count(1) OVER (PARTITION BY `t`.`item_code`)) ELSE 0.0 END) AS `item_qty_dh_order` FROM `test_window_union_t1` t
UNION ALL
SELECT `t`.`orderamount_lj_tq` AS `amount_dh_real_tq`, 0 AS `item_qty_dh_order` FROM `test_window_union_t2` t ;
"""
}