Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A06CD200ACA for ; Thu, 9 Jun 2016 19:12:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9F0E9160A59; Thu, 9 Jun 2016 17:12:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E5C66160A58 for ; Thu, 9 Jun 2016 19:12:22 +0200 (CEST) Received: (qmail 75187 invoked by uid 500); 9 Jun 2016 17:12:21 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 74776 invoked by uid 99); 9 Jun 2016 17:12:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 17:12:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 1FA902C1F64 for ; Thu, 9 Jun 2016 17:12:21 +0000 (UTC) Date: Thu, 9 Jun 2016 17:12:21 +0000 (UTC) From: "Ryan Blue (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AVRO-1861) Avro Schema parser treats Avro float type as Java Double for default values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 09 Jun 2016 17:12:23 -0000 [ https://issues.apache.org/jira/browse/AVRO-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15322882#comment-15322882 ] Ryan Blue commented on AVRO-1861: --------------------------------- Sounds reasonable to me. If you want to submit a PR for this, I'll review it. Thanks, [~amok]! > Avro Schema parser treats Avro float type as Java Double for default values > --------------------------------------------------------------------------- > > Key: AVRO-1861 > URL: https://issues.apache.org/jira/browse/AVRO-1861 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.8.1 > Reporter: Andy Mok > > The following code snippet in the [Schema class|https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/Schema.java] shows that we explicitly treat Avro {{FLOAT}} and {{DOUBLE}} as a Java {{Double}}. > {code:java} > JsonNode defaultValue = field.get("default"); > if (defaultValue != null > && (Type.FLOAT.equals(fieldSchema.getType()) > || Type.DOUBLE.equals(fieldSchema.getType())) > && defaultValue.isTextual()) > defaultValue = > new DoubleNode(Double.valueOf(defaultValue.getTextValue())); > {code} > Jackson has support for [FloatNode|https://fasterxml.github.io/jackson-databind/javadoc/2.3.0/com/fasterxml/jackson/databind/node/FloatNode.html] so why don't we use that? > This is a problem when someone calls [Schema.Field#defaultVal|https://avro.apache.org/docs/1.8.1/api/java/org/apache/avro/Schema.Field.html#defaultVal()] for an Avro field with Avro type {{FLOAT}} and they try to typecast the object to a Java {{float}}. -- This message was sent by Atlassian JIRA (v6.3.4#6332)