You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TPC-H benchmarks correctly specify that all MONEY columns are DECIMAL type (precision and scale are not specified). We currently use DataType::Float64 which is much lighter than a true Decimal type.
To be a valid benchmark we need to ensure we support the same precision as the reference implementation.
@j-a-m-l I think a @xudong963 has a good point that Arrow already includes some support for DecimalArrays.
A good place to start then be to write some tests in sql.rs that create a TableProvider with a column of DecimalArray type and try to run some basic sql
The typical order I would try is something like
// projection
SELECT col + 4 ... FROM table_with_decimal_col
// filter
SELECT col FROM table_with_decimal_col where col < 5
// sort
SELECT col FROM table_with_decimal_col order by col
// grouping / aggregatie
SELECT sum(col) FROM table_with_decimal_col;
SELECT count(other_col) FROM table_with_decimal_col group by col
Writing those tests is probably a good way to figure out how to plumb through the support in DataFusion -- I would also recommend doing it in that order (projection, filter, sort, grouping / aggregation)
Is there any plan for implementation Decimal Type for datafusion?
I don't know of any plans other than what is on this ticket. As I mentioned in #122 (comment) I think figuring out what subtasks are needed (by writing some tests and trying out what works / doesn't work) is a good first step
In order to implement decimal in datafusion, we should ref some data type rules, like spark data type and type coercion.
Now, the numerical data type just support some native type and the type coercion rules are simple. if we add the decimal data type, the type checking, type cast, type promotion and precision checking are all need to be considered.
I know of in DataFusion today that do this type coercion
yep, Now I just try to support some simple demo code for decimal. For example function(min,max) and just Projection the column with decimal data type (without any operation and functions)
The rule of conversion in the above two files should be refactored, If we want to align the behavior with PG database exactly.
In the PG database, decimal and other numerical data type can be convert to each other, and in some case the varchar also can be convert to a decimal data type. In my opinion, we can support some simple and right rules first, and support other complex features later. For example, In the add mathematics operation for the decimal datatype, if left or right is the decimal datatype, we must require that two size are all decimal type. It is means that we don't support the cast or try cast to or from decimal data type implicitly.
In my opinion, we can support some simple and right rules first, and support other complex features later
I think this is a great idea -- taking stock / consolidating the existing coercion logic might be a good place to start (before you try to extend it to support Decimal)
Activity
j-a-m-l commentedon Oct 30, 2021
@alamb any idea about how to start this?
xudong963 commentedon Oct 30, 2021
Hi @j-a-m-l, I see arrow-rs has supported
Decimal, maybe we can directly change here https://github.com/apache/arrow-datafusion/blob/22a7d74e9dece44adb790b5ea3fca27d26a2fe51/datafusion/src/sql/planner.rs#L312 cc @alambalamb commentedon Nov 1, 2021
@j-a-m-l I think a @xudong963 has a good point that Arrow already includes some support for DecimalArrays.
A good place to start then be to write some tests in sql.rs that create a TableProvider with a column of
DecimalArraytype and try to run some basic sqlThe typical order I would try is something like
Writing those tests is probably a good way to figure out how to plumb through the support in DataFusion -- I would also recommend doing it in that order (projection, filter, sort, grouping / aggregation)
j-a-m-l commentedon Nov 1, 2021
Thanks @xudong963 and @alamb
liukun4515 commentedon Nov 8, 2021
Is there any plan for implementation
DecimalType for datafusion?@alamb
xudong963 commentedon Nov 8, 2021
Hi @j-a-m-l, do you have time to work on this?
liukun4515 commentedon Nov 8, 2021
I want to take some tasks to support the decimal data type in the datafusion.
alamb commentedon Nov 8, 2021
I don't know of any plans other than what is on this ticket. As I mentioned in #122 (comment) I think figuring out what subtasks are needed (by writing some tests and trying out what works / doesn't work) is a good first step
j-a-m-l commentedon Nov 9, 2021
No, @xudong963. Currently I don't have enough time to do that, and I'll probably focus first on fixing other issues that I've found, such as #1173.
alamb commentedon Nov 9, 2021
Here are several other issues that seem to be related to DECIMAL:
liukun4515 commentedon Nov 14, 2021
Thanks for the feedback.
I will begin to support
DECIMALdatatype.Please assign this issue to me @alamb
liukun4515 commentedon Nov 22, 2021
minandmaxaggregate #1407=,<,<=,>,>=,!=,is distinct from,is not distinct fromforBooleanArray#1163utils:
i128to get the decimalarray arrow-rs#1009liukun4515 commentedon Nov 23, 2021
In order to implement decimal in datafusion, we should ref some data type rules, like spark data type and type coercion.
Now, the numerical data type just support some native type and the type coercion rules are simple. if we add the decimal data type, the type checking, type cast, type promotion and precision checking are all need to be considered.
alamb commentedon Nov 23, 2021
liukun4515 commentedon Nov 24, 2021
yep, Now I just try to support some simple demo code for decimal. For example function(min,max) and just Projection the column with decimal data type (without any operation and functions)
The rule of conversion in the above two files should be refactored, If we want to align the behavior with PG database exactly.
In the PG database, decimal and other numerical data type can be convert to each other, and in some case the varchar also can be convert to a decimal data type. In my opinion, we can support some simple and right rules first, and support other complex features later. For example, In the
addmathematics operation for the decimal datatype, if left or right is the decimal datatype, we must require that two size are all decimal type. It is means that we don't support thecast or try castto or from decimal data type implicitly.What do you think about? @alamb
alamb commentedon Nov 24, 2021
I think this is a great idea -- taking stock / consolidating the existing coercion logic might be a good place to start (before you try to extend it to support Decimal)
Update roadmap with features completed
Update roadmap with features completed (#1464)
alamb commentedon Mar 13, 2025
I think this is done and no longer tracking anything so closing the ticket!
test: Move MacOS (x86) pipelines to post-commit (apache#122)