Repository navigation
Fix for auto-categoricals in fastparquet - #2113
Conversation
|
Looks fine to me. This makes me curious what Parquet's metadata solution is. What kind of data can we put in there? Are there conventions that other projects have adopted? Is this in the metadata file or in each parquet file? |
|
There is key-value area of the global metadata for arbitrary information, and also key-value areas for each column chunk of each row group. All of this is stored in the global _metadata file, if using multiple files, and replicated to every data file (but on load we only read it once). |
|
I know I'm late to the party on weighing into names, but thoughts on using
the full name categories rather than cats?
…On Fri, Mar 24, 2017 at 8:48 AM, Martin Durant ***@***.***> wrote:
There is key-value area of the global metadata for arbitrary information,
and also key-value areas for each column chunk of each row group. All of
this is stored in the global _metadata file, if using multiple files, and
replicated to every data file (but on load we only read it once).
In this case, I make a key fastparquet.cats with a value of JSON encoded
{'catfield1': num_cats, ...}.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2113 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszMSBHmtPmrcuuWIFUDPapyuVMD3tks5ro7uLgaJpZM4Mln4l>
.
|
|
I don't mind, but this is not meant for public consumption, and "cats" is a frequent variable name for the same purpose in the code. Was there anything else you thought should be stored in a similar way? |
|
We call it cats internally, but we're putting this into data that other projects may be asked to understand. I think it is better to choose names that follow more standard conventions if possible. Short names should probably be discouraged. Ideally we would be able to find a name that other projects might say "oh hey, that is a good idea" and then choose to adopt on their own. Adding fastparquet to the name might preclude that. |
|
Perhaps ask on a Parquet mailing list? It might be wise to ask somewhere where the broader community can weigh in on the right conventions here. cc @wesm, presumably you have run into this problem. Thoughts? |
|
There aren't a lot of conventions I'm aware of surrounding the key-value metadata, but can definitely ask on the Parquet mailing list. I will say surrounding this that, semantically, dictionary-encoded data in Parquet is not the same as pandas.Categorical, so other systems in general will decode such data as though it were PLAIN encoded. Because of the RLE-encoding benefits of the dictionary encoding, most implementations have dictionary encoding turned on for all types and fail over to plain encoding mid-stream when the dictionaries exceed a certain size threshold. |
|
@wesm presumably Arrow will also have this problem, where you'll have to decide if you want to round-trip the fact that a column is categorical. Do you have any intention of propagating this through the parquet-cpp bindings? |
|
Yes, we will eventually need to store metadata to indicate when a particular Parquet logical type is used to represent more than one Arrow type (e.g. Arrow supports time as seconds through nanoseconds, but Parquet only has millis and micros). I figure as long as the stored data isn't "wrong", i.e. the decoded data on other platforms won't be misinterpreted, then it's okay. Since we recently augmented the date and time types in Arrow I suspect in the next month or two we'll address faithful roundtripping of all these types to Parquet. |
|
Do you have any intention of roundtripping the fact that a pandas column is a categorical to parquet? If so then do you want to establish a shared convention now? |
|
Note that we also want to keep track of how many labels in total the categorical can have, so that we need only assign an array of codes big enough to the values. |
|
Yep, pandas.Categorical becomes I created PARQUET-924 to capture this. There is also ARROW-462 which I need to implement in the next couple months |
|
After thinking a bit about this, we should move this discussion to the parquet ML or our bi-weekly hangouts. Off the top of my head I could think of the following possibilities:
Number 1 is the only option that would work well with old readers, 2+3 would produce files that cannot be read correctly by older implementations. As we might also want to support R's factor, we should not abuse the metadata but augment the actual format to support this. Currently old readers will benefit from neither implementation, so adding a backward-compatible format change should be the best option. |
|
The notes above are interesting - please let me know if this discussion has moved elsewhere. |
|
Per @xhochy's note, any discussions about the format will happen on the Parquet mailing list or in the biweekly syncs (with meeting notes sent to the ML), please feel free to join us. I'd like for dask to be able to use parquet-cpp+pyarrow for Parquet reads at some point, so it would be good to not have divergent semantics. |
+1 |
| (pd.DataFrame({'-': [3., 2., None]}), {}, {}), | ||
| (pd.DataFrame({'.': [3., 2., None]}), {}, {}), | ||
| # (pd.DataFrame({'.': [3., 2., None]}), {}, {}), | ||
| # period is not allowed in a field name |
There was a problem hiding this comment.
This is an accident of implementation in fastparquet and should be fixed.
|
+1 from me |
|
Sent a mail about this to the Parquet ML: https://lists.apache.org/thread.html/92dc0acdf237f0cfc2f6fea0101f7255b40d1a263ab0efcd15acd577@%3Cdev.parquet.apache.org%3E @martindurant didn't explicitly cc you as I haven't got an email address from you ;) |
See dask/fastparquet#112