[Rust] Add Avro record format (avro feature) - #827
Conversation
3fe9eec to
59bfd0b
Compare
59bfd0b to
eba720d
Compare
| target/ | ||
| .cargo/ | ||
| # examples/avro is a non-workspace crate; its lockfile is not tracked. | ||
| examples/avro/Cargo.lock |
There was a problem hiding this comment.
It's a side effect of examples/avro being temporarily excluded from the workspace: the excluded crate builds its own lockfile that we don't track. It goes away once avro is ungated and the crate rejoins members (the root lock takes over). Added a comment explaining it.
There was a problem hiding this comment.
We actually probably shouldn't ever "ungate" Avro the same way we didn't "ungate" Arrow. The features flag isn't necessarily for gating a feature, but instead just lets users not pull in parts of the binary they are not interested in. Ideally we would have done this for more parts of the SDK.
c7b7826 to
9df57f6
Compare
| # Excluded: as a member it would force the sdk `avro` feature across the workspace | ||
| # and break ffi/jni. Build it standalone with `cargo build` inside examples/avro. | ||
| exclude = ["examples/avro"] | ||
| resolver = "2" |
There was a problem hiding this comment.
How do we resolve this problem for other features?
There was a problem hiding this comment.
I clarified the comment.
- The avro feature is permanent (never ungated) - it just lets users who don't need Avro skip apache-avro and its Rust 1.85 floor.
- The workspace exclusion (and this untracked lockfile) is the genuinely temporary part. ffi/jni currently build the sdk without avro and match
EncodedRecord/EncodedBatchexhaustively, so makingexamples/avroa member would unifyavroonto them and break those matches (EncodedRecord::Avro(_)not covered).
It goes away when ffi/jni gain Avro support (#830): they'll enable avro on the sdk dependency just like they already do for arrow-flight, add the match arms, and examples/avro rejoins members - at which point this lockfile is tracked like any other.
9df57f6 to
8ecc3b6
Compare
teodordelibasic-db
left a comment
There was a problem hiding this comment.
Not sure if this is planned for a future PR, but cargo test --workspace and make lint (clippy --all) use default features. Every Avro unit test is #[cfg(feature = "avro")]. rust/tests/Cargo.toml enables arrow-flight but not avro. examples/avro is excluded from the workspace, so it has no CI step either. The green checks do not compile this feature.
629fe96 to
b3f71e4
Compare
b3f71e4 to
dc78f50
Compare
teodordelibasic-db
left a comment
There was a problem hiding this comment.
StreamConfigurationOptions.record_type still lists Proto/Json/Unspecified only.
teodordelibasic-db
left a comment
There was a problem hiding this comment.
Let's also fix ingest_record / ingest_records in multiplexed_stream.rs as they still take Into<EncodedRecord>.
pub async fn ingest_record(
&self,
payload: impl Into<PreparedInput>,
) -> ZerobusResult<MessageId> {
self.check_closed()?;
let idx = self.pick_substream();
let stream = &self.streams[idx];
let encoded_batch = stream.prepare_record(payload)?;
self.enqueue_reserved(stream, idx, encoded_batch).await
}dc78f50 to
f7363a9
Compare
f7363a9 to
ad00f87
Compare
teodordelibasic-db
left a comment
There was a problem hiding this comment.
LGTM once the remaining three comments are addressed and we double check CI. We should also probably not link internal Google Docs in the PR description, but no harm done I guess. Feel free to ping for reapproval.
ad00f87 to
da1e5d9
Compare
|
I've rebased onto main and removed my step from the CI job. The avro tests are running as part of the CI since you've added the |
da1e5d9 to
1ca178c
Compare
1ca178c to
41d38b9
Compare
Signed-off-by: Irina Tomic <irina.tomic@databricks.com>
Signed-off-by: Irina Tomic <irina.tomic@databricks.com>
41d38b9 to
7e0e733
Compare
PR stack
What changes are proposed in this pull request?
Adds the Avro record format to the Rust SDK, behind the off-by-default
avrofeature (Beta). Ephemeral streams only; server support is pending. Default builds are unchanged.Declare the writer schema at stream creation with
.avro(schema_json), then ingest either a record object the stream encodes against the schema (AvroRecord(AvroValue)) or a pre-encoded datum (AvroBytes) — both via the existingingest_record_offset/ingest_records_offset.AvroValueisapache_avro::types::Value(re-exported); it can represent every Avro type, so the record path is exhaustive.Implementation notes:
apache-avrois an optional dep, pulled only by theavrofeature. It requires Rust 1.85; default builds are unaffected.impl Into<PreparedInput>(a#[doc(hidden)]payload type). A blanketFrom<T: Into<EncodedRecord>>keeps every existing caller unchanged;AvroRecordcarries an un-encodedAvroValue.build()and stored inTablePropertiesnext to the JSON wire form, so it's reused on ingest and survives stream recovery.--features avrosteps inci-rust.yml(the default--workspace/make lintruns don't touch it).How is this tested?