From dev-return-35600-archive-asf-public=cust-asf.ponee.io@sqoop.apache.org Fri Feb 9 22:27:05 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id A5876180654 for ; Fri, 9 Feb 2018 22:27:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 952D5160C4C; Fri, 9 Feb 2018 21:27:05 +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 DFCF2160C3C for ; Fri, 9 Feb 2018 22:27:04 +0100 (CET) Received: (qmail 91189 invoked by uid 500); 9 Feb 2018 21:27:04 -0000 Mailing-List: contact dev-help@sqoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sqoop.apache.org Delivered-To: mailing list dev@sqoop.apache.org Received: (qmail 91141 invoked by uid 99); 9 Feb 2018 21:27:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Feb 2018 21:27:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 795C2C031C for ; Fri, 9 Feb 2018 21:27:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id cjRxMn1Hiq04 for ; Fri, 9 Feb 2018 21:27:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 97A205F1A1 for ; Fri, 9 Feb 2018 21:27:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C15BAE0257 for ; Fri, 9 Feb 2018 21:27:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2EFA524102 for ; Fri, 9 Feb 2018 21:27:00 +0000 (UTC) Date: Fri, 9 Feb 2018 21:27:00 +0000 (UTC) From: "Greg Lindholm (JIRA)" To: dev@sqoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SQOOP-3285) Hcatalog import is loosing precision on DECIMAL fields MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SQOOP-3285?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1635= 8981#comment-16358981 ]=20 Greg Lindholm commented on SQOOP-3285: -------------------------------------- Patch is attached [^0001-Fix-DECIMAL-percision-loss-with-Hcatalog-imports.p= atch] A couple lines added to org.apache.sqoop.mapreduce.hcat.SqoopHCatImportHelp= er.convertNumberTypes() The fix is for first check if the value is a BigDecimal or a BigInteger and= if so use the value to create the HiveDecimal directly to avoid converting= it to a Double. Here is the logic to new convert a Number into a HiveDecimal. {code:java} =C2=A0=C2=A0=C2=A0 } else if (hfsType =3D=3D HCatFieldSchema.Type.DECIMAL) = { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (n instanceof BigDecimal) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return HiveDecimal.create((BigDe= cimal)n); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (n instanceof BigInteger) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return HiveDecimal.create((BigIn= teger)n); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BigDecimal bd =3D new BigDecimal(n.doubleVal= ue(), =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MathContext.DECIMAL128); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return HiveDecimal.create(bd); =C2=A0=C2=A0=C2=A0 } {code} =C2=A0 > Hcatalog import is loosing precision on DECIMAL fields > ------------------------------------------------------ > > Key: SQOOP-3285 > URL: https://issues.apache.org/jira/browse/SQOOP-3285 > Project: Sqoop > Issue Type: Bug > Components: hive-integration > Affects Versions: 1.4.7 > Reporter: Greg Lindholm > Priority: Major > Attachments: 0001-Fix-DECIMAL-percision-loss-with-Hcatalog-import= s.patch > > > Import with hcatalog for DECIMAL fields is loosing precision. > The bug is in org.apache.sqoop.mapreduce.hcat.SqoopHCatImportHelper.conve= rtNumberTypes() > Internally the BigDecimal value is converted to a Double then back into a= BigDecimal. > As a test I imported from a MySQL db a DECIMAL(38,8) field: > {code:java} > create table sampledata1 ( n38 DECIMAL(38,8) ); > insert into sampledata1 ( n38 ) values ( -123456789012345678901234567890.= 12345678 ) > sqoop import \ > =C2=A0 --connect jdbc:mysql://10.210.144.22:3306/greg --username greg -P = \ > =C2=A0 -m 1 \ > =C2=A0 --table sampledata1 \ > =C2=A0 --hcatalog-table sampledata1_orc2 \ > =C2=A0 --create-hcatalog-table \ > =C2=A0 --hcatalog-storage-stanza 'stored as orc' > {code} > The result in the hive table does not match the input. > {noformat} > Original: > -123456789012345678901234567890.12345678 > Result: > -123456789012345677877719597056.00000000{noformat} > I get the same result with Orc, RCfile, and Avro files. > =C2=A0 > I believe I found the problem and will provide a patch shortly. > =C2=A0 > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)