feat(core): support for Decimal#6068
Merged
bluestreak01 merged 447 commits intomasterfrom Nov 10, 2025
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
RaphDal
commented
Sep 15, 2025
core/src/main/java/io/questdb/griffin/engine/functions/math/AddDecimalFunctionFactory.java
Outdated
Show resolved
Hide resolved
RaphDal
commented
Sep 15, 2025
core/src/main/java/io/questdb/griffin/engine/functions/math/AddDecimalFunctionFactory.java
Outdated
Show resolved
Hide resolved
eea8752 to
2f8ef90
Compare
|
There was an error handling pipeline event 5c007a30-229c-4014-9a75-934c4e8f9b74. |
…d_decimal_integration
567a97d to
22c015c
Compare
…ith corresponding tests
…imal with test case
…n RecordToRowCopier.
…d_decimal_integration
…nto rd_decimal_integration
…d_decimal_integration
This reverts commit 1cc565d.
… FunctionParser and ConcatFunctionFactory
bluestreak01
approved these changes
Nov 10, 2025
Contributor
[PR Coverage check]😍 pass : 10047 / 11341 (88.59%) file detail
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to integrate the Decimal type (implemented in #5991) into the database and make it available to users through SQL, ILP and Parquet.
This integration will support decimal that have a precision of 76 or less, while using the relevant type to store the required value.
SQL
This PR will add the
decimalcolumn type, usable throughCREATE TABLE,ALTER TABLE [table name] ADD COLUMNorALTER TABLE [table name] ALTER COLUMN [column name] TYPE.To declare a
decimalcolumn type, you need to use the syntax:DECIMAL(precision, scale).precisiondefines the maximum count of digits that can be stored into this column. defaults tomin(scale + 15, 76)scaledefines the maximum count of digits in the right side of the dot (a.k.a. the fractional part). defaults to 3For example, to create a table with decimal columns:
This PR also allows you to do some basic arithmetic operations on
decimals such as+,-,/,*,%and to compare decimal types.Note
Unlike the more traditional types like
doubleandint, when an operation cannot give you an accurate value, the database will throw an error. There is an exception for the division operation which will return theHALF_DOWNrounded quotient to the highest scale of the 2 operands, e.g.,10.0 / 6.000will give you1.667.ILP
This PR allows decimals to be inserted through the
InfluxDB Line Protocol.PGWire
With this PR, the decimal type should be compliant with the PGWire protocol, EXCEPT that floating point literals are interpreted as double and not decimal (unlike postgres).
As a consequence, when inserting a value to a decimal column (without the binary format), the user have to manually cast it to a decimal (we don't implicitly convert doubles to decimal to avoid unexpected precision loss) or use the 'm' suffix:
TODO
Decimal256.TableWriter.RowCopier.RecordSink.RecordValueSink. - @RaphDalBindVariableService.WalEventCursor.getDecimal[128/256]in Record.DECIMAL(p, s)syntax to SQL parser and lexer.23m).double.CREATE TABLE.ALTER COLUMN TYPE. - @RaphDal<=,<,==,>,>=). - @puzpuzpuzdouble,long,int,varchar, etc.). - @RaphDallong/int/short/byte:concat,coalesce,nullif. - @RaphDalCASE.rnd_decimal. - @puzpuzpuz::decimal(18,5)error (cast(x as decimal(18,5))works).min/max,avg,first/last,first_not_null/last_not_null,sum,count. - @puzpuzpuzabs,round*,sign,least,greatest,floor,ceil. - @RaphDalcount_distinct,corr,covar_pop,covar_samp,stddev/stddev_samp,stddev_pop,string_agg,string_distinct_agg,variance/var_samp,var_pop.ln,log,exp,sqrt.Outstanding test TODOs: