-
Notifications
You must be signed in to change notification settings - Fork 20
How do I write a BigDecimal value? #177
Comments
Yes, you are right. You would have to write physical types and assign DECIMAL logical type to it. And you are also right about having something that abstracts writes for those fields. It looks like it could be decimal, string, timestamp, date fields, etc. Not sure about adding this to column writer, but we definitely need something. Did you have any particular design in mind? |
What do you think of having BigDecimal support behind a feature flag? Then that could add a variant for a column writer? |
I think you mean Decimal. What Decimal support are you talking about? Decimal is not a Parquet type, and we have column writers for each one of those. You can write decimal values in three different ways. I will start working on record writer, this should solve most of your problems. |
I was talking about
this activates the BigDecimal crate dependency and turns on some modules in the diesel library. Something similar would allow parquet-rs users to get native bigdecimal support without forcing the dependency on all users. |
Fair enough. Sorry, I feel like I lost the context.
Does this answer your question(s)? |
Yes, this one: Having to translate the scale/precision seems like cutting the translation too early. Is it common to work with scale/precision directly? Are there many popular options for arbitrary precision values? Would you be open to transparent BigDecimal serialization/deserialization? |
I am loading numeric data from diesel with:
cast to a struct with
The current ColumnWriter does not include a easily compatible decimal type:
I think I found the decimal type definition here: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#decimal and it looks like it's up to the writer to move between i32/i64/fixed_len_byte_array/binary_array. Is that right? Should we have a ColumnWriter that picks the right type?
For now I'm just going to throw away precision and write a double but I want to come back and do this right 👍
but I see decimal support (read only) in #103 so maybe that work could be extended to be compatible with ColumnWriter?
The text was updated successfully, but these errors were encountered: