[ 
https://issues.apache.org/jira/browse/AVRO-1877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15367651#comment-15367651
 ] 

Yibing Shi edited comment on AVRO-1877 at 7/8/16 1:14 PM:
----------------------------------------------------------

Hi [~rdblue], it was my fault. I accidentally deleted a part of method 
{{javaUnbox}}. I am not sure how it happened though. 
Before AVRO-1847, the javaUnbox method is like below:
{code}
  public String javaType(Schema schema) {
    Conversion<?> conversion = SPECIFIC
        .getConversionFor(schema.getLogicalType());
    if (conversion != null) {
      return conversion.getConvertedType().getName();
    }

    switch (schema.getType()) {
......
{code}

However, AVRO-1847 somehow deleted the conversion part and made it like below:
{code}
  public String javaType(Schema schema) {
    switch (schema.getType()) {
......
{code}

As a result, for logical type timestamp_ms, date and time_ms, method 
{{javaUnbox}} returns "int" instead of JODA classes, which breaks the generated 
Specific Record.

I submitted a patch in this JIRA. Instead of using the original code, I rely on 
method {{javaType}} to do the conversion to avoid maintain the same code in 2 
places, especially when now we have more and more parameters to control whether 
to use upper level classes for a logical type. I also added 2 unit tests in 
this patch to cover this function. Please let me know whether you think this is 
appropriate or not.



was (Author: yibing):
Hi [~rdblue], it was my fault. I accidentally deleted a part of method 
{{javaUnbox}}. I am not sure how it happened though. 
Before AVRO-1847, the javaUnbox method is like below:
{code}
  public String javaType(Schema schema) {
    Conversion<?> conversion = SPECIFIC
        .getConversionFor(schema.getLogicalType());
    if (conversion != null) {
      return conversion.getConvertedType().getName();
    }

    switch (schema.getType()) {
......
{code}

However, AVRO-1847 somehow deleted the conversion part and made it like below:
{code}
  public String javaType(Schema schema) {
    switch (schema.getType()) {
......
{code}

I submitted a patch in this JIRA. Instead of using the original code, I rely on 
method {{javaType}} to do the conversion to avoid maintain the same code in 2 
places, especially when now we have more and more parameters to control whether 
to use upper level classes for a logical type. I also added 2 unit tests in 
this patch to cover this function. Please let me know whether you think this is 
appropriate or not.


> AVRO-1847 accidentally breaks javaUnbox method in SpecificCompiler
> ------------------------------------------------------------------
>
>                 Key: AVRO-1877
>                 URL: https://issues.apache.org/jira/browse/AVRO-1877
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: Yibing Shi
>            Priority: Blocker
>         Attachments: AVRO-1877.1.patch
>
>
> AVRO-1847 accidentally removes the logical type conversion logic in method 
> {{SpecificCompiler.javaUnbox}}, which breaks the data time type compiling in 
> specific compiler.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to