You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently in the KafkaSteps class, when we try to map a date like 2024-09-16, we encounter some troubles because of the avro type.
In fact, when we have a date, we have this kind of Avro schema: { "default": null, "name": "my_date", "type": [ "null", { "logicalType": "date", "type": "int" } ] }
But because, the type is considered as an UNION, the parseAvro method doesn't transform the value in an Integer.
What I suggest is to modify the method like this to cover this situation:
@Nullable
private Object parseAvro(String value, Schema valueSchema) {
return switch (valueSchema.getType()) {
case INT -> {
if("date".equals(valueSchema.getProp("logicalType"))) {
yield (int) LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE).toEpochDay();
} else {
yield Integer.parseInt(value);
}
}
case LONG -> Long.parseLong(value);
case FLOAT -> Float.parseFloat(value);
case DOUBLE -> Double.parseDouble(value);
case BOOLEAN -> Boolean.parseBoolean(value);
default -> value;
};
}
The text was updated successfully, but these errors were encountered:
The behavior you’re describing with Avro’s logicalType for dates makes sense for it to be managed
However, in this case we also need to manage the other subtypes in order to be more inclusive, such as :
• time-millis
• time-micros
• timestamp-millis
• timestamp-micros
• decimal
However, given our current priorities and other ongoing tasks, we will need to schedule this for future work. We will keep you updated in this issue.
In the meantime, feel free to fork the project and contribute 👍 !
Hello,
Currently in the KafkaSteps class, when we try to map a date like 2024-09-16, we encounter some troubles because of the avro type.
In fact, when we have a date, we have this kind of Avro schema:
{ "default": null, "name": "my_date", "type": [ "null", { "logicalType": "date", "type": "int" } ] }
But because, the type is considered as an UNION, the parseAvro method doesn't transform the value in an Integer.
What I suggest is to modify the method like this to cover this situation:
The text was updated successfully, but these errors were encountered: