Skip to content

PARQUET-2249: Write IEEE 754 total order by default for floating-point columns - #3699

Open
Jiayi-Wang-db wants to merge 1 commit into
apache:masterfrom
Jiayi-Wang-db:ieee754-total-order-default
Open

PARQUET-2249: Write IEEE 754 total order by default for floating-point columns#3699
Jiayi-Wang-db wants to merge 1 commit into
apache:masterfrom
Jiayi-Wang-db:ieee754-total-order-default

Conversation

@Jiayi-Wang-db

Copy link
Copy Markdown
Contributor

Rationale for this change

Under the new writer behavior, a floating-point column containing NaN gets finite min/max computed over the non-NaN values, together with a nan_count. A reader that predates nan_count ignores it, accepts the finite bounds, and can incorrectly prune row groups that actually contain NaN. e.g. [1.0, NaN] is written as min = max = 1.0, so an old reader drops the row group for greater(x, 1.0) even though NaN matches.

By contrast, readers ignore statistics written under an unknown sort order. Writing IEEE_754_TOTAL_ORDER by default is therefore the safer, forward-compatible behavior: older readers simply decline to use the stats they can't interpret rather than misinterpreting them.

What changes are included in this PR?

FLOAT, DOUBLE and FLOAT16 columns built without an explicit column order now default to IEEE_754_TOTAL_ORDER

Are these changes tested?

yes

Are there any user-facing changes?

Yes. Floating-point columns are now written with IEEE_754_TOTAL_ORDER by default instead of TYPE_DEFINED_ORDER.

* the type-defined fallback.
*/
private boolean defaultsToIeee754TotalOrder(PrimitiveTypeName primitive) {
if (primitive != PrimitiveTypeName.FLOAT && primitive != PrimitiveTypeName.DOUBLE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this correct? FLOAT16 has FLBA primitive type which will be rejected here. Should we pass LogicalTypeAnnotation explicitly instead of calling getLogicalTypeAnnotation() so these logics are in a single place?

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.

Thanks for catching this. Refactored into a single static defaultColumnOrder(primitive, originalType, logicalTypeAnnotation) that recognizes FLOAT16 .

@Test
public void testSpecBuilderForFloat() {
PrimitiveType type = Types.required(FLOAT).named("test_float");
// NaN/+-0 read semantics are specific to type-defined order (float now defaults to IEEE 754).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are so many similar verbose comments. Should we just remove them? I believe it is clear when test cases have set explicit column orders.

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.

Removed.

@Jiayi-Wang-db
Jiayi-Wang-db force-pushed the ieee754-total-order-default branch from 9388a3e to 38f5429 Compare July 31, 2026 18:00
…t columns

Follow-up to apache#3393, which added IEEE_754_TOTAL_ORDER support but kept
TYPE_DEFINED_ORDER as the default for FLOAT, DOUBLE and FLOAT16 columns.

Keeping the type-defined order as the default is a latent backward-compat
hazard: the writer now computes finite min/max over the non-NaN subset and
records nan_count, but an old reader that predates nan_count ignores it,
accepts the finite bounds, and can incorrectly prune row groups that contain
NaN. Readers instead ignore statistics written under an unknown sort order, so
writing IEEE 754 total order by default is the safer behavior. See the
discussion on apache#3393.

This makes FLOAT, DOUBLE and FLOAT16 columns built without an explicit column
order default to IEEE_754_TOTAL_ORDER (mirroring how apache#3610 defaults INT96 to
INT96_TIMESTAMP_ORDER). Columns with a logical annotation that does not accept
IEEE 754 total order (e.g. an unknown annotation) fall back to type-defined
order so they remain constructible. The default-order selection is unified in
PrimitiveType.defaultColumnOrder so construction and text serialization agree.

To stay backward compatible on read, a footer that carries no column_orders
list predates IEEE_754_TOTAL_ORDER, so floating-point columns read from such a
footer are given type-defined order rather than inheriting the new
construction-time default; their legacy statistics are thus not reinterpreted
under IEEE 754 total order.

The text schema representation now carries a non-default column order
(columnorder(...) after the type/annotation) and MessageTypeParser parses it,
so a column order set explicitly survives toString()/parse round-trips such as
the one GroupWriteSupport performs. Columns left at their default emit no token,
keeping existing schema strings unchanged.

Tests that exercise the legacy type-defined NaN / +-0 semantics set
TYPE_DEFINED_ORDER explicitly, and new tests cover the default serialization,
the column-order-less read path, and the text round-trip.

Co-authored-by: Isaac
@Jiayi-Wang-db
Jiayi-Wang-db force-pushed the ieee754-total-order-default branch from 38f5429 to c8a7179 Compare July 31, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants