Skip to content

[SQL] Ceiling and floor do not throw on overflow #56615

Description

@matthewalex4

With ANSI mode set, ceiling and floor saturate to LONG_MAX/LONG_MIN on overflow instead of throwing. This is in contrast to e.g. abs which throws on overflow.

Steps to reproduce:

-- throws as specified in the docs
SELECT abs(-2147483648);

-- should throw but saturates to 9223372036854775807
SELECT ceiling(1e30);

-- should throw but saturates to -9223372036854775808
SELECT floor(-1e30);
Expected: SparkArithmeticException: ARITHMETIC_OVERFLOW
Actual: 9223372036854775807 / -9223372036854775808

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions