Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 81 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ aes,https://github.com/RustCrypto/block-ciphers,MIT OR Apache-2.0,RustCrypto Dev
aes-siv,https://github.com/RustCrypto/AEADs,Apache-2.0 OR MIT,RustCrypto Developers
ahash,https://github.com/tkaitchuck/ahash,MIT OR Apache-2.0,Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
aho-corasick,https://github.com/BurntSushi/aho-corasick,Unlicense OR MIT,Andrew Gallant <jamslam@gmail.com>
aliasable,https://github.com/avitex/rust-aliasable,MIT,avitex <avitex@wfxlabs.com>
alloc-no-stdlib,https://github.com/dropbox/rust-alloc-no-stdlib,BSD-3-Clause,Daniel Reiter Horn <danielrh@dropbox.com>
alloc-stdlib,https://github.com/dropbox/rust-alloc-no-stdlib,BSD-3-Clause,Daniel Reiter Horn <danielrh@dropbox.com>
allocator-api2,https://github.com/zakarumych/allocator-api2,MIT OR Apache-2.0,Zakarum <zaq.dev@icloud.com>
Expand Down Expand Up @@ -540,6 +541,8 @@ openssl-macros,https://github.com/sfackler/rust-openssl,MIT OR Apache-2.0,The op
openssl-probe,https://github.com/alexcrichton/openssl-probe,MIT OR Apache-2.0,Alex Crichton <alex@alexcrichton.com>
openssl-sys,https://github.com/rust-openssl/rust-openssl,MIT,"Alex Crichton <alex@alexcrichton.com>, Steven Fackler <sfackler@gmail.com>"
ordered-float,https://github.com/reem/rust-ordered-float,MIT,"Jonathan Reem <jonathan.reem@gmail.com>, Matt Brubeck <mbrubeck@limpet.net>"
ouroboros,https://github.com/someguynamedjosh/ouroboros,MIT OR Apache-2.0,Josh <someguynamedjosh@github.com>
ouroboros_macro,https://github.com/someguynamedjosh/ouroboros,MIT OR Apache-2.0,Josh <someguynamedjosh@github.com>
outref,https://github.com/Nugine/outref,MIT,The outref Authors
owo-colors,https://github.com/owo-colors/owo-colors,MIT,jam1garner <8260240+jam1garner@users.noreply.github.com>
p256,https://github.com/RustCrypto/elliptic-curves/tree/master/p256,Apache-2.0 OR MIT,RustCrypto Developers
Expand Down Expand Up @@ -592,6 +595,7 @@ proc-macro-error2,https://github.com/GnomedDev/proc-macro-error-2,MIT OR Apache-
proc-macro-hack,https://github.com/dtolnay/proc-macro-hack,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
proc-macro-nested,https://github.com/dtolnay/proc-macro-hack,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
proc-macro2,https://github.com/dtolnay/proc-macro2,MIT OR Apache-2.0,"David Tolnay <dtolnay@gmail.com>, Alex Crichton <alex@alexcrichton.com>"
proc-macro2-diagnostics,https://github.com/SergioBenitez/proc-macro2-diagnostics,MIT OR Apache-2.0,Sergio Benitez <sb@sergio.bz>
procfs,https://github.com/eminence/procfs,MIT OR Apache-2.0,Andrew Chin <achin@eminence32.net>
procfs-core,https://github.com/eminence/procfs,MIT OR Apache-2.0,Andrew Chin <achin@eminence32.net>
proptest,https://github.com/proptest-rs/proptest,MIT OR Apache-2.0,Jason Lingle
Expand Down Expand Up @@ -937,6 +941,7 @@ writeable,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Dev
wyz,https://github.com/myrrlyn/wyz,MIT,myrrlyn <self@myrrlyn.dev>
xmlparser,https://github.com/RazrFalcon/xmlparser,MIT OR Apache-2.0,Yevhenii Reizner <razrfalcon@gmail.com>
xxhash-rust,https://github.com/DoumanAsh/xxhash-rust,BSL-1.0,Douman <douman@gmx.se>
yansi,https://github.com/SergioBenitez/yansi,MIT OR Apache-2.0,Sergio Benitez <sb@sergio.bz>
yoke,https://github.com/unicode-org/icu4x,Unicode-3.0,Manish Goregaokar <manishsmail@gmail.com>
yoke-derive,https://github.com/unicode-org/icu4x,Unicode-3.0,Manish Goregaokar <manishsmail@gmail.com>
zerocopy,https://github.com/google/zerocopy,BSD-2-Clause OR Apache-2.0 OR MIT,Joshua Liebow-Feeser <joshlf@google.com>
Expand Down
2 changes: 1 addition & 1 deletion lib/codecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name = "generate-avro-fixtures"
path = "tests/bin/generate-avro-fixtures.rs"

