diff options
author | Reynold Xin <rxin@databricks.com> | 2016-04-07 00:46:57 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-04-07 00:46:57 -0700 |
commit | e11aa9ec5c3cdcd8ca08d2486a7208840ad77bf8 (patch) | |
tree | 9688d40b9a8b3ff2e0f8b9f0f4a3cec224106f10 /sql/core | |
parent | 21d5ca128bf3afd5c2d4c7fcc56240e28443474f (diff) | |
download | spark-e11aa9ec5c3cdcd8ca08d2486a7208840ad77bf8.tar.gz spark-e11aa9ec5c3cdcd8ca08d2486a7208840ad77bf8.tar.bz2 spark-e11aa9ec5c3cdcd8ca08d2486a7208840ad77bf8.zip |
[SPARK-14452][SQL] Explicit APIs in Scala for specifying encoders
## What changes were proposed in this pull request?
The Scala Dataset public API currently only allows users to specify encoders through SQLContext.implicits. This is OK but sometimes people want to explicitly get encoders without a SQLContext (e.g. Aggregator implementations). This patch adds public APIs to Encoders class for getting Scala encoders.
## How was this patch tested?
None - I will update test cases once https://github.com/apache/spark/pull/12231 is merged.
Author: Reynold Xin <rxin@databricks.com>
Closes #12232 from rxin/SPARK-14452.
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala b/sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala index c35a969bf0..ad69e23540 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala @@ -44,33 +44,33 @@ abstract class SQLImplicits { } /** @since 1.6.0 */ - implicit def newProductEncoder[T <: Product : TypeTag]: Encoder[T] = ExpressionEncoder() + implicit def newProductEncoder[T <: Product : TypeTag]: Encoder[T] = Encoders.product[T] // Primitives /** @since 1.6.0 */ - implicit def newIntEncoder: Encoder[Int] = ExpressionEncoder() + implicit def newIntEncoder: Encoder[Int] = Encoders.scalaInt /** @since 1.6.0 */ - implicit def newLongEncoder: Encoder[Long] = ExpressionEncoder() + implicit def newLongEncoder: Encoder[Long] = Encoders.scalaLong /** @since 1.6.0 */ - implicit def newDoubleEncoder: Encoder[Double] = ExpressionEncoder() + implicit def newDoubleEncoder: Encoder[Double] = Encoders.scalaDouble /** @since 1.6.0 */ - implicit def newFloatEncoder: Encoder[Float] = ExpressionEncoder() + implicit def newFloatEncoder: Encoder[Float] = Encoders.scalaFloat /** @since 1.6.0 */ - implicit def newByteEncoder: Encoder[Byte] = ExpressionEncoder() + implicit def newByteEncoder: Encoder[Byte] = Encoders.scalaByte /** @since 1.6.0 */ - implicit def newShortEncoder: Encoder[Short] = ExpressionEncoder() + implicit def newShortEncoder: Encoder[Short] = Encoders.scalaShort /** @since 1.6.0 */ - implicit def newBooleanEncoder: Encoder[Boolean] = ExpressionEncoder() + implicit def newBooleanEncoder: Encoder[Boolean] = Encoders.scalaBoolean /** @since 1.6.0 */ - implicit def newStringEncoder: Encoder[String] = ExpressionEncoder() + implicit def newStringEncoder: Encoder[String] = Encoders.STRING // Seqs |