You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/10 19:47:48 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3080: early type checks in `RowConverter`

tustvold commented on code in PR #3080:
URL: https://github.com/apache/arrow-rs/pull/3080#discussion_r1019551725


##########
arrow/src/row/mod.rs:
##########
@@ -229,14 +229,70 @@ impl SortField {
     }
 }
 
+/// Helper that is used for [`downcast_primitive`] and just returns `true`.
+macro_rules! always_true {
+    ($t:ty) => {
+        true
+    };
+}
+
 impl RowConverter {
     /// Create a new [`RowConverter`] with the provided schema
-    pub fn new(fields: Vec<SortField>) -> Self {
+    pub fn new(fields: Vec<SortField>) -> Result<Self> {
+        if !Self::supports_fields(&fields) {
+            return Err(ArrowError::NotYetImplemented(format!(
+                "not yet implemented: {:?}",
+                fields
+            )));
+        }
+
         let interners = (0..fields.len()).map(|_| None).collect();
-        Self {
+        Ok(Self {
             fields: fields.into(),
             interners,
+        })
+    }
+
+    /// Check if the given fields are supported by the row format.
+    pub fn supports_fields(fields: &[SortField]) -> bool {
+        for f in fields {
+            let data_type = &f.data_type;

Review Comment:
   I think this can be simplified to something like
   
   ```
   match data_type {
       DataType::Dictionary(_, v) => !DataType::is_nested(v.as_ref()),
       _ => !DataType::is_nested(data_type),
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org