(key: string, agg: AggregateIrExpression)
| 311 | : false |
| 312 | |
| 313 | const aggregateSelectExpr = (key: string, agg: AggregateIrExpression): string => { |
| 314 | switch (agg._tag) { |
| 315 | case "agg-count": |
| 316 | return `COUNT(1) AS ${key}` |
| 317 | case "agg-count-when": { |
| 318 | if (agg.filter.length === 0) return `COUNT(1) AS ${key}` |
| 319 | const cond = print(agg.filter, null, false) |
| 320 | // Cosmos supports SUM(IIF(cond, 1, 0)) as a conditional count |
| 321 | return `SUM(IIF(${cond}, 1, 0)) AS ${key}` |
| 322 | } |
| 323 | case "agg-sum": { |
| 324 | const fieldRef = dottedToAccess(`f.${agg.field}`) |
| 325 | return `SUM(${fieldRef}) AS ${key}` |
| 326 | } |
| 327 | case "agg-min": { |
| 328 | const fieldRef = dottedToAccess(`f.${agg.field}`) |
| 329 | return `MIN(${fieldRef}) AS ${key}` |
| 330 | } |
| 331 | case "agg-max": { |
| 332 | const fieldRef = dottedToAccess(`f.${agg.field}`) |
| 333 | return `MAX(${fieldRef}) AS ${key}` |
| 334 | } |
| 335 | default: |
| 336 | return assertUnreachable(agg) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | const computedSelectExpr = (key: string, computed: ComputedProjectionIrExpression) => { |
| 341 | const relationPath = computed.path |
no test coverage detected
searching dependent graphs…