You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2020/11/05 08:19:00 UTC
[jira] [Commented] (SPARK-33327) grouped by first and last against
date column returns incorrect results
[ https://issues.apache.org/jira/browse/SPARK-33327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17226571#comment-17226571 ]
Hyukjin Kwon commented on SPARK-33327:
--------------------------------------
[~bullsoverbears], can you show the current output and expected output in the JIRA description with explaining why it's incorrect?
> grouped by first and last against date column returns incorrect results
> -----------------------------------------------------------------------
>
> Key: SPARK-33327
> URL: https://issues.apache.org/jira/browse/SPARK-33327
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.4.6, 2.4.7
> Reporter: Punit Shah
> Priority: Major
> Attachments: users.csv
>
>
> The attached csv file has two columns, namely "User" and "FromDate". The import defaults the "FromDate" column as a timestamp.
> * outDF = spark_session.read.csv("users.csv", inferSchema=True, header=True)
> * outDF.createOrReplaceTempView("table02")
> In this default case the following sql generates correct results:
> {color:#de350b}*"select count(`User`) as cnt, first(`FromDate`) as `FromDate_First`, last(`FromDate`) as `FromDate_Last`, count(distinct(`FromDate`)) as cntdist from table02 group by `User`"*{color}
> {color:#172b4d}However if we read the dataframe like so (where the "FromDate" is read in as a Date, then the above sql query generates incorrect results:{color}
> * {color:#172b4d}outDF = spark_session.read.csv("users.csv", inferSchema=True, header=True).selectExpr("`User`", "cast(`FromDate` as date)"){color}
>
--
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