ixtza commented on code in PR #92:
URL:
https://github.com/apache/doris-kafka-connector/pull/92#discussion_r3084298961
##########
src/main/java/org/apache/doris/kafka/connector/converter/RecordDescriptor.java:
##########
@@ -178,22 +202,42 @@ public RecordDescriptor build() {
Objects.requireNonNull(sinkRecord, "The sink record must be
provided.");
final boolean flattened = !isTombstone(sinkRecord) &&
isFlattened(sinkRecord);
+ final boolean keyFlattened = !keyIsTombstone(sinkRecord) &&
keyIsFlattened(sinkRecord);
readSinkRecordNonKeyData(sinkRecord, flattened);
-
- return new RecordDescriptor(
- sinkRecord, sinkRecord.topic(), nonKeyFieldNames,
allFields, flattened);
+ readSinkRecordKeyData(sinkRecord, keyFlattened);
+
+ if (keyFieldNames.isEmpty()) {
+ return new RecordDescriptor(
+ sinkRecord, sinkRecord.topic(), nonKeyFieldNames,
allFields, flattened);
+ } else {
+ return new RecordDescriptor(
+ sinkRecord,
+ sinkRecord.topic(),
+ nonKeyFieldNames,
+ keyFieldNames,
+ allFields,
+ flattened);
+ }
}
private boolean isFlattened(SinkRecord record) {
return record.valueSchema().name() == null
|| !record.valueSchema().name().contains("Envelope");
}
+ private boolean keyIsFlattened(SinkRecord record) {
+ return record.keySchema().name() == null ||
!record.keySchema().name().contains("Key");
Review Comment:
Accepted, while i am at it, i've also update the
[`isFlattened`](https://github.com/apache/doris-kafka-connector/pull/92/changes/BASE..4a1c2cee6998ca155c9f21ff1c51986e15a6f8d5#diff-c4dd57ceeaade03a9c2eb3d3a43e06210ecc11060c584a8bbe26c98bd7d0f2c3R223).
Will that be a problem @JNSimba ? Originally i though having the
[`isTombstone`](https://github.com/apache/doris-kafka-connector/pull/92/changes/BASE..4a1c2cee6998ca155c9f21ff1c51986e15a6f8d5#diff-c4dd57ceeaade03a9c2eb3d3a43e06210ecc11060c584a8bbe26c98bd7d0f2c3R238)
method is suffice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]