LuciferYang opened a new pull request, #11425:
URL: https://github.com/apache/paimon/pull/11425

   ### Purpose
   
   Fixes #11424.
   
   On Spark 4.3, `MergePaimonScalarSubqueries` runs before Spark's 
`MergeSubplans` on every query, including ones that read no Paimon table. It is 
an old copy of Spark's rule without its later fixes: it returns a wrong sum for 
a CSV read, throws on some nested-subquery, struct and CTE queries, and the 
`WithCTE` it adds makes `MergeSubplans` skip the query.
   
   Spark 4.3 merges DSv2 scans itself for tables that declare 
`TableCapability.SCAN_MERGING` (SPARK-40259). On 4.3 only, this PR uses the 
no-op rule from paimon-spark-common, and `PaimonScanMerging` declares 
`SCAN_MERGING` for a `FileStoreTable` unless its options enable query auth. 
With query auth, the catalog's row filters can depend on the columns read.
   
   4.3 then no longer merges subqueries that read different columns of a 
query-auth table or the same pruned struct field. On Spark 3.3 to 4.2 the old 
rule still merges query-auth tables; that needs a separate fix.
   
   ### Tests
   
   `Spark43ScanMergingTest` in the 4.3 module:
   
   - Paimon subqueries that read different columns become one scan, on an 
append table, on a primary-key table with deletion vectors, and when only one 
side has a data filter. The two writes in that last case have disjoint ranges, 
so a pushed filter would change the sum.
   - A partition filter on one side only keeps two scans. A merged scan keeps 
the bucket filter both sides push.
   - Non-Paimon subqueries with different filters become one scan, the CSV 
reads stay apart, and the nested-subquery, struct and CTE queries return the 
right rows.
   - Data tables declare `SCAN_MERGING`; three system tables and query-auth 
tables do not.
   


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