dannycjones commented on issue #3770:
URL: https://github.com/apache/iceberg-rust/issues/3770#issuecomment-7198947166

   Thanks for opening this issue, @Gri-ffin. I think it would help to explain a 
bit more what's going on here - I think we can summarize it as our Iceberg 
implementation incorrectly interpreting the Parquet statistics which are not 
quite the same for maps and lists.
   
   I agree with the stance to take the same fix as Java for now. That means our 
output is no worse than the Java reference implementation, which I'm OK with. 
We can always explore adding better stats as an enhancement.
   
   Here's my rough understanding of the issue, since my Parquet knowledge is 
still a bit shallow. I've not found a good resource on the Parquet side that 
explains this well. (Maybe this: 
https://parquet.apache.org/docs/file-format/data-pages/)
   
   ---
   
   Parquet doesn't really have a concept of nested objects but rather defines 
things in terms of "definition level" and "repetition". This also influences 
the way it counts values and null values for its statistics.
   
   Imagine some column `tags: list<string>` has four rows:
   
   ```
   row 0: ["a", "b"]
   row 1: []
   row 2: null
   row 3: ["c", null]
   ```
   
   This nesting is actually described by the repetition level and definition 
level.
   
   - Repetition level marks row boundaries: 0 starts a new row, 1 adds another 
element to the current list.
   - Definition level says how far down the path from tags to the element is 
actually present. Here the maximum is 3:
     - 0: tags is null
     - 1: tags exists but the list is empty
     - 2: a list slot exists but the element is null
     - 3: a real value exists
   
   A reader rebuilds rows by scanning the column and starting a new row at 
every entry with repetition level 0. If `[]` or `null`, that row would have no 
entry, and the reader couldn't tell it was there. So every row writes at least 
one entry via the repetition and definition levels. For an empty or null list, 
that entry has no real value. Its definition level records to what level it 
should be defined: 1 for an empty list, 0 for a null list. That entry is what 
we're interpreting as the placeholder.
   
   | Record | Entries (Rep., Def., Value) | Real Elements |
   |--------|--------|--------|
   | `["a","b"]` | `(0, 3, "a"), (1, 3, "b")` | 2 |
   | `[]` | `(0, 1, –)` | 0 |
   | `null` | `(0, 0, –)` | 0 |
   | `["c", null]` | `(0, 3, "c"), (1, 2, –)` | 2 |


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to