@@ -297,12 +297,14 @@ mod tests {
297297 use std:: sync:: Arc ;
298298
299299 use arrow:: datatypes:: { DataType , Field , Schema } ;
300- use datafusion_common:: { DFSchema , assert_contains} ;
300+ use datafusion_common:: stats:: Precision ;
301+ use datafusion_common:: { DFSchema , Result , ScalarValue , assert_contains} ;
301302 use datafusion_expr:: {
302303 Expr , col, execution_props:: ExecutionProps , interval_arithmetic:: Interval , lit,
303304 } ;
304305
305306 use crate :: { AnalysisContext , create_physical_expr} ;
307+ use crate :: expressions:: Column ;
306308
307309 use super :: { ExprBoundaries , analyze} ;
308310
@@ -435,4 +437,39 @@ mod tests {
435437 . unwrap_err ( ) ;
436438 assert_contains ! ( analysis_error. to_string( ) , expected_error) ;
437439 }
440+
441+ #[ test]
442+ fn analyze_not_eq_around ( ) -> Result < ( ) > {
443+ let schema = Arc :: new ( Schema :: new ( vec ! [ make_field( "a" , DataType :: Float32 ) ] ) ) ;
444+ let boundaries = vec ! [ ExprBoundaries {
445+ column: Column :: new( "a" , 0 ) ,
446+ interval: Some ( Interval :: try_new(
447+ ScalarValue :: Float32 ( Some ( -1.0 ) ) ,
448+ ScalarValue :: Float32 ( Some ( 1.0 ) ) ,
449+ ) ?) ,
450+ distinct_count: Precision :: Absent ,
451+ } ] ;
452+
453+ // NOT (a = 0.0)
454+ let pred_not_eq = datafusion_expr:: not ( col ( "a" ) . eq ( lit ( 0.0f32 ) ) ) ;
455+
456+ let df_schema = DFSchema :: try_from ( Arc :: clone ( & schema) ) ?;
457+ let physical_expr =
458+ create_physical_expr ( & pred_not_eq, & df_schema, & ExecutionProps :: new ( ) ) ?;
459+
460+ let out_not_eq = analyze (
461+ & physical_expr,
462+ AnalysisContext :: new ( boundaries) ,
463+ df_schema. as_ref ( ) ,
464+ ) ?;
465+
466+ let actual = out_not_eq. boundaries [ 0 ] . interval . clone ( ) ;
467+ let expected = Some ( Interval :: try_new (
468+ ScalarValue :: Float32 ( Some ( -1.0 ) ) ,
469+ ScalarValue :: Float32 ( Some ( 1.0 ) ) ,
470+ ) ?) ;
471+
472+ assert_eq ! ( expected, actual) ;
473+ Ok ( ( ) )
474+ }
438475}
0 commit comments