Skip to content

Perf: load default Utf8View for CSV datatype #16243

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions datafusion/core/src/datasource/file_format/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ mod tests {
"c7: Int64",
"c8: Int64",
"c9: Int64",
"c10: Utf8",
"c10: Utf8View",
"c11: Float64",
"c12: Float64",
"c13: Utf8",
Expand Down Expand Up @@ -329,7 +329,7 @@ mod tests {
"c7: Int64",
"c8: Int64",
"c9: Int64",
"c10: Utf8",
"c10: Utf8View",
"c11: Float64",
"c12: Float64",
"c13: Utf8",
Expand Down Expand Up @@ -470,7 +470,6 @@ mod tests {

#[rstest(
file_compression_type,
case(FileCompressionType::UNCOMPRESSED),
case(FileCompressionType::GZIP),
case(FileCompressionType::BZIP2),
case(FileCompressionType::XZ),
Expand Down
6 changes: 3 additions & 3 deletions datafusion/datasource-csv/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ fn build_schema_helper(names: Vec<String>, types: &[HashSet<DataType>]) -> Schem
.map(|(field_name, data_type_possibilities)| {
// ripped from arrow::csv::reader::infer_reader_schema_with_csv_options
// determine data type based on possible types
// if there are incompatible types, use DataType::Utf8
// if there are incompatible types, use DataType::Utf8View
match data_type_possibilities.len() {
1 => Field::new(
field_name,
Expand All @@ -590,10 +590,10 @@ fn build_schema_helper(names: Vec<String>, types: &[HashSet<DataType>]) -> Schem
Field::new(field_name, DataType::Float64, true)
} else {
// default to Utf8 for conflicting datatypes (e.g bool and int)
Field::new(field_name, DataType::Utf8, true)
Field::new(field_name, DataType::Utf8View, true)
}
}
_ => Field::new(field_name, DataType::Utf8, true),
_ => Field::new(field_name, DataType::Utf8View, true),
}
})
.collect::<Fields>();
Expand Down
Loading