Oracle does support casting int to decimal.

select cast (0.49 as integer) from dual; Result 0
select cast (0.99 as integer) from dual; Result 1

Looks like Oracle treats it like the ROUND function and not FLOOR
select floor (-0.49) from dual; Result 0
select floor (-0.49) from dual; Result -1

What should our implementation do?

SQL99 doesn't say much about that kind of down casting.
http://docstore.mik.ua/orelly/oracle/guide8i/ch10_03.htm#ch10-72977


On Tue, Sep 10, 2013 at 9:05 PM, James Taylor <notifications@github.com>wrote:

> In
> src/test/java/com/salesforce/phoenix/expression/CoerceExpressionTest.java:
>
> > +import org.junit.Test;
> > +
> > +import com.salesforce.phoenix.schema.PDataType;
> > +
> > +public class CoerceExpressionTest {
> > +    @Test
> > +    public void testCoerceExpression() throws Exception {
> > +        LiteralExpression v = LiteralExpression.newConstant(1, PDataType.INTEGER);
> > +        CoerceExpression e = new CoerceExpression(v, PDataType.DECIMAL);
> > +        ImmutableBytesWritable ptr = new ImmutableBytesWritable();
> > +        boolean evaluated = e.evaluate(null, ptr);
> > +        Boolean result = (Boolean)e.getDataType().toObject(ptr);
> > +        assertTrue(evaluated);
> > +        assertEquals(Boolean.FALSE,result);
> > +    }
> > +}
>
> One more consideration: should coerce from DECIMAL to INTEGER be
> supported? What do other relational databases do in this case? What does
> the SQL92 or SQL99 spec say should happen?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/forcedotcom/phoenix/pull/419/files#r6285464>
> .
>