variant: Support Arrow UInt8/UInt16/UInt32 typed values#10417
Conversation
|
Hi @HuaHuaY! Arrow Variant closely follows the Parquet Variant spec - https://github.com/apache/parquet-format/blob/master/VariantEncoding.md The arrow primitive type mapping you've linked is following the table from the spec here - https://github.com/apache/parquet-format/blob/master/VariantEncoding.md#encoding-types - It's about unshredded Variant. The shredding spec here - https://github.com/apache/parquet-format/blob/master/VariantShredding.md#shredded-value-types - lists which Parquet types should be mapped to each Variant type for shredding.
Here Int* Variant types have to be represented by signed integers in Parquet -> we use signed int arrow arrays to store them. cc @klion26 |
Hi @sdf-jkl! As I understand it, the documentation you provided regarding "unshredded" and "shredded" variants refers to the mapping between variant primitive types and Parquet types. It does not address how Arrow's variant type maps to the Parquet variant. Notably, the Arrow documentation mentions unsigned integers, whereas the Parquet documentation does not. This PR is about unsigned integer types. This PR doesn't aim to directly store unsigned integers; rather, it's precisely to allow arrow-rs to store them as signed integers. |
|
@HuaHuaY you are correct! I was reading more into it and saw where I'm wrong.
This point I made was incorrect and the arrow spec indeed says: "A field named So the PR and the issue make sense given the spec, but I wonder if the spec itself should support I'll raise a question on the Arrow mailing list. |
|
@HuaHuaY I submitted an issue here apache/arrow#50622 |
Which issue does this PR close?
Closes #10416.
Rationale for this change
Arrow allows mapping Uint8/16/32 to Parquet types Int16/32/64. However, the current code does not support this.
Arrow's documentation: https://arrow.apache.org/docs/format/CanonicalExtensions.html#primitive-type-mappings
What changes are included in this PR?
UInt8,UInt16, andUInt32Arrow Varianttyped_valuefields.UInt32Arrow array to ParquetINT64writer coercionAre these changes tested?
Yes.
Are there any user-facing changes?
VariantArrayandshred_variantnow support canonicalUInt8/UInt16/UInt32typed_valuefields.ArrowWritercan also writeUInt32arrays toINT64columns when using a compatible custom Parquet schema. This is because it's not convenient to distinguish whether the column is in a variant within the context ofarrow_writer/mod.rs. I think this is a side effect of this PR; please point out any better suggestions.