Skip to content

Prevent Constructing Decoder for Incompatible Types #1276

@tustvold

Description

@tustvold

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

It is possible to call get_decoder with any T: DataType and a corresponding Encoding, even if that Encoding doesn't make sense for that type. For example

get_decoder::<Int32Type>(Encoding::DELTA_LENGTH_BYTE_ARRAY, ...)
get_decoder::<Int32Type>(Encoding::RLE, ...)
get_decoder::<FloatType>(Encoding::DELTA_BINARY_PACKED, ...)

These will error, or in some case panic, if an attempt is made to use them but it would be better to return an error on construction.

Describe the solution you'd like

Attempting to use an incompatible encoding with a given type should return an error on construction.

Additional context

An additional challenge with the current setup is that it makes the implicit assumption that a Decoder must be able to be created for all DataType even if it doesn't make sense for most types. This makes for some rather confusing code, and prevents decoders from adding constraints that may be true for all valid types, but not all types in general, (e.g. num::FromPrimitive).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelogparquetChanges to the parquet crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions