Skip to content

Error in evaluating expression: "Out of range value for column of Decimal type"  #7079

@nicktobey

Description

@nicktobey

Simplest reproduction case: SELECT CASE 1 WHEN 2 THEN NULL ELSE (6 * 2) / 1 END;

In order for this to reproduce, the numerator in the fraction must be an expression that evaluates to an integer with multiple digits. (So replacing it with something like 12/1 or (3 * 2)/1 will not reproduce the error.

This behavior is reproducible regardless of which side of the CASE the expression is on, provided that the expression is on the side that gets chosen. The behavior is also reproducible when the CASE has multiple branches, provided that every other branch is NULL.

So for instance, the following statements all produce an error:

SELECT CASE 1 WHEN 2 THEN NULL ELSE (6 * 2) / 1  END;
SELECT CASE 1 WHEN 2 THEN NULL WHEN 3 THEN NULL ELSE (6 * 2) / 1  END;
SELECT CASE 1 WHEN 1 THEN (6 * 2) / 1 ELSE NULL END;
SELECT CASE 1 WHEN 1 THEN (6 * 2) / 1 WHEN 2 THEN NULL ELSE NULL END;

But the following will not:

SELECT CASE 1 WHEN 2 THEN NULL ELSE (3 * 2) / 1  END; -- numerator is single-digit
SELECT CASE 1 WHEN 2 THEN NULL ELSE (3 * 4.0) / 1  END; -- numerator is not an integer
SELECT CASE 1 WHEN 2 THEN "x" ELSE (3 * 4.0) / 1  END; -- other branch is not NULL
SELECT CASE 1 WHEN 2 THEN NULL WHEN 3 THEN "x" ELSE (3 * 4.0) / 1  END; -- has a third branch which is not Null
SELECT CASE 1 WHEN 2 THEN NULL WHEN 3 THEN (3 * 4.0) / 1 ELSE (3 * 4.0) / 1  END; -- has a third branch which is not Null (even though it's the same as the problem branch)

This is responsible for ~50 of the 350 remaining sqllogictest failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsqlIssue with SQL

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions