This is an automated email from the ASF dual-hosted git repository.
cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new d92adc1 DRILL-8004: Splunk Sends Newlines in INT Fields, Causing
Exceptions (#2322)
d92adc1 is described below
commit d92adc106cb22a98e4b7b1dedaa350657ebf87c7
Author: Charles S. Givre <[email protected]>
AuthorDate: Sun Sep 26 14:03:45 2021 -0400
DRILL-8004: Splunk Sends Newlines in INT Fields, Causing Exceptions (#2322)
* Initial Commit'
* Addressed Formatting
---
.../apache/drill/exec/store/splunk/SplunkBatchReader.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git
a/contrib/storage-splunk/src/main/java/org/apache/drill/exec/store/splunk/SplunkBatchReader.java
b/contrib/storage-splunk/src/main/java/org/apache/drill/exec/store/splunk/SplunkBatchReader.java
index b74338c..9932801 100644
---
a/contrib/storage-splunk/src/main/java/org/apache/drill/exec/store/splunk/SplunkBatchReader.java
+++
b/contrib/storage-splunk/src/main/java/org/apache/drill/exec/store/splunk/SplunkBatchReader.java
@@ -370,7 +370,17 @@ public class SplunkBatchReader implements
ManagedReader<SchemaNegotiator> {
@Override
public void load(String[] record) {
if (record[columnIndex] != null) {
- int value = Integer.parseInt(record[columnIndex]);
+ // Splunk may include extra garbage such as newlines or other
whitespace in INT fields.
+ String stringValue = record[columnIndex];
+ stringValue = stringValue.replaceAll("\\s", "");
+
+ int value;
+ try {
+ value = Integer.parseInt(stringValue);
+ } catch (NumberFormatException e) {
+ // If we still can't parse the INT field, for whatever reason, set
value to -1
+ value = -1;
+ }
columnWriter.setInt(value);
} else {
columnWriter.setNull();