(negative: bool, interval: Interval)
| 195 | } |
| 196 | |
| 197 | fn 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)?; |
no test coverage detected
searching dependent graphs…