You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "comphead (via GitHub)" <gi...@apache.org> on 2023/02/23 22:24:58 UTC

[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5328: [feat]:fast check has column

comphead commented on code in PR #5328:
URL: https://github.com/apache/arrow-datafusion/pull/5328#discussion_r1116240718


##########
datafusion/common/src/dfschema.rs:
##########
@@ -314,6 +329,26 @@ impl DFSchema {
         }
     }
 
+    /// Find if the field exists with the given name
+    pub fn has_column_with_unqualified_name(&self, name: &str) -> bool {
+        let matches = self.fields_with_unqualified_name(name);
+        matches.len() == 1

Review Comment:
   better to use `.isEmpty`



##########
datafusion/common/src/dfschema.rs:
##########
@@ -314,6 +329,26 @@ impl DFSchema {
         }
     }
 
+    /// Find if the field exists with the given name
+    pub fn has_column_with_unqualified_name(&self, name: &str) -> bool {
+        let matches = self.fields_with_unqualified_name(name);
+        matches.len() == 1
+    }
+
+    /// Find if the field exists with the given qualified name
+    pub fn has_column_with_qualified_name(&self, qualifier: &str, name: &str) -> bool {
+        let matches = self.fields_with_qualified_name(qualifier, name);
+matches.len() == 1 
+    }
+
+    /// Find if the field exists with the given qualified column
+    pub fn has_column(&self, column: &Column) -> bool {

Review Comment:
   its great to have some tests for both qualified/not qualified cases



##########
datafusion/common/src/dfschema.rs:
##########
@@ -314,6 +329,26 @@ impl DFSchema {
         }
     }
 
+    /// Find if the field exists with the given name
+    pub fn has_column_with_unqualified_name(&self, name: &str) -> bool {
+        let matches = self.fields_with_unqualified_name(name);
+        matches.len() == 1
+    }
+
+    /// Find if the field exists with the given qualified name
+    pub fn has_column_with_qualified_name(&self, qualifier: &str, name: &str) -> bool {
+        let matches = self.fields_with_qualified_name(qualifier, name);
+matches.len() == 1 

Review Comment:
   better to use `.isEmpty`



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