I have added this test to SqlOperatorTest:
f.checkScalar("cast(0.012 as DECIMAL(2, 5))", new BigDecimal("0.012"),
"DECIMAL(2, 5) NOT NULL");
and it has passed. That's why I am asking. It should fail, but it doesn't.
Mihai
-----Original Message-----
From: stanilovsky evgeny
Sent: Friday, August 04, 2023 7:00 AM
To: [email protected]
Subject: Re: DECIMAL(2, 3) meaning
Hello Mihai.
A bit older standard describes Precision as : Precision of decimal
floating-point values is a positive value that specifies the number of
significant decimal digits in the mantissa.
Thus:
cast(0.012 as DECIMAL(3, 3)) - ok
cast(0.012 as DECIMAL(2, 3)) - fail
cast(0.012 as DECIMAL(1, 3)) - fail
cast(0.012 as DECIMAL(2, 5)) - fail
> 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