Skip to main content

Limit

Spark Gem

Limits the number of rows in the output.

Parameters

ParameterDescription
DataFrameInput DataFrame
LimitNumber of rows required in output. Allowed range: [0, 231 -1]

Limit to 10 rows

If you want to limit your output to 10 rows, you can input 10 in the Limit gem.

Example usage of Limit

note

Data samples generated before the Limit gem might also be limited. This is because Spark tries to push the limit down to earlier stages of execution to minimize data processing. This means Spark may reduce the number of rows fetched from the source or processed in earlier transformations.

Code

def limit(spark: SparkSession, in0: DataFrame) -> DataFrame:
return in0.limit(10)