Skip to content

Commit

Permalink
feat: Implement daterange range function
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Sep 7, 2024
1 parent 5754922 commit f3e0920
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/gitql-std/src/range/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::collections::HashMap;
#[inline(always)]
pub fn register_std_range_functions(map: &mut HashMap<&'static str, Function>) {
map.insert("int4range", int4range);
map.insert("daterange", daterange);
}

#[inline(always)]
Expand All @@ -19,6 +20,13 @@ pub fn register_std_range_function_signatures(map: &mut HashMap<&'static str, Si
return_type: DataType::Range(Box::new(DataType::Integer)),
},
);
map.insert(
"daterange",
Signature {
parameters: vec![DataType::Date, DataType::Date],
return_type: DataType::Range(Box::new(DataType::Date)),
},
);
}

pub fn int4range(inputs: &[Value]) -> Value {
Expand All @@ -28,3 +36,11 @@ pub fn int4range(inputs: &[Value]) -> Value {
Box::new(inputs[1].clone()),
)
}

pub fn daterange(inputs: &[Value]) -> Value {
Value::Range(
DataType::Date,
Box::new(inputs[0].clone()),
Box::new(inputs[1].clone()),
)
}

0 comments on commit f3e0920

Please sign in to comment.