rahul8383 commented on pull request #11609:
URL: https://github.com/apache/beam/pull/11609#issuecomment-624360661


   > We always convert logical types to their base type when serializing with 
SchemaCoder, and convert back to the input type when deserializing. Other than 
that I think the only time it should get called is when constructing a Row 
instance (unless you use attachValues).
   
   In that case, there is no need to handle this `else` case right? as we are 
making sure that the input has expected length while building the Row.
   
https://github.com/apache/beam/blob/5e1571760b61b8ce247d5375b71c8df4d69d6409/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/logicaltypes/FixedBytes.java#L77
   Even if `attachValues` is used while building the Row and the provided input 
value is invalid(invalid length), during serialization in `SchemaCoder`, the 
input value cannot be converted to base type as it doesn't have expected length 
and an `IllegalArgumentException` will be thrown.
   
   > Would this just be so that we're guaranteed to call `toInputType` whenever 
setting a value on Row? This PR accomplishes the same thing right?
   
   Can we support this feature: depending on the type of the input value 
provided while building the Row, we can call 
`toInputType(toBaseType(inputValue))` or `toInputType(inputValue)` i.e. support 
for providing base value while building the Row. If both the InputType and 
BaseType are one and the same, we can directly call `toInputType(inputValue)`. 
I am thinking that this might be helpful for logical types like `FixedBytes` or 
`FixedLengthString`.


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