关注 spark技术分享,
撸spark源码 玩spark最佳实践

implicits Object — Implicits Conversions

implicits Object — Implicits Conversions

implicits object gives implicit conversions for converting Scala objects (incl. RDDs) into a Dataset, DataFrame, Columns or supporting such conversions (through Encoders).

Table 1. implicits API
Name Description

localSeqToDatasetHolder

Creates a DatasetHolder with the input Seq[T] converted to a Dataset[T] (using SparkSession.createDataset).

Encoders

Encoders for primitive and object types in Scala and Java (aka boxed types)

StringToColumn

Converts $"name" into a Column

rddToDatasetHolder

symbolToColumn

implicits object is defined inside SparkSession and hence requires that you build a SparkSession instance first before importing implicits conversions.

Tip

In Scala REPL-based environments, e.g. spark-shell, use :imports to know what imports are in scope.

implicits object extends SQLImplicits abstract class.

DatasetHolder Scala Case Class

DatasetHolder is a Scala case class that, when created, takes a Dataset[T].

DatasetHolder is created (implicitly) when rddToDatasetHolder and localSeqToDatasetHolder implicit conversions are used.

DatasetHolder has toDS and toDF methods that simply return the Dataset[T] (it was created with) or a DataFrame (using Dataset.toDF operator), respectively.

赞(0) 打赏
未经允许不得转载:spark技术分享 » implicits Object — Implicits Conversions
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