Decimal Columns Appear as Strings When Replicating from HVR to Apache Kafka
Issue
When replicating decimal columns to Apache Kafka, the values appear as strings, such as ixgh, rather than as numeric values in the target Kafka topic.
Environment
- HVR6
- Target: Kafka
Resolution
You can resolve this issue in one of the following ways:
Option 1: With Schema Registry (recommended)
- In HVR, set the location property
Schema_Registry_Format=JSON. - Remove the FileFormat action. By default, HVR will then publish values encoded according to Schema Registry requirements.
- (Optional) In Kafka, verify the topic contents using the
kafka-json-schema-console-consumerutility. The output should contain decoded, human-readable JSON that you can consume directly without additional parsing.
Option 2: Without Schema Registry (not recommended)
- In HVR, remove the FileFormat action. This restores the default HVR JSON behavior (
SCHEMA_PAYLOAD). - On the consumer side, parse the payload according to the schema. Depending on your consumer implementation, you must either:
- Use the Kafka Connect library to parse the payload, or
- Implement custom parsing logic.
We don't recommend this approach because the schema is included with every message, which is inefficient.
Cause
Kafka Connect represents decimals using two components:
- The unscaled value, stored as a BigInteger in binary form.
- The scale, defined in the schema and representing the number of digits after the decimal point.
The numeric value is split across the payload and the schema, so reconstructing decimal values requires schema awareness provided by Schema Registry or consumer-side processing. Without this, the value appears as a string.