avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Wong (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1877) AVRO-1847 accidentally breaks javaUnbox method in SpecificCompiler
Date Sun, 10 Jul 2016 01:04:11 GMT

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

Michael Wong commented on AVRO-1877:
------------------------------------

Hi, I noticed there are still a couple of issues:

# The way you call {{javaType}} from {{javaUnbox}} in this latest patch is not correct. For
example, if you have a {{union \{null, double\}}}, javaType() will turn it into a boxed {{java.lang.Double}}
that is nullable. Your changes to javaUnbox will then incorrectly convert that to a primitive
type {{double}}. My suggestion is to revert to the old code and *maybe* refactor the duplicate
SPECIFIC conversion part into a separate method.
# In AVRO-1847, you had added this to javaType:
{code}
@@ -564,10 +575,13 @@ private String getStringType(JsonNode overrideClassProperty) {
 
   /** Utility for template use.  Returns the java type for a Schema. */
   public String javaType(Schema schema) {
-    Conversion<?> conversion = SPECIFIC
-        .getConversionFor(schema.getLogicalType());
-    if (conversion != null) {
-      return conversion.getConvertedType().getName();
+    if (enableDecimalLogicalType
+        || !(schema.getLogicalType() instanceof LogicalTypes.Decimal)) {
+      Conversion<?> conversion = SPECIFIC
+          .getConversionFor(schema.getLogicalType());
+      if (conversion != null) {
+        return conversion.getConvertedType().getName();
+      }
     }
{code}
The problem is that {{enableDecimalLogicalType}} only applies to the Decimal logical type.
For the other logical types, such as {{date}} or {{timestamp-millis}}, they would be converted
even if you didn't enableDecimalLogicalType. That's at least how it was in 1.8.1. You can
test this is the case by compiling some date or timestamp-millis logical types without setting
enableDecimalLogicalType.

Much appreciated if you can fix these.

> 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)

Mime
View raw message