ClickHouse / metabase-clickhouse-driver

ClickHouse database driver for the Metabase business intelligence front-end
Apache License 2.0
461 stars 84 forks source link

Fields of AggregateFunction type omitted from preview and erroring in Query Editor #197

Open wickyvinn opened 9 months ago

wickyvinn commented 9 months ago

Describe the bug

I have a table that is ReplicatedAggregatingMergeTree, and several fields that have the type AggregateFunction(avg, Float64). When querying this table via the Clickhouse CLI, I'm able to view at least the hash of such functions, for example:

SELECT
    timestamp,
    secure_connection_start_ms
FROM p2p_http_all_aggr_5m_v1_dist
LIMIT 10
┌───────────timestamp─┬─secure_connection_start_ms─┐
│ 2023-09-28 08:00:00 │ @l@                        │
│ 2023-09-28 08:00:00 │ @p@                        │
│ 2023-09-28 08:00:00 │ ?u@                         │
│ 2023-09-28 08:00:00 │ ?v@                         │
│ 2023-09-28 08:00:00 │ v@                         │
│ 2023-09-28 08:00:00 │ ?w@                         │
│ 2023-09-28 08:00:00 │ l@                         │
│ 2023-09-28 08:00:00 │ l?@                         │
│ 2023-09-28 08:00:00 │  l@                        │
│ 2023-09-28 08:00:00 │  j@                        │
└─────────────────────┴────────────────────────────┘

And when interacting in with the Metabase preview, those AggregatedFunction fields are omitted. Furthermore, when querying in the Metabase query editor, I get a groupMap error of “Only groupMap is supported at this point”

Is this intended behavior or should metabase be able to show the AggregatedFunction hashes for data exploration? If intended behavior, the error should be clearer around needing to apply an aggregate function to the AggregateFunction field.

Expected behavior

Show the AggregatedFunction hash or a clearer error message around how to query AggregateFunctions.

Information about your Metabase installation

Chrome Version 117.0.5938.92 (Official Build) (arm64)
ClickHouse server version 23.6.1 revision 54464
Metabase version v0.46.2
slvrtrn commented 9 months ago

See the known limitations:

As the underlying JDBC driver version does not support columns with AggregateFunction type, these columns are excluded from the table metadata and data browser result sets to prevent sync or data browsing errors.

I will keep this issue open as a feature request.

NB: while AggregateFunction columns are excluded from the columns list, SimpleAggregateFunction ones should work fine.

wickyvinn commented 9 months ago

See the known limitations:

As the underlying JDBC driver version does not support columns with AggregateFunction type, these columns are excluded from the table metadata and data browser result sets to prevent sync or data browsing errors.

I will keep this issue open as a feature request.

NB: while AggregateFunction columns are excluded from the columns list, SimpleAggregateFunction ones should work fine.

Thanks @slvrtrn. Unfortunately it appears that SimpleAggregateFunction does not support avg which which is the crux of using ReplicatedAggregatingMergeTree for us. Nonetheless, thanks for keeping it open as a feature request.