On Fri, Jun 27, 2014 at 9:40 AM, Pritchard, Charles X. -ND
<charles.x.pritchard....@disney.com> wrote:
> is there a means to coerce data written as byte[] into String (and the other 
> way around) ?

Not easily today.  Binary string values are a subset of bytes (those
that are valid UTF-8 sequences), so string to bytes would be a
lossless conversion.  Bytes to string however isn't guaranteed to
produce valid data.

Perhaps we should permit one or both of these as a standard type promotion in:

http://avro.apache.org/docs/current/spec.html#Schema+Resolution

(Int-to-float and long-to-float are both lossy promotions that we
already permit.)

In the meantime, the standard Java APIs won't permit this conversion.
I posted a patch that adds support for promotion from string to bytes.
Would this be useful?  If so, please add comments to the issue.

https://issues.apache.org/jira/browse/AVRO-1533

Doug

Reply via email to