Skip to content
Snippets Groups Projects
Commit 76540b6d authored by Reynold Xin's avatar Reynold Xin
Browse files

[SPARK-12242][SQL] Add DataFrame.transform method

Author: Reynold Xin <rxin@databricks.com>

Closes #10226 from rxin/df-transform.
parent 21b3d2a7
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ class TypedColumn[-T, U]( ...@@ -84,7 +84,7 @@ class TypedColumn[-T, U](
* col("`a.column.with.dots`") // Escape `.` in column names. * col("`a.column.with.dots`") // Escape `.` in column names.
* $"columnName" // Scala short hand for a named column. * $"columnName" // Scala short hand for a named column.
* expr("a + 1") // A column that is constructed from a parsed SQL Expression. * expr("a + 1") // A column that is constructed from a parsed SQL Expression.
* lit("1") // A column that produces a literal (constant) value. * lit("abc") // A column that produces a literal (constant) value.
* }}} * }}}
* *
* [[Column]] objects can be composed to form complex expressions: * [[Column]] objects can be composed to form complex expressions:
......
...@@ -1421,6 +1421,19 @@ class DataFrame private[sql]( ...@@ -1421,6 +1421,19 @@ class DataFrame private[sql](
*/ */
def first(): Row = head() def first(): Row = head()
/**
* Concise syntax for chaining custom transformations.
* {{{
* def featurize(ds: DataFrame) = ...
*
* df
* .transform(featurize)
* .transform(...)
* }}}
* @since 1.6.0
*/
def transform[U](t: DataFrame => DataFrame): DataFrame = t(this)
/** /**
* Returns a new RDD by applying a function to all rows of this DataFrame. * Returns a new RDD by applying a function to all rows of this DataFrame.
* @group rdd * @group rdd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment