Skip to content

Commit 1e8646a

Browse files
committed
fix suggestions
1 parent b75ec12 commit 1e8646a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
use chrono::ParseError;
1+
use crate::compile::engine::df::scan::DataFusionError;
22
use chrono::{NaiveDate, NaiveDateTime};
33

4-
pub fn parse_date_str(s: &str) -> Result<NaiveDateTime, ParseError> {
5-
NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S%.f")
4+
pub fn parse_date_str(s: &str) -> Result<NaiveDateTime, DataFusionError> {
5+
let parsed = NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S%.f")
66
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M:%S%.f"))
77
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S"))
88
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S%.fZ"))
99
.or_else(|_| {
1010
NaiveDate::parse_from_str(s, "%Y-%m-%d").map(|date| date.and_hms_opt(0, 0, 0).unwrap())
11-
})
11+
});
12+
13+
parsed.map_err(|e| {
14+
DataFusionError::Internal(format!("Can't parse date/time string literal: {}", e))
15+
})
1216
}

rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4631,18 +4631,14 @@ impl FilterRules {
46314631
}
46324632

46334633
let mut result = Vec::new();
4634-
let resolved_start_date = if let Some(rtd) =
4634+
let Some(resolved_start_date) =
46354635
resolve_time_delta(&date_range_start[0], date_range_start_op)
4636-
{
4637-
rtd
4638-
} else {
4636+
else {
46394637
return false;
46404638
};
4641-
let resolved_end_date = if let Some(rtd) =
4639+
let Some(resolved_end_date) =
46424640
resolve_time_delta(&date_range_end[0], date_range_end_op)
4643-
{
4644-
rtd
4645-
} else {
4641+
else {
46464642
return false;
46474643
};
46484644

0 commit comments

Comments
 (0)