@@ -251,9 +251,11 @@ impl ExprSchemable for Expr {
251
251
ref right,
252
252
..
253
253
} ) => Ok ( left. nullable ( input_schema) ? || right. nullable ( input_schema) ?) ,
254
- Expr :: Like ( Like { expr, .. } ) => expr. nullable ( input_schema) ,
255
- Expr :: ILike ( Like { expr, .. } ) => expr. nullable ( input_schema) ,
256
- Expr :: SimilarTo ( Like { expr, .. } ) => expr. nullable ( input_schema) ,
254
+ Expr :: Like ( Like { expr, pattern, .. } )
255
+ | Expr :: ILike ( Like { expr, pattern, .. } )
256
+ | Expr :: SimilarTo ( Like { expr, pattern, .. } ) => {
257
+ Ok ( expr. nullable ( input_schema) ? || pattern. nullable ( input_schema) ?)
258
+ }
257
259
Expr :: Wildcard => Err ( DataFusionError :: Internal (
258
260
"Wildcard expressions are not valid in a logical query plan" . to_owned ( ) ,
259
261
) ) ,
@@ -437,6 +439,22 @@ mod tests {
437
439
assert ! ( expr. nullable( & get_schema( false ) ) . unwrap( ) ) ;
438
440
}
439
441
442
+ #[ test]
443
+ fn test_like_nullability ( ) {
444
+ let get_schema = |nullable| {
445
+ MockExprSchema :: new ( )
446
+ . with_data_type ( DataType :: Utf8 )
447
+ . with_nullable ( nullable)
448
+ } ;
449
+
450
+ let expr = col ( "foo" ) . like ( lit ( "bar" ) ) ;
451
+ assert ! ( !expr. nullable( & get_schema( false ) ) . unwrap( ) ) ;
452
+ assert ! ( expr. nullable( & get_schema( true ) ) . unwrap( ) ) ;
453
+
454
+ let expr = col ( "foo" ) . like ( lit ( ScalarValue :: Utf8 ( None ) ) ) ;
455
+ assert ! ( expr. nullable( & get_schema( false ) ) . unwrap( ) ) ;
456
+ }
457
+
440
458
#[ test]
441
459
fn expr_schema_data_type ( ) {
442
460
let expr = col ( "foo" ) ;
0 commit comments