Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4263,6 +4263,7 @@ object functions {
*/
def to_binary(e: Column): Column = Column.fn("to_binary", e)

// scalastyle:off line.size.limit
/**
* Convert `e` to a string based on the `format`. Throws an exception if the conversion fails.
*
Expand All @@ -4283,13 +4284,20 @@ object functions {
* (optional, only allowed once at the beginning or end of the format string). Note that 'S'
* prints '+' for positive values but 'MI' prints a space.</li> <li>'PR': Only allowed at the
* end of the format string; specifies that the result string will be wrapped by angle
* brackets if the input value is negative.</li> </ul>
* brackets if the input value is negative.</li> </ul> If `e` is a datetime, `format` shall be
* a valid datetime pattern, see <a
* href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Datetime
* Patterns</a>. If `e` is a binary, it is converted to a string in one of the formats: <ul>
* <li>'base64': a base 64 string.</li> <li>'hex': a string in the hexadecimal format.</li>
* <li>'utf-8': the input binary is decoded to UTF-8 string.</li> </ul>
*
* @group string_funcs
* @since 3.5.0
*/
// scalastyle:on line.size.limit
def to_char(e: Column, format: Column): Column = Column.fn("to_char", e, format)

// scalastyle:off line.size.limit
/**
* Convert `e` to a string based on the `format`. Throws an exception if the conversion fails.
*
Expand All @@ -4310,11 +4318,17 @@ object functions {
* (optional, only allowed once at the beginning or end of the format string). Note that 'S'
* prints '+' for positive values but 'MI' prints a space.</li> <li>'PR': Only allowed at the
* end of the format string; specifies that the result string will be wrapped by angle
* brackets if the input value is negative.</li> </ul>
* brackets if the input value is negative.</li> </ul> If `e` is a datetime, `format` shall be
* a valid datetime pattern, see <a
* href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Datetime
* Patterns</a>. If `e` is a binary, it is converted to a string in one of the formats: <ul>
* <li>'base64': a base 64 string.</li> <li>'hex': a string in the hexadecimal format.</li>
* <li>'utf-8': the input binary is decoded to UTF-8 string.</li> </ul>
*
* @group string_funcs
* @since 3.5.0
*/
// scalastyle:on line.size.limit
def to_varchar(e: Column, format: Column): Column = Column.fn("to_varchar", e, format)

/**
Expand Down
12 changes: 12 additions & 0 deletions python/pyspark/sql/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10423,6 +10423,12 @@ def to_char(col: "ColumnOrName", format: "ColumnOrName") -> Column:
values but 'MI' prints a space.
'PR': Only allowed at the end of the format string; specifies that the result string
will be wrapped by angle brackets if the input value is negative.
If `col` is a datetime, `format` shall be a valid datetime pattern, see
<a href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Patterns</a>.
If `col` is a binary, it is converted to a string in one of the formats:
'base64': a base 64 string.
'hex': a string in the hexadecimal format.
'utf-8': the input binary is decoded to UTF-8 string.

.. versionadded:: 3.5.0

Expand Down Expand Up @@ -10463,6 +10469,12 @@ def to_varchar(col: "ColumnOrName", format: "ColumnOrName") -> Column:
values but 'MI' prints a space.
'PR': Only allowed at the end of the format string; specifies that the result string
will be wrapped by angle brackets if the input value is negative.
If `col` is a datetime, `format` shall be a valid datetime pattern, see
<a href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Patterns</a>.
If `col` is a binary, it is converted to a string in one of the formats:
'base64': a base 64 string.
'hex': a string in the hexadecimal format.
'utf-8': the input binary is decoded to UTF-8 string.

.. versionadded:: 3.5.0

Expand Down
18 changes: 18 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4399,6 +4399,7 @@ object functions {
new ToBinary(e.expr)
}

// scalastyle:off line.size.limit
/**
* Convert `e` to a string based on the `format`.
* Throws an exception if the conversion fails. The format can consist of the following
Expand All @@ -4420,11 +4421,20 @@ object functions {
* 'PR': Only allowed at the end of the format string; specifies that the result string will be
* wrapped by angle brackets if the input value is negative.
*
* If `e` is a datetime, `format` shall be a valid datetime pattern, see
* <a href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Datetime Patterns</a>.
* If `e` is a binary, it is converted to a string in one of the formats:
* 'base64': a base 64 string.
* 'hex': a string in the hexadecimal format.
* 'utf-8': the input binary is decoded to UTF-8 string.
*
* @group string_funcs
* @since 3.5.0
*/
// scalastyle:on line.size.limit
def to_char(e: Column, format: Column): Column = call_function("to_char", e, format)

// scalastyle:off line.size.limit
/**
* Convert `e` to a string based on the `format`.
* Throws an exception if the conversion fails. The format can consist of the following
Expand All @@ -4446,9 +4456,17 @@ object functions {
* 'PR': Only allowed at the end of the format string; specifies that the result string will be
* wrapped by angle brackets if the input value is negative.
*
* If `e` is a datetime, `format` shall be a valid datetime pattern, see
* <a href="https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html">Datetime Patterns</a>.
* If `e` is a binary, it is converted to a string in one of the formats:
* 'base64': a base 64 string.
* 'hex': a string in the hexadecimal format.
* 'utf-8': the input binary is decoded to UTF-8 string.
*
* @group string_funcs
* @since 3.5.0
*/
// scalastyle:on line.size.limit
def to_varchar(e: Column, format: Column): Column = call_function("to_varchar", e, format)

/**
Expand Down