vbarua commented on code in PR #12245:
URL: https://github.com/apache/datafusion/pull/12245#discussion_r1737501114


##########
datafusion/substrait/src/logical_plan/consumer.rs:
##########
@@ -850,6 +868,31 @@ pub async fn from_substrait_rel(
     }
 }
 
+/// Validates that the given Substrait schema matches the given DataFusion 
schema
+/// Returns true if the two schemas have the same qualified named fields with 
the same data types.
+/// Returns false otherwise.
+/// Ignores case when comparing field names
+///
+/// This code is equivalent to [DFSchema::equivalent_names_and_types] except 
that the field name
+/// checking is case-insensitive
+fn validate_substrait_schema(
+    datafusion_schema: &DFSchema,
+    substrait_schema: &DFSchema,
+) -> bool {
+    if datafusion_schema.fields().len() != substrait_schema.fields().len() {
+        return false;
+    }
+    let datafusion_fields = datafusion_schema.iter();
+    let substrait_fields = substrait_schema.iter();
+    datafusion_fields
+        .zip(substrait_fields)
+        .all(|((q1, f1), (q2, f2))| {
+            q1 == q2
+                && f1.name().to_lowercase() == f2.name().to_lowercase()

Review Comment:
   I wasn't sure what the actual requirements around case-sensitivity are in 
DataFusion. I've opted for a more permissive check here, but this could 
potentially be configurable.



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