Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/clients/ValueCounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,20 @@ export class ValueCounts extends MosaicClient {
}

override query(filter: Array<ExprNode> = []): Query {
let col = column(this.#column);
let counts = Query
.from({ source: this.#table })
.select({
value: sql`CASE
WHEN ${column(this.#column)} IS NULL THEN '__quak_null__'
ELSE ${column(this.#column)}
WHEN ${col} IS NULL THEN '__quak_null__'
ELSE CAST(${col} AS VARCHAR)
END`,
count: count(),
})
.groupby("value")
.groupby(sql`CASE
WHEN ${col} IS NULL THEN '__quak_null__'
ELSE CAST(${col} AS VARCHAR)
END`)
.where(filter);
return Query
.with({ counts })
Expand Down