aminghadersohi commented on PR #44604: URL: https://github.com/apache/superset/pull/44604#issuecomment-5838983281
Fixed the derived-table regression in `dbf7abc17072cdf4e18be24465d0a6bb06e05c0e`. **Approach:** SQL Server `TOP ... PERCENT`, `WITH TIES`, and nonliteral limits remain unchanged rather than being wrapped. This avoids introducing derived-table requirements for unique, named output columns—including unknown names behind `*`—without guessing schema or collation rules. These forms are still not treated as fixed row counts, and their original restrictions are never enlarged. Other dialects retain the outer-cap fallback. **Returned-row cap:** The unified executor previously called `fetch_data(cursor)` without a downstream cap, so simply skipping the wrapper was insufficient. The shared sync/async path now truncates the last statement's rows to the explicit request limit, bounded by `SQL_MAX_ROW`, before constructing the result set: [`superset/sql/execution/executor.py:274–287`](https://github.com/apache/superset/blob/dbf7abc17072cdf4e18be24465d0a6bb06e05c0e/superset/sql/execution/executor.py#L274-L287). No request limit leaves existing behavior unchanged; earlier statements are not truncated. **Validation:** Added failing regressions first for duplicate aliases, unnamed expressions, and joins with shared column names under both `PERCENT` and `WITH TIES`; also covered stars, case-variant aliases, nonliteral limits, and both limit methods. Real SQLite cursor tests verify downstream request/server caps, preservation of smaller results, and last-statement-only behavior independently of SQL rewriting. With pinned `sqlglot==30.18.0`, all 2,321 SQL executor/parser, MCP SQL Lab, and tool-inventory tests pass. Pre-commit passes on the touched files and all branch-changed files, including mypy. **Tradeoff:** This caps returned results, not database work or rows fetched. SQL Server `dry_run` preserves the original complex restriction. Both points are documented. No live SQL Server was started or tested. The PR remains draft. -- 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]
