One dimension whose value is a scalar column or a scalar prop.
(dim: string, value: string, where = LIFECYCLE)
| 150 | |
| 151 | /** One dimension whose value is a scalar column or a scalar prop. */ |
| 152 | function dimStatement(dim: string, value: string, where = LIFECYCLE): string { |
| 153 | return `INSERT INTO daily_dim_counts (day, event, dim, value, count, machines) |
| 154 | SELECT e.day, e.event, '${dim}', CAST(${value} AS TEXT), count(*), count(DISTINCT e.machine_id) |
| 155 | FROM events e |
| 156 | WHERE e.day = ? AND ${value} IS NOT NULL AND ${value} <> ''${where} |
| 157 | GROUP BY e.day, e.event, ${value} |
| 158 | ${DIM_CONFLICT}`; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * One usage dimension, from a `usage_daily` column. Absent values are stored as '' |