paleolimbot commented on code in PR #1116:
URL: https://github.com/apache/sedona-db/pull/1116#discussion_r3738717845
##########
rust/sedona-geoparquet/src/format.rs:
##########
@@ -391,7 +391,34 @@ impl FileFormat for GeoParquetFormat {
)
.unwrap();
source.options = self.options.clone();
- Arc::new(source)
+
+ // DataFusion 52 has an issue where field metadata (like
ARROW:extension:name)
+ // is stripped when evaluating embedded projections in ParquetOpener.
This is
+ // because the batch schema comes from the parquet reader (which
doesn't have
+ // extension metadata), and Column::return_field() looks up fields
from that schema.
+ // This isn't a bug in DataFusion because we're the ones that
advertised the table
+ // schema as having metadata'd expressions in the first place.
+ //
+ // We fix this by wrapping Column expressions with
MetadataPreservingColumn,
+ // which stores the correct field from the file schema and returns it
from
+ // return_field() regardless of the input schema.
+ let initial_projection =
source.projection().cloned().unwrap_or_else(|| {
+ let indices: Vec<usize> =
+
(0..source.table_schema().table_schema().fields().len()).collect();
+ ProjectionExprs::from_indices(&indices,
source.table_schema().table_schema())
+ });
+ let projection_with_types = wrap_columns_with_metadata_preserving(
+ initial_projection,
+ source.table_schema().table_schema(),
+ )
+ .map(|projection_with_types|
source.try_pushdown_projection(&projection_with_types));
+
+ // These are both failable but we can't fail here, so fall back to the
original
+ // source.
+ match projection_with_types {
+ Ok(Ok(Some(modified))) => modified,
+ _ => Arc::new(source),
Review Comment:
That's a great point...it's not expected to fail but I added a deferred
error mechanism to make sure we know if it does
--
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]