@@ -23,7 +23,7 @@ use arrow::{
2323
2424use datafusion:: common:: format:: DEFAULT_CAST_OPTIONS ;
2525use datafusion:: common:: Result as DataFusionResult ;
26- use datafusion:: common:: { cast_column , ScalarValue } ;
26+ use datafusion:: common:: ScalarValue ;
2727use datafusion:: logical_expr:: ColumnarValue ;
2828use datafusion:: physical_expr:: PhysicalExpr ;
2929use std:: {
@@ -70,8 +70,7 @@ fn cast_timestamp_micros_to_millis_scalar(
7070}
7171
7272#[ derive( Debug , Clone , Eq ) ]
73- pub struct
74- CometCastColumnExpr {
73+ pub struct CometCastColumnExpr {
7574 /// The physical expression producing the value to cast.
7675 expr : Arc < dyn PhysicalExpr > ,
7776 /// The physical field of the input column.
@@ -146,8 +145,11 @@ impl PhysicalExpr for CometCastColumnExpr {
146145 fn evaluate ( & self , batch : & RecordBatch ) -> DataFusionResult < ColumnarValue > {
147146 let value = self . expr . evaluate ( batch) ?;
148147
149- if value. data_type ( ) . equals_datatype ( self . target_field . data_type ( ) ) {
150- return Ok ( value)
148+ if value
149+ . data_type ( )
150+ . equals_datatype ( self . target_field . data_type ( ) )
151+ {
152+ return Ok ( value) ;
151153 }
152154
153155 let input_physical_field = self . input_physical_field . data_type ( ) ;
@@ -214,10 +216,10 @@ mod tests {
214216 fn test_cast_timestamp_micros_to_millis_array ( ) {
215217 // Create a TimestampMicrosecond array with some values
216218 let micros_array: TimestampMicrosecondArray = vec ! [
217- Some ( 1_000_000 ) , // 1 second in micros
218- Some ( 2_500_000 ) , // 2.5 seconds in micros
219- None , // null value
220- Some ( 0 ) , // zero
219+ Some ( 1_000_000 ) , // 1 second in micros
220+ Some ( 2_500_000 ) , // 2.5 seconds in micros
221+ None , // null value
222+ Some ( 0 ) , // zero
221223 Some ( -1_000_000 ) , // negative value (before epoch)
222224 ]
223225 . into ( ) ;
@@ -263,10 +265,7 @@ mod tests {
263265 fn test_cast_timestamp_micros_to_millis_scalar ( ) {
264266 // Test with a value
265267 let result = cast_timestamp_micros_to_millis_scalar ( Some ( 1_500_000 ) , None ) ;
266- assert_eq ! (
267- result,
268- ScalarValue :: TimestampMillisecond ( Some ( 1500 ) , None )
269- ) ;
268+ assert_eq ! ( result, ScalarValue :: TimestampMillisecond ( Some ( 1500 ) , None ) ) ;
270269
271270 // Test with null
272271 let null_result = cast_timestamp_micros_to_millis_scalar ( None , None ) ;
@@ -305,7 +304,8 @@ mod tests {
305304 let cast_expr = CometCastColumnExpr :: new ( col_expr, input_field, target_field, None ) ;
306305
307306 // Create a record batch with TimestampMicrosecond data
308- let micros_array: TimestampMicrosecondArray = vec ! [ Some ( 1_000_000 ) , Some ( 2_000_000 ) , None ] . into ( ) ;
307+ let micros_array: TimestampMicrosecondArray =
308+ vec ! [ Some ( 1_000_000 ) , Some ( 2_000_000 ) , None ] . into ( ) ;
309309 let batch = RecordBatch :: try_new ( Arc :: new ( schema) , vec ! [ Arc :: new( micros_array) ] ) . unwrap ( ) ;
310310
311311 // Evaluate
0 commit comments