@@ -237,37 +237,37 @@ func simplifyFilters(ctx *sql.Context, a *Analyzer, node sql.Node, scope *plan.S
237237 expression .NewLessThanOrEqual (e .Val , e .Upper ),
238238 ), transform .NewTree , nil
239239 case * expression.Or :
240- if isTrue (e .LeftChild ) {
240+ if isTrue (ctx , e .LeftChild ) {
241241 return e .LeftChild , transform .NewTree , nil
242242 }
243243
244- if isTrue (e .RightChild ) {
244+ if isTrue (ctx , e .RightChild ) {
245245 return e .RightChild , transform .NewTree , nil
246246 }
247247
248- if isFalse (e .LeftChild ) && types .IsBoolean (e .RightChild .Type ()) {
248+ if isFalse (ctx , e .LeftChild ) && types .IsBoolean (e .RightChild .Type ()) {
249249 return e .RightChild , transform .NewTree , nil
250250 }
251251
252- if isFalse (e .RightChild ) && types .IsBoolean (e .LeftChild .Type ()) {
252+ if isFalse (ctx , e .RightChild ) && types .IsBoolean (e .LeftChild .Type ()) {
253253 return e .LeftChild , transform .NewTree , nil
254254 }
255255
256256 return e , transform .SameTree , nil
257257 case * expression.And :
258- if isFalse (e .LeftChild ) {
258+ if isFalse (ctx , e .LeftChild ) {
259259 return e .LeftChild , transform .NewTree , nil
260260 }
261261
262- if isFalse (e .RightChild ) {
262+ if isFalse (ctx , e .RightChild ) {
263263 return e .RightChild , transform .NewTree , nil
264264 }
265265
266- if isTrue (e .LeftChild ) && types .IsBoolean (e .RightChild .Type ()) {
266+ if isTrue (ctx , e .LeftChild ) && types .IsBoolean (e .RightChild .Type ()) {
267267 return e .RightChild , transform .NewTree , nil
268268 }
269269
270- if isTrue (e .RightChild ) && types .IsBoolean (e .LeftChild .Type ()) {
270+ if isTrue (ctx , e .RightChild ) && types .IsBoolean (e .LeftChild .Type ()) {
271271 return e .LeftChild , transform .NewTree , nil
272272 }
273273
@@ -360,12 +360,12 @@ func simplifyFilters(ctx *sql.Context, a *Analyzer, node sql.Node, scope *plan.S
360360 return nil , transform .SameTree , err
361361 }
362362
363- if isFalse (e ) {
363+ if isFalse (ctx , e ) {
364364 emptyTable := plan .NewEmptyTableWithSchema (filter .Schema ())
365365 return emptyTable , transform .NewTree , nil
366366 }
367367
368- if isTrue (e ) {
368+ if isTrue (ctx , e ) {
369369 return filter .Child , transform .NewTree , nil
370370 }
371371
@@ -376,24 +376,24 @@ func simplifyFilters(ctx *sql.Context, a *Analyzer, node sql.Node, scope *plan.S
376376 })
377377}
378378
379- func isFalse (e sql.Expression ) bool {
379+ func isFalse (ctx * sql. Context , e sql.Expression ) bool {
380380 lit , ok := e .(* expression.Literal )
381381 if ! ok || lit == nil || lit .Value () == nil {
382382 return false
383383 }
384- val , err := sql .ConvertToBool (sql . NewEmptyContext () , lit .Value ())
384+ val , err := sql .ConvertToBool (ctx , lit .Value ())
385385 if err != nil {
386386 return false
387387 }
388388 return ! val
389389}
390390
391- func isTrue (e sql.Expression ) bool {
391+ func isTrue (ctx * sql. Context , e sql.Expression ) bool {
392392 lit , ok := e .(* expression.Literal )
393393 if ! ok || lit == nil || lit .Value () == nil {
394394 return false
395395 }
396- val , err := sql .ConvertToBool (sql . NewEmptyContext () , lit .Value ())
396+ val , err := sql .ConvertToBool (ctx , lit .Value ())
397397 if err != nil {
398398 return false
399399 }
0 commit comments