housepower / ClickHouse-Native-JDBC

ClickHouse Native Protocol JDBC implementation
https://housepower.github.io/ClickHouse-Native-JDBC/
Apache License 2.0
523 stars 145 forks source link

Can not support Array(Tuple(name String, previous_value String, new_value String, reason String)) type #456

Open beijishiqidu opened 9 months ago

beijishiqidu commented 9 months ago

Environment

Error logs

com.github.housepower.exception.ClickHouseSQLException: Unknown data type: name
    at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:82)
    at com.github.housepower.jdbc.statement.ClickHouseStatement.executeUpdate(ClickHouseStatement.java:78)
    at com.github.housepower.jdbc.statement.ClickHouseStatement.executeQuery(ClickHouseStatement.java:109)
    at com.huawei.jdbc.NoEncryptJdbcClient.main(NoEncryptJdbcClient.java:23)
Caused by: java.sql.SQLException: Unknown data type: name
    at com.github.housepower.misc.Validate.isTrue(Validate.java:41)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:95)
    at com.github.housepower.data.type.complex.DataTypeTuple.lambda$static$0(DataTypeTuple.java:39)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:68)
    at com.github.housepower.data.type.complex.DataTypeArray.lambda$static$0(DataTypeArray.java:39)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:70)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:55)
    at com.github.housepower.data.Block.readFrom(Block.java:43)
    at com.github.housepower.protocol.DataResponse.readFrom(DataResponse.java:32)
    at com.github.housepower.protocol.Response.readFrom(Response.java:33)
    at com.github.housepower.client.NativeClient.receiveResponse(NativeClient.java:207)
    at com.github.housepower.client.NativeClient.lambda$receiveQuery$0(NativeClient.java:164)
    at com.github.housepower.stream.ClickHouseQueryResult.consumeDataResponse(ClickHouseQueryResult.java:102)
    at com.github.housepower.stream.ClickHouseQueryResult.ensureHeaderConsumed(ClickHouseQueryResult.java:93)
    at com.github.housepower.stream.ClickHouseQueryResult.header(ClickHouseQueryResult.java:54)
    at com.github.housepower.jdbc.statement.ClickHouseStatement.lambda$executeUpdate$0(ClickHouseStatement.java:102)
    at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:76)
    ... 3 more

Steps to reproduce

java code:

public static void main(String[] args) throws Exception {
        Class.forName("com.github.housepower.jdbc.ClickHouseDriver");
        Properties clickHouseProperties = new Properties();
        clickHouseProperties.put("user", "nethouse");
        clickHouseProperties.put("password", "hNG?JW0hnMpX0qb@");
        Connection conn = DriverManager.getConnection("jdbc:clickhouse://10.185.206.152:9120/NETHOUSE",
            clickHouseProperties);
        try {
            ResultSet resultSet = conn.createStatement().executeQuery("select * from system.settings_changes");
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

Other descriptions

execute sql script in the command line:

show create table settings_changes

┌─statement───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ CREATE TABLE system.settings_changes
(
    `version` String,
    `changes` Array(Tuple(name String, previous_value String, new_value String, reason String))
)
ENGINE = SystemSettingsChanges
COMMENT 'SYSTEM TABLE is built on the fly.' │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

I see that the latest clickhouse version adds a lot of table and field types. Example: system.settings_changes