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



##########
File path: core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java
##########
@@ -129,18 +129,34 @@ private SqlSingleOperandTypeChecker 
getChecker(SqlCallBinding callBinding) {
       return typeFactory.createTypeWithNullability(operandType.getValueType(),
           true);
     case ROW:
-      String fieldName = opBinding.getOperandLiteralValue(1, String.class);
-      RelDataTypeField field = operandType.getField(fieldName, false, false);
-      if (field == null) {
-        throw new AssertionError("Cannot infer type of field '"
-            + fieldName + "' within ROW type: " + operandType);
-      } else {
-        RelDataType fieldType = field.getType();
-        if (operandType.isNullable()) {
-          fieldType = typeFactory.createTypeWithNullability(fieldType, true);
+      RelDataType fieldType = null;
+      RelDataType indexType = opBinding.getOperandType(1);
+
+      if (SqlTypeFamily.STRING.contains(indexType)) {
+        String fieldName = opBinding.getOperandLiteralValue(1, String.class);
+        RelDataTypeField field = operandType.getField(fieldName, false, false);
+        if (field == null) {
+          throw new AssertionError("Cannot infer type of field '"
+              + fieldName + "' within ROW type: " + operandType);
+        } else {
+          fieldType = field.getType();
+        }
+      } else if (SqlTypeFamily.INTEGER.contains(indexType)) {
+        Integer index = opBinding.getOperandLiteralValue(1, Integer.class);

Review comment:
       Thanks a lot, it's much more readable with `SqlTypeUtil`.




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