@@ -1672,45 +1672,86 @@ impl TryFrom<DataType> for LogicalType {
16721672 | DataType :: UBigInt
16731673 | DataType :: UInt64 => Ok ( Self :: UBigint ) ,
16741674 DataType :: Boolean => Ok ( Self :: Boolean ) ,
1675- DataType :: Date => Ok ( Self :: Date ) ,
1675+ DataType :: Date => {
1676+ #[ cfg( feature = "time" ) ]
1677+ {
1678+ Ok ( Self :: Date )
1679+ }
1680+ #[ cfg( not( feature = "time" ) ) ]
1681+ {
1682+ Err ( DatabaseError :: UnsupportedStmt (
1683+ "time types require the `time` feature" . to_string ( ) ,
1684+ ) )
1685+ }
1686+ }
16761687 DataType :: Datetime ( precision) => {
1677- if precision. is_some ( ) {
1678- return Err ( DatabaseError :: UnsupportedStmt (
1679- "time's precision" . to_string ( ) ,
1680- ) ) ;
1688+ #[ cfg( feature = "time" ) ]
1689+ {
1690+ if precision. is_some ( ) {
1691+ return Err ( DatabaseError :: UnsupportedStmt (
1692+ "time's precision" . to_string ( ) ,
1693+ ) ) ;
1694+ }
1695+ Ok ( Self :: DateTime )
1696+ }
1697+ #[ cfg( not( feature = "time" ) ) ]
1698+ {
1699+ let _ = precision;
1700+ Err ( DatabaseError :: UnsupportedStmt (
1701+ "time types require the `time` feature" . to_string ( ) ,
1702+ ) )
16811703 }
1682- Ok ( Self :: DateTime )
16831704 }
16841705 DataType :: Time ( precision, info) => {
1685- match precision {
1686- Some ( 0 ..5 ) | None => ( ) ,
1687- _ => {
1706+ #[ cfg( feature = "time" ) ]
1707+ {
1708+ match precision {
1709+ Some ( 0 ..5 ) | None => ( ) ,
1710+ _ => {
1711+ return Err ( DatabaseError :: UnsupportedStmt (
1712+ "time's precision must be less than 5" . to_string ( ) ,
1713+ ) )
1714+ }
1715+ }
1716+ if !matches ! ( info, sqlparser:: ast:: TimezoneInfo :: None ) {
16881717 return Err ( DatabaseError :: UnsupportedStmt (
1689- "time's precision must be less than 5 " . to_string ( ) ,
1690- ) )
1718+ "time's zone is not supported " . to_string ( ) ,
1719+ ) ) ;
16911720 }
1721+ Ok ( Self :: Time ( precision) )
16921722 }
1693- if !matches ! ( info, sqlparser:: ast:: TimezoneInfo :: None ) {
1694- return Err ( DatabaseError :: UnsupportedStmt (
1695- "time's zone is not supported" . to_string ( ) ,
1696- ) ) ;
1723+ #[ cfg( not( feature = "time" ) ) ]
1724+ {
1725+ let _ = ( precision, info) ;
1726+ Err ( DatabaseError :: UnsupportedStmt (
1727+ "time types require the `time` feature" . to_string ( ) ,
1728+ ) )
16971729 }
1698- Ok ( Self :: Time ( precision) )
16991730 }
17001731 DataType :: Timestamp ( precision, info) => {
1701- let mut zone = false ;
1702- match precision {
1703- Some ( 3 | 6 | 9 ) | None => ( ) ,
1704- _ => {
1705- return Err ( DatabaseError :: UnsupportedStmt (
1706- "timestamp's precision must be 3,6,9" . to_string ( ) ,
1707- ) )
1732+ #[ cfg( feature = "time" ) ]
1733+ {
1734+ let mut zone = false ;
1735+ match precision {
1736+ Some ( 3 | 6 | 9 ) | None => ( ) ,
1737+ _ => {
1738+ return Err ( DatabaseError :: UnsupportedStmt (
1739+ "timestamp's precision must be 3,6,9" . to_string ( ) ,
1740+ ) )
1741+ }
17081742 }
1743+ if matches ! ( info, sqlparser:: ast:: TimezoneInfo :: WithTimeZone ) {
1744+ zone = true ;
1745+ }
1746+ Ok ( Self :: TimeStamp ( precision, zone) )
17091747 }
1710- if matches ! ( info, sqlparser:: ast:: TimezoneInfo :: WithTimeZone ) {
1711- zone = true ;
1748+ #[ cfg( not( feature = "time" ) ) ]
1749+ {
1750+ let _ = ( precision, info) ;
1751+ Err ( DatabaseError :: UnsupportedStmt (
1752+ "time types require the `time` feature" . to_string ( ) ,
1753+ ) )
17121754 }
1713- Ok ( Self :: TimeStamp ( precision, zone) )
17141755 }
17151756 DataType :: Decimal ( info)
17161757 | DataType :: DecimalUnsigned ( info)
0 commit comments