Class CustomPostgresValueConverter

  • All Implemented Interfaces:
    io.debezium.relational.ValueConverterProvider

    public class CustomPostgresValueConverter
    extends io.debezium.connector.postgresql.PostgresValueConverter
    A PostgresValueConverter which is able to keep the date and time (wall clock) stored in PostgreSQL for timestamp values, 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. Only timestamp (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.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class io.debezium.jdbc.JdbcValueConverters

        io.debezium.jdbc.JdbcValueConverters.BigIntUnsignedMode, io.debezium.jdbc.JdbcValueConverters.DecimalMode
    • 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
      • Fields inherited from class io.debezium.jdbc.JdbcValueConverters

        adaptiveTimeMicrosecondsPrecisionMode, adaptiveTimePrecisionMode, bigIntUnsignedMode, binaryMode, decimalMode, logger
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Object convertTimestampToLocalDateTime​(io.debezium.relational.Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)
      Converts a PostgreSQL timestamp to LocalDateTime with the date and time (wall clock) stored in the database, if PostgresSourceOptions.SCAN_PRE_EPOCH_TIMESTAMP_WALL_CLOCK_CONVERSION_ENABLED is enabled.
      static CustomPostgresValueConverter of​(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 PostgreSQL timestamp to LocalDateTime with the date and time (wall clock) stored in the database, if PostgresSourceOptions.SCAN_PRE_EPOCH_TIMESTAMP_WALL_CLOCK_CONVERSION_ENABLED is 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:
        convertTimestampToLocalDateTime in class io.debezium.connector.postgresql.PostgresValueConverter