File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
datafusion/sql/src/unparser Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,14 @@ impl Dialect for SqliteDialect {
487487 false
488488 }
489489
490+ fn timestamp_cast_dtype (
491+ & self ,
492+ _time_unit : & TimeUnit ,
493+ _tz : & Option < Arc < str > > ,
494+ ) -> ast:: DataType {
495+ ast:: DataType :: Text
496+ }
497+
490498 fn scalar_function_to_sql_overrides (
491499 & self ,
492500 unparser : & Unparser ,
Original file line number Diff line number Diff line change @@ -3173,4 +3173,24 @@ mod tests {
31733173
31743174 Ok ( ( ) )
31753175 }
3176+
3177+ #[ test]
3178+ fn test_cast_timestamp_sqlite ( ) -> Result < ( ) > {
3179+ let dialect: Arc < dyn Dialect > = Arc :: new ( SqliteDialect { } ) ;
3180+
3181+ let unparser = Unparser :: new ( dialect. as_ref ( ) ) ;
3182+ let expr = Expr :: Cast ( Cast {
3183+ expr : Box :: new ( col ( "a" ) ) ,
3184+ data_type : DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ,
3185+ } ) ;
3186+
3187+ let ast = unparser. expr_to_sql ( & expr) ?;
3188+
3189+ let actual = ast. to_string ( ) ;
3190+ let expected = "CAST(`a` AS TEXT)" . to_string ( ) ;
3191+
3192+ assert_eq ! ( actual, expected) ;
3193+
3194+ Ok ( ( ) )
3195+ }
31763196}
You can’t perform that action at this time.
0 commit comments