ClickHouse / ClickHouse/clickhouse-java

Unknown aggregate function: avgIf` occurs when querying via JDBC. (Trino and Dbeaver)

オープン
#2,824 コメント 10 件 リアクション 4 件 担当者 0 名 GitHub で見る
area:docs bug client-api-v2 jdbc-v2
主要言語
Java
スター
1.6k
フォーク
636
平均マージ
2日 23時間
マージ済み PR(30日)
29

説明

## Description

**Problem Analysis:**

**Core issue:** An error occurs when executing a query against the `default.nm_advert_stats_daily` table via the JDBC driver (DBeaver), whereas a direct query using the native ClickHouse client works correctly.

**Key points:**
1. **Error:** `Unknown aggregate function: avgIf` occurs when querying via JDBC.
2. **Direct query** in the ClickHouse console executes successfully.
3. **The table** uses aggregate functions in its columns:
- `position_avg_state AggregateFunction(avgIf, Float64, UInt8)`
- `position_quantiles_state AggregateFunction(quantilesTDigestIf(0.5, 0.9, 0.95), Float64, UInt8)`

**Software versions:**
- ClickHouse Server: 24.8.8
- JDBC Driver: Official ClickHouse driver (server version 21.3+)

**The Problem:** There is an incompatibility between the JDBC driver version and the ClickHouse server version. The driver does not recognize the syntax of the aggregate functions (`avgIf`) that are supported by the server.

**Solutions suggested by the participants:**
- Fix JDBC driver is up to date due to we can't use native client for Trino and Dbeaver

### Steps to reproduce
1.
2.
3.
### Error Log or Exception StackTrace

```
Trino try to select

select *
from table(ads_ch_ch.system.query(
query => 'select * from default.nm_advert_stats_daily limit 100'
)); -- this is native clickhouse execution

QL Error [65536]: Query failed (#20260407_141005_02502_hqy64): com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Unknown aggregate function: avgIf

```

### Expected Behaviour

### Code Example

```java

```

### Configuration

#### Client Configuration
```java

```

#### Environment
* [ ] Cloud
* Client version:
* Language version:
* OS:

#### ClickHouse Server
* ClickHouse Server version:
* ClickHouse Server non-default settings, if any:
* `CREATE TABLE` statements for tables involved:
* Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

このレポートでは JDBC ドライバー、DBeaver、Trino、そして default.nm_advert_stats_daily テーブルが挙げられていますが、リポジトリのファイルやテストはありません。まず、記載されているサーバーとドライバーのバージョンを使って Trino JDBC クエリを再現し、ネイティブ ClickHouse クエリと比較してください。JDBC 経路が報告されたエラーなしで集約関数 avgIf を処理できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, sql
領域
api, database
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。