You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "AdamGS (via GitHub)" <gi...@apache.org> on 2025/09/24 22:06:14 UTC

[PR] Support new decimal types through SQL and fill-out other relatd functionality [datafusion]

AdamGS opened a new pull request, #17759:
URL: https://github.com/apache/datafusion/pull/17759

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - Closes #17747
   
   ## Rationale for this change
   
   Fills out support for more the new smaller decimal types.
   
   ## What changes are included in this PR?
   
   1. Fills out coercion between various decimal types for binary operations (comparison and arithmetic)
   2. Support for the `abs` function
   3. Support for sorted merge join (including for Decimal256, which I'm not sure if it was omitted before or explicitly unsupported).
   4. Support for decimal32/64 in the slt engine
   
   ## Are these changes tested?
   
   Yes, both new dedicated rust tests and additional dedicated SLT tests, in addition to existing functionality.
   
   ## Are there any user-facing changes?
   
   Yes - there are a few major user-facing changes:
   1. Tables or values casted to decimal types with an appropriate precision, will now be a smaller decimal type.
   2. In some cases - failure to coerce a type might result in a significant change. For example - the spark slt tests including the following test:
   ```sql
   SELECT MOD(2::int, 1.8::decimal(2,1));
   ```
   before this PR, that test returned a 0.2 with a datatype of `Decimal128(2, 1)`. With this PR, this exact statement returns `0` with a datatype of `Int32`, because it actually can't coerce a `Int32` to a `Decimal32(2, 1)`.
   Should it fall-back to floating point types? Some wide-enough predetermined decimal variant? I didn't debug this path fully yet, so the answer potentially hides somewhere there.
   
   Either way - the second breaking change seems to be the biggest open issue I have in this PR, once there's consensus on the desired behavior here, fixing the code and tests appropriately is the easy part.
   
   


-- 
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: [PR] Support new decimal types through SQL and fill-out other relatd functionality [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17759:
URL: https://github.com/apache/datafusion/pull/17759#issuecomment-3578537771

   Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.


-- 
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: [PR] Support new decimal types through SQL and fill-out other relatd functionality [datafusion]

Posted by "AdamGS (via GitHub)" <gi...@apache.org>.
AdamGS commented on PR #17759:
URL: https://github.com/apache/datafusion/pull/17759#issuecomment-3333112240

   After sleeping on it, my current thinking is:
   1. Most SQL oriented systems have on decimal type that hides the underlying size in some way or is just fixed size, I know there's work/thinking going into a more logical-type system in DataFusion, but for now introducing new types is a major change.
   2. Therefore, Decimal32/64 parsing from SQL should be behind some config (I'm not 100% sure if there's a precedence for that or how well wired configuration is to the parser - but that's a change that I can imagine being useful for other things in the future).
   3. The coercion logic should stay as it is here - trying to fit integers/floats into decimals when applicable, or the wider decimal when trying to operate on two decimal types.
   4. There are other changes that I ran into in this PR that could be split into a separate PR that is a natural followup to #17501 - `spark::width_bucket`, `abs`, SMJ support and creating zero scalars.


-- 
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: [PR] Support new decimal types through SQL and fill-out other relatd functionality [datafusion]

Posted by "AdamGS (via GitHub)" <gi...@apache.org>.
AdamGS commented on PR #17759:
URL: https://github.com/apache/datafusion/pull/17759#issuecomment-3336220518

   changed this PR back to a draft, I'm going to split out some of the easier stuff out to make it easier to review


-- 
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: [PR] Support new decimal types through SQL and fill-out other relatd functionality [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #17759: Support new decimal types through SQL and fill-out other relatd functionality
URL: https://github.com/apache/datafusion/pull/17759


-- 
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