itinycheng / flink-connector-clickhouse

Flink SQL connector for ClickHouse. Support ClickHouseCatalog and read/write primary data, maps, arrays to clickhouse.
Apache License 2.0
371 stars 155 forks source link

[Bug]: cluster空指针 #152

Open jackj-ohn1 opened 2 months ago

jackj-ohn1 commented 2 months ago

What happened?

连接ClickHouse集群上的某个节点后,执行基本的查询操作报错。

Affects Versions

commit:279b6ac6dc

What are you seeing the problem on?

Flink-Table-Api (SQL)

How to reproduce

No response

Relevant log output

Caused by: java.lang.NullPointerException
    at org.apache.flink.connector.clickhouse.util.ClickHouseJdbcUtil.getDistributedEngineFull(ClickHouseJdbcUtil.java:70)
    at org.apache.flink.connector.clickhouse.internal.AbstractClickHouseInputFormat$Builder.build(AbstractClickHouseInputFormat.java:208)
进入查看后发现是:
 String engineFull = rs.getString("engine_full").replaceAll("'|\\s", "");
                    Matcher matcher = DISTRIBUTED_TABLE_ENGINE_PATTERN.matcher(engineFull);
                    String cluster;
                    if (matcher.find()) {
                        cluster = matcher.group("cluster");
                        String database = matcher.group("database");
                        String table = matcher.group("table");
                        String shardingKey = matcher.group("shardingKey");
                        DistributedEngineFull var13 = DistributedEngineFull.of(cluster, database, table, ClickHouseUtil.parseShardingKey(shardingKey), (String)null);
                        return var13;
                    }

                    cluster = null;
                    return cluster;这里的cluster被赋值为null,但手动执行查询语句获得的结果是没有问题的SELECT engine_full FROM system.tables WHERE database = ? AND name = ?

Anything else

No response

Are you willing to submit a PR?

Code of Conduct

qingfei1994 commented 2 months ago

试一下用最新的master分支跑一遍? 如果还是不行,发一下SELECT engine_full FROM system.tables WHERE database = ? AND name = ?的输出结果

itinycheng commented 2 months ago

@jackj-ohn1

报错说是第70行空指针,看下是不是url配置的问题,connection为空导致的,代码截图: image

czy006 commented 2 months ago

cc @qingfei1994