spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Herman van Hovell (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SPARK-10893) Lag Analytic function broken
Date Thu, 01 Oct 2015 11:38:26 GMT

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

Herman van Hovell commented on SPARK-10893:
-------------------------------------------

I just tried the following scala code (port from your java code) in the Spark REPL in the
latest master:
{noformat}
val df = Seq(
  ("A", 1),
  ("B", -1),
  ("C", 2),
  ("d", 3),
  (null.asInstanceOf[String], null.asInstanceOf[Int])).
  toDF("VAA", "VBB")

val ldf = df.withColumn(
  "previous",
  lag(df("VBB"), 1).over(Window.orderBy(df.col("VAA"))));

ldf.show
{noformat}
This produces the following result:
{noformat}
+----+----+--------+                                                            
| VAA| VBB|previous|
+----+----+--------+
|null|null|    null|
|   A|   1|    null|
|   B|  -1|       1|
|   C|   2|      -1|
|   d|   3|       2|
+----+----+--------+
{noformat}

Unfortunately, I cannot reproduce your problem. Could you try the code above in the REPL of
you Spark installation?

> Lag Analytic function broken
> ----------------------------
>
>                 Key: SPARK-10893
>                 URL: https://issues.apache.org/jira/browse/SPARK-10893
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core, SQL
>    Affects Versions: 1.5.0
>         Environment: Spark Standalone Cluster on Linux
>            Reporter: Jo Desmet
>
> Trying to aggregate with the LAG Analytic function gives the wrong result. In my testcase
it was always giving the fixed value '103079215105' when I tried to run on an integer.
> Note that this only happens on Spark 1.5.0, and only when running in cluster mode.
> It works fine when running on Spark 1.4.1, or when running in local mode. 
> I did not test on a yarn cluster.
> I did not test other analytic aggregates.
> Input Jason:
> {code:borderStyle=solid}
> {"VAA":"A", "VBB":1}
> {"VAA":"B", "VBB":-1}
> {"VAA":"C", "VBB":2}
> {"VAA":"d", "VBB":3}
> {"VAA":null, "VBB":null}
> {code}
> Java:
> {code:borderStyle=solid}
>     SparkContext sc = new SparkContext(conf);
>     HiveContext sqlContext = new HiveContext(sc);
>     DataFrame df = sqlContext.read().json(getInputPath("input.json"));
>     
>     df = df.withColumn(
>       "previous",
>       lag(dataFrame.col("VBB"), 1)
>         .over(Window.orderBy(dataFrame.col("VAA")))
>       );
> {code}
> Expected Result:
> {code:borderStyle=solid}
> {"VAA":null, "VBB":null, "previous":null}
> {"VAA":"A", "VBB":1, "previous":null}
> {"VAA":"B", "VBB":-1, "previous":1}
> {"VAA":"C", "VBB":2, "previous":-1}
> {"VAA":"d", "VBB":3, "previous":2}
> {code}
> Actual Result:
> {code:borderStyle=solid}
> {"VAA":null, "VBB":null, "previous":103079215105}
> {"VAA":"A", "VBB":1, "previous":103079215105}
> {"VAA":"B", "VBB":-1, "previous":103079215105}
> {"VAA":"C", "VBB":2, "previous":103079215105}
> {"VAA":"d", "VBB":3, "previous":103079215105}
> {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


Mime
View raw message