DRILL-1575: skip creating "key" field for null values in kvgen()
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/6dca24af Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/6dca24af Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/6dca24af Branch: refs/heads/master Commit: 6dca24af0bec007a94c260bd84fbc99abd40d580 Parents: 47a92c7 Author: Mehant Baid <meha...@gmail.com> Authored: Fri Oct 24 00:49:15 2014 -0700 Committer: Mehant Baid <meha...@gmail.com> Committed: Fri Oct 24 18:20:18 2014 -0700 ---------------------------------------------------------------------- .../drill/exec/expr/fn/impl/MappifyUtility.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6dca24af/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java index 92f62ca..7f7a28c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java @@ -40,7 +40,7 @@ public class MappifyUtility { public static void mappify(FieldReader reader, BaseWriter.ComplexWriter writer, DrillBuf buffer) { // Currently we expect single map as input if (!(reader instanceof SingleMapReaderImpl)) { - throw new DrillRuntimeException("Mappify function only supports Simple maps as input"); + throw new DrillRuntimeException("kvgen function only supports Simple maps as input"); } BaseWriter.ListWriter listWriter = writer.rootAsList(); listWriter.start(); @@ -52,9 +52,15 @@ public class MappifyUtility { String str = fieldIterator.next(); FieldReader fieldReader = reader.reader(str); + // Skip the field if its null + if (fieldReader.isSet() == false) { + mapWriter.end(); + continue; + } + // Check if the value field is not repeated if (fieldReader.getType().getMode() == TypeProtos.DataMode.REPEATED) { - throw new DrillRuntimeException("Mappify function does not support repeated type values"); + throw new DrillRuntimeException("kvgen function does not support repeated type values"); } // writing a new field, start a new map @@ -70,12 +76,6 @@ public class MappifyUtility { vh.buffer = buffer; mapWriter.varChar(fieldKey).write(vh); - // Skip the value field if its null - if (fieldReader.isSet() == false) { - mapWriter.end(); - continue; - } - // Write the value to the map MapUtility.writeToMapFromReader(fieldReader, mapWriter, buffer);