[ https://issues.apache.org/jira/browse/KAFKA-6684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16458568#comment-16458568 ]
Amit Sela commented on KAFKA-6684: ---------------------------------- For Connect, it looks like supported logical types have to/fromLogical and schema builder "helpers" - {{org.apache.kafka.connect.data.Date, Decimal, Timestamp, Time}}. My PR suggests to cast to string by simply delegating to Java's {{toString()}} natively on the "logical" form of the data (result of {{toLogical()}}), so if SimpleHeaderConverter uses the same "helpers", they can do the same without a need to re-implement anything really, no? Would it make it easier to have a {{LogicalType}} abstract class? like I mentioned in my PR, Java's {{toString()}} for {{Date}} is not great (not UTC!) but it doesn't feel like the {{Cast}} class is the place for formatting dates, but {{Date}} is actually. [~ewencp] WDYT? > Support casting values with bytes schema to string > --------------------------------------------------- > > Key: KAFKA-6684 > URL: https://issues.apache.org/jira/browse/KAFKA-6684 > Project: Kafka > Issue Type: Improvement > Components: KafkaConnect > Reporter: Amit Sela > Priority: Critical > Fix For: 2.0.0 > > > Casting from BYTES is not supported, which means that casting LogicalTypes is > not supported. > This proposes to allow casting anything to a string, kind of like Java's > {{toString()}}, such that if the object is actually a LogicalType it can be > "serialized" as string instead of bytes+schema. > > {noformat} > Examples: > BigDecimal will cast to the string representation of the number. > Timestamp will cast to the string representation of the timestamp, or maybe > UTC yyyymmddTHH:MM:SS.f format? > {noformat} > > Worst case, bytes are "casted" to whatever the {{toString()}} returns - its > up to the user to know the data. > This would help when using a JSON sink, or anything that's not Avro. -- This message was sent by Atlassian JIRA (v7.6.3#76005)