Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2087

Allow specifying default values for logical types in human-readable form



    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: spec
    • Labels:


      Currently default values for logical types have to be specified as the binary representation of the backing primary type.

      For example, if one wanted to specify 0.00 as the default value for a decimal field, "\u0000" has to be specified as the default value. If the user tries to specify "0.00", like in AVRO-2086, it is silently accepted but results in unexpected behaviour. This value is not parsed and interpreted as a decimal number but is taken to be the byte representation, i.e. the corresponding hexadecimal ASCII byte sequence 30 2E 30 30 = 808333360 with a precision of 2 results in a default decimal value of 8083333.60.

      To set the default value to an arbitrary non-zero value, e.g., 31.80, one has to multiply it by 10^2=100 for a precision of 2, resulting in 3180, which is 0x0C6C when converted to hex. This means that "\u000C\u006C" has to be specified as the default value. Having to do these calculations by hand is not too user (programmer) friendly.

      For a date or timestamp type, the default value has to be specified as a number and not as a string, so an unexpected default value can not be set accidentally in this case. However, one can't use a human-readable representation in this case either, the number of days or seconds (respectively) elapsed since the epoch must be specified, e.g., 1507216329 for the current timestamp.

      The first step towards solving this problem will be coming up with a suggested solution. Once we have that, the JIRA description should be extended with details.


          Issue Links



              • Assignee:
                zi Zoltan Ivanfi
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: