File format specific behaviors for [`DataSource`] # Schema information There are two important schemas for a [`FileSource`]: 1. [`Self::table_schema`] -- the schema for the overall table (file data plus partition columns) 2. The logical output schema, comprised of [`Self::table_schema`] with [`Self::projection`] applied See more details on specific implementations: [`ArrowSource`](https://docs.r
| 63 | /// |
| 64 | /// [`DataSource`]: crate::source::DataSource |
| 65 | pub trait FileSource: Any + Send + Sync { |
| 66 | /// Creates a `dyn FileOpener` based on given parameters. |
| 67 | /// |
| 68 | /// Note: File sources with a native morsel implementation should return an |
| 69 | /// error from this method and implementing [`Self::create_morselizer`] instead. |
| 70 | fn create_file_opener( |
| 71 | &self, |
| 72 | object_store: Arc<dyn ObjectStore>, |
| 73 | base_config: &FileScanConfig, |
| 74 | partition: usize, |
| 75 | ) -> Result<Arc<dyn FileOpener>>; |
| 76 | |
| 77 | /// Creates a `dyn Morselizer` based on given parameters. |
| 78 | /// |
| 79 | /// The default implementation preserves existing behavior by adapting the |
| 80 | /// legacy [`FileOpener`] API into a [`Morselizer`]. |
| 81 | /// |
| 82 | /// It is preferred to implement the [`Morselizer`] API directly by |
| 83 | /// implementing this method. |
| 84 | fn create_morselizer( |
| 85 | &self, |
| 86 | object_store: Arc<dyn ObjectStore>, |
| 87 | base_config: &FileScanConfig, |
| 88 | partition: usize, |
| 89 | ) -> Result<Box<dyn Morselizer>> { |
| 90 | let opener = self.create_file_opener(object_store, base_config, partition)?; |
| 91 | Ok(Box::new(FileOpenerMorselizer::new(opener))) |
| 92 | } |
| 93 | |
| 94 | /// Returns the table schema for the overall table (including partition columns, if any) |
| 95 | /// |
| 96 | /// This method returns the unprojected schema: the full schema of the data |
| 97 | /// without [`Self::projection`] applied. |
| 98 | /// |
| 99 | /// The output schema of this `FileSource` is this TableSchema |
| 100 | /// with [`Self::projection`] applied. |
| 101 | /// |
| 102 | /// Use [`ProjectionExprs::project_schema`] to get the projected schema |
| 103 | /// after applying the projection. |
| 104 | fn table_schema(&self) -> &crate::table_schema::TableSchema; |
| 105 | |
| 106 | /// Initialize new type with batch size configuration |
| 107 | fn with_batch_size(&self, batch_size: usize) -> Arc<dyn FileSource>; |
| 108 | |
| 109 | /// Returns the filter expression that will be applied *during* the file scan. |
| 110 | /// |
| 111 | /// These expressions are in terms of the unprojected [`Self::table_schema`]. |
| 112 | fn filter(&self) -> Option<Arc<dyn PhysicalExpr>> { |
| 113 | None |
| 114 | } |
| 115 | |
| 116 | /// Return the projection that will be applied to the output stream on top |
| 117 | /// of [`Self::table_schema`]. |
| 118 | /// |
| 119 | /// Note you can use [`ProjectionExprs::project_schema`] on the table |
| 120 | /// schema to get the effective output schema of this source. |
| 121 | fn projection(&self) -> Option<&ProjectionExprs> { |
| 122 | None |
no outgoing calls
no test coverage detected
searching dependent graphs…