MCPcopy Create free account
hub / github.com/apache/datafusion / sql_interval_to_expr_impl

Function sql_interval_to_expr_impl

datafusion/sql/src/expr/value.rs:197–266  ·  view source on GitHub ↗
(negative: bool, interval: Interval)

Source from the content-addressed store, hash-verified

195}
196
197fn sql_interval_to_expr_impl(negative: bool, interval: Interval) -> Result<Expr> {
198 if interval.leading_precision.is_some() {
199 return not_impl_err!(
200 "Unsupported Interval Expression with leading_precision {:?}",
201 interval.leading_precision
202 );
203 }
204
205 if interval.last_field.is_some() {
206 return not_impl_err!(
207 "Unsupported Interval Expression with last_field {:?}",
208 interval.last_field
209 );
210 }
211
212 if interval.fractional_seconds_precision.is_some() {
213 return not_impl_err!(
214 "Unsupported Interval Expression with fractional_seconds_precision {:?}",
215 interval.fractional_seconds_precision
216 );
217 }
218
219 if let SQLExpr::BinaryOp { left, op, right } = *interval.value {
220 let df_op = match op {
221 BinaryOperator::Plus => Operator::Plus,
222 BinaryOperator::Minus => Operator::Minus,
223 _ => {
224 return not_impl_err!("Unsupported interval operator: {op:?}");
225 }
226 };
227 let left_expr = sql_interval_to_expr_impl(
228 negative,
229 Interval {
230 value: left,
231 leading_field: interval.leading_field.clone(),
232 leading_precision: None,
233 last_field: None,
234 fractional_seconds_precision: None,
235 },
236 )?;
237 let right_expr = sql_interval_to_expr_impl(
238 false,
239 Interval {
240 value: right,
241 leading_field: interval.leading_field,
242 leading_precision: None,
243 last_field: None,
244 fractional_seconds_precision: None,
245 },
246 )?;
247 return Ok(Expr::BinaryExpr(BinaryExpr::new(
248 Box::new(left_expr),
249 df_op,
250 Box::new(right_expr),
251 )));
252 }
253
254 let value = interval_literal(*interval.value, negative)?;

Callers 1

sql_interval_to_exprMethod · 0.85

Calls 6

newFunction · 0.85
interval_literalFunction · 0.85
BinaryExprClass · 0.50
litFunction · 0.50
cloneMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…