From 28f97d3258e2a07d53c9a6d55c5d9e92a85f4e4a Mon Sep 17 00:00:00 2001 From: Michael Patterson Date: Mon, 3 Apr 2017 10:26:04 -0700 Subject: [PATCH] Start of Scala docs. Need to figure out how to compile the docs. --- .../scala/org/apache/spark/sql/Column.scala | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala index ae0703513cf42..acbaef3afa7f1 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala @@ -781,7 +781,12 @@ class Column(val expr: Expression) extends Logging { def isin(list: Any*): Column = withExpr { In(expr, list.map(lit(_).expr)) } /** - * SQL like expression. + * SQL LIKE expression. For regex string searches, see rlike. + * {{{ + * // find names that start with "Al" + * scala> df.filter( $"name".like("Al%") ).collect() + * Array([Alice,1]) + * }}} * * @group expr_ops * @since 1.3.0 @@ -789,7 +794,12 @@ class Column(val expr: Expression) extends Logging { def like(literal: String): Column = withExpr { Like(expr, lit(literal).expr) } /** - * SQL RLIKE expression (LIKE with Regex). + * Return a Boolean column based on a regex match. + * {{{ + * // find names that end in "ice" + * scala> df.filter( $"name".rlike("ice$") ).collect() + * Array([Alice,1]) + * }}} * * @group expr_ops * @since 1.3.0 @@ -856,7 +866,14 @@ class Column(val expr: Expression) extends Logging { def startsWith(other: Column): Column = withExpr { StartsWith(expr, lit(other).expr) } /** - * String starts with another string literal. + * Return a Boolean Column based on a string match. Note you do not need regex ^. + * {{{ + * // find names that start with "Al" + * scala> df.filter( $"name".startsWith("Al") ).collect() + * Array([Alice,1]) + * scala> df.filter( $"name".startsWith("^Al") ).collect() + * Array() + * }}} * * @group expr_ops * @since 1.3.0 @@ -872,7 +889,14 @@ class Column(val expr: Expression) extends Logging { def endsWith(other: Column): Column = withExpr { EndsWith(expr, lit(other).expr) } /** - * String ends with another string literal. + * Return a Boolean column based on string match. Note you do not need regex $. + * {{{ + * // find names that end with "ice" + * scala> df.filter( $"name".endsWith("ice") ).collect() + * Array([Alice,1]) + * scala> df.filter( $"name".endsWith("ice$") ).collect() + * Array() + * }}} * * @group expr_ops * @since 1.3.0