felixloesing opened a new pull request, #13747:
URL: https://github.com/apache/gluten/pull/13747

   ## What changes are proposed in this pull request?
   With `spark.gluten.sql.columnar.failOnFallback=true`, queries with scalar 
subqueries can fail even when everything would run natively.
   
   The problem is in `GlutenExplainUtils.visitFallbackNodes`, which the 
fallback reporter, the failOnFallback check and the SQL UI all use. It walks 
into AQE subqueries before AQE has finished planning them. At that point their 
columnar rules haven't run, so every operator inside still looks like a vanilla 
Spark node. Each one gets counted as a fallback, and the job is failed.
   
   This PR changes `visitFallbackNodes` to:
   - **Skip unfinished subqueries.** Only AQE subqueries whose plan is final 
are visited. The rest are checked later, when AQE prepares their stages, after 
the columnar rules have run.
   - **Follow reused subqueries.** For `ReusedSubqueryExec`, visit the subquery 
it points to.
   - **Ignore wrapper nodes**. `BaseSubqueryExec` nodes are no longer reported 
as fallback operators. Native Gluten plans are matched first, so they're still 
counted as native.
   - **Visit each node once.** A subquery reached through more than one path is 
only counted once.
   
   Real fallbacks inside subqueries are still caught.
   
   ## How was this patch tested?
   Added two tests to `GlutenFailOnFallbackSuite`:
   - `failOnFallback` allows supported AQE scalar subqueries: two queries with 
scalar subqueries, one in a filter and one in a projection, run with AQE and 
`failOnFallback` on. They return correct results without throwing, and the 
subquery plans contain native scan and aggregate operators.
   - `failOnFallback` still rejects fallbacks inside AQE scalar subqueries: 
blacklisting an expression that's only used inside the subquery (abs, coalesce) 
still throws a `GlutenException`. The message names the expression and doesn't 
list `Subquery:` wrapper nodes as fallbacks.
   
   ## Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code (Claude Opus 5.5)


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to