@@ -1554,3 +1554,68 @@ async fn cast_timestamp_to_timestamptz() -> Result<()> {
15541554
15551555 Ok ( ( ) )
15561556}
1557+
1558+ #[ tokio:: test]
1559+ async fn test_cast_to_time ( ) -> Result < ( ) > {
1560+ let ctx = SessionContext :: new ( ) ;
1561+ let sql = "SELECT 0::TIME" ;
1562+ let actual = execute_to_batches ( & ctx, sql) . await ;
1563+
1564+ let expected = vec ! [
1565+ "+----------+" ,
1566+ "| Int64(0) |" ,
1567+ "+----------+" ,
1568+ "| 00:00:00 |" ,
1569+ "+----------+" ,
1570+ ] ;
1571+ assert_batches_eq ! ( expected, & actual) ;
1572+
1573+ Ok ( ( ) )
1574+ }
1575+
1576+ #[ tokio:: test]
1577+ async fn test_cast_to_time_with_time_zone_should_not_work ( ) -> Result < ( ) > {
1578+ // this should not work until we implement tz for DataType::Time64
1579+ let ctx = SessionContext :: new ( ) ;
1580+ let sql = "SELECT 0::TIME WITH TIME ZONE" ;
1581+ let results = plan_and_collect ( & ctx, sql) . await . unwrap_err ( ) ;
1582+
1583+ assert_eq ! (
1584+ results. to_string( ) ,
1585+ "This feature is not implemented: Unsupported SQL type Time(WithTimeZone)"
1586+ ) ;
1587+
1588+ Ok ( ( ) )
1589+ }
1590+
1591+ #[ tokio:: test]
1592+ async fn test_cast_to_time_without_time_zone ( ) -> Result < ( ) > {
1593+ let ctx = SessionContext :: new ( ) ;
1594+ let sql = "SELECT 0::TIME WITHOUT TIME ZONE" ;
1595+ let actual = execute_to_batches ( & ctx, sql) . await ;
1596+
1597+ let expected = vec ! [
1598+ "+----------+" ,
1599+ "| Int64(0) |" ,
1600+ "+----------+" ,
1601+ "| 00:00:00 |" ,
1602+ "+----------+" ,
1603+ ] ;
1604+ assert_batches_eq ! ( expected, & actual) ;
1605+
1606+ Ok ( ( ) )
1607+ }
1608+
1609+ #[ tokio:: test]
1610+ async fn test_cast_to_timetz_should_not_work ( ) -> Result < ( ) > {
1611+ // this should not work until we implement tz for DataType::Time64
1612+ let ctx = SessionContext :: new ( ) ;
1613+ let sql = "SELECT 0::TIMETZ" ;
1614+ let results = plan_and_collect ( & ctx, sql) . await . unwrap_err ( ) ;
1615+
1616+ assert_eq ! (
1617+ results. to_string( ) ,
1618+ "This feature is not implemented: Unsupported SQL type Time(Tz)"
1619+ ) ;
1620+ Ok ( ( ) )
1621+ }
0 commit comments