paul-rogers opened a new pull request #1945: DRILL-7502: Invalid codegen for typeof() with UNION URL: https://github.com/apache/drill/pull/1945 The gist of the problem is that codegen for a `UNION` using a `FieldReader` for a `@Param` was handled incorrectly. We had code to handle complex and repeated types specially. Turned out we just needed to add `UNION` type to that same logic. Since the fix turned out to be simple (after much sleuthing), I suspect this may have been a regression and this fix simply puts things back the way the original author intended. Also fixes DRILL-6362: typeof() reports NULL for primitive columns with a NULL value. typeof() is meant to return "NULL" if a UNION has a NULL value, but the column type when known, such as for non-UNION columns. Also fixes DRILL-7499: sqltypeof() function with an array returns "ARRAY", not type. This was due to treating REPEATED like LIST. Includes cleanup in files visited during the work. ### Documentation User-visible behaviour changes after this fix: * `typeof()` returns the value type of a specific column value. This is the Drill minor type for most types. For types other than `UNION`, if the value is `NULL`, `typeof() `still reports the column type (since the NULL has a type.) But for a `UNION` column, `typeof()` returns the type of that specific column value, or "NULL" if the column is null. (Since, for UNION, NULL has no type.) * `sqlTypeOf()` works the same except for arrays. Previously (sometime between Drill 1.15 and Drill 1.17), `sqlTypeOf()` returned "ARRAY" for a repeated column. After this fix, it works as in Drill 1.14: `sqlTypeOf()` returns the type name. Thus a repeated INT returns "INT", not "ARRAY". (The `LIST` type still returns "ARRAY", however.) * `drillTypeOf()` returns the actual minor type of a column, even for `UNION` and `DICT` columns. Thus, if a column is `UNION`, `typeOf()` returns the value type, but `drillTypeOf()` returns "UNION." ### Tests Added two new tests to `TestTypeFns`, one which uses the JSON reader to verify `UNION` type behaviour (the test which uncovered this bug.) Reran all unit tests.
---------------------------------------------------------------- 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