Please sign in to comment.
Fix zip join regression on SQL Server
The test fails since #1649 was merged but we didn’t notice because it went into the 3.1 branch which does not yet run on what were then the Slick Extensions drivers. This failure demonstrates that even with the new backend in 3.1 it is still hard to predict all possible results when it comes to comprehension fusion. The cause of the regression is not actually the new reordering from #1649 but the fix for `h2rownum` that was necessary as a result of it. The extra identity mapping prevented `reorderOperations` from pushing a `Subquery.BelowRownum` into a `SortBy` (because there is now an identity mapping in between the two) and then eliminating it entirely when it hits the `TableNode` below. This led to an unnecessary subquery, which would have gone unnoticed if Slick was better at propagating sort order through subqueries. There is an existing rewrite rule in `reorderOperations` to push aliasing mappings under subqueries that are not of type `AboveDistinct`. I added another exception for `BelowRowNumber` and a rule that does the opposite, i.e. push `Subquery.BelowRowNumber` into aliasing mappings just like we already push it into `SortBy` and `Filter`. Since the goal of these rules is to push it down so far that it eventually hits a `TableNode` (where it can be eliminated), this seems like the right direction to take.
- Loading branch information
Showing with 5 additions and 1 deletion.