paleolimbot commented on code in PR #7481:
URL: https://github.com/apache/arrow-rs/pull/7481#discussion_r2078283292
##########
parquet/src/arrow/arrow_reader/mod.rs:
##########
@@ -506,37 +525,47 @@ impl ArrowReaderMetadata {
// parquet_to_arrow_field_levels is expected to throw an error if the
schemas have
// different lengths, but we check here to be safe.
if inferred_len != supplied_len {
- Err(arrow_err!(format!(
- "incompatible arrow schema, expected {} columns received {}",
+ return Err(arrow_err!(format!(
+ "Incompatible supplied Arrow schema: expected {} columns
received {}",
inferred_len, supplied_len
- )))
- } else {
- let diff_fields: Vec<_> = supplied_schema
- .fields()
- .iter()
- .zip(fields.iter())
- .filter_map(|(field1, field2)| {
- if field1 != field2 {
- Some(field1.name().clone())
- } else {
- None
- }
- })
- .collect();
+ )));
+ }
- if !diff_fields.is_empty() {
- Err(ParquetError::ArrowError(format!(
- "incompatible arrow schema, the following fields could not
be cast: [{}]",
- diff_fields.join(", ")
- )))
- } else {
- Ok(Self {
- metadata,
- schema: supplied_schema,
- fields: field_levels.levels.map(Arc::new),
- })
+ let mut errors = Vec::new();
Review Comment:
Hmm...this would mean that extension types can be cast implicitly to their
storage (or perhaps the opposite, depending on which field metadata takes
precedence). It is probably safer to fail, but not the end of the world because
those errors will show up later (an error matching a signature if the extension
metadata is dropped, or an error parsing bytes if unexpected content was given
an extension type by accident). A true "user defined type" solution for
DataFusion would be a place to handle this properly in some future
(`field_common(field_a, field_b) -> Field`, `field_cast(array, array_field,
common_field) -> ArrayRef`, or something).
--
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]