[
https://issues.apache.org/jira/browse/BEAM-10243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134185#comment-17134185
]
Pedro Teixeira commented on BEAM-10243:
---------------------------------------
I was going to try test fix and test this method with
{code:java}
public void testWithFieldValues() {
EnumerationType enumerationType = EnumerationType.create("zero", "one",
"two");
Schema type =
Stream.of(Schema.Field.of("f1_enum",
FieldType.logicalType(enumerationType)))
.collect(toSchema());
Row row =
Row.withSchema(type)
.withFieldValues(ImmutableMap.of("f1_enum",
enumerationType.valueOf("zero")))
.build();
assertEquals(enumerationType.valueOf(0), row.getValue(0));
assertEquals(
enumerationType.valueOf("zero"), row.getLogicalTypeValue(0,
EnumerationType.Value.class));
}
{code}
but it throws `java.lang.NullPointerException` at
`FieldAccessNode.addOverride(RowUtils.java:280)` due to .getFieldId() returning
null
> Incorrect checkState condition in withFieldValues in Row.java
> -------------------------------------------------------------
>
> Key: BEAM-10243
> URL: https://issues.apache.org/jira/browse/BEAM-10243
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Affects Versions: 2.22.0
> Reporter: Pedro Teixeira
> Priority: P2
>
>
> In the following code:
> public FieldValueBuilder withFieldValues(Map<String, Object> values) {
> checkState(values.isEmpty());
> return new FieldValueBuilder(schema, null).withFieldValues(values);
> }
>
> checkState should check `this.values` instead of the passed arguments.
> The issue is that as it is now, we cannot use this function to build a Row
> from Map.
>
> thanks.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)