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)
| 95 | /// of hive style partitioning where some columns are removed from the |
| 96 | /// underlying files. |
| 97 | pub 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 | /// |
no test coverage detected
searching dependent graphs…