Re: Storing RexLiteral as BigDecimal values

2024-01-31 Thread Mihai Budiu
: Storing RexLiteral as BigDecimal values Mihai, I accept your point that literals may have values that are binary floating point. (As we discussed, they are impossible to create via SQL, but may be created via constant reduction.) But I still have a concern that developers will accidentally create

Re: Storing RexLiteral as BigDecimal values

2024-01-31 Thread Julian Hyde
would​ enable changes in the syntax too, but they can be done separately if > desired. > > Mihai > > > From: Mihai Budiu > Sent: Tuesday, January 30, 2024 4:00 PM > To: dev@calcite.apache.org > Subject: Re: Storing RexLiteral as Big

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
I think we should start a new thread. Mihai From: Stephen Carlin Sent: Tuesday, January 30, 2024 5:19 PM To: dev@calcite.apache.org Subject: Re: Storing RexLiteral as BigDecimal values I don't know if this is hijacking or adding to the discussion, but figured

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Stephen Carlin
ired. > > Mihai > > > From: Mihai Budiu > Sent: Tuesday, January 30, 2024 4:00 PM > To: dev@calcite.apache.org > Subject: Re: Storing RexLiteral as BigDecimal values > > > * > Regarding [1], it looks like the power function im

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
​ enable changes in the syntax too, but they can be done separately if desired. Mihai From: Mihai Budiu Sent: Tuesday, January 30, 2024 4:00 PM To: dev@calcite.apache.org Subject: Re: Storing RexLiteral as BigDecimal values * Regarding [1], it looks like

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
le a JIRA issue to enable this feature. Thank you, Mihai From: Julian Hyde Sent: Tuesday, January 30, 2024 3:42 PM To: dev@calcite.apache.org Subject: Re: Storing RexLiteral as BigDecimal values In the case of POWER, Postgres has both a decimal and double

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Julian Hyde
. > > Mihai > > From: Julian Hyde > Sent: Tuesday, January 30, 2024 3:03 PM > To: dev@calcite.apache.org > Subject: Re: Storing RexLiteral as BigDecimal values > > It’s surprising to me that 1004.3e0 should have type DOUBLE or REAL; I wou

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
below, the optimizer will then convert the double result of power into a BigDecimal, rounding it in the process. Mihai From: Julian Hyde Sent: Tuesday, January 30, 2024 3:03 PM To: dev@calcite.apache.org Subject: Re: Storing RexLiteral as BigDecimal values It’s

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Julian Hyde
lue. > In FP the result is the wrong one, but that's the semantics of the power > function in FP. > > Mihai > > From: Julian Hyde > Sent: Tuesday, January 30, 2024 2:50 PM > To: dev@calcite.apache.org > Subject: Re: Storing RexLiter

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
Subject: Re: Storing RexLiteral as BigDecimal values The inputs are decimals, and the correct answer is 1008618.49, also a decimal, and cannot be exactly represented as a binary floating point. I’m not sure why in this case you want a binary floating point. > On Jan 30, 2024, at 2:46 PM, Mi

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Julian Hyde
l. > This rounding error is not really necessary. > > Mihai > > From: Julian Hyde > Sent: Tuesday, January 30, 2024 2:40 PM > To: dev@calcite.apache.org > Subject: Re: Storing RexLiteral as BigDecimal values > > Can you give a

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
. This rounding error is not really necessary. Mihai From: Julian Hyde Sent: Tuesday, January 30, 2024 2:40 PM To: dev@calcite.apache.org Subject: Re: Storing RexLiteral as BigDecimal values Can you give a scenario where a RexLiteral should have a double value

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Julian Hyde
Can you give a scenario where a RexLiteral should have a double value? > On Jan 30, 2024, at 2:36 PM, Mihai Budiu wrote: > > Hello, > > I have a question about the representation of RexLiteral values. > Currently DOUBLE-valued literals are represented using a BigDecimal. > This causes small

Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
Hello, I have a question about the representation of RexLiteral values. Currently DOUBLE-valued literals are represented using a BigDecimal. This causes small rounding errors, introduced in the RexBuilder.clean() function. This causes FP expressions that are evaluated at compilation-time to