Skip to content

spark: an interval literal that overflows Spark's carrier throws a bare ArithmeticException #1271

Description

@nielspardon

ToSparkExpression converts both interval literals into Spark's physical carrier and leans on Math's exact operations to refuse a value that does not fit:

  • visit(IntervalDayLiteral) folds days, seconds and subseconds into a micros Long. It overflows from roughly 106.7M days, well inside int32, so an out-of-range producer reaches it.
  • visit(IntervalYearLiteral) folds years and months into a months Int. It overflows once the flattened total leaves Int.

Both let the raw java.lang.ArithmeticException escape — long overflow or integer overflow. Neither message says which literal failed, what the component values were, or what the carrier's range is, so a producer emitting an out-of-range interval gets a message that could have come from anywhere in the conversion.

Util.toMicroseconds already sets the module's bar here: it throws UnsupportedOperationException naming the offending precision and the legal bounds. Both interval paths should do the same — bounds-check first, or catch the exact-op failure — and report the components alongside the carrier limit.

Worth doing for the two paths together rather than one at a time, so the two literals keep taking the same stance on the same arithmetic. Raised in review of #1140, which left both bare deliberately for that reason.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions