You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Wenchen Fan (Jira)" <ji...@apache.org> on 2021/03/31 05:03:00 UTC

[jira] [Resolved] (SPARK-34909) conv() does not convert negative inputs to unsigned correctly

     [ https://issues.apache.org/jira/browse/SPARK-34909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wenchen Fan resolved SPARK-34909.
---------------------------------
    Fix Version/s: 3.0.3
                   3.1.2
                   2.4.8
                   3.2.0
       Resolution: Fixed

Issue resolved by pull request 32006
[https://github.com/apache/spark/pull/32006]

> conv() does not convert negative inputs to unsigned correctly
> -------------------------------------------------------------
>
>                 Key: SPARK-34909
>                 URL: https://issues.apache.org/jira/browse/SPARK-34909
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: Tim Armstrong
>            Assignee: Tim Armstrong
>            Priority: Major
>             Fix For: 3.2.0, 2.4.8, 3.1.2, 3.0.3
>
>
> {noformat}
> scala> spark.sql("select conv('-10', 11, 7)").show(20, 150)
> +-----------------------+
> |       conv(-10, 11, 7)|
> +-----------------------+
> |4501202152252313413456|
> +-----------------------+
> scala> spark.sql("select hex(conv('-10', 11, 7))").show(20, 150)
> +----------------------------------------------+
> |                         hex(conv(-10, 11, 7))|
> +----------------------------------------------+
> |3435303132303231353232353233313334313334353600|
> +----------------------------------------------+
> {noformat}
> The correct result is 45012021522523134134555. The above output has an incorrect second-to-last digit (6 instead of 5) and the last digit is a non-printing character the null byte.
> I tracked the bug down to NumberConverter.unsignedLongDiv returning incorrect results. I tried replacing with java.lang.Long.divideUnsigned and that fixed it.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org