hi, mbudiu.

thanks for opening this discussion.

I have checked the sql 1999. it also has this limit.
20)The <scale> of an <exact numeric type> shall not be greater than
            the <precision> of the <exact numeric type>.
6.1 (page125)


however, I think calcite allow scale can be greater than precision,
probably considering 'e' notation.
for example:
1.2e-2 can be use DECIMAL(2,3) this type, the precision is 2, it's stored
value is 0.012.

As for you case
```
f.checkScalar("cast(0.012 as DECIMAL(2, 5))", new BigDecimal("0.012"),
        "DECIMAL(2, 5) NOT NULL");
```

although cast(0.012 as DECIMAL(2, 5)) it works, it just cast behavior, not
say 0.012 is DECIMAL(2, 5).
you can try cast cast(0.012 as DECIMAL(1, 5)), cast(0.012 as DECIMAL(2,
5)), cast(0.012 as DECIMAL(6, 5)) all works.

I think here the cast just not check the precision. it's another question.

if i'm wrong, pls correct me. hope it helps you.

Best Regards,
Ran Tao
https://github.com/chucheng92


<[email protected]> 于2023年8月4日周五 06:51写道:

> Hello,
>
>
>
> I notice that Calcite happily accepts decimal type specifications where the
> scale is greater than the precision.
>
> There are quite a few tests with such types.
>
>
>
> What is the meaning of such types?
>
>
>
> The SQL 92 standard has this statement on page 109:
>
>
>
> 15)The <scale> of an <exact numeric type> shall not be greater than
>
>             the <precision> of the <exact numeric type>.
>
>
>
> Thank you,
>
> Mihai
>
>

Reply via email to