Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 2aa0cdf The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Medium impact] Adds click-to-filter actions to table chart cells. The aggregate-filter fallback still needs fixing before this PR is safe to merge.
|
| const aliasMap = chSqlToAliasMap(chSql); | ||
| for (const { name } of inferGroupColumns(meta) ?? []) { | ||
| keys.set(name, aliasMap[name] ?? quoteResultColumnNameIfNeeded(name)); |
There was a problem hiding this comment.
Aggregate clicks break queries
getRawSqlFilterKeys treats every string column as filterable when chSqlToSelectColumns returns nothing. For SELECT any(Body) AS body, count() FROM logs WHERE $__filters, clicking body stores any(Body) as the filter key. This inserts toString(any(Body)) = '…' into WHERE, where aggregate functions are forbidden, and the tile fails. The same problem affects GROUP BY ALL.
Keep aggregate columns out of the fallback, or omit actions when their source expression cannot be checked.
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 439 passed • 1 skipped • 1484s
Tests ran across 4 shards in parallel. |
8a3de77 to
4457c2e
Compare
4457c2e to
ed0cf25
Compare
ed0cf25 to
1f0ac52
Compare
1f0ac52 to
2aa0cdf
Compare
Summary
This PR adds click-to-adhoc-filter functionality to tables, across builder, raw SQL, and PromQL tables.
Most of the complexity comes from determining (a) which columns should be filterable and (b) what expression to filter on when a column / cell is clicked. In general, (a) group-by columns should be filterable while aggregate columns should not be (since other visualizations are unlikely to have the same aggregations) and (b) we try to filter on the underlying expression instead of the alias, since other visualizations may not have the same alias.
This determination is made as follows:
renderSelect). They're matched by position, not by name, because ClickHouse canonicalizes unaliased expressions.chSqlToSelectColumnsin common-utils). Each outer SELECT item lines up with a result column by position. An item is filterable if the GROUP BY lists it by alias, by name, by normalized expression, or by position (GROUP BY 2). If the query can't be read that way (no GROUP BY,GROUP BY ALL,SELECT *, a parse failure, or a column count that doesn't match the result), we fall back to type-based determination (any String type column is filterable).For all table types, DateTime columns aren't filterable, because cells hold ISO UTC timestamps that never equal
toString()of the column. Map and Array cells aren't filterable either, because they render as JSON that wouldn't match the value in a filter condition.Screenshots or video
How to test on Vercel preview
References