[
https://issues.apache.org/jira/browse/AVRO-2087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thiruvalluvan M. G. updated AVRO-2087:
--------------------------------------
Component/s: spec
> Allow specifying default values for logical types in human-readable form
> ------------------------------------------------------------------------
>
> Key: AVRO-2087
> URL: https://issues.apache.org/jira/browse/AVRO-2087
> Project: Apache Avro
> Issue Type: New Feature
> Components: spec
> Reporter: Zoltan Ivanfi
> Priority: Major
>
> 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
(v7.6.3#76005)