somandal opened a new pull request, #10635: URL: https://github.com/apache/pinot/pull/10635
This PR fixes an issue seen with certain types of window function queries using an empty `OVER()` clause. If the window function itself doesn't take any input columns (such as `COUNT(*)` or `ROW_NUMBER()`), the Apache Calcite rule `CoreRules.PROJECT_WINDOW_TRANSPOSE` creates an empty `LogicalProject` below the `LogicalWindow` and removes the `LogicalProject` above the window as it identifies the upper project as a trivial one. The following types of queries fail because of the above Apache Calcite bug: - `SELECT COUNT(*) OVER() from tableName` - `SELECT 42, COUNT(*) OVER() from tableName` - `SELECT ROW_NUMBER() OVER() from tableName` [the [PR](https://github.com/apache/pinot/pull/10587) to add support for this is still under review] The fix this PR adds does the following: - Within the `PinotWindowExchangeNodeInsertRule` we detect the empty `LogicalProject` below `LogicalWindow` for empty OVER() type of queries. - If found: - Add a LogicalProject with a literal below the LogicalWindow - Modify the LogicalWindow's inputs to include the literal - Add the LogicalExchange (as before) - Add a LogicalProject above the LogicalWindow to remove the literal - Else just create the exchange below LogicalWindow like we always did Discussed the above solution with @ankitsultana and @walterddr cc @siddharthteotia @vvivekiyer -- 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]
