Skip to content

Commit

Permalink
chore(es): clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
etolbakov authored Jul 17, 2024
1 parent e1fb975 commit d7c5d28
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::not_nan_f32::NotNaNf32;
use crate::query_ast::QueryAst;
use crate::JsonLiteral;

/// Elasticsearch/OpenSearch uses a set of preconfigured formats, more information could be found here
/// https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
// Elasticsearch/OpenSearch uses a set of preconfigured formats, more information could be found
// here https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

lazy_static! {
static ref ELASTICSEARCH_FORMAT_TO_STRFTIME: HashMap<&'static str, &'static str> = {
Expand All @@ -44,6 +44,7 @@ lazy_static! {
m.insert(r"^date_optional_time$", "%Y-%m-%dT%H:%M:%S.%3f%:z");
m.insert(r"^strict_date_optional_time$", "%Y-%m-%dT%H:%M:%S.%3f%:z");
m.insert(r"^yyyy-MM-dd$", "%Y-%m-%d");
m.insert(r"^basic_date$", "%Y%m%d");
m.insert(r"^yyyyMMdd$", "%Y%m%d");
m
};
Expand Down Expand Up @@ -83,7 +84,7 @@ impl ConvertableToQueryAst for RangeQuery {
format,
} = self.value;
let (gt, gte, lt, lte) = if let Some(JsonLiteral::String(fmt)) = format {
let parser = create_strptime_parser(&fmt)?;
let parser = create_strptime_parser(fmt)?;
(
gt.map(|v| parse_and_convert(v, &parser)).transpose()?,
gte.map(|v| parse_and_convert(v, &parser)).transpose()?,
Expand Down Expand Up @@ -129,7 +130,7 @@ fn parse_and_convert(literal: JsonLiteral, parser: &StrptimeParser) -> anyhow::R
}
}

fn create_strptime_parser(fmt: &String) -> Result<StrptimeParser, Error> {
fn create_strptime_parser(fmt: String) -> Result<StrptimeParser, Error> {
let strptime_format = convert_format_to_strpformat(&fmt)?;
StrptimeParser::from_str(&strptime_format).map_err(|reason| {
anyhow::anyhow!("failed to create parser from : {}; reason: {}", fmt, reason)
Expand Down

0 comments on commit d7c5d28

Please sign in to comment.