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

Method try_from

datafusion/common/src/file_options/csv_writer.rs:67–109  ·  view source on GitHub ↗
(value: &CsvOptions)

Source from the content-addressed store, hash-verified

65 type Error = DataFusionError;
66
67 fn try_from(value: &CsvOptions) -> Result<Self> {
68 let mut builder = WriterBuilder::default()
69 .with_header(value.has_header.unwrap_or(true))
70 .with_quote(value.quote)
71 .with_delimiter(value.delimiter);
72
73 if let Some(v) = &value.date_format {
74 builder = builder.with_date_format(v.into())
75 }
76 if let Some(v) = &value.datetime_format {
77 builder = builder.with_datetime_format(v.into())
78 }
79 if let Some(v) = &value.timestamp_format {
80 builder = builder.with_timestamp_format(v.into())
81 }
82 if let Some(v) = &value.timestamp_tz_format {
83 builder = builder.with_timestamp_tz_format(v.into())
84 }
85 if let Some(v) = &value.time_format {
86 builder = builder.with_time_format(v.into())
87 }
88 if let Some(v) = &value.null_value {
89 builder = builder.with_null(v.into())
90 }
91 if let Some(v) = &value.escape {
92 builder = builder.with_escape(*v)
93 }
94 if let Some(v) = &value.double_quote {
95 builder = builder.with_double_quote(*v)
96 }
97 builder = builder.with_quote_style(value.quote_style.into());
98 if let Some(v) = &value.ignore_leading_whitespace {
99 builder = builder.with_ignore_leading_whitespace(*v)
100 }
101 if let Some(v) = &value.ignore_trailing_whitespace {
102 builder = builder.with_ignore_trailing_whitespace(*v)
103 }
104 Ok(CsvWriterOptions {
105 writer_options: builder,
106 compression: value.compression,
107 compression_level: value.compression_level,
108 })
109 }
110}

Callers

nothing calls this directly

Calls 9

with_double_quoteMethod · 0.80
with_quote_styleMethod · 0.80
with_delimiterMethod · 0.45
with_quoteMethod · 0.45
with_headerMethod · 0.45
intoMethod · 0.45
with_escapeMethod · 0.45

Tested by

no test coverage detected