GitHub user gengliangwang opened a pull request:
https://github.com/apache/spark/pull/22709
[SPARK-25718][SQL]Detect recursive reference in Avro schema and throw
exception
## What changes were proposed in this pull request?
Avro schema allows recursive reference, e.g. the schema for linked-list in
https://avro.apache.org/docs/1.8.2/spec.html#schema_record
```
{
"type": "record",
"name": "LongList",
"aliases": ["LinkedLongs"], // old name for this
"fields" : [
{"name": "value", "type": "long"}, // each element has a
long
{"name": "next", "type": ["null", "LongList"]} // optional next element
]
}
```
In current Spark SQL, it is impossible to convert the schema as
`StructType` . Run `SchemaConverters.toSqlType(avroSchema)` and we will get
stack overflow exception.
We should detect the recursive reference and throw exception for it.
## How was this patch tested?
New unit test case.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gengliangwang/spark avroRecursiveRef
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/22709.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #22709
commit c97f54347cf08edfa1f31ab7026700170a67c848
Author: Gengliang Wang
Date: 2018-10-12T14:59:58Z
detect recusive reference loop in avro schema
---
-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org