avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zoltan Ivanfi (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AVRO-2087) Allow specifying default values for logical types in human-readable form
Date Thu, 05 Oct 2017 15:21:00 GMT
Zoltan Ivanfi created AVRO-2087:
-----------------------------------

             Summary: Allow specifying default values for logical types in human-readable
form
                 Key: AVRO-2087
                 URL: https://issues.apache.org/jira/browse/AVRO-2087
             Project: Avro
          Issue Type: New Feature
            Reporter: Zoltan Ivanfi


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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message