File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -591,6 +591,16 @@ impl DataType {
591591 matches ! ( self , UInt8 | UInt16 | UInt32 | UInt64 )
592592 }
593593
594+ /// Returns true if this type is decimal: (Decimal*).
595+ #[ inline]
596+ pub fn is_decimal ( & self ) -> bool {
597+ use DataType :: * ;
598+ matches ! (
599+ self ,
600+ Decimal32 ( ..) | Decimal64 ( ..) | Decimal128 ( ..) | Decimal256 ( ..)
601+ )
602+ }
603+
594604 /// Returns true if this type is valid as a dictionary key
595605 #[ inline]
596606 pub fn is_dictionary_key_type ( & self ) -> bool {
@@ -1168,6 +1178,15 @@ mod tests {
11681178 assert ! ( !DataType :: is_floating( & DataType :: Int32 ) ) ;
11691179 }
11701180
1181+ #[ test]
1182+ fn test_decimal ( ) {
1183+ assert ! ( DataType :: is_decimal( & DataType :: Decimal32 ( 4 , 2 ) ) ) ;
1184+ assert ! ( DataType :: is_decimal( & DataType :: Decimal64 ( 4 , 2 ) ) ) ;
1185+ assert ! ( DataType :: is_decimal( & DataType :: Decimal128 ( 4 , 2 ) ) ) ;
1186+ assert ! ( DataType :: is_decimal( & DataType :: Decimal256 ( 4 , 2 ) ) ) ;
1187+ assert ! ( !DataType :: is_decimal( & DataType :: Float16 ) ) ;
1188+ }
1189+
11711190 #[ test]
11721191 fn test_datatype_is_null ( ) {
11731192 assert ! ( DataType :: is_null( & DataType :: Null ) ) ;
You can’t perform that action at this time.
0 commit comments