paul-rogers commented on a change in pull request #1945: DRILL-7502: Invalid 
codegen for typeof() with UNION
URL: https://github.com/apache/drill/pull/1945#discussion_r362616012
 
 

 ##########
 File path: common/src/main/java/org/apache/drill/common/types/Types.java
 ##########
 @@ -906,4 +908,16 @@ public static boolean isNullable(final MajorType type) {
         throw new UnsupportedOperationException("Unexpected/unhandled DataMode 
value " + type.getMode());
     }
   }
+
+  /**
+   * The number of minor types. Actually, the largest minor type ordinal.
+   * (There are holes in the ordering.) Update this if a new type
+   * is added. Use this value when allocating arrays to be indexed
+   * by minor type.
+   *
+   * @return the maximum minor type ordinal
+   */
+  public static final int typeCount() {
 
 Review comment:
   I agree it seems it *looks like* it should work. However, when a I ran a 
test that uses the `DICT` type I got array out of bounds errors. Reason: the 
number of values in the types list has holes: Type 2 is missing, as are a 
number of others. So, when we ask how many values exist, we get something like 
40. But, `DICT` has an index of 44 (because of the hole.) So, when we request 
the `DICT`th entry in an array, we get an OOB error.
   
   The other approach is to introduce a value for the missing ordinals, maybe 
"UNUSEDx" type. I'll try that instead.

----------------------------------------------------------------
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

Reply via email to