-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use PartiallyConstructedTypedColumn for functions.col
- Loading branch information
Itamar Ravid
committed
Sep 22, 2017
1 parent
897e499
commit 0be79f0
Showing
3 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
dataset/src/main/scala/frameless/functions/PartiallyConstructedTypedColumn.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package frameless | ||
package functions | ||
|
||
import org.apache.spark.sql.functions.{ col => sparkCol } | ||
import shapeless.Witness | ||
|
||
case class PartiallyConstructedTypedColumn[K <: Symbol](column: Witness.Aux[K]) | ||
object PartiallyConstructedTypedColumn { | ||
implicit def toTypedColumn[T, K <: Symbol, A](p: PartiallyConstructedTypedColumn[K])( | ||
implicit | ||
exists: TypedColumn.Exists[T, K, A], | ||
encoder: TypedEncoder[A]): TypedColumn[T, A] = { | ||
val untypedExpr = sparkCol(p.column.value.name).as[A](TypedExpressionEncoder[A]) | ||
new TypedColumn[T, A](untypedExpr) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters