* Returns the set of source aliases that are on the nullable side of outer joins. * * For a LEFT join the joined (right) side is nullable. * For a RIGHT join the main (left/from) side is nullable. * For a FULL join both sides are nullable. * * WHERE clauses that reference only a nullable sourc
(query: QueryIR)
| 327 | * incorrectly survive residual filtering. |
| 328 | */ |
| 329 | function getNullableJoinSources(query: QueryIR): Set<string> { |
| 330 | const nullable = new Set<string>() |
| 331 | if (query.join) { |
| 332 | const leftAliases = new Set( |
| 333 | getFromSources(query.from).map((source) => source.alias), |
| 334 | ) |
| 335 | for (const join of query.join) { |
| 336 | const joinedAlias = join.from.alias |
| 337 | if (join.type === `left` || join.type === `full`) { |
| 338 | nullable.add(joinedAlias) |
| 339 | } |
| 340 | if (join.type === `right` || join.type === `full`) { |
| 341 | for (const leftAlias of leftAliases) { |
| 342 | nullable.add(leftAlias) |
| 343 | } |
| 344 | } |
| 345 | leftAliases.add(joinedAlias) |
| 346 | } |
| 347 | } |
| 348 | return nullable |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Applies recursive predicate pushdown optimization. |
no test coverage detected