ClickHouse / ClickHouse/clickhouse-java

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

未关闭
#2,824 10 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
area:docs bug client-api-v2 jdbc-v2
主要语言
Java
星标
1.6k
派生
636
平均合并
2 天 23 小时
30 天内合并 PR
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 摘要。