You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/04/10 11:01:03 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4042: feat: DataType::contains support nested type

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


##########
arrow-schema/src/datatype.rs:
##########
@@ -498,6 +498,29 @@ impl DataType {
                 }
             }
     }
+
+    /// Check to see if `self` is a superset of `other`
+    ///
+    /// If DataType is a nested type, then it will check to see if the nested type is a superset of the other nested type
+    /// else it will check to see if the DataType is equal to the other DataType
+    pub fn contains(&self, other: &DataType) -> bool {
+        match self {
+            DataType::List(field)
+            | DataType::LargeList(field)
+            | DataType::Map(field, _)
+            | DataType::FixedSizeList(field, _) => field.data_type().contains(other),

Review Comment:
   I think this should call through to Field::contains, which in turn should call through to DataType



##########
arrow-schema/src/datatype.rs:
##########
@@ -498,6 +498,29 @@ impl DataType {
                 }
             }
     }
+
+    /// Check to see if `self` is a superset of `other`
+    ///
+    /// If DataType is a nested type, then it will check to see if the nested type is a superset of the other nested type
+    /// else it will check to see if the DataType is equal to the other DataType
+    pub fn contains(&self, other: &DataType) -> bool {
+        match self {
+            DataType::List(field)
+            | DataType::LargeList(field)
+            | DataType::Map(field, _)
+            | DataType::FixedSizeList(field, _) => field.data_type().contains(other),
+            DataType::Struct(fields) => {
+                fields.iter().any(|field| field.data_type().contains(other))

Review Comment:
   This should call through to Fields::contains



-- 
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