pyspark.sql.functions.ceiling#

pyspark.sql.functions.ceiling(col, scale=None)[source]#

Computes the ceiling of the given value.

Added in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
colColumn or column name

The target column or column name to compute the ceiling on. A column that evaluates to a numeric.

scaleColumn or int

An optional parameter to control the rounding behavior. A column that evaluates to an integer. Must be a constant.

Added in version 4.0.0.

Returns:
Column

A column for the computed results. Returns a column that evaluates to a long or decimal.

Examples

Example 1: Compute the ceiling of a column value

>>> from pyspark.sql import functions as sf
>>> spark.range(1).select(sf.ceiling(sf.lit(-0.1))).show()
+-------------+
|ceiling(-0.1)|
+-------------+
|            0|
+-------------+

Example 2: Compute the ceiling of a column value with a specified scale

>>> from pyspark.sql import functions as sf
>>> spark.range(1).select(sf.ceiling(sf.lit(-0.1), 1)).show()
+----------------+
|ceiling(-0.1, 1)|
+----------------+
|            -0.1|
+----------------+