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

Writing dates as parquet datetime types #288

Open
ptyrlik1 opened this issue May 9, 2023 · 5 comments
Open

Writing dates as parquet datetime types #288

ptyrlik1 opened this issue May 9, 2023 · 5 comments

Comments

@ptyrlik1
Copy link

ptyrlik1 commented May 9, 2023

I have a program that writes a list of objects of a specific type to parquet. The issue is when it is writing date properties to the parquet file they are saved as strings rather than a datetime type.

This is how I have my parser configured

using (var parser = new ChoParquetWriter(outSteam)
.Configure(c => c.Culture = CultureInfo.InvariantCulture)
.Configure(c => c.TypeConverterFormatSpec = new ChoTypeConverterFormatSpec { DateTimeFormat = "o" })

This is the definition of the property in the class

public DateTime? date_reported { get; set; }

And this is a example of what the date looks in the database I am reading from

2023-01-09 00:00:00.000

And this is how it is stores in the object
image

@Cinchoo
Copy link
Owner

Cinchoo commented May 10, 2023

Well, underlying parquet driver doesn't support datetime type, hence storing it as text.

@ptyrlik1
Copy link
Author

Is there a datetime like type that it does support such as datetimeoffset?

@Cinchoo
Copy link
Owner

Cinchoo commented May 12, 2023

yes, there is way to use datetimeoffset. let me add it. Will update.

@ptyrlik1
Copy link
Author

Did you push this update and if so how is it used?

@Cinchoo
Copy link
Owner

Cinchoo commented Sep 13, 2023

Yes, here is how you can control the output

                using (var w = new ChoParquetWriter(filePath)
                    .Configure(c => c.TreatDateTimeAsDateTimeOffset = true)
                    )
                {
                    w.Write(recs);
                }

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

No branches or pull requests

2 participants