HyukjinKwon opened a new pull request, #244: URL: https://github.com/apache/spark-connect-rust/pull/244
### What changes were proposed in this pull request? [SPARK-61044](https://issues.apache.org/jira/browse/SPARK-61044): `rowsBetween` and `rangeBetween` now send their frame boundaries, and `Window` checks its columns, as PySpark Connect does. - A range frame sends the boundaries of its values as long literals, and a row frame as int literals, as PySpark's `WindowExpression` does. A boundary is no longer truncated to an int. - As PySpark's `rowsBetween` and `rangeBetween`, a `start` of `-sys.maxsize` or less is unbounded preceding, and an `end` of `sys.maxsize` or more unbounded following. A `start` of `Window.unboundedFollowing`, or an `end` of `Window.unboundedPreceding`, is a value. - A row frame raises `VALUE_NOT_BETWEEN` for a boundary out of the range of an int, and a frame of a float asserts an int. The client raises these when the frame is made; PySpark raises them when it sends the plan. - `Window.partitionBy` and `orderBy` raise `NOT_EXPECTED_TYPE` of the argument `col`, as PySpark's `F._to_col` does, for a column that is neither a Column nor a column name, such as a tuple. ### Why are the changes needed? The client sent each boundary as an int literal of its value truncated to an int. So `Window.orderBy("id").rangeBetween(-(1 << 40), 0)` was the frame of the current row only: `sum("id")` over it was `[0, 1, 2, 3]` rather than `[0, 1, 3, 6]`. These wrong results are the main fix. It also: - raised `TypeError`s for `rowsBetween(-sys.maxsize, sys.maxsize)` and for boundaries out of the range of an int - took `Window.unboundedFollowing` as a start, and `Window.unboundedPreceding` as an end, as unbounded - took a tuple of columns, and named the argument of its errors `cols` ### Does this PR introduce _any_ user-facing change? Yes. Window frames return the rows of PySpark 4.3.0, and these methods raise its errors. ### How was this patch tested? - A new live test checks the sums over range frames of boundaries out of the range of an int, and over unbounded frames, and the `VALUE_NOT_BETWEEN` of a row frame. It passes with official PySpark 4.3.0, and fails without this change. - A new offline test checks the frames and their errors, and the errors of the columns. - A new lib test checks the literals of the boundaries of row and range frames. - On a local server, 19 cases of window frames and columns behave as in official PySpark 4.3.0, and 5 frames have its reprs. - The lib tests of both crates (572 passed), the build of all tests, also with `wasm-udf`, the offline Python suites (1811 passed, 8 skipped), and the live drop-in and Arrow suites (109 passed) and live cases (10 passed) against a local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 This pull request and its description were written by Isaac. -- 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]
