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

Function get_writer_schema

datafusion/datasource/src/write/mod.rs:97–114  ·  view source on GitHub ↗

Converts table schema to writer schema, which may differ in the case of hive style partitioning where some columns are removed from the underlying files.

(config: &FileSinkConfig)

Source from the content-addressed store, hash-verified

95/// of hive style partitioning where some columns are removed from the
96/// underlying files.
97pub fn get_writer_schema(config: &FileSinkConfig) -> Arc<Schema> {
98 if !config.table_partition_cols.is_empty() && !config.keep_partition_by_columns {
99 let schema = config.output_schema();
100 let partition_names: Vec<_> =
101 config.table_partition_cols.iter().map(|(s, _)| s).collect();
102 Arc::new(Schema::new_with_metadata(
103 schema
104 .fields()
105 .iter()
106 .filter(|f| !partition_names.contains(&f.name()))
107 .map(|f| (**f).clone())
108 .collect::<Vec<_>>(),
109 schema.metadata().clone(),
110 ))
111 } else {
112 Arc::clone(config.output_schema())
113 }
114}
115
116/// A builder for an [`AsyncWrite`] that writes to an object store location.
117///

Calls 12

newFunction · 0.85
collectMethod · 0.80
is_emptyMethod · 0.45
output_schemaMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
filterMethod · 0.45
fieldsMethod · 0.45
containsMethod · 0.45
nameMethod · 0.45
cloneMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…