Skip to content
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

[SPARK-19089][SQL] Add support for nested sequences #18011

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 11 additions & 44 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,93 +111,60 @@ abstract class SQLImplicits extends LowPrioritySQLImplicits {

/**
* @since 1.6.1
* @deprecated use [[newIntSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newIntSeqEncoder: Encoder[Seq[Int]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newLongSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newLongSeqEncoder: Encoder[Seq[Long]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newDoubleSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newDoubleSeqEncoder: Encoder[Seq[Double]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newFloatSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newFloatSeqEncoder: Encoder[Seq[Float]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newByteSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newByteSeqEncoder: Encoder[Seq[Byte]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newShortSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newShortSeqEncoder: Encoder[Seq[Short]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newBooleanSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newBooleanSeqEncoder: Encoder[Seq[Boolean]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newStringSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
def newStringSeqEncoder: Encoder[Seq[String]] = ExpressionEncoder()

/**
* @since 1.6.1
* @deprecated use [[newProductSequenceEncoder]]
* @deprecated use [[newSequenceEncoder]]
*/
implicit def newProductSeqEncoder[A <: Product : TypeTag]: Encoder[Seq[A]] = ExpressionEncoder()
def newProductSeqEncoder[A <: Product : TypeTag]: Encoder[Seq[A]] = ExpressionEncoder()

/** @since 2.2.0 */
implicit def newIntSequenceEncoder[T <: Seq[Int] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newLongSequenceEncoder[T <: Seq[Long] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newDoubleSequenceEncoder[T <: Seq[Double] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newFloatSequenceEncoder[T <: Seq[Float] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newByteSequenceEncoder[T <: Seq[Byte] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newShortSequenceEncoder[T <: Seq[Short] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newBooleanSequenceEncoder[T <: Seq[Boolean] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newStringSequenceEncoder[T <: Seq[String] : TypeTag]: Encoder[T] =
ExpressionEncoder()

/** @since 2.2.0 */
implicit def newProductSequenceEncoder[T <: Seq[Product] : TypeTag]: Encoder[T] =
ExpressionEncoder()
implicit def newSequenceEncoder[T <: Seq[_] : TypeTag]: Encoder[T] = ExpressionEncoder()

// Arrays

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ class DatasetPrimitiveSuite extends QueryTest with SharedSQLContext {
ListClass(List(1)) -> Queue("test" -> SeqClass(Seq(2))))
}

test("nested sequences") {
checkDataset(Seq(Seq(Seq(1))).toDS(), Seq(Seq(1)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also add test for specific collection type, e.g. List(Queue(1))

}

test("package objects") {
import packageobject._
checkDataset(Seq(PackageClass(1)).toDS(), PackageClass(1))
Expand Down