From 0116239a8e437433b50bd0f5b2b657b67c0f5d8a Mon Sep 17 00:00:00 2001 From: vidyasankarv Date: Sun, 12 May 2024 10:16:24 +0530 Subject: [PATCH] put in fixes for clippy and scalafix issues. --- core/src/execution/datafusion/expressions/cast.rs | 10 +++++----- .../test/scala/org/apache/comet/CometCastSuite.scala | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/execution/datafusion/expressions/cast.rs b/core/src/execution/datafusion/expressions/cast.rs index ca4786435f..d713eec8a1 100644 --- a/core/src/execution/datafusion/expressions/cast.rs +++ b/core/src/execution/datafusion/expressions/cast.rs @@ -1516,7 +1516,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult> } fn return_result(date_str: &str, eval_mode: EvalMode) -> CometResult> { - return if eval_mode == EvalMode::Ansi { + if eval_mode == EvalMode::Ansi { Err(CometError::CastInvalidValue { value: date_str.to_string(), from_type: "STRING".to_string(), @@ -1524,7 +1524,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult> }) } else { Ok(None) - }; + } } // end local functions @@ -1571,7 +1571,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult> } 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; @@ -1593,7 +1593,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult> 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, @@ -1603,7 +1603,7 @@ fn date_parser(date_str: &str, eval_mode: EvalMode) -> CometResult> Ok(Some(duration_since_epoch.to_i32().unwrap())) } None => Ok(None), - }; + } } #[cfg(test)] diff --git a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala index fe3c4f5532..d09d8c9513 100644 --- a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala @@ -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") {