You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean Zhong (JIRA)" <ji...@apache.org> on 2016/09/21 00:25:20 UTC
[jira] [Updated] (SPARK-17617) Remainder(%) expression.eval returns
incorrect result
[ https://issues.apache.org/jira/browse/SPARK-17617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Zhong updated SPARK-17617:
-------------------------------
Description:
h2.Problem
Remainder(%) expression returns incorrect result when using expression.eval to calculate the result. expression.eval is called in case like constant folding.
{code}
scala> -5083676433652386516D % 10
res19: Double = -6.0
// Wrong answer with eval!!!
scala> Seq("-5083676433652386516D").toDF.select($"value" % 10).show
|(value % 10)|
+------------+
| 0.0|
+------------+
// Triggers codegen, will not do constant folding
scala> sc.makeRDD(Seq("-5083676433652386516D")).toDF.select($"value" % 10).show
+------------+
|(value % 10)|
+------------+
| -6.0|
+------------+
{code}
Behavior of postgres:
{code}
seanzhong=# select -5083676433652386516.0 % 10;
?column?
----------
-6.0
(1 row)
{code}
was:
h2.Problem
Remainder(%) expression returns incorrect result when eval is called to do constant folding
{code}
scala> -5083676433652386516D % 10
res19: Double = -6.0
// Wrong answer because of constant folding!!!
scala> Seq("-5083676433652386516D").toDF.select($"value" % 10).show
|(value % 10)|
+------------+
| 0.0|
+------------+
// Triggers codegen, will not do constant folding
scala> sc.makeRDD(Seq("-5083676433652386516D")).toDF.select($"value" % 10).show
+------------+
|(value % 10)|
+------------+
| -6.0|
+------------+
{code}
Behavior of postgres:
{code}
seanzhong=# select -5083676433652386516.0 % 10;
?column?
----------
-6.0
(1 row)
{code}
> Remainder(%) expression.eval returns incorrect result
> -----------------------------------------------------
>
> Key: SPARK-17617
> URL: https://issues.apache.org/jira/browse/SPARK-17617
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Reporter: Sean Zhong
>
> h2.Problem
> Remainder(%) expression returns incorrect result when using expression.eval to calculate the result. expression.eval is called in case like constant folding.
> {code}
> scala> -5083676433652386516D % 10
> res19: Double = -6.0
> // Wrong answer with eval!!!
> scala> Seq("-5083676433652386516D").toDF.select($"value" % 10).show
> |(value % 10)|
> +------------+
> | 0.0|
> +------------+
> // Triggers codegen, will not do constant folding
> scala> sc.makeRDD(Seq("-5083676433652386516D")).toDF.select($"value" % 10).show
> +------------+
> |(value % 10)|
> +------------+
> | -6.0|
> +------------+
> {code}
> Behavior of postgres:
> {code}
> seanzhong=# select -5083676433652386516.0 % 10;
> ?column?
> ----------
> -6.0
> (1 row)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org