·
15 commits
to main
since this release
The Apache Avro Rust SDK 0.22.0 release is a large release with lots of features, fixes and breaking changes. It is strongly recommended to read the Breaking changes and New features sections of the changelog.
What's changed
Breaking changes
- Resolve schema(ta) in the builder of
Writerby @Kriskras99 in #328- The builder now returns an
AvroResult
- The builder now returns an
- Rework schema compatibility by @Kriskras99 in #342
SchemaCompatiblity::can_readandSchemaCompatiblity::mutual_readnow return aCompatiblitytype
- Bump MSRV from 1.85 to 1.88 by @Kriskras99 in #342, #348
Schema::Durationnow has aFixedSchemaallowing access to attributes andSerializeandDeserializeis implemented forapache_avro::Durationby @jdarais in #382AvroSchemaandAvroSchemaComponentare no longer behind thederivefeature and have moved fromapache_avro::schema::derivetoapache_avro::serdeby @martin-g in #394 and @Kriskras99 in #433- Change the implementation of
AvroSchemaComponentforUuidfromSchema::Uuid(String)toSchema::Uuid(Fixed(name: "org.apache.avro.rust.Uuid", size: 16))and allow overwriting a field's schema with thewithattribute when using#[derive(AvroSchema)]by @Kriskras99 in #397, #558- When
#[avro(with)]is specified without an argument, it will call theget_schema_in_ctxt(&mut HashSet<Name>, NamespaceRef<'_>) -> Schemain the same module as specified by#[serde(with)] - When
#[avro(with = path::to::some_fn)]is specified with a path, the function it's pointing to will be called with two parameters&mut HashSet<Name>, NamespaceRef<'_> - When
#[avro(with = || {})]is specified with a closure, that closure is invoked - The name of the schema for
uuid::Uuidisorg.apache.avro.rust.uuid - The schema for
Uuidcan be changed back to aSchema::Uuid(String)using#[avro(with = || Schema::Uuid(UuidSchema::String))]on a field with aUuidand settinghuman_readabletotrue
- When
- Replace the
From<&str>implementations forNameandAliaswithTryFrom<&str>,TryFrom<String>, andFromStras the conversion is not fallible by @Kriskras99 in #423 - Rework
SpecificSingleObjectWriterremoving::with_capacityand changingwrite_avro_datum_refto also take a&NamesRefparameter by @Kriskras99 in #445 - Remove the
defaultfield fromFixedSchemaas it is not in the specification by @Kriskras99 in #460 AvroSchemaComponent::get_schema_in_ctxtnow takes a&mut HashSet<Name>parameter for thenamed_schemasparameter by @Kriskras99 in #471- Replace the
Schema::map{,_with_attributes}andSchema::array{,_with_attributes}with builders allowing the user to set more fields by @martin-g in #472- This also adds
Schema::r#enum,Schema::fixedandSchema::record
- This also adds
- Stricter schema parsing by @Kriskras99 in #479
- This now rejects schemas that were previously accepted by this library, they were already rejected by parsers in different languages
Alias::nameandAlias::namespacenow return references by @Kriskras99 in #486- Remove unused
orderandpositionfields inRecordFieldby @Kriskras99 in #491 - Rework
Nameto be more performant which requires changing theSchemaNameValidatortrait by @Kriskras99 in #493- The regex returned by
SchemaNameValidator::regexmust have a capture group namednamewhich captures the unqualified name when not overriding theSchemaNameValidator::validatefunction - The
SchemaNameValidator::validatemust now return the start byte of the unqualified name
- The regex returned by
- Support enums and tuples in
SchemaAwareSerializer, implementSchemaAwareDeserializerand document the mapping between the Serde and Avro data models by @Kriskras99 in #512, #558- The
SchemaAware*now have specific requirements for what input they accept, so type definitions might need to be modified to make them work with the new code (especially for enums and tuples) - This also makes
human_readableconfigurable per reader and writer instance - Array and Map serialisation will not write the block size in bytes unless configured to do so, allowing unbuffered serialisation
- The
AvroSchemaComponentimplementation forstd::time::Durationhas changed to match the (de)serialisation implementation as defined by Serde- It is now a
Schema::Record(name: "org.apache.avro.rust.Duration", fields: ["secs": "org.apache.avro.rust.u64", "nanos": "long"])
- It is now a
- The
AvroSchemaComponentimplementation forBigDecimalis now aSchema::Stringmatching the (de)serialisation implementation as defined by bigdecimal- It can be changed back to a
Schema::Stringusing#[serde(with = "apache_avro::serde::bigdecimal"), avro(with)]on a field with aBigDecimal
- It can be changed back to a
- The
SchemaAwareDeserializerdoes not support schema resolution, for that use the oldfrom_valueimplementation (see #575)
- The
New features
- Make
DeflateSettings::compression_levelpublic by @EmilyMatt in #335 - Support
fixedas a type foruuidby @Kriskras99 in #339 - Don't depend on Serde to provide fields in the right order by @Kriskras99 in #351
- It is still recommended to match the field order between the type and the schema as out-of-order serialisation incurs a performance penalty
- Support the
#[serde(flatten)]attribute by @Kriskras99 in #359, #448- This attribute is not supported when using
apache_avro::serde::to_value
- This attribute is not supported when using
- Use the Serde attributes and check for conflict with the Avro attributes by @Kriskras99 in #377
- This deprecates the Avro attributes for which the value must always match the Serde attribute:
- Container attributes:
#[avro(name = "..")]->#[serde(rename = "..")]#[avro(rename_all = "..")]->#[serde(rename_all = "..")]
- Variant attributes:
#[avro(rename = "..")]->#[serde(rename = "..")]
- Field attributes:
#[avro(alias = "..")]->#[serde(alias = "..")]#[avro(rename = "..")]->#[serde(rename = "..")]#[avro(skip)]->#[serde(skip)]
- Container attributes:
- On nightly compilers, using deprecated attributes will throw a compiler warning
- This deprecates the Avro attributes for which the value must always match the Serde attribute:
- Support the
#[serde(transparent)]attribute on structs by @Kriskras99 in #398 - Implement
AvroSchemaComponentforchar,u64,u128,i128,()by @Kriskras99 in #414, #486, #558char:Schema::Stringu64:Schema::Fixed(name: "org.apache.avro.rust.u64", size: 8)u128:Schema::Fixed(name: "org.apache.avro.rust.u128", size: 16)i128:Schema::Fixed(name: "org.apache.avro.rust.i128", size: 16)():Schema::Null
- Add
RecordSchemaBuilder::try_namewhich accepts anyTryInto<Name>and makeRecordFieldBuilder::nametake anyInto<String>by @martin-g in #429 - Move and rename the
serde_avro_*modules toapache_avro::serde::*, the old modules are still available but deprecated and will be removed in a future release by @Kriskras99 in #430apache_avro::serde_avro_bytes->apache_avro::serde::bytesapache_avro::serde_avro_bytes_opt->apache_avro::serde::bytes_optapache_avro::serde_avro_fixed->apache_avro::serde::fixedapache_avro::serde_avro_fixed_opt->apache_avro::serde::fixed_optapache_avro::serde_avro_slice->apache_avro::serde::sliceapache_avro::serde_avro_slice_opt->apache_avro::serde::slice_opt
- Add posibility to append values to writer without validating by @Kriskras99 in #447
- This renames
Writer::appendtoWriter::append_valuealthough the old function currently still exists and is deprecated - This adds
Writer::unvalidated_append_valueandWriter::unvalidated_append_value_refwhich skip the validation step
- This renames
- Rework the documentation by @Kriskras99 in #451
- The introduction to Avro itself was moved to the
documentation::primermodule - Using the crate the "Avro" way was moved to the
documentation::genericmodule - Using the crate the "Serde" way was moved to the
serdemodule - Calculating schema fingerprints was moved to the
Schema::fingerprintfunction - Custom name validators was moved to the
validatormodule - Custom schema equality was moved to the
schema_equalitymodule - Document
#[derive(AvroSchema)]in theserdemodule - Suggest the
booleantype when a schema contains a type namedboolthat does not resolve by @Kriskras99 in #459 - Add support for resetting a
Writerbacked by a clearable buffer by @Kriskras99 in #469 - Make
Schema::denormalizepublic by @Kriskras99 in #470 - Allow types implementing
AvroSchemaComponentto provide a default value by @Kriskras99 in #477 - Custom
Debugimplementations for*Schematypes hiding empty fields for more readability by @Kriskras99 in #488 - Add a builder for unions:
UnionSchemaBuilderby @Kriskras99 in #486 - Replace the
from_avro_datum*functions withGenericDatumReaderby @Kriskras99 in #496- The functions are still available, but are deprecated and will be removed in a future version
- Replace the
to_datum*functions withGenericDatumWriterby @Kriskras99 in #499- The functions are still available, but are deprecated and will be removed in a future version
- Support
#[serde(remote = "..")]by @Kriskras99 in #564 - Support deriving
AvroSchemaon enums and tuples by @Kriskras99 in #569- If some enum or tuple is not supported, and you think it should, please open an issue!
- Allow to supply own names when using
Value::resolveandValue::Validateby @Kriskras99 in #579
Fixes
- Choose correct schema when serializing an
Option<Enum>by @PookieBuns in #337 - Support deserialization of
BigDecimalfields when using "the Serde way" by @eft-prima in #338 - Don't write the
avro.codecattribute if the codec is Null by @Kriskras99 in #356 - Resolving a
Value::Longinto aValue::Intno longer truncates and returns an error instead by @Kriskras99 in #392 logicalTypeis no longer included in custom attributes by @jdarais in #395- Do not match types by name in the derive code by @Kriskras99 in #401
- Calculate the
RecordSchemalookup table onRecordSchemaBuilder::build()by @martin-g in #411 UnionSchema::newno longer accepts multiple schemas with the same name by @marting-g in #413- Support recursive types for
Schema::independent_canonical_formby @Kriskras99 in #420 - Select the first union variant with the correct byte length when serializing by @Kriskras99 in #421
- Use RAII for setting thread locals used during (de)serialisation so failure doesn't impact the next (de)serialisation by @martin-g in #432
- Ensure
SpecificSingleObjectWriterwrites header on every call by @flxo in #438 - Don't allow serializing
bytesas aUuid::Stringby @Kriskras99 in #441 - Don't allow resolving a schema that is already known by @martin-g in #444
- Don't silently truncate numbers larger than
i64::MAXwhen converting from JSON by @Kriskras99 in #450 - Fix links in rustdoc by @martin-g in #505
- Remove unused
CHANGELOG.mdby @martin-g in #541 - Support
BigDecimalinDeserializerwhenapache_avro::serde::bigdecimalis used by @jdarais in #543 - Return an error instead of panicking on invalid name, alias, or type reference by @youichi-uda in #547
- Accept JSON string defaults for decimal fields in unions by @valdo404 and @slavische in #580
- Don't allow negative object counts and don't allow negative block lengths by @MitNarodia in #586
- Bound decompression size to guard against decompression bombs by @iemejia in #582
- Bound the size of decoded
Value::MapandValue::Arrayto the max allocation size by @iemejia in #581 - Support enum inside an untagged enum by @Kriskras99 in #591
Internal changes
- Simplify reader tests by @Kriskras99 in #355
- Fix the
test_overflowtest to actually test for overflow by @Kriskras99 in #357 - Uncomment old test by @Kriskras99 in #362
- Enable the
stdfeature for Serde by @Kriskras99 in #364- This feature was already transitively enabled by dependencies on the
avrocrate but not when building only theavro_derivecrate
- This feature was already transitively enabled by dependencies on the
- Configure Clippy in the workspace instead of the CI by @Kriskras99 in #369
- Remove unnecessary mod in
avro_derive/tests/derive.rsby @Kriskras99 in #375 - Add CI check for license headers in all non-generated files by @martin-g in #387
- Debug print the error in
TestResultby @martin-g in #393 - Split
schema.rsin various modules by @martin-g in #405, #409, #410, #412, #415, #417 - Simplify
Deserializerby @Kriskras99 in #416 - Disable the test logger helper on wasm32 by @martin-g in #426
- Remove anyhow as a dev-dependency by @martin-g in #427
- Simplify
Serializerby @Kriskras99 in #428 - Restructure resolving logic by @Kriskras99 in #442
- Remove a benchmark for serde_json by @martin-g in #446
- Split
reader.rsinto various modules by @martin-g in #474, #475, #478 - Small code improvements by @Kriskras99 in #336, #486, #513, #559
- Refactor derive code by @Kriskras99 in #487, #560, #561
- Split
writer.rsinto various modules by @Kriskras99 in #497, #498 - Use macrotest to test the
AvroSchemaderive generated code by @Kriskras99 in #501 - Run tests on fewer targets by @Kriskras99 in #503
- Add CI step for
cargo docby @martin-g in #507 - Apply some suggestion from
-Dclippy::pedanticby @martin-g in #514 - Do not use Dependabot to update Github Actions by @martin-g in #525
- Enabling updating PR branches from Github UI by @martin-g in #527
- Optimize
Alias::new()andParser::fix_aliases_namespaceby @Kriskras99 in #557 - Fix clippy lints from Rust 1.90.1 by @martin-g in #330
- Fix CI setup by @Kriskras99 in #577
- Group
github/codeql-action/*updates by @Kriskras99 in #592 - Replace
dtolnay/rust-toolchainwith manualrustupcalls by @martin-g in #596
Dependency bumps
- Bump actions/cache from 5 to 6.1.0
- Bump actions/checkout from 5 to 7.0.0
- Bump actions/dependency-review-action from 4 to 5.0.0
- Bump actions/setup-java from 5.0.0 to 5.6.0
- Bump bigdecimal from 0.4.9 to 0.4.10
- Bump bon from 3.8.1 to 3.9.3
- Bump criterion from 0.7.0 to 0.8.2
- Bump darling from 0.21.3 to 0.23.0
- Bump digest from 0.11.2 to 0.11.3
- Bump env_logger from 0.11.8 to 0.11.11
- Bump github/codeql-action/* from 4.36.2 to 4.37.1
- Bump hex-literal from 1.0.0 to 1.1.0
- Bump liblzma from 0.4.5 to 0.4.7
- Bump log from 0.4.28 to 0.4.33
- Bump miniz_oxide from 0.8.9 to 0.9.1
- Bump num-bigint from 0.4.6 to 0.4.8
- Bump proc-macro2 from 1.0.103 to 1.0.107
- Bump proptest from 1.9.0 to 1.11.0
- Bump quote from 1.0.41 to 1.0.47
- Bump rand from 0.9.2 to 0.10.2
- Bump regex-lite from 0.1.8 to 0.1.9
- Bump rustversion from 1.0.22 to 1.0.23
- Bump serde from 1.0.228 to 1.0.229
- Bump serde_json from from 1.0.145 to 1.0.150
- Bump sha2 from 0.10.9 to 0.11.0
- Bump shogo82148/actions-setup-perl from 1 to 1.42.0
- Bump snap from 1.1.0 to 1.1.2
- Bump strum from 0.27.2 to 0.28.0 and replace strum-macros with
features = ["derive"]on strum by @Kriskras99 in #483 - Bump syn from 2.0.108 to 2.0.119
- Bump taiki-e/install-action from 2 to 2.84.0
- Bump thiserror from 2.0.17 to 2.0.19
- Bump trybuild from 1.0.114 to 1.0.118
- Bump uuid from 1.18.1 to 1.23.5
- Bump wasm-bindgen from 0.2.97 to 0.2.114
- Bump wasm-bindgen-test from 0.3.55 to 0.3.64
- Bump zizmorcore/zizmore-action from 0.5.7 to 0.6.0
- Replace ctor (v0.6.0) with linktime (v0.18.0)
- Pin cargo-rdme to 1.4.2 by @martin-g in #567
- This is because cargo-rdme 2 depends on specific nightly versions and therefore easily breaks in CI
New Contributors
- @Fokko made their first contribution in #280
- @timsaucer made their first contribution in #284
- @roofdiver made their first contribution in #293
- @EmilyMatt made their first contribution in #335
- @PookieBuns made their first contribution in #337
- @eft-prima made their first contribution in #338
- @flxo made their first contribution in #438
- @asf-gitbox-commits made their first contribution in #544
- @youichi-uda made their first contribution in #548
- @slavische made their first contribution in #580
- @MitNarodia made their first contribution in #586
- @iemejia made their first contribution in #582
Full Changelog: rel/release-0.20.0...rel/release-0.22.0