Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rust): remove unreachable path in write_anyvalue #6727

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions polars/polars-io/src/csv/write_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ fn fast_float_write<N: ToLexical>(f: &mut Vec<u8>, n: N, write_size: usize) -> s
Ok(())
}

fn write_anyvalue(f: &mut Vec<u8>, value: AnyValue, options: &SerializeOptions) {
fn write_anyvalue(
f: &mut Vec<u8>,
value: AnyValue,
options: &SerializeOptions,
datetime_format: &str,
) {
match value {
AnyValue::Null => write!(f, "{}", &options.null),
AnyValue::Int8(v) => write!(f, "{v}"),
Expand Down Expand Up @@ -91,10 +96,7 @@ fn write_anyvalue(f: &mut Vec<u8>, value: AnyValue, options: &SerializeOptions)
TimeUnit::Milliseconds => temporal_conversions::timestamp_ms_to_datetime(v),
};
match tz {
None => match &options.datetime_format {
None => write!(f, "{ndt}"),
Some(fmt) => write!(f, "{}", ndt.format(fmt)),
},
None => write!(f, "{}", ndt.format(datetime_format)),
Some(tz) => {
write!(f, "{}", PlTzAware::new(ndt, tz))
}
Expand Down Expand Up @@ -201,6 +203,7 @@ pub(crate) fn write<W: Write>(
options.datetime_format = Some("%FT%H:%M:%S.%3f".to_string());
}
}
let datetime_format: &str = options.datetime_format.as_ref().unwrap();

let len = df.height();
let n_threads = POOL.current_num_threads();
Expand Down Expand Up @@ -242,7 +245,7 @@ pub(crate) fn write<W: Write>(
for col in &mut col_iters {
match col.next() {
Some(value) => {
write_anyvalue(&mut write_buffer, value, options);
write_anyvalue(&mut write_buffer, value, options, datetime_format);
}
None => {
finished = true;
Expand Down