Source:
<code>@Test void testValidateRexFieldAccess() { final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final RexBuilder builder = new RexBuilder(typeFactory); RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER); RelDataType longType = typeFactory.createSqlType(SqlTypeName.BIGINT); RelDataType structType = typeFactory.createStructType( Arrays.asList(intType, longType), Arrays.asList("x", "y")); RexInputRef inputRef = builder.makeInputRef(structType, 0); IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", -1, intType); new RexFieldAccess(inputRef, field); }); assertThat(e1.getMessage(), is("Field #-1: z INTEGER does not exist for expression $0")); <START> <END> IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", 100, intType); new RexFieldAccess(inputRef, field); }); assertThat(e2.getMessage(), is("Field #100: z INTEGER does not exist for expression $0")); IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", 0, longType); new RexFieldAccess(inputRef, field); }); assertThat(e3.getMessage(), is("Field #0: z BIGINT does not exist for expression $0")); RelDataTypeField field = new RelDataTypeFieldImpl("x", 0, intType); RexFieldAccess fieldAccess = new RexFieldAccess(inputRef, field); RexChecker checker = new RexChecker(structType, () -> null, Litmus.THROW); assertThat(fieldAccess.accept(checker), is(true)); }</code><technical_language>complete: a test fails index == fieldList.size() (I guess 2 in this specific case)</technical_language>

Target:
@Test void testValidateRexFieldAccess() { final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final RexBuilder builder = new RexBuilder(typeFactory); RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER); RelDataType longType = typeFactory.createSqlType(SqlTypeName.BIGINT); RelDataType structType = typeFactory.createStructType( Arrays.asList(intType, longType), Arrays.asList("x", "y")); RexInputRef inputRef = builder.makeInputRef(structType, 0); IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", -1, intType); new RexFieldAccess(inputRef, field); }); assertThat(e1.getMessage(), is("Field #-1: z INTEGER does not exist for expression $0")); IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", 2, intType); new RexFieldAccess(inputRef, field); }); assertThat(e2.getMessage(), is("Field #2: z INTEGER does not exist for expression $0")); IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> { RelDataTypeField field = new RelDataTypeFieldImpl("z", 0, longType); new RexFieldAccess(inputRef, field); }); assertThat(e3.getMessage(), is("Field #0: z BIGINT does not exist for expression $0")); RelDataTypeField field = new RelDataTypeFieldImpl("x", 0, intType); RexFieldAccess fieldAccess = new RexFieldAccess(inputRef, field); RexChecker checker = new RexChecker(structType, () -> null, Litmus.THROW); assertThat(fieldAccess.accept(checker), is(true)); }