andygrove commented on code in PR #10137:
URL: 
https://github.com/apache/arrow-datafusion/pull/10137#discussion_r1572580329


##########
datafusion/common/src/functional_dependencies.rs:
##########
@@ -68,11 +68,26 @@ impl Constraints {
         let constraints = constraints
             .iter()
             .map(|c: &TableConstraint| match c {
-                TableConstraint::Unique {
-                    columns,
-                    is_primary,
-                    ..
-                } => {
+                TableConstraint::Unique { columns, .. } => {
+                    let field_names = df_schema.field_names();
+                    // Get primary key and/or unique indices in the schema:
+                    let indices = columns
+                        .iter()
+                        .map(|pk| {
+                            let idx = field_names
+                                .iter()
+                                .position(|item| *item == pk.value)
+                                .ok_or_else(|| {
+                                    DataFusionError::Execution(
+                                        "Unique key doesn't exist".to_string(),

Review Comment:
   Can we include the field name in the error message to make it easier for the 
user to debug when they hit this error?



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

Reply via email to