Skip to content

Commit ebe9c82

Browse files
authored
Fix value counts SQL columns (#84)
1 parent d75e1fa commit ebe9c82

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/clients/ValueCounts.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ export class ValueCounts extends MosaicClient {
6868
}
6969

7070
override query(filter: Array<ExprNode> = []): Query {
71+
let col = column(this.#column);
7172
let counts = Query
7273
.from({ source: this.#table })
7374
.select({
7475
value: sql`CASE
75-
WHEN ${column(this.#column)} IS NULL THEN '__quak_null__'
76-
ELSE ${column(this.#column)}
76+
WHEN ${col} IS NULL THEN '__quak_null__'
77+
ELSE CAST(${col} AS VARCHAR)
7778
END`,
7879
count: count(),
7980
})
80-
.groupby("value")
81+
.groupby(sql`CASE
82+
WHEN ${col} IS NULL THEN '__quak_null__'
83+
ELSE CAST(${col} AS VARCHAR)
84+
END`)
8185
.where(filter);
8286
return Query
8387
.with({ counts })

0 commit comments

Comments
 (0)