This is an automated email from the ASF dual-hosted git repository.
timothyfarkas 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 2b5b759 DRILL-6706: fixed null pointer exception in HashJoin
2b5b759 is described below
commit 2b5b75965ae02e8d2f3c10b956198e43987776ce
Author: Salim Achouche <[email protected]>
AuthorDate: Sat Aug 25 18:52:46 2018 -0700
DRILL-6706: fixed null pointer exception in HashJoin
closes #1445
---
.../apache/drill/exec/record/RecordBatchSizer.java | 96 +++++++++++++++++++++-
1 file changed, 94 insertions(+), 2 deletions(-)
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchSizer.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchSizer.java
index caea5f2..c89d512 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchSizer.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchSizer.java
@@ -20,8 +20,8 @@ package org.apache.drill.exec.record;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import java.util.Collection;
import java.util.Map;
-
import org.apache.drill.common.map.CaseInsensitiveMap;
import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.types.TypeProtos.DataMode;
@@ -633,7 +633,7 @@ public class RecordBatchSizer {
// This keeps information for only top level columns. Information for nested
// columns can be obtained from children of topColumns.
- private Map<String, ColumnSize> columnSizes =
CaseInsensitiveMap.newHashMap();
+ private Map<String, ColumnSize> columnSizes = new
QuoteInsensitiveMap(CaseInsensitiveMap.newHashMap());
/**
* This field is used by the convenience method {@link #columnsList()}.
@@ -963,4 +963,96 @@ public class RecordBatchSizer {
colSize.allocateVector(w.getValueVector(), recordCount);
}
}
+
+ /**
+ * A map that can handle quoted and unquoted column names; ideally this
logic temporary and
+ * should be removed as soon as all readers standardize handling of missing
columns. Quoted columns
+ * have been added in DRILL-4264.
+ */
+ private static final class QuoteInsensitiveMap implements Map<String,
ColumnSize> {
+ /** Original Map */
+ private final Map<String, ColumnSize> originalMap;
+
+ private QuoteInsensitiveMap(Map<String, ColumnSize> originalMap) {
+ this.originalMap = originalMap;
+ }
+
+ @Override
+ public int size() {
+ return originalMap.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return originalMap.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return originalMap.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return originalMap.containsValue(value);
+ }
+
+ @Override
+ public ColumnSize get(Object key) {
+ ColumnSize value = originalMap.get(key);
+
+ if (value == null) {
+ value = originalMap.get(quoteString(key));
+ }
+ return value;
+ }
+
+ @Override
+ public ColumnSize put(String key, ColumnSize value) {
+ return originalMap.put(key, value);
+ }
+
+ @Override
+ public ColumnSize remove(Object key) {
+ ColumnSize value = originalMap.remove(key);
+
+ if (value == null) {
+ value = originalMap.remove(quoteString(key));
+ }
+ return value;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends ColumnSize> m) {
+ originalMap.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ originalMap.clear();
+ }
+
+ @Override
+ public Set<String> keySet() {
+ return originalMap.keySet();
+ }
+
+ @Override
+ public Collection<ColumnSize> values() {
+ return originalMap.values();
+ }
+
+ @Override
+ public Set<Entry<String, ColumnSize>> entrySet() {
+ return originalMap.entrySet();
+ }
+
+ private String quoteString(Object key) {
+ if (key instanceof String) {
+ return "`" + key + '`';
+ }
+ throw new IllegalArgumentException();
+ }
+
+ }
}