letian-jiang commented on PR #3086:
URL: https://github.com/apache/drill/pull/3086#issuecomment-6063267891
I've updated the parameterizer to preserve HAVING and QUALIFY expressions
whenever the SELECT expressions are preserved for grouping, ordering, or window
definitions. This keeps matching expressions consistent across clauses.
Eligible WHERE literals can still be rebound.
I don't think replanning the original SQL after a planning failure is a
reliable general fallback. Exception types alone cannot distinguish failures
introduced by dynamic parameters from errors in the original query. Also,
parameterization can produce incorrect results without throwing an exception.
For example, before this fix:
```sql
SELECT x + 1 AS k,
ROW_NUMBER() OVER (ORDER BY x + 1) AS rn
FROM (VALUES (1, 1), (1, 2), (2, 3)) AS t(x, v)
WHERE v > 0
QUALIFY x + 1 = 2
AND ROW_NUMBER() OVER (ORDER BY x + 1) = 1
ORDER BY x + 1;
```
With plan caching disabled, this returned one row: (k = 2, rn = 1). With
caching enabled, it returned zero rows without any exception, both on initial
planning and on a confirmed cache hit. An exception-triggered fallback would
not catch this regression.
--
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]