ClickHouse / ClickHouse/clickhouse-java

In the JDBC query result set, columns of type AggregateFunction cannot be parsed normally

Open
#2,662 1 comment 0 reactions 0 assignees View on GitHub
area:data-type bug client-api-v2
Dominant language
Java
Stars
1.6k
Forks
636
Avg merge
2d 16h
Merged PRs (30d)
28

Description

## Description

When creating a materialized view, specify the Select statement as follows:

```sql
SELECT
toDate(timestamp) AS date,
countState(*) AS count,
quantileState(0.9)(duration) AS tp90_duration_ms,
quantileState(0.99)(duration) AS tp99_duration_ms,
avgState(duration) AS avg_duration_ms,
maxState(duration) AS max_duration_ms,
minState(duration) AS min_duration_ms
FROM test.test_table_local
GROUP BY
date
```
This statement is queried directly with JDBC, and the final error is:
java.sql.SQLException: Failed to read value for column count

final debug result:

1. BinaryStreamReader.java -> readValue method

case AggregateFunction:
return (T)this.readBitmap(actualColumn);
2. readBitmap method
```java
private ClickHouseBitmap readBitmap(ClickHouseColumn column) throws IOException {
return ClickHouseBitmap.deserialize(this.input, ((ClickHouseColumn)column.getNestedColumns().get(0)).getDataType());
}
```
column.getNestedColumns() is empty

Image

3.

### Error Log or Exception StackTrace

```
This statement is queried directly with JDBC, and the final error is:
java.sql.SQLException: Failed to read value for column count
```

### Expected Behaviour

### Code Example

```java

```

### Configuration

#### Client Configuration
```java

```

#### Environment
* [ ] Cloud
* Client version: 0.9.4
* Language version: 1.8
* OS: mac

#### ClickHouse Server
* ClickHouse Server version: 25.5.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.