Class CustomPostgresValueConverter
- java.lang.Object
-
- io.debezium.jdbc.JdbcValueConverters
-
- io.debezium.connector.postgresql.PostgresValueConverter
-
- io.debezium.connector.postgresql.CustomPostgresValueConverter
-
- All Implemented Interfaces:
io.debezium.relational.ValueConverterProvider
public class CustomPostgresValueConverter extends io.debezium.connector.postgresql.PostgresValueConverterAPostgresValueConverterwhich is able to keep the date and time (wall clock) stored in PostgreSQL fortimestampvalues, instead of letting the time zone of the JVM shift them.This behavior is only enabled by
PostgresSourceOptions.SCAN_PRE_EPOCH_TIMESTAMP_WALL_CLOCK_CONVERSION_ENABLED, otherwise the conversion of the parent implementation is kept. Onlytimestamp(without time zone) values are affected, timestamp values with time zone always use the parent implementation, and the schema of the converted values is never changed. The constructor and factory mirror the Debezium implementation and must remain aligned with it when the Debezium version changes.
-
-
Field Summary
-
Fields inherited from class io.debezium.connector.postgresql.PostgresValueConverter
N_A_N, NEGATIVE_INFINITY, NEGATIVE_INFINITY_DATE, NEGATIVE_INFINITY_INSTANT, NEGATIVE_INFINITY_LOCAL_DATE, NEGATIVE_INFINITY_LOCAL_DATE_TIME, NEGATIVE_INFINITY_OFFSET_DATE_TIME, NEGATIVE_INFINITY_TIMESTAMP, POSITIVE_INFINITY, POSITIVE_INFINITY_DATE, POSITIVE_INFINITY_INSTANT, POSITIVE_INFINITY_LOCAL_DATE, POSITIVE_INFINITY_LOCAL_DATE_TIME, POSITIVE_INFINITY_OFFSET_DATE_TIME, POSITIVE_INFINITY_TIMESTAMP
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCustomPostgresValueConverter(Charset databaseCharset, io.debezium.jdbc.JdbcValueConverters.DecimalMode decimalMode, io.debezium.jdbc.TemporalPrecisionMode temporalPrecisionMode, java.time.ZoneOffset defaultOffset, io.debezium.jdbc.JdbcValueConverters.BigIntUnsignedMode bigIntUnsignedMode, boolean includeUnknownDatatypes, io.debezium.connector.postgresql.TypeRegistry typeRegistry, io.debezium.connector.postgresql.PostgresConnectorConfig.HStoreHandlingMode hStoreMode, io.debezium.config.CommonConnectorConfig.BinaryHandlingMode binaryMode, io.debezium.connector.postgresql.PostgresConnectorConfig.IntervalHandlingMode intervalMode, byte[] toastPlaceholder, int moneyFractionDigits, boolean wallClockConversionEnabled)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectconvertTimestampToLocalDateTime(io.debezium.relational.Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)Converts a PostgreSQLtimestamptoLocalDateTimewith the date and time (wall clock) stored in the database, ifPostgresSourceOptions.SCAN_PRE_EPOCH_TIMESTAMP_WALL_CLOCK_CONVERSION_ENABLEDis enabled.static CustomPostgresValueConverterof(io.debezium.connector.postgresql.PostgresConnectorConfig connectorConfig, Charset databaseCharset, io.debezium.connector.postgresql.TypeRegistry typeRegistry)-
Methods inherited from class io.debezium.connector.postgresql.PostgresValueConverter
convertArray, convertBinaryToBase64, convertBinaryToBytes, convertBinaryToHex, convertBit, convertBits, convertCitext, convertDecimal, converter, convertGeography, convertGeometry, convertHStore, convertInterval, convertMoney, convertPoint, convertString, convertTime, convertTimestampWithZone, convertTimeWithZone, getTimePrecision, handleUnknownData, schemaBuilder, toSpecialValue
-
Methods inherited from class io.debezium.jdbc.JdbcValueConverters
byteOrderOfBitType, convertBigInt, convertBinary, convertBits, convertBoolean, convertDateToEpochDays, convertDateToEpochDaysAsDate, convertDecimal, convertDouble, convertFloat, convertInteger, convertNumeric, convertReal, convertRowId, convertSmallInt, convertTimestampToEpochMicros, convertTimestampToEpochMillis, convertTimestampToEpochMillisAsDate, convertTimestampToEpochNanos, convertTimeToMicrosPastMidnight, convertTimeToMillisPastMidnight, convertTimeToMillisPastMidnightAsDate, convertTimeToNanosPastMidnight, convertTinyInt, convertValue, normalizeBinaryData, padLittleEndian, toBigDecimal, toByteBuffer, unexpectedBinary, withScaleAdjustedIfNeeded
-
-
-
-
Constructor Detail
-
CustomPostgresValueConverter
protected CustomPostgresValueConverter(Charset databaseCharset, io.debezium.jdbc.JdbcValueConverters.DecimalMode decimalMode, io.debezium.jdbc.TemporalPrecisionMode temporalPrecisionMode, java.time.ZoneOffset defaultOffset, io.debezium.jdbc.JdbcValueConverters.BigIntUnsignedMode bigIntUnsignedMode, boolean includeUnknownDatatypes, io.debezium.connector.postgresql.TypeRegistry typeRegistry, io.debezium.connector.postgresql.PostgresConnectorConfig.HStoreHandlingMode hStoreMode, io.debezium.config.CommonConnectorConfig.BinaryHandlingMode binaryMode, io.debezium.connector.postgresql.PostgresConnectorConfig.IntervalHandlingMode intervalMode, byte[] toastPlaceholder, int moneyFractionDigits, boolean wallClockConversionEnabled)
-
-
Method Detail
-
of
public static CustomPostgresValueConverter of(io.debezium.connector.postgresql.PostgresConnectorConfig connectorConfig, Charset databaseCharset, io.debezium.connector.postgresql.TypeRegistry typeRegistry)
-
convertTimestampToLocalDateTime
protected Object convertTimestampToLocalDateTime(io.debezium.relational.Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)
Converts a PostgreSQLtimestamptoLocalDateTimewith the date and time (wall clock) stored in the database, ifPostgresSourceOptions.SCAN_PRE_EPOCH_TIMESTAMP_WALL_CLOCK_CONVERSION_ENABLEDis enabled.The parent implementation converts through
Timestamp.toInstant(), which applies the historical offsets of the JVM default time zone and may thus shift the date and time fields of values before 1970-01-01. The column and field definitions are intentionally unused because this conversion only depends on the JDBC value.- Overrides:
convertTimestampToLocalDateTimein classio.debezium.connector.postgresql.PostgresValueConverter
-
-