Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parquet_derive] support decoding Option<T> for ParquetRecordReader #6879

Open
andrew-rj opened this issue Dec 13, 2024 · 1 comment
Open
Labels
enhancement Any new improvement worthy of a entry in the changelog

Comments

@andrew-rj
Copy link

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I'm trying to have a single struct with optional fields that can be written and read as parquet. I want to have something like this:

#[derive(ParquetRecordWriter, ParquetRecordReader, Default)]
pub(crate) struct TabularIdentifier {
    id: u64,
    type: String,
    maybe_thing: Option<String>,
}

This however does not compile. I get a compiler error that looks like this:

error: proc-macro derive panicked
   --> src/bin/commands/generators/parquet/records.rs:146:31
    |
146 | #[derive(ParquetRecordWriter, ParquetRecordReader, Default)]
    |                               ^^^^^^^^^^^^^^^^^^^
    |
    = help: message: not implemented: Unsupported: Option(
                TypePath(
                    Type::Path {
                        qself: None,
                        path: Path {
                            leading_colon: None,
                            segments: [
                                PathSegment {
                                    ident: Ident {
                                        ident: "String",
                                        span: #0 bytes(90325..90331),
                                    },
                                    arguments: PathArguments::None,
                                },
                            ],
                        },
                    },
                ),
            )

Describe the solution you'd like
It would be really helpful to be able to encode and decode a single struct that has optional fields via parquet-derive.

Describe alternatives you've considered
An alternative might be a more manual process that reads out the parquet data and constructs the struct. That is a fair bit more manual than I would like.

@andrew-rj andrew-rj added the enhancement Any new improvement worthy of a entry in the changelog label Dec 13, 2024
@tustvold
Copy link
Contributor

tustvold commented Dec 14, 2024

FWIW the arrow APIs support this and more complex nesting, and will also be orders of magnitude faster. There are various options for converting structs to/from arrow, e.g. https://crates.io/crates/arrow_convert or https://crates.io/crates/serde_arrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

No branches or pull requests

2 participants