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

Zhenhua Wang updated SPARK-18111:
---------------------------------
    Description: 
When multiple records have the minimum value, the answer of 
ApproximatePercentile is wrong.

For example, the following query returns 2.0 for percentile 0.5, but the 
correct answer should be 1.0

0: jdbc:hive2://localhost:10000> select key from src2;
+------+--+
| key  |
+------+--+
| 1    |
| 1    |
| 2    |
| 2    |
+------+--+
4 rows selected (0.185 seconds)
0: jdbc:hive2://localhost:10000> select percentile_approx(key, array(0.5)) from 
src2;
+------------------------------------------------------------+--+
| percentile_approx(CAST(key AS DOUBLE), array(0.5), 10000)  |
+------------------------------------------------------------+--+
| [2.0]                                                      |
+------------------------------------------------------------+--+
1 row selected (0.292 seconds)

  was:
When multiple records have the minimum value, the answer of 
ApproximatePercentile is wrong.
For example, the following query returns 2.0 for percentile 0.5, but the 
correct answer should be 1.0
0: jdbc:hive2://localhost:10000> select key from src2;
+------+--+
| key  |
+------+--+
| 1    |
| 1    |
| 2    |
| 2    |
+------+--+
4 rows selected (0.185 seconds)
0: jdbc:hive2://localhost:10000> select percentile_approx(key, array(0.5)) from 
src2;
+------------------------------------------------------------+--+
| percentile_approx(CAST(key AS DOUBLE), array(0.5), 10000)  |
+------------------------------------------------------------+--+
| [2.0]                                                      |
+------------------------------------------------------------+--+
1 row selected (0.292 seconds)


> Wrong ApproximatePercentile answer when multiple records have the minimum 
> value
> -------------------------------------------------------------------------------
>
>                 Key: SPARK-18111
>                 URL: https://issues.apache.org/jira/browse/SPARK-18111
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.1
>            Reporter: Zhenhua Wang
>
> When multiple records have the minimum value, the answer of 
> ApproximatePercentile is wrong.
> For example, the following query returns 2.0 for percentile 0.5, but the 
> correct answer should be 1.0
> 0: jdbc:hive2://localhost:10000> select key from src2;
> +------+--+
> | key  |
> +------+--+
> | 1    |
> | 1    |
> | 2    |
> | 2    |
> +------+--+
> 4 rows selected (0.185 seconds)
> 0: jdbc:hive2://localhost:10000> select percentile_approx(key, array(0.5)) 
> from src2;
> +------------------------------------------------------------+--+
> | percentile_approx(CAST(key AS DOUBLE), array(0.5), 10000)  |
> +------------------------------------------------------------+--+
> | [2.0]                                                      |
> +------------------------------------------------------------+--+
> 1 row selected (0.292 seconds)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to