HyukjinKwon opened a new pull request, #225: URL: https://github.com/apache/spark-connect-rust/pull/225
### What changes were proposed in this pull request? [SPARK-60915](https://issues.apache.org/jira/browse/SPARK-60915): the Python client now sends the origins of DataFrame API calls, as PySpark Connect does, so that errors carry the DataFrame query contexts of PySpark. As PySpark's `_with_origin` and `with_origin_to_class`, `col()` and the `Column` methods give the expressions that they build an origin. It has the name of the function, such as `col` or `__add__`, and its call site in user code. The client sends it as the `python_origin` of the expressions' common fields. So does a column name that a DataFrame method takes, as PySpark's `F._to_col` makes it with `col()`. `spark.python.sql.dataFrameDebugging.enabled`, which PySpark reads once, turns this off when it is false. For an error in such an expression, the server reports a `DataFrameQueryContext` whose `fragment()` is the function and whose `callSite()` is the `file:line` of the user code. `repartitionById`, `sampleBy` and `unpivot` make their columns of column names with `col()`, as PySpark's `F._to_col` does. A column name of a UDF or UDTF call is a `ColumnReference` of it without an origin, as PySpark's `to_expr` makes it, rather than the column of `col()`. The client reads the configuration and the call site with `pyspark.errors.utils.is_debugging_enabled` and `_capture_call_site`, as PySpark's `_with_origin` does. The core expressions take the origin of the thread when they are made, as PySpark's `Expression.__init__` does. ### Why are the changes needed? Errors carried no DataFrame query context. In PySpark 4.3.0, `spark.range(1).select("no_such_col").collect()` and `select(F.col("nope") + 1)` raise errors whose `getQueryContext()` is a `DataFrameQueryContext` of `col` at the call site. An ANSI `F.lit(1) / F.lit(0)` reports `__truediv__`. The client returned none. ### Does this PR introduce _any_ user-facing change? Yes. Errors carry the DataFrame query contexts of PySpark 4.3.0. ### How was this patch tested? - A new live test checks the `DataFrameQueryContext` of each of these errors, with the call site in the test file, of `repartitionById`, `sampleBy` and `unpivot` by a name, and none for a UDF called with a name. It also passes with official PySpark 4.3.0, and fails without this change. - The offline tests read `spark.python.sql.dataFrameDebugging.enabled` once, without a session, before they run, so that a test whose session has no server does not wait to read it. - A new offline test checks, in new interpreters against a mock Connect server, the origins of the expressions of `F.col("a") + 1`, and none when DataFrame debugging is disabled. It fails without this change. The mock now serves Config `GetWithDefault` requests. - A new lib test checks the origins of core expressions. - The lib tests and every integration test, e2e included, against a local Spark 4.3.0 server (673 passed, and 129 of the transport crate), the build of all tests with `wasm-udf`, the offline Python suites (1788 passed, 8 skipped), and the live drop-in and Arrow suites (96 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]
