Skip to main content
Version: Java (Groovy)

whereNotIn

The whereNotIn method returns a new table containing rows from the source table, where the rows do not match values in the filter table. The filter is updated whenever either table changes.

note

whereNotIn is not appropriate for all situations. Its purpose is to enable more efficient filtering for an infrequently changing filter table.

Syntax

table.whereNotIn(rightTable, columnsToMatch...)

Parameters

ParameterTypeDescription
rightTableTable

The table containing the set of values to filter on.

columnsToMatchString...

The columns to match between the two tables.

  • "X" will match on the same column name. Equivalent to "X = X".
  • "X = Y" will match when the columns have different names, with X being the source table column and Y being the filter table column.
columnsToMatchCollection

The columns to match between the two tables.

Returns

A new table containing rows from the source table, where the rows do not match values in the filter table.

Examples

The following example creates a table containing only the colors not present in the filter table.

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),
)

filter = newTable(
stringCol("Colors", "blue", "red", "purple", "white")
)

result = source.whereNotIn(filter, "Color = Colors")

The following example creates a table containing only the colors and codes not present in the filter table. When using multiple matches, the resulting table will exclude only values that are not in both matches. In this example, only one row matches both color AND codes. This results in a new table that has all but one matching value.

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, 10, 16, 14, NULL_INT),
)

filter = newTable(
stringCol("Colors", "blue", "red", "purple", "white"),
intCol("Codes", 10, 12, 14, 16)
)

result = source.whereNotIn(filter, "Color = Colors", "Code = Codes")