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

Method create

datafusion/catalog/src/stream.rs:50–81  ·  view source on GitHub ↗
(
        &self,
        state: &dyn Session,
        cmd: &CreateExternalTable,
    )

Source from the content-addressed store, hash-verified

48#[async_trait]
49impl TableProviderFactory for StreamTableFactory {
50 async fn create(
51 &self,
52 state: &dyn Session,
53 cmd: &CreateExternalTable,
54 ) -> Result<Arc<dyn TableProvider>> {
55 let schema: SchemaRef = Arc::clone(cmd.schema.inner());
56 let location = cmd.location.clone();
57 let encoding = cmd.file_type.parse()?;
58 let header = if let Ok(opt) = cmd
59 .options
60 .get("format.has_header")
61 .map(|has_header| bool::from_str(has_header.to_lowercase().as_str()))
62 .transpose()
63 {
64 opt.unwrap_or(false)
65 } else {
66 return config_err!(
67 "Valid values for format.has_header option are 'true' or 'false'"
68 );
69 };
70
71 let source = FileStreamProvider::new_file(schema, location.into())
72 .with_encoding(encoding)
73 .with_batch_size(state.config().batch_size())
74 .with_header(header);
75
76 let config = StreamConfig::new(Arc::new(source))
77 .with_order(cmd.order_exprs.clone())
78 .with_constraints(cmd.constraints.clone());
79
80 Ok(Arc::new(StreamTable(Arc::new(config))))
81 }
82}
83
84/// The data encoding for [`StreamTable`]

Callers 2

writerMethod · 0.45
refreshMethod · 0.45

Calls 15

from_strFunction · 0.85
newFunction · 0.85
StreamTableClass · 0.85
with_encodingMethod · 0.80
innerMethod · 0.45
cloneMethod · 0.45
parseMethod · 0.45
mapMethod · 0.45
getMethod · 0.45
as_strMethod · 0.45
with_headerMethod · 0.45
with_batch_sizeMethod · 0.45

Tested by

no test coverage detected