From 91059cdf5bbf2d4adaae68830c74e744c40ed683 Mon Sep 17 00:00:00 2001 From: Jack Luo Date: Wed, 20 Nov 2024 04:55:21 +0800 Subject: [PATCH] Retain boolean type from CLPLogRecordExtractor decoder. --- .../inputformat/clplog/CLPLogRecordExtractor.java | 11 +++++++++++ .../inputformat/clplog/CLPLogRecordExtractorTest.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/pinot-plugins/pinot-input-format/pinot-clp-log/src/main/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractor.java b/pinot-plugins/pinot-input-format/pinot-clp-log/src/main/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractor.java index 16ca7749ba41..764a03d537df 100644 --- a/pinot-plugins/pinot-input-format/pinot-clp-log/src/main/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractor.java +++ b/pinot-plugins/pinot-input-format/pinot-clp-log/src/main/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractor.java @@ -129,6 +129,17 @@ public GenericRow extract(Map from, GenericRow to) { return to; } + /** + * In addition to the basic conversion, we also needs to retain the type info of Boolean input. + */ + @Override + protected Object convertSingleValue(Object value) { + if (value instanceof Boolean) { + return value; + } + return super.convertSingleValue(value); + } + /** * Encodes a field with CLP *

diff --git a/pinot-plugins/pinot-input-format/pinot-clp-log/src/test/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractorTest.java b/pinot-plugins/pinot-input-format/pinot-clp-log/src/test/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractorTest.java index 72058be3451e..0ad198fe1839 100644 --- a/pinot-plugins/pinot-input-format/pinot-clp-log/src/test/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractorTest.java +++ b/pinot-plugins/pinot-input-format/pinot-clp-log/src/test/java/org/apache/pinot/plugin/inputformat/clplog/CLPLogRecordExtractorTest.java @@ -43,6 +43,8 @@ public class CLPLogRecordExtractorTest { private static final int _TIMESTAMP_FIELD_VALUE = 10; private static final String _LEVEL_FIELD_NAME = "level"; private static final String _LEVEL_FIELD_VALUE = "INFO"; + private static final String _BOOLEAN_FIELD_NAME = "booleanField"; + private static final boolean _BOOLEAN_FIELD_VALUE = true; private static final String _MESSAGE_1_FIELD_NAME = "message1"; private static final String _MESSAGE_1_FIELD_VALUE = "Started job_123 on node-987: 4 cores, 8 threads and " + "51.4% memory used."; @@ -105,6 +107,7 @@ public void testBadCLPEncodingConfig() { row = extract(props, null); assertEquals(row.getValue(_TIMESTAMP_FIELD_NAME), _TIMESTAMP_FIELD_VALUE); assertEquals(row.getValue(_LEVEL_FIELD_NAME), _LEVEL_FIELD_VALUE); + assertEquals(row.getValue(_BOOLEAN_FIELD_NAME), _BOOLEAN_FIELD_VALUE); validateClpEncodedField(row, _MESSAGE_1_FIELD_NAME, _MESSAGE_1_FIELD_VALUE); validateClpEncodedField(row, _MESSAGE_2_FIELD_NAME, _MESSAGE_2_FIELD_VALUE); } @@ -153,6 +156,7 @@ private GenericRow extract(Map props, Set fieldsToRead) record.put(_MESSAGE_1_FIELD_NAME, _MESSAGE_1_FIELD_VALUE); record.put(_MESSAGE_2_FIELD_NAME, _MESSAGE_2_FIELD_VALUE); record.put(_LEVEL_FIELD_NAME, _LEVEL_FIELD_VALUE); + record.put(_BOOLEAN_FIELD_NAME, _BOOLEAN_FIELD_VALUE); GenericRow row = new GenericRow(); extractor.extract(record, row);