[
https://issues.apache.org/jira/browse/BEAM-7345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17365181#comment-17365181
]
Brian Hulette edited comment on BEAM-7345 at 6/17/21, 11:59 PM:
----------------------------------------------------------------
I think some action is necessary here. I thought we failed when we encountered
generic types, but I just discovered that JavaFieldSchema will attempt to infer
a schema for a class with a single generic-typed parameter, e.g.:
{code:java}
class GenericPOJO<T> {
T my_field;
public GenericPOJO() {}
}
{code}
Results in the schema: {{my_field: ROW<>}} because it falls through here:
https://github.com/apache/beam/blob/83774787e7875bfd10affea8181c1cbda6c83195/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/StaticSchemaInference.java#L166
There should be a check for {{type.hasUnresolvedParameters()}} somewhere around
there. I'm not sure what we should *do* when that's true though, should we
raise some exception? or maybe just bubble up and the SchemaProvider should
return null?
cc: [~reuvenlax]
was (Author: bhulette):
I think some action is necessary here. I thought we failed when we encountered
generic types, but I just discovered that JavaFieldSchema will attempt to infer
a schema for a class with a single generic-typed parameter, e.g.:
{code:java}
class GenericPOJO<T> {
T my_field;
public GenericPOJO() {}
}
{code}
Results in the schema: {{my_field: ROW<>}} because it fall through here:
https://github.com/apache/beam/blob/83774787e7875bfd10affea8181c1cbda6c83195/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/StaticSchemaInference.java#L166
There should be a check for {{type.hasUnresolvedParameters()}} somewhere around
there. I'm not sure what we should *do* when that's true though, should we
raise some exception? or maybe just bubble up and the SchemaProvider should
return null?
cc: [~reuvenlax]
> Add support for generics in schema inference
> --------------------------------------------
>
> Key: BEAM-7345
> URL: https://issues.apache.org/jira/browse/BEAM-7345
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-java-core
> Reporter: Brian Hulette
> Priority: P3
> Labels: Clarified
>
> Currently schema inference doesn't work for getters that return a
> parameterized type. Fixing this would most likely involve plumbing
> TypeDescriptor through FieldValueTypeSupplier, FieldValueTypeInformation,
> StaticSchemaInference, etc.. rather than Class.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)