Skip to content

AVRO-3847: [Rust] Support default value of pre-defined name for Union type field - #2468

Merged
martin-g merged 1 commit into
apache:masterfrom
sarutak:complex-default-value
Aug 31, 2023
Merged

martin-g merged 1 commit into
apache:masterfrom
sarutak:complex-default-value

Conversation

@sarutak

@sarutak sarutak commented Aug 26, 2023 •

Copy link
Copy Markdown
Member

AVRO-3847

What is the purpose of the change

This PR fixes an issue that the current Rust binding doesn't support default value of pre-defined name for Union type field.

Given we have a schema like as follows.

{
    "name": "record1",
    "type": "record",
    "fields": [
        {
            "name": "f1",
            "type": {
                "name": "record2",
                "type": "record",
                "fields": [
                    {
                        "name": "f1_1",
                        "type": "int"
                    }
                ]
            }
        },  {
            "name": "f2",
            "type": ["record2", "int"],
            "default": {
                "f1_1": 100
            }
        }
    ]
}

The type of the field f2 is union of record2 and int, and the type of the default value is record2, which is pre-defined.
Current Rust binding doesn't accept such schemas, raising a error message like as follows.

Error: One union type Ref must match the `default`'s value type Map

The root cause is the resolution for the type of default value doesn't care about known schemas.
So, the fix is giving such schemas to the resolution.

Verifying this change

Added new tests.

Documentation

  • Does this pull request introduce a new feature? (no)

@github-actions github-actions Bot added the Rust label Aug 26, 2023
@martin-g
martin-g merged commit b9cbf9a into apache:master Aug 31, 2023
martin-g pushed a commit that referenced this pull request Aug 31, 2023
@martin-g

Copy link
Copy Markdown
Member

Thank you, @sarutak !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants