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 produ

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 rou

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
seful. 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

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Julian Hyde
ful. > 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 gi

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Mihai Budiu
e.org 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 P

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 RexLite

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
. > > 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
to file 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 Mihai Budiu
his 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 BigDecimal values * Regarding [1], it look

Re: Storing RexLiteral as BigDecimal values

2024-01-30 Thread Stephen Carlin
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

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 fi

Re: Storing RexLiteral as BigDecimal values

2024-01-31 Thread Julian Hyde
his > 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 RexLite

Re: Storing RexLiteral as BigDecimal values

2024-01-31 Thread Mihai Budiu
t: Re: 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 c