From issues-return-213149-archive-asf-public=cust-asf.ponee.io@spark.apache.org Sat Jan 5 02:13:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0E42818067A for ; Sat, 5 Jan 2019 02:13:03 +0100 (CET) Received: (qmail 18222 invoked by uid 500); 5 Jan 2019 01:13:03 -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 18165 invoked by uid 99); 5 Jan 2019 01:13: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; Sat, 05 Jan 2019 01:13: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 9C72EC25EE for ; Sat, 5 Jan 2019 01:13:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -108.188 X-Spam-Level: X-Spam-Status: No, score=-108.188 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URI_HEX=1.313, 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 W4iiZSQhPEoH for ; Sat, 5 Jan 2019 01:13:01 +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 1EDEB60F4E for ; Sat, 5 Jan 2019 01:13: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 5EDE6E262F for ; Sat, 5 Jan 2019 01:13: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 11CF025428 for ; Sat, 5 Jan 2019 01:13:00 +0000 (UTC) Date: Sat, 5 Jan 2019 01:13:00 +0000 (UTC) From: "Dongjoon Hyun (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-26540) Requirement failed when reading numeric arrays from PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SPARK-26540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Dongjoon Hyun updated SPARK-26540: ---------------------------------- Priority: Minor (was: Major) > Requirement failed when reading numeric arrays from PostgreSQL > -------------------------------------------------------------- > > Key: SPARK-26540 > URL: https://issues.apache.org/jira/browse/SPARK-26540 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.2.2, 2.3.2, 2.4.0 > Reporter: Takeshi Yamamuro > Priority: Minor > > This bug was reported in spark-user: http://apache-spark-user-list.1001560.n3.nabble.com/Spark-jdbc-postgres-numeric-array-td34280.html > To reproduce this; > {code} > // Creates a table in a PostgreSQL shell > postgres=# CREATE TABLE t (v numeric[], d numeric); > CREATE TABLE > postgres=# INSERT INTO t VALUES('{1111.222,2222.332}', 222.4555); > INSERT 0 1 > postgres=# SELECT * FROM t; > v | d > ---------------------+---------- > {1111.222,2222.332} | 222.4555 > (1 row) > postgres=# \d t > Table "public.t" > Column | Type | Modifiers > --------+-----------+----------- > v | numeric[] | > d | numeric | > // Then, reads it in Spark > ./bin/spark-shell --jars=postgresql-42.2.4.jar -v > scala> import java.util.Properties > scala> val options = new Properties(); > scala> options.setProperty("driver", "org.postgresql.Driver") > scala> options.setProperty("user", "maropu") > scala> options.setProperty("password", "") > scala> val pgTable = spark.read.jdbc("jdbc:postgresql:postgres", "t", options) > scala> pgTable.printSchema > root > |-- v: array (nullable = true) > | |-- element: decimal(0,0) (containsNull = true) > |-- d: decimal(38,18) (nullable = true) > scala> pgTable.show > 9/01/05 09:16:34 ERROR Executor: Exception in task 0.0 in stage 0.0 (TID 0) > java.lang.IllegalArgumentException: requirement failed: Decimal precision 4 exceeds max precision 0 > at scala.Predef$.require(Predef.scala:281) > at org.apache.spark.sql.types.Decimal.set(Decimal.scala:116) > at org.apache.spark.sql.types.Decimal$.apply(Decimal.scala:465) > ... > {code} > I looked over the related code and then I think we need more logics to handle numeric arrays; > https://github.com/apache/spark/blob/2a30deb85ae4e42c5cbc936383dd5c3970f4a74f/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala#L41 > -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org