apache / apache/avro-rs

"type" in schema JSON objects should only be allowed to be a string.

Open
#531 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
130
Forks
62
Avg merge
11h
Merged PRs (30d)
45

Description

Hey all!

This implementation allows us to parse a schema of the form:

```
{
"type": {
....some correct schema here
}
}
```

for instance, in this implementation, we can parse

```
{
"type": {
"type": "enum",
"name": "testEnum",
"symbols": ["A","B","C"]
}
}
```
however, in the Java implementation this fails with:

```
No type: {"type":{"type":"enum","name":"testEnum","symbols":["A","B","C"]}}
```

From the [spec](https://avro.apache.org/docs/++version++/specification/) :

> A Schema is represented in [JSON](https://www.json.org/) by one of:
>
> - A JSON string, naming a defined type.
> - A JSON object, of the form:
>
>{"type": "typeName", ...attributes...}
>
>where typeName is either a primitive or derived type name, as defined below. Attributes not defined in this document are permitted as metadata, but must not affect the format of serialized data.
>
> - A JSON array, representing a union of embedded types.

which, in my reading, makes it clear that when we are inside a JSON object as a schema, "type" can only be a string that equals a type name.

What seems to be vague in the specification is if this type name should only be allowed to be a built-in type name or if user defined type names are allowed. My belief is that the rational option is to only allow built-in type names. I opened a [Jira issue](https://issues.apache.org/jira/browse/AVRO-4243) about this ambiguity in the spec.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no file, test, or parser entry point. Start by locating the Rust code that parses schema JSON objects and compare its handling of an object-valued "type" with the Java behavior and the linked specification. Done means the accepted forms match the agreed interpretation, with tests covering the reported nested schema and the chosen handling of built-in versus user-defined type names.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.