You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@parquet.apache.org by "Jiayi-Wang-db (via GitHub)" <gi...@apache.org> on 2026/07/31 15:20:52 UTC

[PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Jiayi-Wang-db opened a new pull request, #3699:
URL: https://github.com/apache/parquet-java/pull/3699

   
   
   ### 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.
   
   <!-- Please uncomment the line below and replace ${GITHUB_ISSUE_ID} with the actual Github issue id. -->
   <!-- Closes #${GITHUB_ISSUE_ID} -->
   


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Jiayi-Wang-db (via GitHub)" <gi...@apache.org>.
Jiayi-Wang-db commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5177816662

   Could anyone help to merge this PR? Thanks!


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#discussion_r3691851732


##########
parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java:
##########
@@ -648,6 +662,20 @@ public PrimitiveType(
     this.columnOrder = requireValidColumnOrder(columnOrder);
   }
 
+  /**
+   * Whether a {@code FLOAT} or {@code DOUBLE} column with no explicit column order should default to
+   * IEEE 754 total order. This is skipped when a logical type annotation is present but does not
+   * accept IEEE 754 total order (e.g. an unknown annotation), so the type stays constructible with
+   * the type-defined fallback.
+   */
+  private boolean defaultsToIeee754TotalOrder(PrimitiveTypeName primitive) {
+    if (primitive != PrimitiveTypeName.FLOAT && primitive != PrimitiveTypeName.DOUBLE) {

Review Comment:
   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?



##########
parquet-column/src/test/java/org/apache/parquet/column/statistics/TestStatistics.java:
##########
@@ -775,7 +776,9 @@ private void testBuilder(PrimitiveType type, Object min, byte[] minBytes, Object
 
   @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).

Review Comment:
   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.



-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Jiayi-Wang-db (via GitHub)" <gi...@apache.org>.
Jiayi-Wang-db commented on code in PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#discussion_r3700189302


##########
parquet-column/src/main/java/org/apache/parquet/schema/MessageTypeParser.java:
##########
@@ -240,6 +246,26 @@ private static void addPrimitiveType(
     }
   }
 
+  private static ColumnOrder parseColumnOrder(String t, Tokenizer st) {
+    ColumnOrder.ColumnOrderName name;
+    try {
+      name = ColumnOrder.ColumnOrderName.valueOf(t.toUpperCase(Locale.ENGLISH));
+    } catch (IllegalArgumentException e) {
+      throw new IllegalArgumentException("Unknown column order: " + t + " at " + st.getLocationString(), e);
+    }
+    switch (name) {
+      case UNDEFINED:
+        return ColumnOrder.undefined();
+      case TYPE_DEFINED_ORDER:
+        return ColumnOrder.typeDefined();
+      case IEEE_754_TOTAL_ORDER:
+        return ColumnOrder.ieee754TotalOrder();
+      default:
+        throw new IllegalArgumentException(
+            "Unsupported column order: " + name + " at " + st.getLocationString());

Review Comment:
   Good point, I think it should be degraded to Undefined, and not throw explicit exception. Made the change.



-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5208464582

   Let's move this forward and let me cut another RC. Thanks everyone!


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Jiayi-Wang-db (via GitHub)" <gi...@apache.org>.
Jiayi-Wang-db commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5168232888

   > It looks good to me. There is however a potential follow up issue from codex:
   > 
   > > [P2] Keep mixed-version floating schemas mergeable
   > > PrimitiveType.java:661-667 makes new floating schemas default to IEEE_754_TOTAL_ORDER, while ParquetMetadataConverter.java:2064-2070 reads legacy footers as TYPE_DEFINED_ORDER. PrimitiveType.java:910-913 rejects those differing orders during strict schema union, and ParquetInputFormat.java:378-385 uses strict global-metadata merging for client-side split planning. Consequently, metadata aggregation over otherwise identical pre- and post-upgrade files can fail with IncompatibleSchemaModificationException. Please add a mixed-footer regression test and reconcile differing floating orders conservatively during aggregation, for example as UNDEFINED.
   
   
   Hi Gobor, thanks for flagging this. It makes sense to me that we should use the `UNDEFINED` column order in the merged schema when there is a conflict instead of throwing exception.
   AFAIK, when reading files, the reader ignores the column order in the merged schema and uses the column order from each file’s footer instead. So I don’t see any issue with changing it to `UNDEFINED`.
   cc @wgtmac @Fokko , I’d appreciate another pair of eyes on this.
   


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5187034273

   Just noticed that `PrimitiveType.union()` is also used by the deprecated `_metadata` writing APIs. Since `_metadata` is deprecated, I don't think this needs to block the PR.


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#discussion_r3700084749


##########
parquet-column/src/main/java/org/apache/parquet/schema/MessageTypeParser.java:
##########
@@ -240,6 +246,26 @@ private static void addPrimitiveType(
     }
   }
 
+  private static ColumnOrder parseColumnOrder(String t, Tokenizer st) {
+    ColumnOrder.ColumnOrderName name;
+    try {
+      name = ColumnOrder.ColumnOrderName.valueOf(t.toUpperCase(Locale.ENGLISH));
+    } catch (IllegalArgumentException e) {
+      throw new IllegalArgumentException("Unknown column order: " + t + " at " + st.getLocationString(), e);
+    }
+    switch (name) {
+      case UNDEFINED:
+        return ColumnOrder.undefined();
+      case TYPE_DEFINED_ORDER:
+        return ColumnOrder.typeDefined();
+      case IEEE_754_TOTAL_ORDER:
+        return ColumnOrder.ieee754TotalOrder();
+      default:
+        throw new IllegalArgumentException(
+            "Unsupported column order: " + name + " at " + st.getLocationString());

Review Comment:
   Should we throw here, or emit a null/unknown `ColumnOrder`?



-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "Jiayi-Wang-db (via GitHub)" <gi...@apache.org>.
Jiayi-Wang-db commented on code in PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#discussion_r3693133117


##########
parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java:
##########
@@ -648,6 +662,20 @@ public PrimitiveType(
     this.columnOrder = requireValidColumnOrder(columnOrder);
   }
 
+  /**
+   * Whether a {@code FLOAT} or {@code DOUBLE} column with no explicit column order should default to
+   * IEEE 754 total order. This is skipped when a logical type annotation is present but does not
+   * accept IEEE 754 total order (e.g. an unknown annotation), so the type stays constructible with
+   * the type-defined fallback.
+   */
+  private boolean defaultsToIeee754TotalOrder(PrimitiveTypeName primitive) {
+    if (primitive != PrimitiveTypeName.FLOAT && primitive != PrimitiveTypeName.DOUBLE) {

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



##########
parquet-column/src/test/java/org/apache/parquet/column/statistics/TestStatistics.java:
##########
@@ -775,7 +776,9 @@ private void testBuilder(PrimitiveType type, Object min, byte[] minBytes, Object
 
   @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).

Review Comment:
   Removed.



-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5159030290

   @Fokko @gszadovszky Do you want to take a look?


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] PARQUET-2249: Write IEEE 754 total order by default for floating-point columns [parquet-java]

Posted by "gszadovszky (via GitHub)" <gi...@apache.org>.
gszadovszky commented on PR #3699:
URL: https://github.com/apache/parquet-java/pull/3699#issuecomment-5164749458

   It looks good to me. There is however a potential follow up issue from codex:
   
   >[P2] Keep mixed-version floating schemas mergeable
   >
   >PrimitiveType.java:661-667 makes new floating schemas default to IEEE_754_TOTAL_ORDER, while ParquetMetadataConverter.java:2064-2070 reads legacy footers as TYPE_DEFINED_ORDER. PrimitiveType.java:910-913 rejects those differing orders during strict schema union, and ParquetInputFormat.java:378-385 uses strict global-metadata merging for client-side split planning. Consequently, metadata aggregation over otherwise identical pre- and post-upgrade files can fail with IncompatibleSchemaModificationException. Please add a mixed-footer regression test and reconcile differing floating orders conservatively during aggregation, for example as UNDEFINED.


-- 
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: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org