Skip to content

Commit

Permalink
fix: error in case of invalid interval expression (#5987)
Browse files Browse the repository at this point in the history
This PR addresses an error that occurs when interval expressions contains invalid amount of components.
The error type was previously unclear and confusing: `NotYetImplemented`. That doesn't seem correct, because such values are not going to be supported.

Let's take a look at such example:

```sql
INTERVAL '1 MONTH DAY'
```
This is an obvious typo/mistake which leads to such error, but in fact it's just invalid value (missing number before `DAY`)
  • Loading branch information
DDtKey committed Jul 2, 2024
1 parent 859c4ad commit ebc1cb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arrow-cast/src/cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4403,17 +4403,17 @@ mod tests {
test_unsafe_string_to_interval_err!(
vec![Some("foobar")],
IntervalUnit::YearMonth,
r#"Not yet implemented: Unsupported Interval Expression with value "foobar""#
r#"Parser error: Invalid input syntax for type interval: "foobar""#
);
test_unsafe_string_to_interval_err!(
vec![Some("foobar")],
IntervalUnit::DayTime,
r#"Not yet implemented: Unsupported Interval Expression with value "foobar""#
r#"Parser error: Invalid input syntax for type interval: "foobar""#
);
test_unsafe_string_to_interval_err!(
vec![Some("foobar")],
IntervalUnit::MonthDayNano,
r#"Not yet implemented: Unsupported Interval Expression with value "foobar""#
r#"Parser error: Invalid input syntax for type interval: "foobar""#
);
test_unsafe_string_to_interval_err!(
vec![Some("2 months 31 days 1 second")],
Expand Down
4 changes: 2 additions & 2 deletions arrow-cast/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,8 +1381,8 @@ fn parse_interval_components(

// invalid amounts?
if !invalid_amounts.is_empty() {
return Err(ArrowError::NotYetImplemented(format!(
"Unsupported Interval Expression with value {value:?}"
return Err(ArrowError::ParseError(format!(
"Invalid input syntax for type interval: {value:?}"
)));
}

Expand Down

0 comments on commit ebc1cb1

Please sign in to comment.