You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/11/23 05:47:39 UTC
[arrow-rs] branch master updated: Add Decimal128, Decimal256, Float16 to DataType::is_numeric (#3121)
This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new ca92306f8 Add Decimal128, Decimal256, Float16 to DataType::is_numeric (#3121)
ca92306f8 is described below
commit ca92306f801ca39372a4b4c8d9b4d430ead38f64
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Wed Nov 23 05:47:33 2022 +0000
Add Decimal128, Decimal256, Float16 to DataType::is_numeric (#3121)
---
arrow-schema/src/datatype.rs | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/arrow-schema/src/datatype.rs b/arrow-schema/src/datatype.rs
index b9be4bec7..cf85902e4 100644
--- a/arrow-schema/src/datatype.rs
+++ b/arrow-schema/src/datatype.rs
@@ -263,30 +263,13 @@ impl fmt::Display for DataType {
impl DataType {
/// Returns true if the type is primitive: (numeric, temporal).
+ #[inline]
pub fn is_primitive(t: &DataType) -> bool {
- use DataType::*;
- matches!(
- t,
- Int8 | Int16
- | Int32
- | Int64
- | UInt8
- | UInt16
- | UInt32
- | UInt64
- | Float32
- | Float64
- | Date32
- | Date64
- | Time32(_)
- | Time64(_)
- | Timestamp(_, _)
- | Interval(_)
- | Duration(_)
- )
+ Self::is_numeric(t) || Self::is_temporal(t)
}
- /// Returns true if this type is numeric: (UInt*, Int*, or Float*).
+ /// Returns true if this type is numeric: (UInt*, Int*, Float*, Decimal*).
+ #[inline]
pub fn is_numeric(t: &DataType) -> bool {
use DataType::*;
matches!(
@@ -299,12 +282,16 @@ impl DataType {
| Int16
| Int32
| Int64
+ | Float16
| Float32
| Float64
+ | Decimal128(_, _)
+ | Decimal256(_, _)
)
}
/// Returns true if this type is temporal: (Date*, Time*, Duration, or Interval).
+ #[inline]
pub fn is_temporal(t: &DataType) -> bool {
use DataType::*;
matches!(
@@ -320,6 +307,7 @@ impl DataType {
}
/// Returns true if this type is valid as a dictionary key
+ #[inline]
pub fn is_dictionary_key_type(t: &DataType) -> bool {
use DataType::*;
matches!(