asolimando commented on a change in pull request #2230:
URL: https://github.com/apache/calcite/pull/2230#discussion_r514567383



##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -2517,6 +2517,18 @@ public static Object item(Object object, Object index) {
     if (object instanceof List && index instanceof Number) {
       return arrayItem((List) object, ((Number) index).intValue());
     }
+    if (index instanceof Number) {

Review comment:
       I had a closer look, for both `ARRAY` and `ROW` we require the index to 
be in the int family (`SqlTypeFamily.INTEGER`), which includes `TINYINT`, 
`SMALLINT`, `INTEGER` and `BIGINT`, so we can't really throw if the index is 
not `int`.
   
   I have tried other numeric values not in the int family, and the validator 
fails, when we reach this point type validation already guarantees we have a 
correct type, and relying on `Numeric` becomes just a shorthand for `Long`, 
`Short`, `Integer`, etc.
   
   If you agree I'd be inclined to leave it as-is, since adding an assert for 
each of the legal types would harm readability for not much.




----------------------------------------------------------------
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:
[email protected]


Reply via email to