Skip to content

Commit

Permalink
[bug](fold) fix fold constant rule can't handle variable expr
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Mar 15, 2024
1 parent 3e07897 commit bcb3131
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public Expr apply(Expr expr, Analyzer analyzer, ExprRewriter.ClauseType clauseTy
// children should have been folded at this point.
for (Expr child : expr.getChildren()) {
if (!child.isLiteral() && !(child instanceof CastExpr) && !((child instanceof FunctionCallExpr
|| child instanceof ArithmeticExpr || child instanceof TimestampArithmeticExpr))) {
|| child instanceof ArithmeticExpr || child instanceof TimestampArithmeticExpr
|| child instanceof VariableExpr))) {
return expr;
}
}
Expand Down
37 changes: 37 additions & 0 deletions regression-test/suites/delete_p0/test_delete.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,41 @@ suite("test_delete") {
"""
sql "set experimental_enable_nereids_planner = false;"
sql "delete from test3 where statistic_date >= date_sub('2024-01-16',INTERVAL 1 day);"

sql "drop table if exists bi_acti_per_period_plan"
sql """
CREATE TABLE `bi_acti_per_period_plan` (
`proj_id` bigint(20) NULL,
`proj_name` varchar(400) NULL,
`proj_start_date` datetime NULL,
`proj_end_date` datetime NULL,
`last_data_date` datetime NULL,
`data_date` datetime NULL,
`data_batch_num` datetime NULL,
`la_sum_base_proj_id` varchar(200) NULL,
`sum_base_proj_id` varchar(200) NULL,
`today_date` datetime NULL,
`count` bigint(20) NULL,
`count_type` varchar(50) NULL,
`bl_count` bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(`proj_id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`proj_id`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);
"""
sql """
INSERT INTO bi_acti_per_period_plan (proj_id,proj_name,proj_start_date,proj_end_date,last_data_date,data_date,data_batch_num,la_sum_base_proj_id,sum_base_proj_id,today_date,count,count_type,bl_count) VALUES
(4508,'建筑工程项目A','2023-05-30 00:00:00','2024-03-07 00:00:00','2023-06-01 00:00:00','2023-08-15 00:00:00','2024-01-31 00:00:00','4509','4509','2023-08-27 00:00:00',5,'plan',4);
"""
sql "set experimental_enable_nereids_planner = false;"
sql "set @data_batch_num='2024-01-31 00:00:00';"
sql "delete from bi_acti_per_period_plan where data_batch_num =@data_batch_num; "
}

0 comments on commit bcb3131

Please sign in to comment.