DBZ-1498 Docs added; microseconds changed to numeric; nanos supported

This commit is contained in:
Jiri Pechanec 2019-10-09 06:39:18 +02:00 committed by Gunnar Morling
parent 20363f24bb
commit cf7eccb152
4 changed files with 19 additions and 8 deletions

View File

@ -120,7 +120,7 @@ public enum IntervalHandlingMode implements EnumeratedValue {
/**
* Represents interval as inexact microseconds count
*/
MICROSECONDS("microseconds"),
NUMERIC("numeric"),
/**
* Represents interval as ISO 8601 time interval
@ -770,12 +770,12 @@ public static SchemaRefreshMode parse(String value) {
public static final Field INTERVAL_HANDLING_MODE = Field.create("interval.handling.mode")
.withDisplayName("Interval Handling")
.withEnum(IntervalHandlingMode.class, IntervalHandlingMode.MICROSECONDS)
.withEnum(IntervalHandlingMode.class, IntervalHandlingMode.NUMERIC)
.withWidth(Width.MEDIUM)
.withImportance(Importance.LOW)
.withDescription("Specify how INTERVAL columns should be represented in change events, including:"
+ "'string' represents values as exact ISO formatted string"
+ "'microseconds' (default) represents values using inexact conversion into microseconds");
+ "'string' represents values as an exact ISO formatted string"
+ "'numeric' (default) represents values using the inexact conversion into microseconds");
public static final Field STATUS_UPDATE_INTERVAL_MS = Field.create("status.update.interval.ms")
.withDisplayName("Status update interval (ms)")

View File

@ -588,7 +588,7 @@ protected List<SchemaAndValueField> schemaAndValuesForDateTimeTypes() {
protected List<SchemaAndValueField> schemaAndValuesForIntervalAsString() {
//1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds, 78000 ms
final String expectedInterval = "P1Y2M3DT4H5M" + 6.78 + "S";
final String expectedInterval = "P1Y2M3DT4H5M6.78S";
return Arrays.asList(
new SchemaAndValueField("it", Interval.builder().optional().build(), expectedInterval)
);

View File

@ -69,8 +69,8 @@ private Interval() {
*/
public static String toIsoString(int years, int months, int days, int hours, int minutes, BigDecimal seconds) {
// ISO pattern - PnYnMnDTnHnMnS
if (seconds.scale() > 6) {
seconds = seconds.setScale(6, RoundingMode.DOWN);
if (seconds.scale() > 9) {
seconds = seconds.setScale(9, RoundingMode.DOWN);
}
return "P" + years + "Y" + months + "M" + days + "D" + "T" + hours + "H" + minutes + "M" + seconds.stripTrailingZeros().toPlainString() + "S";
}

View File

@ -913,9 +913,16 @@ The _semantic type_ describes how the Kafka Connect schema captures the _meaning
|`INTERVAL [P]`
|`INT64`
|`io.debezium.time.MicroDuration`
|`io.debezium.time.MicroDuration` +
(default)
|The approximate number of microseconds for a time interval using the `365.25 / 12.0` formula for days per month average
|`INTERVAL [P]`
|`String`
|`io.debezium.time.Interval` +
(when `interval.handling.mode` is set to `string`)
|The string representation of the interval value that follows pattern `P<years>Y<months>M<days>DT<hours>H<minutes>M<seconds>S`
|`BYTEA`
|`BYTES`
|n/a
@ -1530,6 +1537,10 @@ Debezium will instead use the publication as defined.
|`map`
| Specifies how the connector should handle values for `hstore` columns: `map` (the default) represents using `MAP`; or `json` represents them using `json string`.`json` option encodes values as formatted string such as `{"key" : "val"}`. See <<hstore-values>>.
|`interval.handling.mode`
|`numeric`
| Specifies how the connector should handle values for `interval` columns: `numeric` (the default) represents interval using approximate number of microseconds; `string` represents them using exact string pattern representation `P<years>Y<months>M<days>DT<hours>H<minutes>M<seconds>S`. See <<data-types>>.
|`database.sslmode`
|`disable`
|Whether to use an encrypted connection to the PostgreSQL server. Options include: *disable* (the default) to use an unencrypted connection ; *require* to use a secure (encrypted) connection, and fail if one cannot be established; *verify-ca* like `require` but additionally verify the server TLS certificate against the configured Certificate Authority (CA) certificates, or fail if no valid matching CA certificates are found; *verify-full* like `verify-ca` but additionally verify that the server certificate matches the host to which the connection is attempted. See https://www.postgresql.org/docs/current/static/libpq-connect.html[the PostgreSQL documentation] for more information.