Skip to main content
Version: Java (Groovy)

ungroup

ungroup ungroups column content. It is the reverse of the groupBy method. ungroup expands columns containing either Deephaven arrays or Java arrays.

caution

Arrays of different lengths within a row result in an error.

Syntax

table.ungroup()
table.ungroup(nullFill)
table.ungroup(nullFill, columnsToUngroup...)
table.ungroup(columnsToUngroup...)
table.ungroup(columnNames...)

Parameters

ParameterTypeDescription
columnsToUngroupString...

The column(s) by which to ungroup data.

  • NULL all array columns from the source table will be expanded.
  • "X" will unwrap column X.
  • "X", "Y" will unwrap columns X and Y.
columnsToUngroupCollection<? extends ColumnName>

The column(s) by which to ungroup data.

  • NULL all array columns from the source table will be expanded.
  • "X" will unwrap column X.
  • "X", "Y" will unwrap columns X and Y.
nullFillbooleanIndicates if the ungrouped table should allow differently sized arrays and fill shorter columns with null values. If set to `false`, all arrays should be the same length.

Returns

A new table in which array columns from the source table are expanded into separate rows.

Examples

In this example, groupBy returns an array of values for each column, as grouped by X. ungroup will undo this operation and all array columns from the source table are expanded into separate rows.

source = newTable(
stringCol("X", "A", "B", "A", "C", "B", "A", "B", "B", "C"),
stringCol("Y", "M", "N", "O", "N", "P", "M", "O", "P", "M"),
intCol("Number", 55, 76, 20, 130, 230, 50, 73, 137, 214),
)

arrayTable = source.groupBy("X")

result = arrayTable.ungroup()

In this example, groupBy returns an array of values for each column, as grouped by X, while ungroup will expand the created array Y so each element is a new row.

source = newTable(
stringCol("X", "A", "B", "A", "C", "B", "A", "B", "B", "C"),
stringCol("Y", "M", "N", "O", "N", "P", "M", "O", "P", "M"),
intCol("Number", 55, 76, 20, 130, 230, 50, 73, 137, 214),
)

arrayTable = source.groupBy("X")

result = arrayTable.ungroup("Y")