You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Kevin Oliver <KO...@salesforce.com> on 2009/07/27 22:24:17 UTC

Schema resolution and promotion

Question on schema resolution and type promotion.

The spec currently allows for the writer's schema to be promoted to the reader's as follows:
    *  int is promotable to long, float, or double
    * long is promotable to float or double
    * float is promotable to double

I was wondering if this could be extended to allow for int and long types to be promoted to a string. This seems like it would be a fairly standard procedure in most client languages. For example in Java, this would be Integer.toString(int) and Long.toString(long).

I am happy to create a patch for this, but I wanted to know if this is something that is worth pursuing, or if this is something you see as being done client-side after the record is read.

Re: Schema resolution and promotion

Posted by Doug Cutting <cu...@apache.org>.
Kevin Oliver wrote:
> I was wondering if this could be extended to allow for int and long types to be promoted to a string.

Can you better motivate this?  It does not seem intuitive to me. 
Promotion is best when there are common operations.  For numbers, these 
are arithmetic, comparisons, functions, etc.  However strings and 
numbers do not share that many operations: prefix match, substring, 
character coding, etc. are not normally considered numeric operations, 
and addition, subtraction and multiplication are not string operations.

Doug