Commit e46be6b
feat: add TableSchemaBuilder; store partition cols as Fields
Introduce `TableSchemaBuilder` as the preferred way to construct a
`TableSchema`. The file schema is the only required input; partition
columns are optional, and the concatenated table schema is computed
exactly once in `build()` (rather than being recomputed on every
incremental setter call).
`TableSchema` now stores its partition columns as `arrow::datatypes::Fields`
(an immutable `Arc<[FieldRef]>`) instead of `Arc<Vec<FieldRef>>`: the
idiomatic Arrow field-list type, a single `Arc<[FieldRef]>` (one fewer
indirection), shareable zero-copy with an existing schema, and -- being
immutable -- it makes the shared-`Arc` mutation panic that motivated recent
changes structurally impossible. `TableSchemaBuilder::with_table_partition_cols`
takes `impl Into<Fields>`, accepting an existing schema's `Fields` without a
`Vec` round-trip.
`TableSchema::table_partition_cols()` (and the delegating
`FileScanConfig::table_partition_cols()`) now return `&Fields`. `Fields`
derefs to `&[FieldRef]`, so iteration/indexing/`len`/`is_empty` callers are
unchanged; only the arrow `FileFormat` path needed `.to_vec()`.
The mutating `TableSchema::with_table_partition_cols` setter is deprecated
in favor of the builder; `new`/`from_file_schema` are kept as conveniences
that route through the builder. Documented in the 55.0.0 upgrade guide.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c20f245 commit e46be6b
7 files changed
Lines changed: 248 additions & 112 deletions
File tree
- datafusion
- datasource-arrow/src
- datasource/src
- file_scan_config
- docs/source/library-user-guide/upgrading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
1059 | | - | |
| 1059 | + | |
1060 | 1060 | | |
1061 | 1061 | | |
1062 | 1062 | | |
| |||
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
2056 | | - | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
2057 | 2060 | | |
2058 | 2061 | | |
2059 | 2062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
0 commit comments