You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by gp...@apache.org on 2019/09/08 03:00:14 UTC

[drill] 04/04: DRILL-7369: Schema for MaprDB tables is not used for the case when several fields are queried

This is an automated email from the ASF dual-hosted git repository.

gparai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 65df1fdeffbec41a8e538bdcbdf42356e5e94015
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Fri Sep 6 14:57:41 2019 +0300

    DRILL-7369: Schema for MaprDB tables is not used for the case when several fields are queried
    
    closes #1852
---
 .../org/apache/drill/exec/vector/complex/fn/JsonReaderUtils.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/JsonReaderUtils.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/JsonReaderUtils.java
index 5895ba5..0485e39 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/JsonReaderUtils.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/JsonReaderUtils.java
@@ -74,12 +74,14 @@ public class JsonReaderUtils {
       TypeProtos.MajorType majorType = allTextMode
           ? Types.optional(TypeProtos.MinorType.VARCHAR)
           : Types.optional(TypeProtos.MinorType.INT);
+      ColumnMetadata metadata = null;
       if (columnMetadata != null) {
-        ColumnMetadata metadata = columnMetadata.metadata(fieldPath.getNameSegment().getPath());
+        metadata = columnMetadata.metadata(fieldPath.getNameSegment().getPath());
         majorType = metadata != null ? metadata.majorType() : majorType;
       }
       types.add(majorType);
-      if (fieldWriter.isEmptyMap()) {
+      // for the case if metadata is specified, ensures that required fields are created
+      if (fieldWriter.isEmptyMap() || metadata != null) {
         emptyStatus.set(fieldIndex, true);
       }
       if (fieldIndex == 0 && !allTextMode && schema == null) {