Hi,
I have a question that is explained also in this SO thread:
I have an Avro schema with a logicaltype timestamp-millis:
{
"name": "wardId",
"type": "long"
},
{
"name": "date",
"type": {
"type": "long",
"connect.version": 1,
"connect.name": "org.apache.kafka.connect.data.Timestamp",
"logicalType": "timestamp-millis"
}
}
]
}
When I try to convert the GenericRecord to the associated schema throws an error that cannot convert Long to Instant:
@Override
public void init(ProcessorContext processorContext) {
}
@Override
public EventPatientLocation transform(final GenericRecord eventLocation) {
EventPatientLocation patientLocation = new EventPatientLocation();
Schema schema = eventLocation.getSchema();
/*if (EventPatientPlanned.getClassSchema().equals(schema)) {
EventPatientPlanned patientPlanned = (EventPatientPlanned) SpecificData.get().deepCopy(EventPatientPlanned.SCHEMA$, eventLocation);
patientLocation.setPatientId(patientPlanned.getPatientId());
patientLocation.setWardId(patientPlanned.getWardId());
patientLocation.setEpisodeOfCareId(patientPlanned.getEpisodeOfCareId());
patientLocation.setDate(patientPlanned.getDate());
patientLocation.setStatus(EncounterStatus.PLANNED);
} else
*/
if (EventPatientCheckedIn.getClassSchema().equals(schema)) {
EventPatientCheckedIn patientCheckedIn = (EventPatientCheckedIn) SpecificData.get().deepCopy(EventPatientCheckedIn.SCHEMA$, eventLocation);
Anyone has find a good solution to solve this problem?
Thanks,
Pietro
Not really. I tried using the decimal logical type about 5 years ago. But it took a lot of effort to get it properly working + you could not easily get the value. In this case it probably a lot easier to just use the long primitive.