HyukjinKwon opened a new pull request, #532:
URL: https://github.com/apache/spark-connect-rust/pull/532
### What changes were proposed in this pull request?
- `Catalog.createTable(..., **options)` now takes a bytes option as
PySpark's protobuf map of strings does: UTF-8 bytes are sent decoded, bytes
that are not UTF-8 raise protobuf's `ValueError`, and a bytearray or memoryview
raises its `TypeError`.
- `DataStreamReader.option` and the reader's format methods (`csv`, `json`,
`orc`, `parquet`, `text`, `xml`) now send a value as `str()` gives it, so a
bool is `"True"`/`"False"`, as PySpark's `DataStreamReader.option` does.
`options()` and `load()`, which lowercase a bool through `to_str` in PySpark,
are unchanged, as are the batch reader and writers and the stream writer.
### Why are the changes needed?
```python
spark.catalog.createTable("t", source="no_such_source", a=b"x")
# before: TypeError: b'x' has type <class 'bytes'>, but expected one of:
(<class 'bytes'>, <class 'str'>)
# PySpark 4.3.0: the request is sent (here the server answers
DATA_SOURCE_NOT_FOUND)
spark.readStream.option("a", True) # before {'a':
'true'}, PySpark {'a': 'True'}
spark.readStream.csv(p, header=True, inferSchema=False) # before
'true'/'false', PySpark 'True'/'False'
spark.readStream.options(a=True) # 'true' in both,
unchanged
```
The server reads both spellings of a built-in boolean option, but a custom
data source sees the text as sent. This is a follow-up of SPARK-61429 (#504).
### Does this PR introduce _any_ user-facing change?
Yes. `createTable` takes UTF-8 bytes options, and the stream reader's
`option` and format methods send a bool as `"True"`/`"False"`, both as PySpark
does.
### How was this patch tested?
- New offline tests in `python/tests/test_dropin_offline.py`,
`test_stream_reader_converts_bool_options_as_pyspark` and
`test_catalog_create_table_takes_bytes_options_as_protobuf_does`, which fail
without the fix. The existing
`test_stream_reader_checks_its_arguments_as_pyspark` now expects `"True"` for
`json(..., multiLine=True)`, as the reference gives.
- A new e2e test in `python/tests/test_dropin_e2e.py` runs a stream
`csv(header=True)` and a `createTable` with `compression=b"snappy"` against a
Spark 4.3.0 server.
- Probes of the reference client and this one give the same values and
errors.
- The offline suite (1837 passed), the e2e suite against Spark 4.3.0 (262
passed), the Rust library tests, the `--no-run` builds (with and without
`wasm-udf`), `cargo fmt --check`, `scripts/audit_no_stubs.sh` and the ruff
gates.
### 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]