KazydubB commented on a change in pull request #1870: DRILL-7359: Add support for DICT type in RowSet Framework URL: https://github.com/apache/drill/pull/1870#discussion_r353132642
########## File path: exec/vector/src/main/java/org/apache/drill/exec/vector/accessor/reader/UnionReaderImpl.java ########## @@ -268,4 +274,51 @@ public String getAsString() { } return requireReader(type).getAsString(); } + + private UnionReaderImpl getNullReader() { + AbstractObjectReader[] nullVariants = new AbstractObjectReader[variants.length]; + for (int i = 0; i < variants.length; i++) { + nullVariants[i] = variants[i].createNullReader(); + } + return new NullUnionReader(schema(), unionAccessor, nullVariants); + } + + private static class NullUnionReader extends UnionReaderImpl { + + private NullUnionReader(ColumnMetadata metadata, VectorAccessor va, AbstractObjectReader[] variants) { Review comment: Regarding points of your suggestion: - `DictReaderImpl` has `NullStateReaders.REQUIRED_STATE_READER` `NullStateReader`, i.e. it can't be `NULL` (like `MapReader`). - `DICT` can't have `NULL` key as it is `REQUIRED`. - If the `DICT` has a key, but the value is `NULL`, then `isNull()` for the value returns `true` - yes. - in the (tricky) case of a missing key from the `DICT`, the latter approach was taken - there is no differentiation between missing key and `NULL` value. (The new `Null*Reader`s are introduced to be used in the case of a missing key - their `isNull()` always returns `true`; note, that in case when a key is present and the value is `NULL`, current (non-null) readers' `isNull()` will return `true` for that particular position, as corresponding value reader keeps track of nullability). The former approach was discarded to ensure uniform behavior without a chance of getting `NPE` or making `null`-checks. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services