Commit 0356ac0
[SPARK-40876][SQL] Widening type promotion from integers to decimal in Parquet vectorized reader
### What changes were proposed in this pull request?
This is a follow-up from #44368 and #44513, implementing an additional type promotion from integers to decimals in the parquet vectorized reader, bringing it at parity with the non-vectorized reader in that regard.
### Why are the changes needed?
This allows reading parquet files that have different schemas and mix decimals and integers - e.g reading files containing either `Decimal(15, 2)` and `INT32` as `Decimal(15, 2)` - as long as the requested decimal type is large enough to accommodate the integer values without precision loss.
### Does this PR introduce _any_ user-facing change?
Yes, the following now succeeds when using the vectorized Parquet reader:
```
Seq(20).toDF($"a".cast(IntegerType)).write.parquet(path)
spark.read.schema("a decimal(12, 0)").parquet(path).collect()
```
It failed before with the vectorized reader and succeeded with the non-vectorized reader.
### How was this patch tested?
- Tests added to `ParquetWideningTypeSuite`
- Updated relevant `ParquetQuerySuite` test.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #44803 from johanl-db/SPARK-40876-widening-promotion-int-to-decimal.
Authored-by: Johan Lasperas <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>1 parent fa60a7e commit 0356ac0
File tree
4 files changed
+150
-27
lines changed- sql/core/src
- main/java/org/apache/spark/sql/execution/datasources/parquet
- test/scala/org/apache/spark/sql/execution/datasources/parquet
4 files changed
+150
-27
lines changedLines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1407 | 1407 | | |
1408 | 1408 | | |
1409 | 1409 | | |
1410 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1411 | 1415 | | |
1412 | 1416 | | |
1413 | 1417 | | |
| |||
1436 | 1440 | | |
1437 | 1441 | | |
1438 | 1442 | | |
1439 | | - | |
| 1443 | + | |
1440 | 1444 | | |
1441 | 1445 | | |
1442 | | - | |
| 1446 | + | |
1443 | 1447 | | |
1444 | 1448 | | |
1445 | 1449 | | |
1446 | | - | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
1447 | 1455 | | |
1448 | 1456 | | |
1449 | 1457 | | |
| |||
1641 | 1649 | | |
1642 | 1650 | | |
1643 | 1651 | | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
1644 | 1658 | | |
1645 | 1659 | | |
1646 | 1660 | | |
| |||
1652 | 1666 | | |
1653 | 1667 | | |
1654 | 1668 | | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
1655 | 1683 | | |
1656 | 1684 | | |
1657 | 1685 | | |
| |||
1662 | 1690 | | |
1663 | 1691 | | |
1664 | 1692 | | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
1665 | 1696 | | |
1666 | 1697 | | |
1667 | 1698 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
158 | 157 | | |
159 | | - | |
| 158 | + | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
167 | | - | |
| 166 | + | |
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
| |||
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1037 | 1037 | | |
1038 | 1038 | | |
1039 | 1039 | | |
1040 | | - | |
1041 | | - | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1042 | 1044 | | |
1043 | 1045 | | |
1044 | 1046 | | |
| |||
1067 | 1069 | | |
1068 | 1070 | | |
1069 | 1071 | | |
| 1072 | + | |
1070 | 1073 | | |
1071 | 1074 | | |
1072 | 1075 | | |
1073 | 1076 | | |
| 1077 | + | |
1074 | 1078 | | |
1075 | 1079 | | |
1076 | 1080 | | |
| |||
Lines changed: 106 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
124 | 139 | | |
125 | 140 | | |
126 | 141 | | |
| |||
145 | 160 | | |
146 | 161 | | |
147 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
148 | 184 | | |
149 | 185 | | |
150 | 186 | | |
| |||
157 | 193 | | |
158 | 194 | | |
159 | 195 | | |
160 | | - | |
161 | | - | |
162 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
163 | 221 | | |
164 | 222 | | |
165 | 223 | | |
166 | 224 | | |
167 | 225 | | |
168 | 226 | | |
| 227 | + | |
169 | 228 | | |
170 | 229 | | |
171 | 230 | | |
172 | 231 | | |
173 | 232 | | |
174 | 233 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
178 | 267 | | |
179 | 268 | | |
180 | 269 | | |
| |||
201 | 290 | | |
202 | 291 | | |
203 | 292 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
215 | 304 | | |
216 | 305 | | |
217 | 306 | | |
| |||
0 commit comments