Spec: Float sort order puts `-NaN` first but says it matches Java

オープン
#19,040 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@mbutrovich がすでに取り組んでいます。

2026年11月20日 から。

  • #19069 @mbutrovich による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
documentation

調査の方向性

Start with the floating-point sorting rule in format/spec.md and compare it with Java's Double.compareTo behavior described in the issue. Review the discussion and proposal in issue #2891 for prior concerns. Done means the spec clearly states that all NaN representations compare equal and sort after Infinity, while stored NaN bits remain unchanged.

索引モデルが issue の本文から書いたものです。

説明

bug
Apache Iceberg version

main (development)

Query engine

None

Please describe the bug 🐞

The sorting rule orders floats as -NaN < -Infinity < -value < -0 < 0 < value < Infinity < NaN and says this "aligns with the implementation of Java floating-point types comparisons." Java's Double.compareTo treats every NaN as equal and greater than +Infinity, so Java has no -NaN at the low end. The listed order is IEEE 754 totalOrder.

Implementations follow different halves of the sentence. Iceberg Java compares floats with Comparator.naturalOrder(), which is Double.compareTo. iceberg-rust uses total_cmp, which puts negative NaNs first and orders NaNs by payload.

Following totalOrder also makes a computed NaN's position depend on hardware. IEEE 754 doesn't specify the sign of a NaN result. For 0.0 / 0.0, x86 SSE returns 0xfff8000000000000 and AArch64 returns 0x7ff8000000000000, so the same expression sorts first on one writer and last on another. This matters most where position must be exact, such as the ordering keys in the secondary index spec (#16961), which cites this rule.

#2891 proposed removing -NaN and grouping all NaNs after Infinity. @RussellSpitzer supported it, but it was closed without a decision. The concern there was that requiring writers to canonicalize NaN is extra work and discards legitimate NaN bit patterns. #2891 also let NaN representations sort in an arbitrary order, which would leave different NaN bit patterns as distinct keys.

Could the rule say that all NaN representations compare equal and sort after Infinity? This matches Java and the sentence that already claims it does. It constrains only comparison, so stored values keep their bits and writers don't canonicalize.

Willingness to contribute
  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
主要言語
Java
スター
9.4k
フォーク
3.7k
平均マージ
2日 15時間
マージ済み PR(30日)
169

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/iceberg のほかの issue

apache/iceberg の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。