Skip to content
Draft
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
13 changes: 8 additions & 5 deletions datafusion-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,14 @@ impl AdjustedPrintOptions {
}

fn config_file_type_from_str(ext: &str) -> Option<ConfigFileType> {
match ext.to_lowercase().as_str() {
"csv" => Some(ConfigFileType::CSV),
"json" => Some(ConfigFileType::JSON),
"parquet" => Some(ConfigFileType::PARQUET),
_ => None,
if ext.eq_ignore_ascii_case("csv") {
Some(ConfigFileType::CSV)
} else if ext.eq_ignore_ascii_case("json") {
Some(ConfigFileType::JSON)
} else if ext.eq_ignore_ascii_case("parquet") {
Some(ConfigFileType::PARQUET)
} else {
None
}
}

Expand Down
13 changes: 8 additions & 5 deletions datafusion-cli/src/object_storage/instrumented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ impl FromStr for InstrumentedObjectStoreMode {
type Err = DataFusionError;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"disabled" => Ok(Self::Disabled),
"summary" => Ok(Self::Summary),
"trace" => Ok(Self::Trace),
_ => Err(DataFusionError::Execution(format!("Unrecognized mode {s}"))),
if s.eq_ignore_ascii_case("disabled") {
Ok(Self::Disabled)
} else if s.eq_ignore_ascii_case("summary") {
Ok(Self::Summary)
} else if s.eq_ignore_ascii_case("trace") {
Ok(Self::Trace)
} else {
Err(DataFusionError::Execution(format!("Unrecognized mode {s}")))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions datafusion-cli/src/print_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl FromStr for MaxRows {
type Err = String;

fn from_str(maxrows: &str) -> Result<Self, Self::Err> {
if maxrows.to_lowercase() == "inf"
|| maxrows.to_lowercase() == "infinite"
|| maxrows.to_lowercase() == "none"
if maxrows.eq_ignore_ascii_case("inf")
|| maxrows.eq_ignore_ascii_case("infinite")
|| maxrows.eq_ignore_ascii_case("none")
{
Ok(Self::Unlimited)
} else {
Expand Down
23 changes: 15 additions & 8 deletions datafusion/functions/src/datetime/date_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use datafusion_macros::user_doc;
argument(
name = "part",
description = r#"Part of the date to return. The following date parts are supported:

- year
- quarter (emits value in inclusive range [1, 4] based on which quartile of the year the date is in)
- month
Expand Down Expand Up @@ -214,13 +214,20 @@ impl ScalarUDFImpl for DatePartFunc {
}
} else {
// special cases that can be extracted (in postgres) but are not interval units
match part_trim.to_lowercase().as_str() {
"qtr" | "quarter" => date_part(array.as_ref(), DatePart::Quarter)?,
"doy" => date_part(array.as_ref(), DatePart::DayOfYear)?,
"dow" => date_part(array.as_ref(), DatePart::DayOfWeekSunday0)?,
"isodow" => date_part(array.as_ref(), DatePart::DayOfWeekMonday0)?,
"epoch" => epoch(array.as_ref())?,
_ => return exec_err!("Date part '{part}' not supported"),
if part_trim.eq_ignore_ascii_case("qtr")
|| part_trim.eq_ignore_ascii_case("quarter")
{
date_part(array.as_ref(), DatePart::Quarter)?
} else if part_trim.eq_ignore_ascii_case("doy") {
date_part(array.as_ref(), DatePart::DayOfYear)?
} else if part_trim.eq_ignore_ascii_case("dow") {
date_part(array.as_ref(), DatePart::DayOfWeekSunday0)?
} else if part_trim.eq_ignore_ascii_case("isodow") {
date_part(array.as_ref(), DatePart::DayOfWeekMonday0)?
} else if part_trim.eq_ignore_ascii_case("epoch") {
epoch(array.as_ref())?
} else {
return exec_err!("Date part '{part}' not supported");
}
};

Expand Down