Skip to content

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

@CCweixiao

Description

@CCweixiao

Description

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

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

    private ClickHouseBitmap readBitmap(ClickHouseColumn column) throws IOException {
        return ClickHouseBitmap.deserialize(this.input, ((ClickHouseColumn)column.getNestedColumns().get(0)).getDataType());
    }

    column.getNestedColumns() is empty

Image

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

Configuration

Client Configuration

Environment

  • Cloud
  • Client version: 0.9.4
  • Language version: 1.8
  • OS: mac

ClickHouse Server

  • ClickHouse Server version: 25.5.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions