Ngone51 commented on a change in pull request #26881: [SPARK-30252][SQL] 
Disallow negative scale of Decimal under ansi mode
URL: https://github.com/apache/spark/pull/26881#discussion_r365335986
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/results/literals.sql.out
 ##########
 @@ -211,7 +211,7 @@ select 1E309, -1E309
 -- !query 21
 select 0.3, -0.8, .5, -.18, 0.1111, .1111
 -- !query 21 schema
-struct<0.3:decimal(1,1),-0.8:decimal(1,1),0.5:decimal(1,1),-0.18:decimal(2,2),0.1111:decimal(4,4),0.1111:decimal(4,4)>
 
 Review comment:
   Actually, I think this is an existed bug in Spark: for a number less than 
`1`, its precision&scale are different between `Decimal` and `DecimalType` if 
it's created from literal(because precision&scale are defined separately). This 
PR fixes it by:
   
   `private[sql] def fromDecimal(d: Decimal): DecimalType = 
DecimalType(d.precision, d.scale)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to