GitHub user maropu opened a pull request:
https://github.com/apache/spark/pull/17318
[SPARK-19896][SQL] Throw an exception if case classes have circular
references in toDS
## What changes were proposed in this pull request?
If case classes have circular references below, it throws
StackOverflowError;
```
scala> :pasge
case class classA(i: Int, cls: classB)
case class classB(cls: classA)
scala> Seq(classA(0, null)).toDS()
java.lang.StackOverflowError
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1494)
at
scala.reflect.runtime.JavaMirrors$JavaMirror$$anon$1.scala$reflect$runtime$SynchronizedSymbols$SynchronizedSymbol$$super$info(JavaMirrors.scala:66)
at
scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
at
scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
at
scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)
at
scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:123)
at
scala.reflect.runtime.JavaMirrors$JavaMirror$$anon$1.gilSynchronizedIfNotThreadsafe(JavaMirrors.scala:66)
at
scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.info(SynchronizedSymbols.scala:127)
at
scala.reflect.runtime.JavaMirrors$JavaMirror$$anon$1.info(JavaMirrors.scala:66)
at
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:48)
at
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
at
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
at
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
at
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
```
This pr added code to throw UnsupportedOperationException in that case as
soon as possible.
## How was this patch tested?
Added tests in `DatasetSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/maropu/spark SPARK-19896
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/17318.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 #17318
----
commit bb3b6a3471c27c58df6f9224b3d8755c2b55b1a0
Author: Takeshi Yamamuro <[email protected]>
Date: 2017-03-10T11:57:37Z
Throw an exception if case classes have circular references
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]