zhangshenghang opened a new pull request, #12786: URL: https://github.com/apache/seatunnel/pull/12786
### Purpose of this pull request The Tablestore sink fails with a `ClassCastException` on the first row for most numeric column types. `DefaultSeaTunnelRowSerializer` converts row values with direct casts that do not match the Java types SeaTunnel actually puts in the row: ```java // convertColumn, INTEGER case — reached for INT, TINYINT, SMALLINT, BIGINT columns ColumnValue.fromLong((long) value); // (long) on Object compiles to checkcast Long // convertColumn, DOUBLE case — reached for FLOAT, DOUBLE, DECIMAL columns ColumnValue.fromDouble((Double) value); // checkcast Double // convertPrimaryKeyColumn, INTEGER case — reached for integer primary keys PrimaryKeyValue.fromLong((long) value); ``` SeaTunnel rows carry `Integer`/`Byte`/`Short` for INT/TINYINT/SMALLINT and `Float`/`BigDecimal` for FLOAT/DECIMAL, and a `checkcast` to `Long`/`Double` rejects those types, so: - any table with an `int`, `tinyint`, or `smallint` column → `ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long` on the first row; - any table with a `float` or `decimal` column → `ClassCastException` (`Float`/`BigDecimal` cannot be cast to `Double`); - an `int` primary key fails the same way. Only `bigint` and `double` columns ever worked, although `convertColumnType` explicitly maps INT/TINYINT/SMALLINT → INTEGER and FLOAT/DECIMAL → DOUBLE (i.e. these types are supposed to be supported). The fix converts through `Number` (`((Number) value).longValue()` / `.doubleValue()`), which handles `Byte`, `Short`, `Integer`, `Long`, `Float`, `Double` and `BigDecimal` uniformly. ### Does this PR introduce _any_ user-facing change? No API/config change. Behaviour change: tables containing `int`/`tinyint`/`smallint`/`float`/`decimal` columns (or integer primary keys) can now be written instead of failing with `ClassCastException` on the first row. ### How was this patch tested? Added `DefaultSeaTunnelRowSerializerTest`: integer-family columns (`tinyint`/`smallint`/`int`/`bigint`), floating-point columns (`float`/`double`/`decimal`), an `int` primary key, plus string/boolean/binary baseline cases and the configured table name. Verified against the pre-fix code that the integer/floating-point/primary-key tests fail with exactly the reported `ClassCastException`s and pass after the fix. Full module suite passes: `connector-tablestore` — 14 tests, 0 failures. `spotless:check` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
