pyspark.sql.functions.ceiling#

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

Computes the ceiling of the given value.

New in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

The target column or column name to compute the ceiling on.

scaleColumn or int

An optional parameter to control the rounding behavior.

New in version 4.0.0.

Returns
Column

A column for the computed results.

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|
+----------------+