gengliangwang commented on code in PR #47425:
URL: https://github.com/apache/spark/pull/47425#discussion_r1730635996
##########
connector/avro/src/main/scala/org/apache/spark/sql/avro/SchemaConverters.scala:
##########
@@ -201,29 +259,33 @@ object SchemaConverters {
s,
existingRecordNames,
useStableIdForUnionType,
- stableIdPrefixForUnionType)
-
- val fieldName = if (useStableIdForUnionType) {
- // Avro's field name may be case sensitive, so field names
for two named type
- // could be "a" and "A" and we need to distinguish them. In
this case, we throw
- // an exception.
- // Stable id prefix can be empty so the name of the field
can be just the type.
- val tempFieldName =
s"${stableIdPrefixForUnionType}${s.getName}"
- if
(!fieldNameSet.add(tempFieldName.toLowerCase(Locale.ROOT))) {
- throw new IncompatibleSchemaException(
- "Cannot generate stable identifier for Avro union type
due to name " +
- s"conflict of type name ${s.getName}")
- }
- tempFieldName
+ stableIdPrefixForUnionType,
+ recursiveFieldMaxDepth)
+ if (schemaType == null) {
+ null
} else {
- s"member$i"
- }
+ val fieldName = if (useStableIdForUnionType) {
Review Comment:
@hkulyc yes, what about the recursive union schema?
For example
```
{
"type": "record",
"name": "TreeNode",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "value",
"type": [
"string",
"int"
]
},
{
"name": "children",
"type": [
"null",
{
"type": "array",
"items": "TreeNode"
}
],
"default": null
}
]
}
```
Do we have a test case for that?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]