Commit 3e9191e
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 1b8451c commit 3e9191e
6 files changed
Lines changed: 221 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 | | |
| |||
1095 | 1095 | | |
1096 | 1096 | | |
1097 | 1097 | | |
1098 | | - | |
| 1098 | + | |
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
| |||
2092 | 2092 | | |
2093 | 2093 | | |
2094 | 2094 | | |
2095 | | - | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2096 | 2099 | | |
2097 | 2100 | | |
2098 | 2101 | | |
| |||
| 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