2010YOUY01 commented on code in PR #27620:
URL: https://github.com/apache/datafusion/pull/27620#discussion_r4656072933


##########
datafusion/common/src/functional_dependencies.rs:
##########
@@ -22,6 +24,24 @@ pub enum Constraint {
     Unique(Vec<usize>),
 }
 
+impl Constraint {
+    /// Returns `true` if the constraint columns identify a row also when NULL
+    /// values are treated as equal, as when sorting: always for a primary key,
+    /// and for a unique key only if none of its columns is nullable in
+    /// `schema`. See [`FunctionalDependence::is_valid_across_nulls`].
+    pub fn is_valid_across_nulls(&self, schema: &Schema) -> bool {

Review Comment:
   I suggest to make it a internal-only public API: 
https://datafusion.apache.org/contributor-guide/api-health.html#datafusion-internal-public-apis



##########
datafusion/common/src/functional_dependencies.rs:
##########
@@ -22,6 +24,24 @@ pub enum Constraint {
     Unique(Vec<usize>),
 }
 
+impl Constraint {
+    /// Returns `true` if the constraint columns identify a row also when NULL
+    /// values are treated as equal, as when sorting: always for a primary key,
+    /// and for a unique key only if none of its columns is nullable in
+    /// `schema`. See [`FunctionalDependence::is_valid_across_nulls`].
+    pub fn is_valid_across_nulls(&self, schema: &Schema) -> bool {

Review Comment:
   Optional nit: To make this function more redable, perhaps we can rename it 
to `does_constraint_imply_unique_order_prefix` and add a comment with an 
example:
   
   ```
   Given UNIQUE(a, b), where both a and b are non-null, an existing sort prefix 
(a, b) uniquely identifies each row, making subsequent sort keys redundant.
   ```
   
   It might also help to clarify in the `Constraint` enum documentation that 
SQL UNIQUE constraints generally allow NULLs. For example, the rows (1, NULL) 
and (1, NULL) can coexist without violating UNIQUE(a, b).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to