Skip to content

Spec: Clarify null_value_count applies to nullable fields - #17609

Closed
xndai wants to merge 3 commits into
apache:mainfrom
xndai:spec-null-value-count-effective-nullability
Closed

Spec: Clarify null_value_count applies to nullable fields#17609
xndai wants to merge 3 commits into
apache:mainfrom
xndai:spec-null-value-count-effective-nullability

Conversation

@xndai

@xndai xndai commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

null_value_count was documented as only used for optional fields, but a required field nested within an optional struct is null whenever an ancestor value is null. Add definition of nullability by the full path from root, scope the required-field contract to a present enclosing struct, and require readers to rely on null_value_count == 0 rather than the required flag.

null_value_count was documented as only used for optional fields, but a
required field nested within an optional struct is null whenever an
ancestor value is null. Define nullability by the full path from root,
scope the required-field contract to a present enclosing struct, and
require readers to rely on null_value_count == 0 rather than the
required flag.
@github-actions github-actions Bot added the Specification Issues that may introduce spec changes. label Aug 11, 2026
@CTTY

CTTY commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Linking the discussion thread: https://lists.apache.org/thread/93c86nsm4k4zz3yv86mxrjnzw1blogb0

Comment thread format/spec.md
| _optional_ | 3 | `tight_bounds` | `boolean` | all primitives except for `geometry` and `geography` | When true, `lower_bound` and `upper_bound` must be equal to the min and max values |
| _optional_ | 4 | `value_count` | `long` | all | Number of values in the column (including null and NaN values) |
| _optional_ | 5 | `null_value_count` | `long` | optional fields | Number of null values in the column |
| _optional_ | 5 | `null_value_count` | `long` | nullable fields | Number of null values in the column |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change from the current behavior of our statistics.

Right now, our null count matches what Parquet produces, which is a null count that is up to the number of values for the field. If a parent is null, it doesn't show up in the field-level count. It shows up in that the field has a different value count than the parent or the number of records in the data file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our null count matches what Parquet produces, which is a null count that is up to the number of values for the field. If a parent is null, it doesn't show up in the field-level count.

I thought this was a bug, and even created a PR for that (#17560). We do see cases where planner was misleaded and produced wrong results.

I will take a look at #17413 and discuss there.

@rdblue rdblue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on this change.

This is a breaking change that would invalidate existing statistics. It also introduces a new confusing but specific term, nullable, that is not needed.

I think we can work on clarifying how to detect nested struct fields, but this is an incorrect way to fix the problem.

@rdblue

rdblue commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@xndai, @CTTY, let's try to keep discussion in one place. Right now, this is being discussed and addressed primarily in #17413. That's not a great place to finish the work because this is a separate change, but we can at least keep the discussion there until we identify the changes we need to fix this issue.

@xndai xndai closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Specification Issues that may introduce spec changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants