Skip to content

Commit

Permalink
put in fixes for clippy and scalafix issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
vidyasankarv committed May 12, 2024
1 parent ace7456 commit 0116239
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/src/execution/datafusion/expressions/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,15 +1516,15 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult<Option<i32>>
}

fn return_result(date_str: &str, eval_mode: EvalMode) -> CometResult<Option<i32>> {
return if eval_mode == EvalMode::Ansi {
if eval_mode == EvalMode::Ansi {
Err(CometError::CastInvalidValue {
value: date_str.to_string(),
from_type: "STRING".to_string(),
to_type: "DATE".to_string(),
})
} else {
Ok(None)
};
}
}
// end local functions

Expand Down Expand Up @@ -1571,7 +1571,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult<Option<i32>>
} else {
//increment value of current segment by the next digit
let parsed_value = (b - b'0') as i32;
if parsed_value < 0 || parsed_value > 9 {
if !(0..=9).contains(&parsed_value) {
return return_result(date_str, eval_mode);
} else {
current_segment_value = current_segment_value * 10 + parsed_value;
Expand All @@ -1593,7 +1593,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult<Option<i32>>

date_segments[current_segment as usize] = current_segment_value;

return match NaiveDate::from_ymd_opt(
match NaiveDate::from_ymd_opt(
sign * date_segments[0],
date_segments[1] as u32,
date_segments[2] as u32,
Expand All @@ -1603,7 +1603,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult<Option<i32>>
Ok(Some(duration_since_epoch.to_i32().unwrap()))
}
None => Ok(None),
};
}
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion spark/src/test/scala/org/apache/comet/CometCastSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
*/
private val numericPattern = "0123456789deEf+-." + whitespaceChars

private val datePattern = "0123456789/" + whitespaceChars
private val timestampPattern = "0123456789/:T" + whitespaceChars

test("all valid cast combinations covered") {
Expand Down

0 comments on commit 0116239

Please sign in to comment.