flavray / avro-rs

Avro client library implementation in Rust
MIT License
169 stars 95 forks source link

Resolution of logical types in Unions #175

Closed zyxw59 closed 3 years ago

zyxw59 commented 3 years ago

The following resolves:

    let schema_json = r#"{"type": "long", "logicalType": "timestamp-millis"}"#;
    let schema = Schema::parse_str(&schema_json)?;
    let value = Value::Long(1611598212212);
    let resolved = value.resolve(&schema)?; // Value::TimestampMillis(1611598212212)

But this doesn't:

    let schema_json = r#"["null", {"type": "long", "logicalType": "timestamp-millis"}]"#;
    let schema = Schema::parse_str(&schema_json)?;
    let value = Value::Long(1611598212212);
    let resolved = value.resolve(&schema)?; // Error::FindUnionVariant

To my understanding, I think the second one should also resolve to Value::Union(Value::TimestampMillis(1611598212212))