diff --git a/pkg/planner/core/rule_predicate_simplification.go b/pkg/planner/core/rule_predicate_simplification.go index 84b09309cd789..8b7bf3e0af6ba 100644 --- a/pkg/planner/core/rule_predicate_simplification.go +++ b/pkg/planner/core/rule_predicate_simplification.go @@ -55,6 +55,9 @@ func findPredicateType(expr expression.Expression) (*expression.Column, predicat return nil, orPredicate } args := v.GetArgs() + if len(args) == 0 { + return nil, otherPredicate + } col, colOk := args[0].(*expression.Column) if !colOk { return nil, otherPredicate diff --git a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result index d5bc8ced2167f..62405e0f25a1b 100644 --- a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result +++ b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result @@ -750,3 +750,9 @@ NULL NULL 2 2 4 2 show warnings; Level Code Message drop table if exists t1, t2, t3, t4; +drop table if exists t0, v0; +drop view if exists v0; +CREATE TABLE t0(c0 INTEGER); +CREATE VIEW v0(c0) AS SELECT 'a' FROM t0 WHERE (CASE t0.c0 WHEN t0.c0 THEN false END ); +SELECT t0.c0 FROM v0, t0 WHERE RAND(); +c0 diff --git a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test index 679cf8cb6c767..37e87a519e77b 100644 --- a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test +++ b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test @@ -517,3 +517,10 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b order by 1, 2, 3, 4, 5; show warnings; drop table if exists t1, t2, t3, t4; + +# TestIssue56270 +drop table if exists t0, v0; +drop view if exists v0; +CREATE TABLE t0(c0 INTEGER); +CREATE VIEW v0(c0) AS SELECT 'a' FROM t0 WHERE (CASE t0.c0 WHEN t0.c0 THEN false END ); +SELECT t0.c0 FROM v0, t0 WHERE RAND();