ClickHouse / ClickHouse/clickhouse-java

POJO serializer cannot handle nested custom objects with Nested types

未关闭
#2,709 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
client-api-v2 feature-request
主要语言
Java
星标
1.6k
派生
636
平均合并
2 天 23 小时
30 天内合并 PR
29

描述

## Description

The POJO serializer cannot serialize nested custom objects when using ClickHouse `Nested` data types. It expects flattened List fields matching the flattened column names but doesn't traverse nested object graphs.

### Steps to reproduce
1. Create a POJO with a nested custom object field (e.g., `Address address`)
2. Define ClickHouse table with `Nested` type (e.g., `address Nested(street String, city String)`)
3. Attempt to insert POJO using client.insert()

See PR #2708 for complete working example.

### Error Log or Exception StackTrace

```
[main] INFO com.clickhouse.examples.client_v2.POJO2DbWriter - Table initialized. Registering class.
[main] WARN com.clickhouse.client.api.serde.POJOSerDe - No getter method found for column: addressstreet
[main] WARN com.clickhouse.client.api.serde.POJOSerDe - No setter method found for column: addressstreet
[main] WARN com.clickhouse.client.api.serde.POJOSerDe - No getter method found for column: addresscity
[main] WARN com.clickhouse.client.api.serde.POJOSerDe - No setter method found for column: addresscity
Exception in thread "main" java.lang.IllegalArgumentException: No serializer found for column 'address.street'. Did you forget to register it?
at com.clickhouse.client.api.Client.insert(Client.java:1238)
at com.clickhouse.examples.client_v2.POJO2DbWriter.flush(POJO2DbWriter.java:94)
at com.clickhouse.examples.client_v2.POJO2DbWriter.submit(POJO2DbWriter.java:89)
at com.clickhouse.examples.client_v2.Main.main(Main.java:59)
```

### Expected Behaviour

POJO serializer should traverse nested object graphs and call `getAddress().getStreet()` when encountering nested custom objects.

### Configuration

#### Environment
* Client version: main branch
* Language version: Java 17
* OS: macOS

#### ClickHouse Server
* ClickHouse Server version: latest (Docker image)

贡献指南

打开贡献指南

调研方向

从 com.clickhouse.client.api.serde.POJOSerDe 开始,并使用 stack trace 中显示的 POJO2DbWriter 插入路径重现 PR #2708 中描述的情况。当包含 Address 对象的 POJO 可以插入 Nested address 列,且不会出现缺少 getter 或 serializer 的错误时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。