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
3 changes: 3 additions & 0 deletions changelog.d/avro_date_time_millis_encoding.enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The Avro codec now supports encoding and decoding Date and TimeMillis values.

authors: omwbennett
12 changes: 3 additions & 9 deletions lib/codecs/src/decoding/format/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ impl From<&AvroDeserializerOptions> for AvroSerializerOptions {
pub struct AvroDeserializerOptions {
/// The Avro schema definition.
/// **Note**: The following [`apache_avro::types::Value`] variants are *not* supported:
/// * `Date`
/// * `Decimal`
/// * `Duration`
/// * `Fixed`
/// * `TimeMillis`
#[configurable(metadata(
docs::examples = r#"{ "type": "record", "name": "log", "fields": [{ "name": "message", "type": "string" }] }"#,
docs::additional_props_description = r#"Supports most avro data types, unsupported data types includes
["decimal", "duration", "local-timestamp-millis", "local-timestamp-micros"]"#,
["decimal", "duration", "fixed"]"#,
))]
pub schema: String,

Expand Down Expand Up @@ -190,9 +188,7 @@ pub fn try_from(value: AvroValue) -> vector_common::Result<VrlValue> {
}
AvroValue::Boolean(boolean) => Ok(VrlValue::from(boolean)),
AvroValue::Bytes(bytes) => Ok(VrlValue::from(bytes)),
AvroValue::Date(_) => Err(vector_common::Error::from(
"AvroValue::Date is not supported",
)),
AvroValue::Date(days) => Ok(VrlValue::from(days)),
AvroValue::Decimal(_) => Err(vector_common::Error::from(
"AvroValue::Decimal is not supported",
)),
Expand Down Expand Up @@ -220,9 +216,7 @@ pub fn try_from(value: AvroValue) -> vector_common::Result<VrlValue> {
.map(|v| VrlValue::Object(v.into_iter().collect())),
AvroValue::String(string) => Ok(VrlValue::from(string)),
AvroValue::TimeMicros(time_micros) => Ok(VrlValue::from(time_micros)),
AvroValue::TimeMillis(_) => Err(vector_common::Error::from(
"AvroValue::TimeMillis is not supported",
)),
AvroValue::TimeMillis(millis) => Ok(VrlValue::from(millis)),
AvroValue::TimestampMicros(ts_micros) => Ok(VrlValue::from(ts_micros)),
AvroValue::TimestampMillis(ts_millis) => Ok(VrlValue::from(ts_millis)),
AvroValue::Union(_, v) => try_from(*v),
Expand Down
Loading
Loading