Top rows

Supported in: Batch

Picks the top rows in each sorted partition.

Transform categories: Aggregate

Declared arguments

  • Dataset - Input dataset.
    Table
  • Partition by columns - Set of columns to determine each partition from.
    Set<Column<AnyType>>
  • Sort specification - Specification for how to sort each partition. At least one specification is required.
    List<Tuple<Column<AnyType>, Enum<Ascending, Descending>>>
  • optional Number of rows - Number of rows to select, defaults to 1.
    Literal<Integer>

Examples

Example 1: Base case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Partition by columns: {airline}
  • Sort specification: [(airport, DESCENDING), (miles, ASCENDING)]
  • Number of rows: null

Input:

airlineairportmiles
foundry airwaysJFK1002345
foundry airwaysLHR2221324
new airSFO21356673
new airJFK12323456
foundry airwaysLHR12542352
new airJFK12232355

Output:

airlineairportmiles
foundry airwaysLHR2221324
new airSFO21356673

Example 2: Base case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Partition by columns: {}
  • Sort specification: [(airline, DESCENDING), (airport, DESCENDING), (miles, ASCENDING)]
  • Number of rows: 2

Input:

airlineairportmiles
foundry airwaysJFK1002345
foundry airwaysLHR2221324
new airSFO21356673
new airJFK12323456
foundry airwaysLHR12542352
new airJFK12232355

Output:

airlineairportmiles
new airSFO21356673
new airJFK12232355

Example 3: Base case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Partition by columns: {}
  • Sort specification: []
  • Number of rows: 1

Input:

airlineairportmiles
foundry airwaysJFK1002345
foundry airwaysLHR2221324
new airSFO21356673
new airJFK12323456
foundry airwaysLHR12542352
new airJFK12232355

Output:

airlineairportmiles
foundry airwaysJFK1002345