You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While round tripping dictionary-encoded arrays in dictionary-encoded parquet files in arrow2, I have been unable to have pyarrow read all values from the dictionary page. This contrasts with (py)spark, that can read them.
Attached to this issue is a parquet file generated from rust's arrow2 whereby I read the IPC "generated_dictionary" file and write it into parquet (v1) with dictionary-encoding. I.e. 2 pages, one with the values, the other with the indices.
which is incorrect as the largest index (8) is larger than the len (5) of the values.
The indices are being read correctly, but not all values are. For clarity, the buffer in the dictionary page (PLAIN-encoded as per spec) on the attached parquet is:
and the reported number of values in the dict page header is 10. I would expect all values to be read directly to the dictionary.
We cannot discard the possibility that I am doing something wrong in writing. So far I was able to round-trip these within arrow2 and can read dict-encoded from both pyarrow and pyspark, which suggests that the arrow2 reader is correct.
Micah Kornfield / @emkornfield:
So what I believe is happening is someplace in the Arrow decoding path we make the assumption that dictionary values are unique and don't remap indices being read if they arent.
is the problematic line. It appears the documentation isn't too specific but what InsertMemoValues does appears to dedupe the values. So I think the two options are:
1. Make that method act more like a multimap.
2. Bypass that method and construct a dictionary array without deduping.
3. Recalculate indices when reading them in (likely has the biggest performance hit but likely lowest amount of downstream impact). I suppose we could also special case this if there are duplicates in the dictionary.
@wesm originally wrote this code I think, and I seem to recall there being some issues here so curious if he recalls any downstream issues of not-dedupping.
While round tripping dictionary-encoded arrays in dictionary-encoded parquet files in arrow2, I have been unable to have pyarrow read all values from the dictionary page. This contrasts with (py)spark, that can read them.
Attached to this issue is a parquet file generated from rust's arrow2 whereby I read the IPC "generated_dictionary" file and write it into parquet (v1) with dictionary-encoding. I.e. 2 pages, one with the values, the other with the indices.
The expected result for the column 0, "dict0" is
However, I have been unable to correctly read it from pyarrow. The result I get:
which is incorrect as the largest index (8) is larger than the len (5) of the values.
The indices are being read correctly, but not all values are. For clarity, the buffer in the dictionary page (PLAIN-encoded as per spec) on the attached parquet is:
and the reported number of values in the dict page header is 10. I would expect all values to be read directly to the dictionary.
We cannot discard the possibility that I am doing something wrong in writing. So far I was able to round-trip these within arrow2 and can read dict-encoded from both pyarrow and pyspark, which suggests that the arrow2 reader is correct.
Reporter: Jorge Leitão / @jorgecarleitao
Original Issue Attachments:
PRs and other links:
Note: This issue was originally created as ARROW-13487. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: