Skip to contents

Creates a comparison level that checks whether a column equals a fixed literal value on the left record, right record, or both. This is useful as a gate inside cl_levels() to restrict a comparison to records with a known value (e.g., only compare names when country = 'US').

Usage

cl_literal(value, side = c("both", "left", "right"))

Arguments

value

A scalar value to compare against. Character values are quoted in the generated SQL. Numerics are not.

side

Which record to check: 'both' (default), 'left', or 'right'.

Value

A comparison-level object for use in il_compare() or cl_levels().

Examples

il_spec() |>
  il_compare(
    country,
    cl_levels(
      cl_null(),
      cl_literal('US', side = 'both'),
      cl_exact(),
      cl_else()
    )
  )
#> Linkage Specification
#>   Comparisons (1):
#>     country : levels
#>   Blocking rules: (none)