Skip to main content
Version: Java (Groovy)

tail

The tail method returns a table with a specific number of rows from the end of the source table.

Syntax

table.tail(size)

Parameters

ParameterTypeDescription
sizelong

The number of rows to return.

Returns

A new table with a specific number of rows from the end of the source table.

Examples

The following example filters the table to the last two rows.

source = newTable(
stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),
intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),
stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),
intCol("Code", 12, 13, 11, NULL_INT, 16, 14, NULL_INT),
)

result = source.tail(2)

The following example uses tail on a blink table. Note that tail treats the blink table like an append-only table, showing the five rows that were most recently added to the table, regardless of what update cycle they are a part of.

source = timeTableBuilder().period("PT0.5S").blinkTable(true).build()

result = source.tail(5)

img