File tree Expand file tree Collapse file tree
datafusion/physical-expr/src/expressions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4889,10 +4889,22 @@ mod tests {
48894889 ) ;
48904890
48914891 // The probability of being distinct is 1 - 1 / 16 = 15 / 16.
4892- assert_eq ! (
4893- neq. evaluate_statistics( & [ left_stat, right_stat] ) ?,
4894- Distribution :: new_bernoulli( ScalarValue :: from( 15.0 / 16.0 ) ) ?
4895- ) ;
4892+ let got = neq. evaluate_statistics ( & [ left_stat, right_stat] ) ?;
4893+ let expected = Distribution :: new_bernoulli ( ScalarValue :: from ( 15.0 / 16.0 ) ) ?;
4894+ match ( got, expected) {
4895+ ( Bernoulli ( g) , Bernoulli ( e) ) => {
4896+ let gp = match g. p_value ( ) {
4897+ ScalarValue :: Float64 ( Some ( v) ) => v,
4898+ _ => panic ! ( "got unexpected p type" ) ,
4899+ } ;
4900+ let ep = match e. p_value ( ) {
4901+ ScalarValue :: Float64 ( Some ( v) ) => v,
4902+ _ => panic ! ( "expected unexpected p type" ) ,
4903+ } ;
4904+ assert ! ( ( gp - ep) . abs( ) < 1e-12 ) ;
4905+ }
4906+ _ => panic ! ( "unexpected distribution variants" ) ,
4907+ }
48964908
48974909 Ok ( ( ) )
48984910 }
Original file line number Diff line number Diff line change @@ -196,4 +196,26 @@ mod tests {
196196 assert ! ( err. contains( "expr_id=Some(7)" ) ) ;
197197 assert ! ( err. contains( "PhysicalColumn" ) ) ;
198198 }
199+
200+ #[ cfg( feature = "proto" ) ]
201+ #[ test]
202+ fn unknown_column_proto_roundtrip ( ) {
203+ use datafusion_proto_models:: protobuf;
204+
205+ let name = "col_b" . to_string ( ) ;
206+ let node = protobuf:: PhysicalExprNode {
207+ expr_id : Some ( 42 ) ,
208+ expr_type : Some ( protobuf:: physical_expr_node:: ExprType :: UnknownColumn (
209+ protobuf:: UnknownColumn { name : name. clone ( ) } ,
210+ ) ) ,
211+ } ;
212+
213+ let schema = Schema :: empty ( ) ;
214+ let decoder = DummyDecode ;
215+ let ctx = PhysicalExprDecodeCtx :: new ( & schema, & decoder) ;
216+
217+ let decoded = UnKnownColumn :: try_from_proto ( & node, & ctx) . unwrap ( ) ;
218+ let col = decoded. as_ref ( ) . downcast_ref :: < UnKnownColumn > ( ) . unwrap ( ) ;
219+ assert_eq ! ( col. name( ) , name. as_str( ) ) ;
220+ }
199221}
You can’t perform that action at this time.
0 commit comments