skyyyy955 commented on code in PR #11346:
URL: https://github.com/apache/paimon/pull/11346#discussion_r4662844527


##########
docs/docs/spark/sql-query.md:
##########
@@ -245,6 +245,31 @@ Scans below expressions using `input_file_name()`, 
`input_file_block_start()`, o
 `input_file_block_length()` are skipped: these functions need the source 
reader's
 task-local file context, which is not carried through a shuffle.
 
+### TopN on Older PyPaimon Snapshots
+
+Spark sorts `NaN` above all numeric values. In Spark 3.5.9, a descending
+`ORDER BY ... LIMIT` on a floating-point column can miss `NaN` if an older

Review Comment:
   Thanks for checking the current native writer. The updated section describes 
the finite file maximum as the trigger and calls out the native batch writer 
case with `pypaimon-rust` 0.5.0. Documentation CI passed. 
[Update](https://github.com/apache/paimon/pull/11346/commits/d9ec2ed97327724a407dc6bcffa58bce74615297)
 ยท [CI run](https://github.com/apache/paimon/actions/runs/45130893851)



##########
docs/docs/spark/sql-query.md:
##########
@@ -245,6 +245,31 @@ Scans below expressions using `input_file_name()`, 
`input_file_block_start()`, o
 `input_file_block_length()` are skipped: these functions need the source 
reader's
 task-local file context, which is not carried through a shuffle.
 
+### TopN on Older PyPaimon Snapshots
+
+Spark sorts `NaN` above all numeric values. In Spark 3.5.9, a descending
+`ORDER BY ... LIMIT` on a floating-point column can miss `NaN` if an older
+PyPaimon writer recorded a finite file maximum for a file containing `NaN`.
+The Paimon scan can skip that file based on its recorded maximum.
+
+For an affected snapshot, repartition the query input before sorting to keep
+TopN in Spark above the shuffle. Replace the table name and snapshot ID in
+this example with the ones you want to read.
+
+```sql
+CREATE OR REPLACE TEMP VIEW scores_for_sort AS
+SELECT /*+ REPARTITION(1) */ score

Review Comment:
   Thanks for checking the physical plan. I replaced the repartition hint with 
`ORDER BY isnan(score) DESC, score DESC LIMIT 1` and added an `EXPLAIN 
EXTENDED` check for `TakeOrderedAndProject` and the absence of `TopN:` on the 
Paimon scan. [Documentation 
CI](https://github.com/apache/paimon/actions/runs/45130893851) passed.



-- 
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]

Reply via email to