MCPcopy Create free account
hub / github.com/apache/datafusion / register_file_format

Method register_file_format

datafusion/core/src/execution/session_state.rs:885–905  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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.

Callers 4

custom_file_formatFunction · 0.80
set_view_stateFunction · 0.80
buildMethod · 0.80

Calls 3

get_extMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected