turboFei commented on issue #25701: [SPARK-29000][SQL] Decimal precision overflow when don't allow precision loss URL: https://github.com/apache/spark/pull/25701#issuecomment-528739147 > @turboFei thanks for this PR. I don't understand very well the difference before and after your patch. Indeed, it seems to be that the case when operand always becomes a `decimal(34, 24)` as well as the `1` or `1.0`. May you please explain what changes before and after? We can check the code below: https://github.com/apache/spark/blob/4664a082c2c7ac989e818958c465c72833d3ccfe/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecision.scala#L123-L128 If a decimal(34,24) * 1.0, p1=34, s1=24, p2=2,s2=1, And the result type is Decimal(38,25) <img width="1076" alt="image-20190905145151701" src="https://user-images.githubusercontent.com/6757692/64407902-0f412c00-d0b8-11e9-9682-ef0b5477d5df.png"> If a decimal(34,24) * 1, p1 =34,s1=24,p2=34,s2=24. And the result type is Decimal(38,38). <img width="1167" alt="image-20190905145246902" src="https://user-images.githubusercontent.com/6757692/64407919-1c5e1b00-d0b8-11e9-8247-1e780401c10b.png"> The result will overflow.
---------------------------------------------------------------- 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]
