Skip to content

Comments

Cleanup CSV WriterBuilder, Default to AutoSI Second Precision (#4735)#4909

Merged
tustvold merged 4 commits intoapache:masterfrom
tustvold:cleanup-csv-formatting
Oct 11, 2023
Merged

Cleanup CSV WriterBuilder, Default to AutoSI Second Precision (#4735)#4909
tustvold merged 4 commits intoapache:masterfrom
tustvold:cleanup-csv-formatting

Conversation

@tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 9, 2023

Which issue does this PR close?

Closes #4735
Closes #4906

Rationale for this change

Cleans up WriterBuilder to not default the format strings, this not only saves allocations, but also allows using the fast formatting path for RFC3339 formatting.

What changes are included in this PR?

Are there any user-facing changes?

This changes timestamps to default to AutoSI. I'm not sure this really counts as a breaking change, any well-behaved parser should handle this

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 9, 2023
}

/// Set whether to write headers
#[deprecated(note = "Use Self::with_header")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const DEFAULT_DATE_FORMAT: &str = "%F";
const DEFAULT_TIME_FORMAT: &str = "%T";
const DEFAULT_TIMESTAMP_FORMAT: &str = "%FT%H:%M:%S.%9f";
const DEFAULT_TIMESTAMP_TZ_FORMAT: &str = "%FT%H:%M:%S.%9f%:z";
Copy link
Contributor Author

@tustvold tustvold Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice cleanup. Thank you @tustvold

@@ -97,26 +92,14 @@ pub struct Writer<W: Write> {
/// Is the beginning-of-writer
beginning: bool,
/// The value to represent null entries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The value to represent null entries
/// The value to represent null entries. If not specified, [`DEFAULT_NULL_VALUE`] is used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might help to add information about the default values for the formats above as well

pub struct WriterBuilder {
/// Optional column delimiter. Defaults to `b','`
delimiter: Option<u8>,
delimiter: u8,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the idea that a u8 is more space efficient than Option<u8>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more just unnecessary 😅

}
drop(writer);

let left = "c1,c2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this test removed?

I see the output is identical in the two cases -- is there still coverage showing that `

arrow_csv::WriterBuilder::new()
        .with_rfc3339()

Produces the default values?

Perhaps given .with_rfc3339() is the default, maybe it should should be deprecated too 🤔 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add read access to settings in csv::WriterBuilder

2 participants