Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Risingwavelabs Risingwave DatetimeTypeConverter

From Leeroopedia
Revision as of 16:31, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Risingwavelabs_Risingwave_DatetimeTypeConverter.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Property Value
Component CDC Source - Debezium Converters
Language Java
Lines 71
License Apache 2.0
Repository risingwavelabs/risingwave

Overview

DatetimeTypeConverter is a custom Debezium type converter that transforms DATE column values from their internal epoch-day representation into ISO-formatted date strings (yyyy-MM-dd). RisingWave expects DATE type values in JSON CDC payloads to be human-readable strings rather than raw numeric epoch days. This converter is registered with the Debezium engine so that any DATE column encountered during CDC capture is automatically converted to the expected string format before being passed to RisingWave's Debezium JSON parser.

The class implements the Debezium CustomConverter<SchemaBuilder, RelationalColumn> interface, which provides a pluggable mechanism for overriding default type conversions in the CDC pipeline.

Code Reference

Source Location

java/connector-node/risingwave-source-cdc/src/main/java/com/risingwave/connector/cdc/debezium/converters/DatetimeTypeConverter.java

View on GitHub

Signature

public class DatetimeTypeConverter implements CustomConverter<SchemaBuilder, RelationalColumn>

Key Methods

// Configures the date formatter to use "yyyy-MM-dd" pattern
@Override
public void configure(Properties props)

// Registers the converter for DATE columns with an optional string schema
@Override
public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBuilder> registration)

// Converts an epoch-day input to a formatted date string
private String convertDate(Object input)

Imports

import io.debezium.spi.converter.CustomConverter;
import io.debezium.spi.converter.RelationalColumn;
import io.debezium.time.Date;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Properties;
import org.apache.kafka.connect.data.SchemaBuilder;

I/O Contract

Input

  • Column metadata: A RelationalColumn describing the database column type. The converter activates only when column.typeName() equals "DATE" (case-insensitive).
  • Raw value: An Object representing the date value in epoch-day format (integer number of days since epoch), as provided by the Debezium Date utility class.

Output

  • Converted value: A String in "yyyy-MM-dd" format (e.g., "1988-05-04"), or null if the input is null.
  • Schema: An optional string schema named "rw.cdc.date.string", registered with the Debezium converter framework.

Side Effects

None. This converter is stateless and performs pure value transformation.

Usage Examples

Registering the Converter with Debezium

The converter is typically registered in the Debezium connector configuration properties:

// In Debezium engine configuration
props.put("converters", "datetime");
props.put("datetime.type", "com.risingwave.connector.cdc.debezium.converters.DatetimeTypeConverter");

Manual Conversion (from built-in main method)

var converter = new DatetimeTypeConverter();
// null input returns null
converter.convertDate(null);        // -> null
// LocalDate input
converter.convertDate(LocalDate.of(1988, 5, 4));  // -> "1988-05-04"
// Integer epoch day
converter.convertDate(8989);        // -> "1994-08-10"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment