Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal256 coercion #7034

Merged
merged 8 commits into from
Jul 20, 2023
Merged

Decimal256 coercion #7034

merged 8 commits into from
Jul 20, 2023

Conversation

jdye64
Copy link
Contributor

@jdye64 jdye64 commented Jul 20, 2023

Which issue does this PR close?

Closes #7033

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Jul 20, 2023
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jdye64

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jdye64

This seems like a fine incremental improvement to me, but it seems like there is a lot more work needed to properly support Decimal 256, just FYI

@@ -480,7 +480,7 @@ pub fn is_avg_support_arg_type(arg_type: &DataType) -> bool {
_ => matches!(
arg_type,
arg_type if NUMERICS.contains(arg_type)
|| matches!(arg_type, DataType::Decimal128(_, _))
|| matches!(arg_type, DataType::Decimal128(_, _)| DataType::Decimal256(_, _))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change imply that people can run AVG(dec256_col) now? I tried to run this query

create table t as values (arrow_cast(123, 'Decimal256'));
select AVG(column1) from t;

But it seems like datafusion support for Decimal256 is still in progress

❯ create table t as values (arrow_cast(123, 'Decimal256(10,3)'));
Optimizer rule 'simplify_expressions' failed
caused by
This feature is not implemented: Can't create a scalar from array of type "Decimal256(10, 3)"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yes, I was under the impression that it should. In Dask-Sql's case we are not using the physical planner from DataFusion and rather using our own so maybe this error is coming in from some similar missed Decimal256 coverage there? That would also explain why I don't see this issue when running as a library with dask-sql I guess?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify_expressions is an optimization pass on the logical plan.
I suppose you're not using those or having your own.

Anyway, would be good to have some more support / (end-to-end) tests for Decimal256.

@jdye64
Copy link
Contributor Author

jdye64 commented Jul 20, 2023

I agree. I stumbled across this in a dask-sql test and while this solves my immediate issue there is more to it for sure

@Dandandan Dandandan merged commit 8668da6 into apache:main Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFusion-Expr TypeCoercion missing Decimal256
4 participants