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 42B1B200D5D for ; Wed, 6 Dec 2017 01:02:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 41297160C1C; Wed, 6 Dec 2017 00:02:07 +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 86527160C1B for ; Wed, 6 Dec 2017 01:02:06 +0100 (CET) Received: (qmail 37072 invoked by uid 500); 6 Dec 2017 00:02:05 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 37063 invoked by uid 99); 6 Dec 2017 00:02:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Dec 2017 00:02:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id ED3AD1A1700 for ; Wed, 6 Dec 2017 00:02:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -98.702 X-Spam-Level: X-Spam-Status: No, score=-98.702 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_NUMSUBJECT=0.5, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id mUS1GTOps9Ge for ; Wed, 6 Dec 2017 00:02: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 C69BF5F250 for ; Wed, 6 Dec 2017 00:02: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 EDC3AE0044 for ; Wed, 6 Dec 2017 00:02: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 31BE7255C5 for ; Wed, 6 Dec 2017 00:02:00 +0000 (UTC) Date: Wed, 6 Dec 2017 00:02:00 +0000 (UTC) From: "Sean Owen (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-22706) Cannot read Teradata CLOB column type correctly in Spark 2.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 06 Dec 2017 00:02:07 -0000 [ https://issues.apache.org/jira/browse/SPARK-22706?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sean Owen updated SPARK-22706: ------------------------------ Priority: Minor (was: Major) On its surface, it looks like it's because the driver's CLOB implementation class doesn't implement toString(), or that its ResultSet.getString doesn't do what you want for a CLOB. That is I think this is a Teradata driver issue, but can't say I'm 100% sure. > Cannot read Teradata CLOB column type correctly in Spark 2.2.0 > -------------------------------------------------------------- > > Key: SPARK-22706 > URL: https://issues.apache.org/jira/browse/SPARK-22706 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.2.0 > Environment: Spark 2.2.0 > Teradata driver version: 16.20.00.02 (terajdbc4.jar) > I am testing with Mac > Reporter: Nannan Yu > Priority: Minor > > When I try to read the table from Teradata dababase with URL like "jdbc:teradata://IP/Database". > It works well for most of the column datatype. > But for the CLOB datatype, it cannot read the correct contest: > If I am using Spark: it will get some result like this: > ----------------------------------------------------------------------- > DT_INT | DT_CLOB > ------------------------------------------------------------------------------ > 1 | com.teradata.jdbc.jdk6_SQL_Clob@3cc9ee67 > 2 | com.teradata.jdbc.jdk6_SQL_Clob@7cf9ecad > -------------------------------------------------------------------------------- > Actually, it should show the real Character Large Object as this: > ----------------------------------------------------------------------- > DT_INT | DT_CLOB > ------------------------------------------------------------------------------ > 1 | JESSIE > 2 | CATHY > -------------------------------------------------------------------------------- > Note: This issue is not for all the 'CLOB' column datatype, for example, DB2-CLOB datatype works fine with Spark. > For teradata, we have this issue maybe related to this reason: > https://www.dwhpro.com/teradata-clob/ > " The data of a CLOB column is stored {color:#f6c342}as a separate sub-table{color}. " for TeraData CLOB? > From the Spark SourceCode in the file: org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala > * case StringType* => > (rs: ResultSet, row: InternalRow, pos: Int) => > // TODO(davies): use getBytes for better performance, if the encoding is UTF-8 > row.update(pos, UTF8String.fromString(rs.getString(pos + 1))) > It seems we cannot use this way for the CLOB column from Teradata. > Actually, I tried to use some other way to read the CLOB data from Teradata, it works well. Also it also works for the DB2-CLOB data. > case StringType => > (rs: ResultSet, row: InternalRow, pos: Int) => { > val sqlType = rs.getMetaData.getColumnType(pos + 1) > if (java.sql.Types.CLOB == sqlType) { > val clobData = rs.getClob(pos + 1); > if (clobData != null) > row.update(pos, UTF8String.fromString(clobData.getSubString(1, clobData.length().toInt))) > else > row.update(pos, UTF8String.fromString(rs.getString(pos + 1))) > } > else { > // TODO(davies): use getBytes for better performance, if the encoding is UTF-8 > row.update(pos, UTF8String.fromString(rs.getString(pos + 1))) > } > } > Should we handle the CLOB datatype differently with the normal 'StringType'? -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org