Conversation
|
mohamed.hanchi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
@HanchiMed |
|
@HanchiMed |
|
@HanchiMed |
|
Hello @chernser The tests were added. Regards |
|
@HanchiMed Thanks! |
|
@chernser Regards |
|
@HanchiMed Thank you! |
Description
Steps to reproduce
create a Clickhouse table with columns :
create table test
(
numliv UInt32,
cdc_changesequence UInt128
)
ENGINE = SharedReplacingMergeTree(cdc_changesequence)
ORDER BY (numliv)
create à PutDatabaseRecord on Nifi
Insert json with column cdc_changesequence filled by a BigInt
{"numliv" : 54878 , "cdc_changesequence " : 20260219145041580000000000403034229 }
Error Log or Exception StackTrace
Failed to put Records to database for FlowFile[filename=c797411d-7c71-4403-9f92-e204c26849a2]. Routing to failure.: java.io.IOException: Unable to setObject() with value 20260219145041580000000000403034240 at index 208 of type 1111
Caused by: java.sql.SQLException: Cannot convert OTHER to a ClickHouse one. Consider using java.sql.JDBCType or com.clickhouse.data.ClickHouseDataType
Expected Behaviour
Insertion is functionnal in case of cdc_changesequence is typed as String or BigInt
cdc_changesequence as BigInt
{"numliv" : 54878 , "cdc_changesequence " : 20260219145041580000000000403034229 }
cdc_changesequence as BigInt
{"numliv" : 54878 , "cdc_changesequence " : "20260219145041580000000000403034229" }
Code Example
com.clickhouse.jdbc.JdbcTypeMapping:
public int toSqlType : .......
case UInt64:
case Int128:
case UInt128:
case Int256:
case UInt256:
sqlType = Types.NUMERIC;
break;
com.clickhouse.jdbc.internal.JdbcUtils:
private static Map<ClickHouseDataType, SQLType> generateTypeMap() { ...........
map.put(ClickHouseDataType.Int128, JDBCType.NUMERIC);
map.put(ClickHouseDataType.Int256, JDBCType.NUMERIC);
map.put(ClickHouseDataType.UInt64, JDBCType.NUMERIC);
map.put(ClickHouseDataType.UInt128, JDBCType.NUMERIC);
map.put(ClickHouseDataType.UInt256, JDBCType.NUMERIC);
Note
Medium Risk
Changes JDBC type/class mappings for large integer ClickHouse types, which can affect
ResultSetMetaDataandsetObject/getObjectbehavior for existing consumers expectingOTHER/BigDecimal. Scope is limited to type mapping and conversion paths and is covered by new unit/integration tests.Overview
Fixes large-integer handling by mapping ClickHouse
UInt64/Int128/UInt128/Int256/UInt256to JDBCNUMERICand JavaBigInteger(instead ofOTHERorDECIMAL) in both the legacyJdbcTypeMappingandjdbc-v2JdbcUtils.Updates
jdbc-v2conversion to supportBigIntegervalues and adjustsSQL_TYPE_TO_CLASS_MAPsoNUMERICresolves toBigInteger. Adds new unit tests for the mappings and a new integration test that validates inserts (including nullable columns),ResultSetMetaDatatypes/class names, andgetObject(..., BigInteger.class)for these columns.Written by Cursor Bugbot for commit 3cd682e. This will update automatically on new commits. Configure here.