Commit d463533
[SPARK-24676][SQL] Project required data from CSV parsed data when column pruning disabled
## What changes were proposed in this pull request?
This pr modified code to project required data from CSV parsed data when column pruning disabled.
In the current master, an exception below happens if `spark.sql.csv.parser.columnPruning.enabled` is false. This is because required formats and CSV parsed formats are different from each other;
```
./bin/spark-shell --conf spark.sql.csv.parser.columnPruning.enabled=false
scala> val dir = "/tmp/spark-csv/csv"
scala> spark.range(10).selectExpr("id % 2 AS p", "id").write.mode("overwrite").partitionBy("p").csv(dir)
scala> spark.read.csv(dir).selectExpr("sum(p)").collect()
18/06/25 13:48:46 ERROR Executor: Exception in task 2.0 in stage 2.0 (TID 7)
java.lang.ClassCastException: org.apache.spark.unsafe.types.UTF8String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:101)
at org.apache.spark.sql.catalyst.expressions.BaseGenericInternalRow$class.getInt(rows.scala:41)
...
```
## How was this patch tested?
Added tests in `CSVSuite`.
Author: Takeshi Yamamuro <[email protected]>
Closes #21657 from maropu/SPARK-24676.1 parent bcf7121 commit d463533
File tree
2 files changed
+70
-13
lines changed- sql/core/src
- main/scala/org/apache/spark/sql/execution/datasources/csv
- test/scala/org/apache/spark/sql/execution/datasources/csv
2 files changed
+70
-13
lines changedLines changed: 41 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
41 | | - | |
| 51 | + | |
| 52 | + | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
48 | 67 | | |
49 | 68 | | |
50 | | - | |
51 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
52 | 73 | | |
53 | 74 | | |
54 | 75 | | |
55 | 76 | | |
56 | | - | |
57 | 77 | | |
58 | | - | |
| 78 | + | |
59 | 79 | | |
60 | 80 | | |
61 | 81 | | |
| |||
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
85 | | - | |
| 105 | + | |
86 | 106 | | |
87 | 107 | | |
88 | 108 | | |
| |||
183 | 203 | | |
184 | 204 | | |
185 | 205 | | |
186 | | - | |
| 206 | + | |
187 | 207 | | |
188 | 208 | | |
189 | 209 | | |
| |||
197 | 217 | | |
198 | 218 | | |
199 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
200 | 226 | | |
201 | | - | |
| 227 | + | |
202 | 228 | | |
203 | 229 | | |
204 | 230 | | |
205 | | - | |
206 | | - | |
| 231 | + | |
| 232 | + | |
207 | 233 | | |
208 | | - | |
| 234 | + | |
209 | 235 | | |
210 | 236 | | |
211 | 237 | | |
| |||
222 | 248 | | |
223 | 249 | | |
224 | 250 | | |
| 251 | + | |
| 252 | + | |
225 | 253 | | |
226 | | - | |
227 | | - | |
| 254 | + | |
| 255 | + | |
228 | 256 | | |
229 | 257 | | |
230 | 258 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
1582 | 1611 | | |
0 commit comments