[dependencies]
apache-avro = { version = "0.21.0", default-features = false }
apache-avro = { version = "0.22.0", default-features = false }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Document stricter Avro schema validation

With this version upgrade, schemas previously accepted by Vector but invalid under the Avro specification are rejected while building an Avro encoder or decoder, so affected configurations will fail to start after upgrading Vector. Because the change is user-observable and requires users to rewrite schemas such as the formerly accepted field-level array/map declarations, it needs a breaking changelog fragment rather than the proposed no-changelog treatment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omwbennett can you provide an example here? Trying to understand how big of a breaking change this is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I linked an old issue in the PR description, I've updated to link to the correct github issue + PR.

The core problem seems to be that avro-rs previously allowed defining complex types (e.g. array, enum etc.) directly in a field definition, when they should be inside a type block.
For example this was previously accepted by avro-rs:

{
  "type": "record",
  "name": "Test",
  "fields": [
    {"name": "enum_field", "type": "enum", "symbols": ["Spades", "Hearts", "Diamonds", "Clubs"]},
    {"name": "array_field", "type": "array", "items": "string"},
    {"name": "map_field", "type": "map", "values": "string"},
    {"name": "fixed_field", "type": "fixed", "size": 16}
  ]
}

but must now be:

{
  "type": "record",
  "name": "Test",
  "fields": [
    {"name": "enum_field", "type": {"type": "enum", "name": "Suit", "symbols": ["Spades", "Hearts", "Diamonds", "Clubs"]}},
    {"name": "array_field", "type": {"type": "array", "items": "string"}},
    {"name": "map_field", "type": {"type": "map", "values": "string"}},
    {"name": "fixed_field", "type": {"type": "fixed", "name": "FixedField", "size": 16}}
  ]
}

This brings it in line with the Python/Java SDKs, so it seems unlikely that users would be using these invalid schemas but I suppose it's still possible.

arrow = { version = "59.1.0", default-features = false, features = ["ipc", "json"], optional = true }
parquet = { version = "59.1.0", default-features = false, features = [
"arrow",
Expand Down
22 changes: 18 additions & 4 deletions lib/codecs/src/decoding/format/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ impl Deserializer for AvroDeserializer {
bytes
};

let value = apache_avro::from_avro_datum(&self.schema, &mut bytes.reader(), None)?;
let value = apache_avro::reader::datum::GenericDatumReader::builder(&self.schema)
.build()?
.read_value(&mut bytes.reader())?;

let apache_avro::types::Value::Record(fields) = value else {
return Err(vector_common::Error::from("Expected an avro Record"));
Expand Down Expand Up @@ -280,7 +282,11 @@ mod tests {
message: "hello from avro".to_owned(),
};
let record_value = apache_avro::to_value(event).unwrap();
let record_datum = apache_avro::to_avro_datum(&schema, record_value).unwrap();
let record_datum = apache_avro::writer::datum::GenericDatumWriter::builder(&schema)
.build()
.unwrap()
.write_value_to_vec(record_value)
.unwrap();
let record_bytes = Bytes::from(record_datum);

let deserializer = AvroDeserializer::new(schema, false);
Expand All @@ -303,7 +309,11 @@ mod tests {
message: "hello from avro".to_owned(),
};
let record_value = apache_avro::to_value(event).unwrap();
let record_datum = apache_avro::to_avro_datum(&schema, record_value).unwrap();
let record_datum = apache_avro::writer::datum::GenericDatumWriter::builder(&schema)
.build()
.unwrap()
.write_value_to_vec(record_value)
.unwrap();

let mut bytes = BytesMut::new();
bytes.extend([0, 0, 0, 0, 0]); // 0 prefix + 4 byte schema id
Expand Down Expand Up @@ -331,7 +341,11 @@ mod tests {
};
let value = apache_avro::to_value(event).unwrap();
// let value = value.resolve(&schema).unwrap();
let datum = apache_avro::to_avro_datum(&schema, value).unwrap();
let datum = apache_avro::writer::datum::GenericDatumWriter::builder(&schema)
.build()
.unwrap()
.write_value_to_vec(value)
.unwrap();

let mut bytes = BytesMut::new();
bytes.extend([0, 0, 0, 0, 0]); // 0 prefix + 4 byte schema id
Expand Down
4 changes: 3 additions & 1 deletion lib/codecs/src/encoding/format/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ impl Encoder<Event> for AvroSerializer {
let log = event.into_log();
let value = apache_avro::to_value(log)?;
let value = value.resolve(&self.schema)?;
let bytes = apache_avro::to_avro_datum(&self.schema, value)?;
let writer = apache_avro::writer::datum::GenericDatumWriter::builder(&self.schema)
.build()?;
let bytes = writer.write_value_to_vec(value)?;
buffer.put_slice(&bytes);
Ok(())
}
Expand Down
Loading
Loading