Skip to content

Commit 503a5d8

Browse files
committed
some touches
1 parent d4f9b92 commit 503a5d8

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

datafusion/datasource-avro/src/source.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ impl FileSource for AvroSource {
8888
fn with_schema(&self, schema: TableSchema) -> Arc<dyn FileSource> {
8989
let mut conf = self.clone();
9090
// TableSchema may have partition columns, but AvroSource does not use partition columns or values atm
91-
conf.schema = Some(Arc::clone(&schema.file_schema()));
91+
conf.schema = Some(Arc::clone(schema.file_schema()));
9292
Arc::new(conf)
9393
}
94+
9495
fn with_statistics(&self, statistics: Statistics) -> Arc<dyn FileSource> {
9596
let mut conf = self.clone();
9697
conf.projected_statistics = Some(statistics);

docs/source/library-user-guide/upgrading.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ As part of this change, the `FileSource::with_schema()` method signature has cha
150150
Arc::new(Self {
151151
- schema: Some(schema),
152152
+ // Use schema.file_schema() to get the file schema without partition columns
153-
+ schema: Some(Arc::clone(&schema.file_schema())),
153+
+ schema: Some(Arc::clone(schema.file_schema())),
154154
..self.clone()
155155
})
156156
}
@@ -159,17 +159,19 @@ As part of this change, the `FileSource::with_schema()` method signature has cha
159159

160160
For implementations that need access to partition columns:
161161

162-
```rust
162+
```rust,ignore
163163
fn with_schema(&self, schema: TableSchema) -> Arc<dyn FileSource> {
164164
Arc::new(Self {
165-
file_schema: Arc::clone(&schema.file_schema()),
165+
file_schema: Arc::clone(schema.file_schema()),
166166
partition_cols: schema.table_partition_cols().clone(),
167-
table_schema: Arc::clone(&schema.table_schema()),
167+
table_schema: Arc::clone(schema.table_schema()),
168168
..self.clone()
169169
})
170170
}
171171
```
172172

173+
**Note**: Most `FileSource` implementations only need to store the file schema (without partition columns), as shown in the first example. The second pattern of storing all three schema components is typically only needed for advanced use cases where you need access to different schema representations for different operations (e.g., ParquetSource uses the file schema for building pruning predicates but needs the table schema for filter pushdown logic).
174+
173175
**Using `TableSchema` directly:**
174176

175177
If you're constructing a `FileScanConfig` or working with table schemas and partition columns, you can now use `TableSchema`:
@@ -193,9 +195,9 @@ let partition_cols = vec![
193195
let table_schema = TableSchema::new(file_schema, partition_cols);
194196

195197
// Access different schema representations
196-
let file_schema = table_schema.file_schema(); // Schema without partition columns
197-
let table_schema = table_schema.table_schema(); // Complete schema with partition columns
198-
let partition_cols = table_schema.table_partition_cols(); // Just the partition columns
198+
let file_schema_ref = table_schema.file_schema(); // Schema without partition columns
199+
let full_schema = table_schema.table_schema(); // Complete schema with partition columns
200+
let partition_cols_ref = table_schema.table_partition_cols(); // Just the partition columns
199201
```
200202

201203
## DataFusion `50.0.0`

0 commit comments

Comments
 (0)