HyukjinKwon opened a new pull request, #192:
URL: https://github.com/apache/spark-connect-rust/pull/192

   ### What changes were proposed in this pull request?
   
   [SPARK-60948](https://issues.apache.org/jira/browse/SPARK-60948): Column 
reprs now follow the `Expression` reprs of PySpark Connect 4.3.0.
   
   | Expression | PySpark 4.3.0 and now | Before |
   | --- | --- | --- |
   | `F.col("id") + 1` | `+(id, 1)` | `(id + 1)` |
   | `-F.col("a")`, `~F.col("a")` | `negative(a)`, `not(a)` | `(- a)`, `(NOT 
a)` |
   | `F.col("a").between(1, 2)` | `and(>=(a, 1), <=(a, 2))` | `((a >= 1) and (a 
<= 2))` |
   | `F.countDistinct("a")` | `count(distinct a)` | `count(a)` |
   | `F.col("a").cast("int")`, `try_cast` | `CAST(a AS INT)`, `TRY_CAST(a AS 
INT)` | `CAST(a AS int)` for both |
   | `F.col("*")`, `F.col("t.*")` | `unresolvedstar()`, `unresolvedstar(t.*)` | 
`*`, `t.*` |
   | `F.col("a")[0]` | `a['0']` | `a[0]` |
   | `F.lit(True)`, `F.lit(b"xy")` | `True`, `b'xy'` | `true`, `[120, 121]` |
   | `F.lit(date(2020, 1, 2))` | `2020-01-02` | `18263` |
   | `F.lit(datetime(2020, 1, 2, 3, 4, 5))` | `2020-01-02 03:04:05.000000`, in 
the local time zone | microseconds since the epoch |
   | `F.lit(1e20)` | `1e+20`, Python's float repr | `100000000000000000000` |
   | a window function | `WindowExpression(sum(a), (WindowSpec(PartitionBy(g), 
OrderBy(o DESC NULLS LAST), WindowFrame(ROW_FRAME, -1, 1))))` | the Rust debug 
form |
   | `F.transform("a", lambda x: x + 1)` | `transform(a, LambdaFunction(+(x_0, 
1), x_0))` | the Rust debug form |
   
   Also:
   - a day-time interval literal renders as pandas' ISO duration, 
`P1DT0H0M2.000003S`;
   - a time literal renders as `01:02:00.000000`;
   - a regex column renders as `UnresolvedRegex(...)`, and a shuffle partition 
id as `DirectShufflePartitionID(child=...)`;
   - a user-defined function renders as its name and arguments;
   - `WindowSpec.__repr__` shows the partitioning, ordering and frame, as in 
PySpark, instead of `WindowSpec()`.
   
   The crate now depends on `chrono` directly, already in the lockfile through 
Arrow, for the local time of timestamp literals, as Python's 
`datetime.fromtimestamp` gives it. AGENTS.md now describes the render this way.
   
   ### Why are the changes needed?
   
   The repr differed for 50 of 77 common expressions. It also appears in error 
messages, such as `SparkSession.sql`'s for a keyword argument that is not a 
column reference. Window, lambda and UDF columns rendered the Rust debug form 
of the expression.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, Column reprs are those of PySpark Connect 4.3.0. Plans are unchanged.
   
   ### How was this patch tested?
   
   - A probe of 77 expressions gives the same reprs as official PySpark 4.3.0. 
One is left: a window ordered by a plain column renders `ASC NULLS LAST` here. 
That is a sort-order bug rather than a repr bug, which #191 (SPARK-60990) fixes.
   - A probe of 22 more expressions gives the same reprs in the UTC, 
`America/Los_Angeles` and `Asia/Seoul` time zones: timestamps, dates, bytes, 
special floats, decimals, window frames and specs, and casts to nested types. 
The exception is `timedelta` literals, which #189 (SPARK-60986) adds, and whose 
repr this change formats.
   - New offline tests check 30 reprs, also in a non-UTC time zone. They also 
pass with official PySpark 4.3.0.
   - The unit tests and the expression-sharing tests now pin the new reprs.
   - The lib tests and every integration test, e2e included, against a local 
Spark 4.3.0 server (647 passed), the build of all tests with `wasm-udf`, the 
offline Python suites (717 passed, 9 skipped), and the live drop-in and Arrow 
suites (70 passed) and live cases (10 passed). 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]

Reply via email to