ClickHouse / ClickHouse/clickhouse-java
Unknown aggregate function: avgIf` occurs when querying via JDBC. (Trino and Dbeaver)
- Ngôn ngữ chính
- Java
- Star
- 1.6k
- Fork
- 636
- Merge trung bình
- 2 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 29
Mô tả
## 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
Hướng dẫn đóng góp
Hướng nghiên cứu
Báo cáo đề cập đến JDBC driver, DBeaver, Trino và bảng default.nm_advert_stats_daily, nhưng không có tệp hoặc kiểm thử nào trong repository. Hãy bắt đầu bằng cách tái hiện truy vấn Trino JDBC và so sánh truy vấn đó với truy vấn ClickHouse native bằng các phiên bản server và driver đã nêu; công việc được xem là hoàn tất khi đường đi JDBC xử lý được hàm tổng hợp avgIf mà không gặp lỗi đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, sql
- Lĩnh vực
- api, database
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100