Repository navigation
Description
Describe the bug
According to the documentation, underscore is a valid character in a column name:
Non-quoted identifiers must match the regex ^[a-zA-Z_][0-9a-zA-Z_]*$ and can not be equal to [keywords](https://clickhouse.com/docs/en/sql-reference/syntax#keywords). Examples: x, _1, X_y__Z123_.
But when I try to register an POJO for a table in the Java client-v2, an error occurs for any column that contains an underscore in the name:
Exception in thread "main" java.lang.IllegalArgumentException: No serializer found for column 'ORA_ROW_ID'. Did you forget to register it?
at com.clickhouse.client.api.Client.insert(Client.java:1178)
at com.clickhouse.client.api.Client.insert(Client.java:1124)
at solutions.a2.oracle.expimp.pipe.DtoTest.main(DtoTest.java:84)
Steps to reproduce
- Create project with Java client-v2, i.e. for Gradle add dependency:
def clickHouseVersion = "0.7.0"
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client
implementation("com.clickhouse:client-v2:$clickHouseVersion")
- Create table
CREATE TABLE TEST4CH(
ORA_ROW_ID String,
OWNER String,
NAME String,
TYPE String,
LINE UInt32,
TEXT String,
ORIGIN_CON_ID Nullable(UInt32)) engine = MergeTree order by ();
- Try to register POJO for this table and then insert to this table
Expected behaviour
Successful execution
Code example
client.register(dynamicClass, client.getTableSchema("TEST4CH"));
InsertSettings settings = new InsertSettings().compressClientRequest(true);
try (InsertResponse response = client.insert("TEST4CH", list).get()) {
System.out.println("rows written=" + response.getWrittenRows());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
client.close();
Error log
6:50:01,415 INFO main Client:build:886 - Using server timezone: UTC
06:50:01,712 INFO main Client:poolConnectionManager:201 - Connection reuse strategy: FIFO
06:50:01,745 INFO main Client::110 - client compression: true, server compression: true, http compression: false
06:50:01,746 INFO main Client::168 - Using new http client implementation
06:50:03,499 WARN main Client:register:1087 - No getter method found for column: orarowid
06:50:03,499 WARN main Client:register:1095 - No setter method found for column: orarowid
06:50:03,509 WARN main Client:register:1087 - No getter method found for column: originconid
06:50:03,509 WARN main Client:register:1095 - No setter method found for column: originconid
Exception in thread "main" java.lang.IllegalArgumentException: No serializer found for column 'ORA_ROW_ID'. Did you forget to register it?
at com.clickhouse.client.api.Client.insert(Client.java:1178)
at com.clickhouse.client.api.Client.insert(Client.java:1124)
at solutions.a2.oracle.expimp.pipe.DtoTest.main(DtoTest.java:84)
Configuration
Environment
- Client version: 0.7.0
- Language version: N/A
- OS: Linux
ClickHouse server
24.6.2
CREATE TABLEstatements for tables involved:
CREATE TABLE TEST4CH(
ORA_ROW_ID String,
OWNER String,
NAME String,
TYPE String,
LINE UInt32,
TEXT String,
ORIGIN_CON_ID Nullable(UInt32)) engine = MergeTree order by ();
Activity
averemee-si commentedon Oct 11, 2024
Proposed PR - register(): make underscore legal in column name
chernser commentedon Oct 11, 2024
@averemee-si thank you for reporting the issue!
Would you please give us an example of your POJO?
If it doesn't have getters please let us know.
Thank you!
averemee-si commentedon Oct 11, 2024
Sergey,
I'm not using a static POJO because we need to build a bootstrapped Oracle database with thousands of tables, each table with up to five hundred columns, and each name with an underscore. Due to these limitations, we use dynamic construction of the POJO
Thanks/ Заранее признателен!
Aleksei
chernser commentedon Oct 15, 2024
@averemee-si Thank you for explaining!
This is fine - I will think on the solution to make it more general. Something like settings where exact mapping or strategy can be passed. Hopefully this week I can provide the solution.
chernser commentedon Oct 22, 2024
Good day, @averemee-si!
Have you a chance to test the nightly build?
Thanks!
averemee-si commentedon Oct 22, 2024
Hi Sergey,
Thanks for the update.
I'll check it tomorrow.
Regards,
Aleksei
averemee-si commentedon Oct 23, 2024
Hi Sergey,
I started checking and realized that I can't download the nightly build. Please tell me where I can find it.
Thanks.
Regards,
Aleksei
chernser commentedon Oct 23, 2024
@averemee-si here is a gist with instructions https://gist.github.com/chernser/b4eacfde70093847449e3aef8e51ae8e
averemee-si commentedon Oct 23, 2024
Thanks!
Cool.
Tested with build 20241022-155731-21
Regards,
Aleksei
chernser commentedon Oct 23, 2024
@averemee-si
Does it resolve the issue?
averemee-si commentedon Oct 23, 2024
Yes, thanks.
that's what Cool meant
Regards,
Aleksei