You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Liang-Chi Hsieh (JIRA)" <ji...@apache.org> on 2018/06/20 14:11:00 UTC

[jira] [Commented] (SPARK-24607) Distribute by rand() can lead to data inconsistency

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

Liang-Chi Hsieh commented on SPARK-24607:
-----------------------------------------

From the following test, looks it is ok.

{code:java}
scala> val df1 = sql("select count(*) from a1")
df1: org.apache.spark.sql.DataFrame = [count(1): bigint]

scala> val df2 = sql("select count(*) from (select * from a1 distribute by rand()) a")
df2: org.apache.spark.sql.DataFrame = [count(1): bigint]
{code}
{code:java}
scala> df1.show                                                                                                                    
+--------+
|count(1)|
+--------+
|    1000|
+--------+


scala> df2.show
+--------+
|count(1)|
+--------+
|    1000|
+--------+
{code}
{code:java}
scala> df1.explain
== Physical Plan ==
*(2) HashAggregate(keys=[], functions=[count(1)])
+- Exchange SinglePartition
   +- *(1) HashAggregate(keys=[], functions=[partial_count(1)])
      +- *(1) FileScan parquet default.a1[] Batched: true, Format: Parquet, Location: InMemoryFileIndex[file:/root/repos/spark-1/spark-warehouse/a1], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<>

scala> df2.explain
== Physical Plan ==
*(3) HashAggregate(keys=[], functions=[count(1)])
+- Exchange SinglePartition
   +- *(2) HashAggregate(keys=[], functions=[partial_count(1)])
      +- *(2) Project
         +- Exchange hashpartitioning(_nondeterministic#100, 200)
            +- *(1) Project [rand(1677810096404215833) AS _nondeterministic#100]
               +- *(1) FileScan parquet default.a1[key#69L,t1#70L,t2#71L] Batched: true, Format: Parquet, Location: InMemoryFileIndex[file:
/root/repos/spark-1/spark-warehouse/a1], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<key:bigint,t1:bigint,t2:bigint>
{code}

> Distribute by rand() can lead to data inconsistency
> ---------------------------------------------------
>
>                 Key: SPARK-24607
>                 URL: https://issues.apache.org/jira/browse/SPARK-24607
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.2.0, 2.3.1
>            Reporter: zenglinxi
>            Priority: Major
>
> Noticed the following queries can give different results:
> {code:java}
> select count(*) from tbl;
> select count(*) from (select * from tbl distribute by rand()) a;{code}
> this issue was first reported by someone using kylin for building cube with hiveSQL which include  distribute by rand, I think it's also an hidden serious problem in sparksql.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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