Skip to content

Commit c31e07c

Browse files
authored
expression: fail ColumnSubstituteImpl if creating function returns error (#53716) (#54191)
close #53580, close #53582, close #53594, close #53603
1 parent 9c3a66e commit c31e07c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

pkg/expression/util.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,11 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression
519519
}
520520
}
521521
if substituted {
522-
return true, hasFail, NewFunctionInternal(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
522+
newFunc, err := NewFunction(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
523+
if err != nil {
524+
return true, true, v
525+
}
526+
return true, hasFail, newFunc
523527
}
524528
}
525529
return false, false, expr

tests/integrationtest/r/planner/core/integration.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3952,3 +3952,10 @@ p o v a
39523952
3 5 5 3
39533953
3 9 9 9
39543954
set @@tidb_enable_pipelined_window_function=DEFAULT;
3955+
drop table if exists t;
3956+
create table t (col TEXT);
3957+
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
3958+
case when (
3959+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
3960+
) then 1 else 2 end;
3961+
1

tests/integrationtest/t/planner/core/integration.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,4 +2071,10 @@ set @@tidb_enable_pipelined_window_function=0;
20712071
select *, first_value(v) over (partition by p order by o range between 3.1 preceding and 2.9 following) as a from planner__core__integration.first_range;
20722072
set @@tidb_enable_pipelined_window_function=DEFAULT;
20732073

2074-
2074+
# TestIssue53580
2075+
drop table if exists t;
2076+
create table t (col TEXT);
2077+
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
2078+
case when (
2079+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
2080+
) then 1 else 2 end;

0 commit comments

Comments
 (0)