-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
field [fieldName] is expected to be one of these: RECORD, NULL, for nested record with non defined nullable values #9
Comments
Hey @gadaldo, (using a default value) def 'should convert nested nullable records'() {
given:
def schema = '''
{
"type": "record",
"name": "Root",
"fields": [
{
"name": "field1",
"type": [
"long",
"null"
]
},
{
"name": "nestedRecord",
"type": [
{
"type": "record",
"namespace": "root",
"name": "NestedRecord",
"fields": [
{
"name": "nested1",
"type": [
"long",
"null"
]
},
{
"name": "nested2",
"type": [
"long",
"null"
], "default": 42
}
]
},
"null"
]
}
]
}
'''
def json = '''
{
"field1" : 10999859003,
"nestedRecord":
{
"nested1" : 123321321, "nested2":42
}
}
'''
when:
def result = converter.convertToJson(converter.convertToAvro(json.bytes, schema), schema)
then:
toMap(result) == toMap(json)
}```
**(using a provided value)**
```groovy
def 'should convert nested nullable records2'() {
given:
def schema = '''
{
"type": "record",
"name": "Root",
"fields": [
{
"name": "field1",
"type": [
"long",
"null"
]
},
{
"name": "nestedRecord",
"type": [
{
"type": "record",
"namespace": "root",
"name": "NestedRecord",
"fields": [
{
"name": "nested1",
"type": [
"long",
"null"
]
},
{
"name": "nested2",
"type": [
"long",
"null"
]
}
]
},
"null"
]
}
]
}
'''
def json = '''
{
"field1" : 10999859003,
"nestedRecord":
{
"nested1" : 123321321, "nested2":43
}
}
'''
when:
def result = converter.convertToJson(converter.convertToAvro(json.bytes, schema), schema)
then:
toMap(result) == toMap(json)
}``` |
At level 0 of the tree it does, the problem is just when the algorithm goes in recursion. |
is this issue got fixed? Please let me know how to resolve it |
I got:
Could not evaluate union, field [fieldName] is expected to be one of these: RECORD, NULL. If this is a complex type, check if offending field: trafficSource.adwordsClickInfo adheres to schema.
when I have nested records, where some of the 'nullable' fields are not specified.
schema sample:
and json string such as:
I think when it goes in recursion it is not able to skip missing values because for those missing value at level 0 it skips the missing values.
Thank you
The text was updated successfully, but these errors were encountered: