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

Ken Geis commented on SPARK-7196:
---------------------------------

I get closer when I apply [PR5803|https://github.com/apache/spark/pull/5803] 
from SPARK-5456. The field is a DECIMAL(12, 2) in the database. When I save it 
to Hive and then query off that, the scale is off.

{noformat}
scala> val amounts = sqlContext.jdbc(coeusURL, """(SELECT 
total_direct_cost_total FROM osp$proposal WHERE rownum < 2)""")
scala> amounts.show()
TOTAL_DIRECT_COST_TOTAL
19999                  
scala> amounts.saveAsTable("amounts")
scala> sqlContext.sql("SELECT * FROM amounts").show()
TOTAL_DIRECT_COST_TOTAL
199.99                 
{noformat}


> decimal precision lost when loading DataFrame from JDBC
> -------------------------------------------------------
>
>                 Key: SPARK-7196
>                 URL: https://issues.apache.org/jira/browse/SPARK-7196
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.3.1
>            Reporter: Ken Geis
>            Assignee: Liang-Chi Hsieh
>             Fix For: 1.3.2, 1.4.0
>
>
> I have a decimal database field that is defined as 10.2 (i.e. ##########.##). 
> When I load it into Spark via sqlContext.jdbc(..), the type of the 
> corresponding field in the DataFrame is DecimalType, with precisionInfo None. 
> Because of that loss of precision information, SPARK-4176 is triggered when I 
> try to .saveAsTable(..).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to