Github user vvysotskyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/805#discussion_r117748249
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java
 ---
    @@ -548,23 +567,57 @@ public void populatePruningVector(ValueVector v, int 
index, SchemaPath column, S
             NullableVarCharVector varCharVector = (NullableVarCharVector) v;
             Object s = partitionValueMap.get(f).get(column);
             byte[] bytes;
    -        if (s instanceof String) { // if the metadata was read from a JSON 
cache file it maybe a string type
    -          bytes = ((String) s).getBytes();
    -        } else if (s instanceof Binary) {
    -          bytes = ((Binary) s).getBytes();
    -        } else if (s instanceof byte[]) {
    -          bytes = (byte[]) s;
    +        if (s == null) {
    +          varCharVector.getMutator().setNull(index);
    +          return;
             } else {
    -          throw new UnsupportedOperationException("Unable to create column 
data for type: " + type);
    +          bytes = getBytes(type, s);
             }
             varCharVector.getMutator().setSafe(index, bytes, 0, bytes.length);
             return;
           }
    +      case INTERVAL: {
    +        NullableIntervalVector intervalVector = (NullableIntervalVector) v;
    +        Object s = partitionValueMap.get(f).get(column);
    +        byte[] bytes;
    +        if (s == null) {
    +          intervalVector.getMutator().setNull(index);
    +          return;
    +        } else {
    +          bytes = getBytes(type, s);
    +        }
    +        intervalVector.getMutator().setSafe(index, 1,
    +          ParquetReaderUtility.getIntFromLEBytes(bytes, 0),
    +          ParquetReaderUtility.getIntFromLEBytes(bytes, 4),
    +          ParquetReaderUtility.getIntFromLEBytes(bytes, 8));
    +        return;
    +      }
           default:
             throw new UnsupportedOperationException("Unsupported type: " + 
type);
         }
       }
     
    +  /**
    +   * Returns the sequence of bytes received from {@code Object source}.
    +   *
    +   * @param type   the column type
    +   * @param source the source of the bytes sequence
    +   * @return bytes sequence obtained from {@code Object source}
    +   */
    +  private byte[] getBytes(MinorType type, Object source) {
    +    byte[] bytes;
    +    if (source instanceof String) { // if the metadata was read from a 
JSON cache file it maybe a string type
    +      bytes = Base64.decodeBase64(((String) source).getBytes());
    --- End diff --
    
    It is necessary  for the cases when value has encoding order other than 
UTF-8. When creating string from the byte array for example with little-endian 
byte order without manually setting the charset, getBytes() would return byte 
array that differs from the passed into the String constructor.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to