File tree Expand file tree Collapse file tree
native/spark-expr/src/datetime_funcs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616// under the License.
1717
1818use arrow:: array:: { Array , Date32Array , Int32Array } ;
19+ use arrow:: compute:: cast;
1920use arrow:: compute:: kernels:: arity:: binary;
2021use arrow:: datatypes:: DataType ;
2122use datafusion:: common:: { utils:: take_function_args, DataFusionError , Result } ;
@@ -84,6 +85,12 @@ impl ScalarUDFImpl for SparkDateDiff {
8485 let end_arr = end_date. into_array ( num_rows) ?;
8586 let start_arr = start_date. into_array ( num_rows) ?;
8687
88+ // Normalize dictionary arrays (important for Iceberg)
89+ let end_arr = cast ( & end_arr, & DataType :: Date32 )
90+ . map_err ( |e| DataFusionError :: Execution ( e. to_string ( ) ) ) ?;
91+ let start_arr = cast ( & start_arr, & DataType :: Date32 )
92+ . map_err ( |e| DataFusionError :: Execution ( e. to_string ( ) ) ) ?;
93+
8794 let end_date_array = end_arr
8895 . as_any ( )
8996 . downcast_ref :: < Date32Array > ( )
@@ -106,8 +113,4 @@ impl ScalarUDFImpl for SparkDateDiff {
106113
107114 Ok ( ColumnarValue :: Array ( Arc :: new ( result) ) )
108115 }
109-
110- fn aliases ( & self ) -> & [ String ] {
111- & self . aliases
112- }
113116}
You can’t perform that action at this time.
0 commit comments