* Removes redundant subqueries that don't add value. * A subquery is redundant if it only wraps another query without adding * WHERE, SELECT, GROUP BY, HAVING, ORDER BY, or LIMIT/OFFSET clauses. * * @param query - The QueryIR to process * @returns A new QueryIR with redundant subqueries removed
(query: QueryIR)
| 452 | * @returns A new QueryIR with redundant subqueries removed |
| 453 | */ |
| 454 | function removeRedundantSubqueries(query: QueryIR): QueryIR { |
| 455 | return { |
| 456 | ...query, |
| 457 | from: removeRedundantFromClause(query.from), |
| 458 | join: query.join?.map((joinClause) => ({ |
| 459 | ...joinClause, |
| 460 | from: removeRedundantJoinFromClause(joinClause.from), |
| 461 | })), |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Removes redundant subqueries from a FROM clause. |
no test coverage detected