lokesh-lingarajan commented on a change in pull request #11630:
URL: https://github.com/apache/druid/pull/11630#discussion_r721680961



##########
File path: 
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/data/input/kafkainput/KafkaStringHeaderFormat.java
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.kafkainput;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.kafka.common.header.Headers;
+
+import javax.annotation.Nullable;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+
+public class KafkaStringHeaderFormat implements KafkaHeaderFormat
+{
+  private final Charset encoding;
+
+  public KafkaStringHeaderFormat(
+      @JsonProperty("encoding") @Nullable String encoding

Review comment:
       done

##########
File path: docs/ingestion/data-formats.md
##########
@@ -151,6 +151,57 @@ Be sure to change the `delimiter` to the appropriate 
delimiter for your data. Li
 }
 ```
 
+### KAFKA
+
+The `inputFormat` to load complete kafka record including header, key and 
value. An example is:
+
+```json
+"ioConfig": {
+  "inputFormat": {
+      "type": "kafka",
+      "headerLabelPrefix": "kafka.header.",
+      "timestampColumnName": "kafka.timestamp",
+      "keyColumnName": "kafka.key",
+      "headerFormat":
+      {
+        "type": "string"
+      },
+      "keyFormat":
+      {
+        "type": "json"
+      },
+      "valueFormat":
+      {
+        "type": "json"
+      }
+  },
+  ...
+}
+```
+
+The KAFKA `inputFormat` has the following components:
+
+| Field | Type | Description | Required |
+|-------|------|-------------|----------|
+| type | String | This should say `kafka`. | yes |
+| headerLabelPrefix | String | A custom label prefix for all the header 
columns. | no (default = "kafka.header.") |
+| timestampColumnName | String | Specifies the name of the column for the 
kafka record's timestamp.| no (default = "kafka.timestamp") |
+| keyColumnName | String | Specifies the name of the column for the kafka 
record's key.| no (default = "kafka.key") |
+| headerFormat | Object | headerFormat specifies how to parse the kafka 
headers. Current supported type is "string". | no |
+| keyFormat | [InputFormat](#input-format) | keyFormat can be any existing 
inputFormat to parse the kafka key. The current behavior is to only process the 
first entry of the input format. See [the below 
section](../development/extensions-core/kafka-ingestion.md#specifying-data-format)
 for details about specifying the input format. | no |
+| valueFormat | [InputFormat](#input-format) | valueFormat can be any existing 
inputFormat to parse the kafka value payload. See [the below 
section](../development/extensions-core/kafka-ingestion.md#specifying-data-format)
 for details about specifying the input format. | yes |
+
+```
+> For any conflicts in dimension/metric names, this inputFormat will prefer 
kafka value's column names.
+> This will enable seemless porting of existing kafka ingestion inputFormat to 
this new format, with additional columns from kafka header and key.
+
+> Kafka input format fundamentally blends information from header, key and 
value portions of a kafka record to create a druid row. It does this by 
+> exploding individual records from the value and augmenting each of these 
values with the selected key/header columns.
+
+> Kafka input format also by default exposes kafka timestamp 
(timestampColumnName), which can be used as the primary timestamp column. 
+> One can also choose timestamp column from either key or value payload, if 
there is no timestamp available then the default kafka timestamp is our savior.

Review comment:
       agreed.




-- 
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]

Reply via email to