You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "theirix (via GitHub)" <gi...@apache.org> on 2026/08/22 11:51:28 UTC

[I] percentile_cont is wrong for `Decimal32` with lower interpolation precision [datafusion]

theirix opened a new issue, #24576:
URL: https://github.com/apache/datafusion/issues/24576

   ### Describe the bug
   
   A follow-up for #24419, which introduced pure-decimal interpolation, where a smaller interpolation precision was used for Decimal32 types with Euclidean interpolation. Seems like, a smaller precision for Decimal32 is not enough, and we have to widen i32 inputs to i64 to handle edge cases
   
   ### To Reproduce
   
   @Jefffrey noted:
   
   > I mainly ask since i had codex check some of the math and it mentioned some edge cases where the wrong value can be returned, for example:
   
   ```sql
   > SELECT percentile_cont(0.00009) WITHIN GROUP (ORDER BY v)
   FROM (VALUES (arrow_cast(0, 'Decimal32(9,0)')), (arrow_cast(999999999, 'Decimal32(9,0)'))) as t (v);
   +---------------------------------------------------------------------+
   | percentile_cont(Float64(0.00009)) WITHIN GROUP [t.v ASC NULLS LAST] |
   +---------------------------------------------------------------------+
   | 0                                                                   |
   +---------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.010 seconds.
   ```
   
   > this is only for decimal32, decimal64 & above seems fine. for reference, if done on float:
   
   ```sql
   > SELECT percentile_cont(0.00009) WITHIN GROUP (ORDER BY v)
   FROM (VALUES (0), (999999999)) as t (v);
   +---------------------------------------------------------------------+
   | percentile_cont(Float64(0.00009)) WITHIN GROUP [t.v ASC NULLS LAST] |
   +---------------------------------------------------------------------+
   | 89999.99991                                                         |
   +---------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.010 seconds.
   ```
   
   > i havent looked too closely at the interpolation maths, but i wonder if this is something we should try fix if possible? or can do in followup
   
   ### Expected behavior
   
   The mentioned query should provide `89999.99991` as with duckdb
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] percentile_cont is wrong for `Decimal32` with lower interpolation precision [datafusion]

Posted by "theirix (via GitHub)" <gi...@apache.org>.
theirix commented on issue #24576:
URL: https://github.com/apache/datafusion/issues/24576#issuecomment-5380162498

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] percentile_cont is wrong for `Decimal32` with lower interpolation precision [datafusion]

Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew closed issue #24576: percentile_cont is wrong for `Decimal32` with lower interpolation precision
URL: https://github.com/apache/datafusion/issues/24576


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org