Adds or updates a [FileFormatFactory] which can be used with COPY TO or CREATE EXTERNAL TABLE statements for reading and writing files of custom formats.
(
&mut self,
file_format: Arc<dyn FileFormatFactory>,
overwrite: bool,
)
| 883 | /// CREATE EXTERNAL TABLE statements for reading and writing files of custom |
| 884 | /// formats. |
| 885 | pub fn register_file_format( |
| 886 | &mut self, |
| 887 | file_format: Arc<dyn FileFormatFactory>, |
| 888 | overwrite: bool, |
| 889 | ) -> Result<(), DataFusionError> { |
| 890 | let ext = file_format.get_ext().to_lowercase(); |
| 891 | match (self.file_formats.entry(ext.clone()), overwrite) { |
| 892 | (Entry::Vacant(e), _) => { |
| 893 | e.insert(file_format); |
| 894 | } |
| 895 | (Entry::Occupied(mut e), true) => { |
| 896 | e.insert(file_format); |
| 897 | } |
| 898 | (Entry::Occupied(_), false) => { |
| 899 | return config_err!( |
| 900 | "File type already registered for extension {ext}. Set overwrite to true to replace this extension." |
| 901 | ); |
| 902 | } |
| 903 | }; |
| 904 | Ok(()) |
| 905 | } |
| 906 | |
| 907 | /// Retrieves a [FileFormatFactory] based on file extension which has been registered |
| 908 | /// via SessionContext::register_file_format. Extensions are not case sensitive. |
no test coverage detected