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

Csv to Parquet - Nullable types #314

Open
MaxZ2033 opened this issue Apr 4, 2024 · 1 comment · May be fixed by #317
Open

Csv to Parquet - Nullable types #314

MaxZ2033 opened this issue Apr 4, 2024 · 1 comment · May be fixed by #317

Comments

@MaxZ2033
Copy link

MaxZ2033 commented Apr 4, 2024

Hello!

First off, great library and very useful for my use-case of converting csv to parquet files. Thanks for all the work you put into this!

I'm currently facing one problem though and hope you can help me out:

The primitives in my parquet files need to be Nullable. I registered this delegate:

c.MapParquetType = type =>
{
    return type switch
    {
        // Ensures that chars are converted to string before they are passed to Parquet.Net.
        // Parquet.Net does not support values of type 'char'.
        not null when type == typeof(char) => typeof(string),
        // The ParquetWriter cannot handle null values of primitives.
        // Null values get converted to their default value.
        not null when type == typeof(long) => typeof(long?),
        not null when type == typeof(double) => typeof(double?),
        _ => type
    };
};

This works as expected. The problem is, that type string is then assigned to these Nullable types:

else if (asRaw && type.IsNullableType())
return typeof(string);

Is there a specific reason for this choice, or is there another way to enable Nullables for the Parquet writer?

(A small change in the RecordWriter code fixes this issue for me. I'll gladly create a PR if this is considered a bug and not a design choice 😉)

Thanks for your time!

@Cinchoo
Copy link
Owner

Cinchoo commented Apr 22, 2024

Pls raise PR. will look into it. thx

@MaxZ2033 MaxZ2033 linked a pull request Apr 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants