Commit d635a1f
committed
[SPARK-57570][SQL] Support TimeType in vectorized-reader column population
### What changes were proposed in this pull request?
Make the vectorized reader handle `TimeType` when it populates partition, missing, and constant columns.
The only production change is one branch in `ColumnVectorUtils.appendValue` (the `toBatch` path): a TIME value is now appended as its nanos-of-day `long` via `DateTimeUtils.localTimeToNanos`. Before, there was no `TimeType` case and it failed with "Datatype not supported". The `populate` path already worked, since `TimeType` is physically a `long`.
This builds on SPARK-54203, which added the underlying `RowToColumnConverter` and column-vector allocation support.
The unsupported-type branch still throws `_LEGACY_ERROR_TEMP_3192` for other types; renaming that legacy error is tracked separately in SPARK-57745.
### Why are the changes needed?
This makes `TimeType` a first-class citizen in the vectorized (columnar) read path instead of a type that fails depending on where a column comes from. Concretely, it enables:
- **TIME partition columns in vectorized reads.** A table partitioned by a TIME column previously errored when the partition value was materialized into the columnar batch. With this change such reads succeed with the vectorized reader engaged, so partition pruning and the columnar scan both work.
- **Schema-evolution / "missing" TIME columns.** When a Parquet/ORC file predates a TIME column added to the table schema, the reader fills that column via the same population path; those reads now succeed instead of failing.
- **Constant-folded TIME columns** injected into a scan populate correctly.
- **`toBatch` round-trips with TIME**, e.g. row-to-columnar conversions that carry `java.time.LocalTime` values.
Without this, queries touching TIME columns in these scenarios either fail with an unsupported-datatype error or fall back to the slower row-based reader. After the change, TIME behaves consistently with `DATE`, `TIMESTAMP`, and interval types in this layer, and downstream code built on `ColumnarBatch` can carry TIME columns through the population path without special-casing. It also clears a blocker in the SPARK-54203 umbrella and keeps the vectorized layer's hand-maintained type dispatch in step with the other datetime types.
Note: physically reading TIME data columns stored inside Parquet/ORC files (as opposed to populated partition / missing / constant columns) is a separate concern and is out of scope here.
### Does this PR introduce _any_ user-facing change?
No. TIME is an in-progress, not-yet-released data type; this only widens internal vectorized support so that previously-failing TIME column population now succeeds.
### How was this patch tested?
New unit tests:
- `ColumnVectorUtilsSuite` (the `populate` / constant-column path): TIME across precisions 0/6/7/9, boundary values (`00:00:00`, `23:59:59.999999999`), null (missing column), and TIME nested in struct / array / map.
- `ColumnarBatchSuite` (the `toBatch` path): `TimeType` added to the random-schema test and `compareStruct` (top-level and array element), a per-precision `testVector` (0/6/7/9 + boundaries), a nested struct/array `toBatch` test, and a negative unsupported-type case.
Ran `build/sbt 'sql/testOnly *ColumnVectorUtilsSuite *ColumnarBatchSuite'` (93 tests pass). Scalastyle and Java checkstyle pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor
Closes #56858 from MaxGekk/time-vec-column-pop.
Authored-by: Maxim Gekk <max.gekk@gmail.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>1 parent 2539e18 commit d635a1f
3 files changed
Lines changed: 184 additions & 4 deletions
File tree
- sql/core/src
- main/java/org/apache/spark/sql/execution/vectorized
- test/scala/org/apache/spark/sql/execution/vectorized
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| 240 | + | |
| 241 | + | |
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
| |||
Lines changed: 97 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 | | |
22 | | - | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
260 | 356 | | |
Lines changed: 84 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
1432 | 1432 | | |
1433 | 1433 | | |
1434 | 1434 | | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1435 | 1439 | | |
1436 | 1440 | | |
1437 | 1441 | | |
| |||
1506 | 1510 | | |
1507 | 1511 | | |
1508 | 1512 | | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
1509 | 1524 | | |
1510 | 1525 | | |
1511 | 1526 | | |
| |||
1562 | 1577 | | |
1563 | 1578 | | |
1564 | 1579 | | |
1565 | | - | |
| 1580 | + | |
| 1581 | + | |
1566 | 1582 | | |
1567 | 1583 | | |
1568 | 1584 | | |
| |||
2126 | 2142 | | |
2127 | 2143 | | |
2128 | 2144 | | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
2129 | 2210 | | |
2130 | 2211 | | |
2131 | 2212 | | |
| |||
0 commit comments