range table-valued function

Returns a table of values within a specified range.

Syntax

range(end)

range(start, end [, step [, numParts] ] )

Arguments

  • start: An optional BIGINT literal defaulted to 0, marking the first value generated.
  • end: A BIGINT literal marking endpoint (exclusive) of the number generation.
  • step: An optional BIGINT literal defaulted to 1, specifying the increment used when generating values.
  • numParts: An optional INTEGER literal specifying how the production of rows is spread across partitions.

Returns

A table with a single BIGINT column named id.

Examples

> SELECT spark_partition_id(), t.* FROM range(5) AS t;
  3 0
  6 1
  9 2
 12 3
 15 4

> SELECT * FROM range(-3, 0);
 -3
 -2
 -1

> SELECT spark_partition_id(), t.* FROM range(0, -5, -1, 2) AS t;
 0   0
 0  -1
 1  -2
 1  -3
 1  -4