HyukjinKwon opened a new pull request, #894:
URL: https://github.com/apache/spark-connect-rust/pull/894
### What changes were proposed in this pull request?
`pyspark.sql.connect.proto` in the drop-in is its own protobuf runtime in
Rust, which does not require `protobuf`. This closes its documented differences
from upb, the implementation of a `protobuf` install that pyspark-client 4.3.0
uses, and those of the plugins' protoc-generated modules that import the protos
of Spark Connect (such as Delta Lake's Connect client). Where `protobuf` is
installed, as a plugin needs it, the runtime behaves as upb; without it, it is
unchanged.
- The runtime's classes are of upb's shape:
- a metaclass whose classes subclass `google.protobuf.message.Message`,
and protobuf's well-known-type mixins (`WKTBASES`);
- protobuf's descriptors of its default pool;
- upb's `TypeError` for a subclass;
- upb's `ScalarMapContainer` and `MessageMapContainer`;
- protobuf's `DecodeError` and `EncodeError`;
- protobuf's pickles: nested types through `_InternalConstructMessage`,
and `Any` and `Timestamp` byte-identical to upb's. Without protobuf, plain
names.
- protobuf's `message_factory`, `symbol_database` and builder give the
runtime's classes of the plugins' files. That holds for proto2 and editions
(presence, defaults, packing, closed enums, required fields, groups), the
well-known types, and modules of protoc before 3.20.
- A plugin's dependencies of its own non-empty package, and their importers,
are taken over (Delta Lake's `base.proto`); Google's and other packages' files
never are. A file that the runtime cannot hold (extension ranges) gives the
files that it imports back to protobuf.
- upb's limits and decoding:
- the 100-level depth limit, following `SetAllowOversizeProtos` and
pure-Python `SetRecursionLimit`;
- upb's decoding of corrupt input and the parse states that a failure
leaves;
- PySpark's error of a response that the client cannot decode ("Exception
deserializing response!"), through a `ClientCodec` of the proto crate that tags
the client's decode failures.
- Docstring-only `*_pb2.py` source files, so that pyright finds the sources
of the modules of messages, as with pyspark-client.
- The performance of copies, pickles, class attributes, imports and
protobuf's lookups is at or near the previous runtime's.
### Why are the changes needed?
To close these differences from PySpark (the known-differences review).
### Does this PR introduce _any_ user-facing change?
Yes: the messages above behave as upb's where protobuf is installed. What
remains is documented in `docs/compatibility.md` and
`dev/parity/known-differences.md`:
- protobuf extensions;
- one Python object per message;
- a few corner cases of the plugins' layouts and of a cloudpickled closure
over an unowned class.
The proto crate gains `ClientCodec` and its error tag.
### How was this patch tested?
- New tests in `python/tests/test_proto_rust_offline.py` (upb, pure-Python
mode and without protobuf), the core crates, and the e2e suites. Each round's
new tests fail without its change.
- Five rounds of an independent review that compared the drop-in with
PySpark 4.3.0 (upb) and with the previous runtime:
- probes of plugin layouts, pickles, depth and oversize limits, and
pure-Python mode;
- performance;
- about 90 million differential fuzz cases of the decoder, with no crash.
Every finding was fixed or documented.
- The core tests (release and debug), wasm, clippy, rustdoc, the stubs, the
offline suite under coverage, and the live e2e and ML e2e.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code
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]