tabular-io / iceberg-kafka-connect

Apache License 2.0
192 stars 41 forks source link

Record Conversion fails with column value having type `java.util.Date` #80

Closed tnweiss closed 11 months ago

tnweiss commented 11 months ago

When the source topic has a Date Column using Kafka's Date connector class

...
{
    "name": "some_date",
    "type": {
        "connector.name": "org.apache.kafka.connect.data.Date",
        "connect.version": 1,
        "logicalType": "date",
        "type": "int"
    }
},
...

the connector fails to convert the logical value (java.util.Date) into a LocalDate resulting in a RuntimeException with this message.

Cannot convert date:  Mon Dec 13 00:00:00 UTC 2021

The java.util.Date conversion case is missing from the convertDateValue method.

Adding this, on line 315, seems to resolve the issue.

    } else if (value instanceof Date) {
      return ((Date) value).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    }
bryanck commented 11 months ago

Thanks for reporting this, I'll have a fix later today.

bryanck commented 11 months ago

Here's the PR for this, which also adds it for the time conversion and adds some missing tests: https://github.com/tabular-io/iceberg-kafka-connect/pull/81

bryanck commented 11 months ago

The PR was merged, feel free to reopen if it didn't fix the issue.