Registers a [`ListingTable`] that can assemble multiple files from locations in an [`ObjectStore`] instance into a single table. This method is `async` because it might need to resolve the schema. [`ObjectStore`]: object_store::ObjectStore
(
&self,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: ListingOptions,
provided_schema: Option<SchemaRef>,
sql_definition:
| 1812 | /// |
| 1813 | /// [`ObjectStore`]: object_store::ObjectStore |
| 1814 | pub async fn register_listing_table( |
| 1815 | &self, |
| 1816 | table_ref: impl Into<TableReference>, |
| 1817 | table_path: impl AsRef<str>, |
| 1818 | options: ListingOptions, |
| 1819 | provided_schema: Option<SchemaRef>, |
| 1820 | sql_definition: Option<String>, |
| 1821 | ) -> Result<()> { |
| 1822 | let table_ref = table_ref.into(); |
| 1823 | let table_path = |
| 1824 | ListingTableUrl::parse(table_path)?.with_table_ref(table_ref.clone()); |
| 1825 | let resolved_schema = match provided_schema { |
| 1826 | Some(s) => s, |
| 1827 | None => options.infer_schema(&self.state(), &table_path).await?, |
| 1828 | }; |
| 1829 | let config = ListingTableConfig::new(table_path) |
| 1830 | .with_listing_options(options) |
| 1831 | .with_schema(resolved_schema); |
| 1832 | let table = ListingTable::try_new(config)? |
| 1833 | .with_definition(sql_definition) |
| 1834 | .with_cache(self.runtime_env().cache_manager.get_file_statistic_cache()); |
| 1835 | self.register_table(table_ref, Arc::new(table))?; |
| 1836 | Ok(()) |
| 1837 | } |
| 1838 | |
| 1839 | fn register_type_check<P: DataFilePaths>( |
| 1840 | &self, |