Skip to content

Commit 9ddf280

Browse files
author
James Cor
committed
fix and optimization
1 parent 893a99e commit 9ddf280

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

enginetest/queries/script_queries.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7837,6 +7837,12 @@ where
78377837
{123},
78387838
},
78397839
},
7840+
{
7841+
Query: "select * from t where ((true and -1) >= 0);",
7842+
Expected: []sql.Row{
7843+
{123},
7844+
},
7845+
},
78407846
},
78417847
},
78427848
{

sql/analyzer/optimization_rules.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ func simplifyFilters(ctx *sql.Context, a *Analyzer, node sql.Node, scope *plan.S
264264
return e.RightChild, transform.NewTree, nil
265265
}
266266

267-
if isTrue(e.LeftChild) {
267+
if isTrue(e.LeftChild) && types.IsBoolean(e.RightChild.Type()) {
268268
return e.RightChild, transform.NewTree, nil
269269
}
270270

271-
if isTrue(e.RightChild) {
271+
if isTrue(e.RightChild) && types.IsBoolean(e.LeftChild.Type()) {
272272
return e.LeftChild, transform.NewTree, nil
273273
}
274274

0 commit comments

Comments
 (0)