@@ -391,7 +391,9 @@ impl Unparser<'_> {
391
391
Expr :: ScalarVariable ( _, _) => {
392
392
not_impl_err ! ( "Unsupported Expr conversion: {expr:?}" )
393
393
}
394
- Expr :: IsNull ( _) => not_impl_err ! ( "Unsupported Expr conversion: {expr:?}" ) ,
394
+ Expr :: IsNull ( expr) => {
395
+ Ok ( ast:: Expr :: IsNull ( Box :: new ( self . expr_to_sql ( expr) ?) ) )
396
+ }
395
397
Expr :: IsNotFalse ( _) => not_impl_err ! ( "Unsupported Expr conversion: {expr:?}" ) ,
396
398
Expr :: GetIndexedField ( _) => {
397
399
not_impl_err ! ( "Unsupported Expr conversion: {expr:?}" )
@@ -863,7 +865,7 @@ mod tests {
863
865
use datafusion_expr:: {
864
866
case, col, exists,
865
867
expr:: { AggregateFunction , AggregateFunctionDefinition } ,
866
- lit, not, not_exists, table_scan, wildcard, ColumnarValue , ScalarUDF ,
868
+ lit, not, not_exists, table_scan, when , wildcard, ColumnarValue , ScalarUDF ,
867
869
ScalarUDFImpl , Signature , Volatility , WindowFrame , WindowFunctionDefinition ,
868
870
} ;
869
871
@@ -933,6 +935,14 @@ mod tests {
933
935
. otherwise( lit( ScalarValue :: Null ) ) ?,
934
936
r#"CASE "a" WHEN 1 THEN true WHEN 0 THEN false ELSE NULL END"# ,
935
937
) ,
938
+ (
939
+ when( col( "a" ) . is_null( ) , lit( true ) ) . otherwise( lit( false ) ) ?,
940
+ r#"CASE WHEN "a" IS NULL THEN true ELSE false END"# ,
941
+ ) ,
942
+ (
943
+ when( col( "a" ) . is_not_null( ) , lit( true ) ) . otherwise( lit( false ) ) ?,
944
+ r#"CASE WHEN "a" IS NOT NULL THEN true ELSE false END"# ,
945
+ ) ,
936
946
(
937
947
Expr :: Cast ( Cast {
938
948
expr: Box :: new( col( "a" ) ) ,
@@ -959,6 +969,18 @@ mod tests {
959
969
ScalarUDF :: new_from_impl( DummyUDF :: new( ) ) . call( vec![ col( "a" ) , col( "b" ) ] ) ,
960
970
r#"dummy_udf("a", "b")"# ,
961
971
) ,
972
+ (
973
+ ScalarUDF :: new_from_impl( DummyUDF :: new( ) )
974
+ . call( vec![ col( "a" ) , col( "b" ) ] )
975
+ . is_null( ) ,
976
+ r#"dummy_udf("a", "b") IS NULL"# ,
977
+ ) ,
978
+ (
979
+ ScalarUDF :: new_from_impl( DummyUDF :: new( ) )
980
+ . call( vec![ col( "a" ) , col( "b" ) ] )
981
+ . is_not_null( ) ,
982
+ r#"dummy_udf("a", "b") IS NOT NULL"# ,
983
+ ) ,
962
984
(
963
985
Expr :: Like ( Like {
964
986
negated: true ,
@@ -1081,6 +1103,7 @@ mod tests {
1081
1103
r#"COUNT(*) OVER (ORDER BY "a" DESC NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 2 FOLLOWING)"# ,
1082
1104
) ,
1083
1105
( col( "a" ) . is_not_null( ) , r#""a" IS NOT NULL"# ) ,
1106
+ ( col( "a" ) . is_null( ) , r#""a" IS NULL"# ) ,
1084
1107
(
1085
1108
( col( "a" ) + col( "b" ) ) . gt( lit( 4 ) ) . is_true( ) ,
1086
1109
r#"(("a" + "b") > 4) IS TRUE"# ,
0 commit comments