You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "Mark Farnan (Jira)" <ji...@apache.org> on 2022/12/30 12:54:00 UTC
[jira] [Comment Edited] (AVRO-3695) [Rust] Can't validate schema with value when Nullable union has multiple types.
[ https://issues.apache.org/jira/browse/AVRO-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17653123#comment-17653123 ]
Mark Farnan edited comment on AVRO-3695 at 12/30/22 12:53 PM:
--------------------------------------------------------------
On further review, this seems to be similar issue being looked at in https://issues.apache.org/jira/browse/AVRO-3646 ?
Though the PR for it dosn't seem to resolve these particular to_schema issues.
was (Author: markfarnan):
On further review, this seems to be similar issue (same even ?) being looked at in https://issues.apache.org/jira/browse/AVRO-3646 ?
> [Rust] Can't validate schema with value when Nullable union has multiple types.
> -------------------------------------------------------------------------------
>
> Key: AVRO-3695
> URL: https://issues.apache.org/jira/browse/AVRO-3695
> Project: Apache Avro
> Issue Type: Bug
> Components: rust
> Reporter: Mark Farnan
> Priority: Blocker
> Labels: pull-request-available, rust
> Time Spent: 10m
> Remaining Estimate: 0h
>
> If a union has more than one 'type' (other than null), to_avro_datum is unable to validate the schema with the value type, and throws a validation error.
>
> Schema:
>
> {code:java}
> { "type": "record", "namespace": "datatypes", "name": "nullunion", "fields": [ {"name": "item", "type": [ "null", "long", "double" ] } ] } {code}
>
> Struct: (This was generated by rsgen-avro)
> {code:java}
> /// Auto-generated type for unnamed Avro union variants.
> #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
> pub enum UnionLongDouble { Long(i64), Double(f64),}
> #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
> pub struct NullUnion { pub item: Option<UnionLongDouble>,}{code}
>
> {code:java}
> #[test]
> fn test_multivalue_union_tovalue() {
> let nuschema = r#"
> {
> "type": "record",
> "namespace": "datatypes",
> "name": "nullunion",
> "fields":
> [
> {"name": "item",
> "type": [
> "null",
> "long",
> "double"
> ]
> }
> ]
> }
> "#;
> let nullunion = NullUnion {
> item: Some(UnionLongDouble::Long(34)),
> }; let schema = Schema::parse_str(nuschema).unwrap();
> let nu_value = to_value(nullunion).unwrap();
> let nu_encoded = to_avro_datum(&schema, nu_value).unwrap();
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)