haruki-830 opened a new pull request, #4416:
URL: https://github.com/apache/flink-cdc/pull/4416

   **Summary**
   
   This commit fixes the Debezium JSON serialization failure when columns have 
non-string default value expressions in the Kafka sink connector, ensuring 
type-safe default value handling during CDC synchronization operations.
   
   **Key Changes**
   
   1. Default Value Type Conversion
   
   - Added convertDefaultValue method to DebeziumJsonSerializationSchema that 
converts string default value expressions to the correct Java type matching the 
Debezium schema
   - Supports comprehensive type coverage: BOOLEAN, TINYINT, SMALLINT, INTEGER, 
BIGINT, FLOAT, DOUBLE, DECIMAL, DATE, TIME, TIMESTAMP, 
TIMESTAMP_WITH_TIME_ZONE, BINARY, VARBINARY, CHAR, VARCHAR, and 
TIMESTAMP_WITH_LOCAL_TIME_ZONE
   - Added NumberFormatException handling with WARN-level logging to gracefully 
skip unconvertible default values instead of failing
   
   2. Schema Serialization Fix
   
   - Updated convertCDCDataTypeToDebeziumDataType(Column) to invoke 
convertDefaultValue instead of directly passing the raw string expression to 
field.defaultValue()
   - Previously, passing a string default value to a non-string Debezium schema 
field would fail
   
   3. Supporting Additions
   
   - Added Logger and LoggerFactory for conversion failure logging
   - Added BigDecimal and RoundingMode imports for DECIMAL type default value 
handling
   
   4. Comprehensive Testing
   
   - Added testSerializeWithNonStringDefaultValues test covering all supported 
type conversions
   - Verifies that schema serialization with default values no longer throws 
type mismatch exceptions
   - Validates correct Debezium JSON output including default fields in the 
schema section
   
   **Before Fix**
   
   Column with INT type and default value "10" → serialization fails with type 
mismatch error
   
   **After Fix**
   
   Column with INT type and default value "10" → correctly serialized as 
"default": 10 in Debezium schema
   
   **JIRA Reference**
   
   [https://issues.apache.org/jira/browse/FLINK-39757](url)


-- 
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]

Reply via email to