-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16792][SQL] Dataset containing a Case Class with a List type causes a CompileException (converting sequence to list) #16240
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
Changes from 8 commits
c47f189
8c15b47
b04f46e
c4c0129
96f9d9d
b530bf5
f75a8f1
21d9e97
c45bee4
efd0801
2ad7eb0
68810c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,6 +130,34 @@ class DatasetPrimitiveSuite extends QueryTest with SharedSQLContext { | |
| checkDataset(Seq(Array(Tuple1(1))).toDS(), Array(Tuple1(1))) | ||
| } | ||
|
|
||
| test("arbitrary sequences") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's also test nested sequences, e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some sequence-product combination tests. |
||
| import scala.collection.immutable.Queue | ||
| checkDataset(Seq(Queue(1)).toDS(), Queue(1)) | ||
| checkDataset(Seq(Queue(1.toLong)).toDS(), Queue(1.toLong)) | ||
| checkDataset(Seq(Queue(1.toDouble)).toDS(), Queue(1.toDouble)) | ||
| checkDataset(Seq(Queue(1.toFloat)).toDS(), Queue(1.toFloat)) | ||
| checkDataset(Seq(Queue(1.toByte)).toDS(), Queue(1.toByte)) | ||
| checkDataset(Seq(Queue(1.toShort)).toDS(), Queue(1.toShort)) | ||
| checkDataset(Seq(Queue(true)).toDS(), Queue(true)) | ||
| checkDataset(Seq(Queue("test")).toDS(), Queue("test")) | ||
| // Implicit resolution problem - encoder needs to be provided explicitly | ||
| implicit val queueEncoder = newProductSeqEncoder[Tuple1[Int], Queue[Tuple1[Int]]] | ||
| checkDataset(Seq(Queue(Tuple1(1))).toDS(), Queue(Tuple1(1))) | ||
|
|
||
| import scala.collection.mutable.ArrayBuffer | ||
| checkDataset(Seq(ArrayBuffer(1)).toDS(), ArrayBuffer(1)) | ||
| checkDataset(Seq(ArrayBuffer(1.toLong)).toDS(), ArrayBuffer(1.toLong)) | ||
| checkDataset(Seq(ArrayBuffer(1.toDouble)).toDS(), ArrayBuffer(1.toDouble)) | ||
| checkDataset(Seq(ArrayBuffer(1.toFloat)).toDS(), ArrayBuffer(1.toFloat)) | ||
| checkDataset(Seq(ArrayBuffer(1.toByte)).toDS(), ArrayBuffer(1.toByte)) | ||
| checkDataset(Seq(ArrayBuffer(1.toShort)).toDS(), ArrayBuffer(1.toShort)) | ||
| checkDataset(Seq(ArrayBuffer(true)).toDS(), ArrayBuffer(true)) | ||
| checkDataset(Seq(ArrayBuffer("test")).toDS(), ArrayBuffer("test")) | ||
| // Implicit resolution problem - encoder needs to be provided explicitly | ||
| implicit val arrayBufferEncoder = newProductSeqEncoder[Tuple1[Int], ArrayBuffer[Tuple1[Int]]] | ||
| checkDataset(Seq(ArrayBuffer(Tuple1(1))).toDS(), ArrayBuffer(Tuple1(1))) | ||
| } | ||
|
|
||
| test("package objects") { | ||
| import packageobject._ | ||
| checkDataset(Seq(PackageClass(1)).toDS(), PackageClass(1)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
can we just use
newProductSeqEncoder[T <: Seq[Product] : TypeTag]: Encoder[T]here? Then we don't need the workaround implicitUh oh!
There was an error while loading. Please reload this page.
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.
Seqdeclares covariance onTso it works and solves all the problems I was having. Thanks