@@ -53,18 +53,17 @@ use crate::extension::datetime::Time;
5353use crate :: extension:: datetime:: TimeUnit ;
5454use crate :: extension:: datetime:: Timestamp ;
5555
56- /// Canonical Arrow extension name for Parquet Variant — handled as `DType::Variant` rather
57- /// than going through the extension registry.
56+ /// Arrow's Parquet Variant extension name. We map it to `DType::Variant` directly,
57+ /// not through the extension registry.
5858pub const ARROW_EXT_NAME_VARIANT : & str = "arrow.parquet.variant" ;
5959
6060/// Trait for converting Arrow types to Vortex types.
6161pub trait FromArrowType < T > : Sized {
6262 /// Convert the Arrow type to a Vortex type.
6363 fn from_arrow ( value : T ) -> Self ;
6464
65- /// Convert the Arrow type to a Vortex type, consulting `session` for extension lookup.
66- ///
67- /// Unregistered or malformed extension metadata falls back to the storage dtype.
65+ /// Convert an Arrow type to a Vortex type, looking up extensions in `session`.
66+ /// Unregistered or malformed extensions fall back to the storage dtype.
6867 fn from_arrow_with_session ( value : T , session : & VortexSession ) -> Self {
6968 let _ = session;
7069 Self :: from_arrow ( value)
@@ -269,8 +268,9 @@ fn dtype_from_field(field: &Field, dtypes: &DTypeSession) -> DType {
269268 }
270269}
271270
272- /// Resolve the [`ExtDTypeRef`] for a Field whose `ARROW:extension:name` names a registered
273- /// Vortex extension. Returns `None` for missing/unregistered/malformed metadata.
271+ /// Look up the extension dtype for a Field's `ARROW:extension:name` against the session.
272+ /// Returns `None` (after logging a warning) if the extension is missing, unregistered,
273+ /// or has malformed metadata.
274274pub ( crate ) fn resolve_extension_dtype (
275275 field : & Field ,
276276 dtypes : & DTypeSession ,
@@ -315,8 +315,7 @@ pub(crate) fn resolve_extension_dtype(
315315 }
316316}
317317
318- /// Extensions base64-encode arbitrary binary metadata to survive Arrow's String-typed
319- /// metadata channel.
318+ /// Arrow's metadata channel is a `String`, so we base64-encode the raw extension bytes.
320319fn decode_extension_metadata ( field : & Field ) -> VortexResult < Vec < u8 > > {
321320 match field. extension_type_metadata ( ) {
322321 None | Some ( "" ) => Ok ( Vec :: new ( ) ) ,
@@ -326,8 +325,7 @@ fn decode_extension_metadata(field: &Field) -> VortexResult<Vec<u8>> {
326325 }
327326}
328327
329- /// Build the storage [`DType`] for `field`, recursing through nested children so each level
330- /// runs the extension lookup against `dtypes`.
328+ /// Build the storage [`DType`] for `field`, running the extension lookup at every nested level.
331329fn storage_dtype_from_field ( field : & Field , dtypes : & DTypeSession ) -> DType {
332330 let nullability: Nullability = field. is_nullable ( ) . into ( ) ;
333331 match field. data_type ( ) {
@@ -374,10 +372,10 @@ impl DType {
374372 Ok ( builder. finish ( ) )
375373 }
376374
377- /// Returns the Arrow [`DataType`] that best corresponds to this Vortex [`DType`].
375+ /// Returns the Arrow [`DataType`] for this Vortex [`DType`].
378376 ///
379- /// Extensions without a native Arrow mapping degrade to their storage `DataType`;
380- /// identity only survives via `Field` metadata (see [`Self::to_arrow_schema`]) .
377+ /// Extensions without a native Arrow mapping return only their storage `DataType`.
378+ /// Use [`Self::to_arrow_schema`] to keep the extension identity on the Field .
381379 pub fn to_arrow_dtype ( & self ) -> VortexResult < DataType > {
382380 arrow_dtype_from_dtype ( self )
383381 }
@@ -450,8 +448,7 @@ fn arrow_dtype_from_dtype(dtype: &DType) -> VortexResult<DataType> {
450448 if let Some ( native) = native_arrow_dtype_for_extension ( ext_dtype) {
451449 return Ok ( native) ;
452450 }
453- // Extension identity lives on the Field (see `field_from_dtype`), not on
454- // DataType, so here we only encode the storage type.
451+ // Extension identity lives on the Field, not the DataType — emit only storage here.
455452 arrow_dtype_from_dtype ( ext_dtype. storage_dtype ( ) ) ?
456453 }
457454 } )
@@ -473,8 +470,8 @@ fn field_from_dtype(name: &str, dtype: &DType) -> VortexResult<Field> {
473470 }
474471
475472 if let DType :: Extension ( ext) = dtype {
476- // Native Arrow mapping carries the semantics in DataType; emitting extension metadata
477- // on top would break consumers that only understand native Arrow types .
473+ // Temporal extensions map to native Arrow types — don't add extension metadata,
474+ // it would confuse Arrow- only consumers .
478475 if let Some ( native) = native_arrow_dtype_for_extension ( ext) {
479476 return Ok ( Field :: new ( name, native, dtype. is_nullable ( ) ) ) ;
480477 }
@@ -501,8 +498,8 @@ fn field_from_dtype(name: &str, dtype: &DType) -> VortexResult<Field> {
501498 ) )
502499}
503500
504- /// Returns the native Arrow [`DataType`] for extensions Arrow models directly (e.g. temporal).
505- /// `None` means the extension should round-trip via storage + Field metadata.
501+ /// The native Arrow [`DataType`] for extensions Arrow models directly (currently temporal),
502+ /// or `None` if the extension should round-trip via storage + Field metadata.
506503fn native_arrow_dtype_for_extension ( ext_dtype : & ExtDTypeRef ) -> Option < DataType > {
507504 let temporal = ext_dtype. metadata_opt :: < AnyTemporal > ( ) ?;
508505 Some ( match temporal {
0 commit comments