Commit 365a29b
[SPARK-22100][SQL] Make percentile_approx support date/timestamp type and change the output type to be the same as input type
## What changes were proposed in this pull request?
The `percentile_approx` function previously accepted numeric type input and output double type results.
But since all numeric types, date and timestamp types are represented as numerics internally, `percentile_approx` can support them easily.
After this PR, it supports date type, timestamp type and numeric types as input types. The result type is also changed to be the same as the input type, which is more reasonable for percentiles.
This change is also required when we generate equi-height histograms for these types.
## How was this patch tested?
Added a new test and modified some existing tests.
Author: Zhenhua Wang <[email protected]>
Closes apache#19321 from wzhfy/approx_percentile_support_types.1 parent 20adf9a commit 365a29b
File tree
7 files changed
+70
-19
lines changed- R/pkg/tests/fulltests
- docs
- python/pyspark/sql
- sql
- catalyst/src
- main/scala/org/apache/spark/sql/catalyst/expressions/aggregate
- test/scala/org/apache/spark/sql/catalyst/expressions/aggregate
- core/src/test/scala/org/apache/spark/sql
7 files changed
+70
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2538 | 2538 | | |
2539 | 2539 | | |
2540 | 2540 | | |
2541 | | - | |
| 2541 | + | |
2542 | 2542 | | |
2543 | 2543 | | |
2544 | 2544 | | |
2545 | 2545 | | |
2546 | 2546 | | |
2547 | 2547 | | |
2548 | | - | |
| 2548 | + | |
2549 | 2549 | | |
2550 | 2550 | | |
2551 | 2551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1553 | 1553 | | |
1554 | 1554 | | |
1555 | 1555 | | |
| 1556 | + | |
1556 | 1557 | | |
1557 | 1558 | | |
1558 | 1559 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
1053 | | - | |
1054 | | - | |
| 1053 | + | |
| 1054 | + | |
1055 | 1055 | | |
1056 | 1056 | | |
1057 | 1057 | | |
| |||
Lines changed: 29 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
127 | 138 | | |
128 | 139 | | |
129 | 140 | | |
| |||
134 | 145 | | |
135 | 146 | | |
136 | 147 | | |
137 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
138 | 162 | | |
139 | 163 | | |
140 | 164 | | |
| |||
155 | 179 | | |
156 | 180 | | |
157 | 181 | | |
| 182 | + | |
158 | 183 | | |
159 | | - | |
| 184 | + | |
160 | 185 | | |
161 | 186 | | |
162 | 187 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
274 | 273 | | |
275 | 274 | | |
276 | 275 | | |
| |||
281 | 280 | | |
282 | 281 | | |
283 | 282 | | |
284 | | - | |
285 | 283 | | |
286 | 284 | | |
287 | 285 | | |
| |||
299 | 297 | | |
300 | 298 | | |
301 | 299 | | |
302 | | - | |
| 300 | + | |
303 | 301 | | |
304 | 302 | | |
305 | 303 | | |
| |||
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
70 | 97 | | |
71 | 98 | | |
72 | 99 | | |
| |||
88 | 115 | | |
89 | 116 | | |
90 | 117 | | |
91 | | - | |
| 118 | + | |
92 | 119 | | |
93 | 120 | | |
94 | 121 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
806 | | - | |
807 | | - | |
808 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| |||
0 commit comments