-
Notifications
You must be signed in to change notification settings - Fork 3k
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
tests(datahub-client): new tests for the AvroSchemaConverter #12087
base: master
Are you sure you want to change the base?
tests(datahub-client): new tests for the AvroSchemaConverter #12087
Conversation
assertSchemaField( | ||
schema.getFields().get(1), | ||
"[version=2.0].[type=MapType].[type=map].[type=ComplexType].mapOfComplexType", | ||
"ComplexType", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should native type be map<string,ComplexType>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense
assertSchemaField( | ||
schema.getFields().get(4), | ||
"[version=2.0].[type=MapType].[type=map].[type=union].mapOfNullableString", | ||
"union", | ||
false, | ||
false, | ||
new SchemaFieldDataType() | ||
.setType( | ||
SchemaFieldDataType.Type.create( | ||
new MapType().setKeyType("string").setValueType("union")))); | ||
assertSchemaField( | ||
schema.getFields().get(5), | ||
"[version=2.0].[type=MapType].[type=map].[type=union].[type=string].mapOfNullableString", | ||
"string", | ||
false, | ||
false, | ||
new SchemaFieldDataType().setType(SchemaFieldDataType.Type.create(new StringType()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avro schema
{
"name": "mapOfNullableString",
"type": {
"type": "map",
"values": ["null", "string"]
}
},
the native type is union
, no reference to map
expectedNullable
for the value is false
instead of true
it's a union
but only one tested field 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it should be nullable, and native type maybe should be union<null, string>
assertSchemaField( | ||
schema.getFields().get(10), | ||
"[version=2.0].[type=MapType].[type=map].[type=array].mapOfArray", | ||
"array(string)", | ||
false, | ||
false, | ||
new SchemaFieldDataType() | ||
.setType( | ||
SchemaFieldDataType.Type.create( | ||
new ArrayType().setNestedType(new StringArray("string"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avro schema
{
"name": "mapOfArray",
"type": {
"type": "map",
"values": {
"type": "array",
"items": "string"
}
}
},
native type should be map of string array
and the schemafielddatatype is also missing references to MapType
new SchemaFieldDataType()
.setType(
SchemaFieldDataType.Type.create(
new MapType().setKeyType("string").setValueType(<XXXX>))));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I think you are right
assertSchemaField( | ||
schema.getFields().get(11), | ||
"[version=2.0].[type=MapType].[type=map].[type=map].mapOfMap", | ||
"map<string,int>", | ||
false, | ||
false, | ||
new SchemaFieldDataType() | ||
.setType( | ||
SchemaFieldDataType.Type.create( | ||
new MapType().setKeyType("string").setValueType("int")))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avro schema
{
"name": "mapOfMap",
"type": {
"type": "map",
"values": {
"type": "map",
"values": "int"
}
}
},
map of <string, int> !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right
assertSchemaField( | ||
schema.getFields().get(9), | ||
"[version=2.0].[type=StructType].[type=ComplexStruct].structField.[type=union].fieldUnion", | ||
"union", | ||
true, | ||
false, | ||
new SchemaFieldDataType() | ||
.setType( | ||
SchemaFieldDataType.Type.create( | ||
new UnionType().setNestedTypes(new StringArray("union"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering this comes from
{
"name": "fieldUnion",
"type": [
"null",
"string",
"int"
]
},
I would expect something like
assertSchemaField( | |
schema.getFields().get(9), | |
"[version=2.0].[type=StructType].[type=ComplexStruct].structField.[type=union].fieldUnion", | |
"union", | |
true, | |
false, | |
new SchemaFieldDataType() | |
.setType( | |
SchemaFieldDataType.Type.create( | |
new UnionType().setNestedTypes(new StringArray("union"))))); | |
assertSchemaField( | |
schema.getFields().get(9), | |
"[version=2.0].[type=StructType].[type=ComplexStruct].structField.[type=union].fieldUnion", | |
"union<string, int>", | |
true, | |
false, | |
new SchemaFieldDataType() | |
.setType( | |
SchemaFieldDataType.Type.create( | |
new UnionType().setNestedTypes(new StringArray("string", "int"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be union<null, string, int>
as native type as it is nullable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 508 is about nullable flag
but yes, union<null, string, int>
would also look good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but I feel like in Avro this is the actual native type
assertSchemaField( | ||
schema.getFields().get(18), | ||
"[version=2.0].[type=users_record].[type=map].[type=int].props", | ||
"int", | ||
true, | ||
false, | ||
new SchemaFieldDataType().setType(SchemaFieldDataType.Type.create(new NumberType()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avro schema
{
"name": "props",
"type": [
"null",
{
"type": "map",
"values": [
"null",
"int"
]
}
],
"default": null
},
so this should be
assertSchemaField( | |
schema.getFields().get(18), | |
"[version=2.0].[type=users_record].[type=map].[type=int].props", | |
"int", | |
true, | |
false, | |
new SchemaFieldDataType().setType(SchemaFieldDataType.Type.create(new NumberType()))); | |
assertSchemaField( | |
schema.getFields().get(18), | |
"[version=2.0].[type=users_record].[type=map].[type=int].props", | |
"map<string, int>", | |
true, | |
false, | |
new SchemaFieldDataType() | |
.setType( | |
SchemaFieldDataType.Type.create( | |
new MapType().setKeyType("string").setValueType("int")))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, correctly it should be your suggested change
Checklist