Skip to content

Commit bb57c76

Browse files
author
Jiayu Liu
committed
use upper case
1 parent 5d96e52 commit bb57c76

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

datafusion/src/physical_plan/window_functions.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@ impl FromStr for WindowFunction {
5858

5959
impl fmt::Display for BuiltInWindowFunction {
6060
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
61-
// uppercase of the debug.
62-
write!(f, "{}", format!("{:?}", self).to_uppercase())
61+
match self {
62+
BuiltInWindowFunction::RowNumber => write!(f, "ROW_NUMBER"),
63+
BuiltInWindowFunction::Rank => write!(f, "RANK"),
64+
BuiltInWindowFunction::DenseRank => write!(f, "DENSE_RANK"),
65+
BuiltInWindowFunction::PercentRank => write!(f, "PERCENT_RANK"),
66+
BuiltInWindowFunction::CumeDist => write!(f, "CUME_DIST"),
67+
BuiltInWindowFunction::Ntile => write!(f, "NTILE"),
68+
BuiltInWindowFunction::Lag => write!(f, "LAG"),
69+
BuiltInWindowFunction::Lead => write!(f, "LEAD"),
70+
BuiltInWindowFunction::FirstValue => write!(f, "FIRST_VALUE"),
71+
BuiltInWindowFunction::LastValue => write!(f, "LAST_VALUE"),
72+
BuiltInWindowFunction::NthValue => write!(f, "NTH_VALUE"),
73+
}
6374
}
6475
}
6576

@@ -108,18 +119,18 @@ pub enum BuiltInWindowFunction {
108119
impl FromStr for BuiltInWindowFunction {
109120
type Err = DataFusionError;
110121
fn from_str(name: &str) -> Result<BuiltInWindowFunction> {
111-
Ok(match name.to_lowercase().as_str() {
112-
"row_number" => BuiltInWindowFunction::RowNumber,
113-
"rank" => BuiltInWindowFunction::Rank,
114-
"dense_rank" => BuiltInWindowFunction::DenseRank,
115-
"percent_rank" => BuiltInWindowFunction::PercentRank,
116-
"cume_dist" => BuiltInWindowFunction::CumeDist,
117-
"ntile" => BuiltInWindowFunction::Ntile,
118-
"lag" => BuiltInWindowFunction::Lag,
119-
"lead" => BuiltInWindowFunction::Lead,
120-
"first_value" => BuiltInWindowFunction::FirstValue,
121-
"last_value" => BuiltInWindowFunction::LastValue,
122-
"nth_value" => BuiltInWindowFunction::NthValue,
122+
Ok(match name.to_uppercase().as_str() {
123+
"ROW_NUMBER" => BuiltInWindowFunction::RowNumber,
124+
"RANK" => BuiltInWindowFunction::Rank,
125+
"DENSE_RANK" => BuiltInWindowFunction::DenseRank,
126+
"PERCENT_RANK" => BuiltInWindowFunction::PercentRank,
127+
"CUME_DIST" => BuiltInWindowFunction::CumeDist,
128+
"NTILE" => BuiltInWindowFunction::Ntile,
129+
"LAG" => BuiltInWindowFunction::Lag,
130+
"LEAD" => BuiltInWindowFunction::Lead,
131+
"FIRST_VALUE" => BuiltInWindowFunction::FirstValue,
132+
"LAST_VALUE" => BuiltInWindowFunction::LastValue,
133+
"NTH_VALUE" => BuiltInWindowFunction::NthValue,
123134
_ => {
124135
return Err(DataFusionError::Plan(format!(
125136
"There is no built-in window function named {}",
@@ -206,6 +217,7 @@ mod tests {
206217
let fun = WindowFunction::from_str(name)?;
207218
let fun2 = WindowFunction::from_str(name.to_uppercase().as_str())?;
208219
assert_eq!(fun, fun2);
220+
assert_eq!(fun.to_string(), name.to_uppercase());
209221
}
210222
Ok(())
211223
}

0 commit comments

Comments
 (0)