Skip to contents

Returns "val" or "value" — whichever the given table actually has.

Usage

sdm_val_col(con, tbl)

Arguments

con

open connection to a release database, or to a set of views over one

tbl

name of the table to inspect, e.g. "zone", "cell_metric"

Value

"val" or "value"

Details

Releases disagree, and so do the two forms of the same release. v1-v7 named the measurement value throughout (zone, zone_metric, cell_metric, model_cell). v8 renamed it val, away from DuckDB's reserved word — but the release step also writes a value alias into the served views, so a v8 serve.duckdb carries both while the v8 source sdm.duckdb it was built from carries only val.

The practical consequence, and the reason this is a function rather than a constant: code that hardcodes value runs against every served release and fails against a v8 source database, while code that hardcodes val does the exact opposite. Both spellings appeared in one app file. val is preferred where both exist, since that is the name the data is actually stored under.

The failure this prevents is not a clean missing-column error. In dplyr/dbplyr a bare value with no such column resolves to a function further up the scope chain, so the error reads cannot coerce type 'closure' to vector of type 'character' from somewhere inside the SQL translator, far from the table that lacks the column.

Examples

if (FALSE) { # \dontrun{
con <- attach_atlas(version = "v7")
sdm_val_col(con, "zone_metric")   # "value"
} # }