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

feat(spark): add MakeDecimal support #298

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

andrew-coleman
Copy link
Contributor

The Spark query optimiser injects an internal function (MakeDecimal) when numeric literals appear in a query. This commit adds support for this, which drastically improves the pass rate for the TPC-DS test suite.

@vbarua vbarua changed the title feat: add MakeDecimal support to spark module feat(spark): add MakeDecimal support Oct 1, 2024
Copy link
Member

@vbarua vbarua left a comment

Choose a reason for hiding this comment

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

This seems pretty reasonable overall. There's likely always going to be functions that require some form of special handling. Once we accumulate more we can think about patterns to make it easier to work with them.

I did leave one comment about the matching logic for it though.

case "make_decimal" => expr.outputType match {
// Need special case handing of this internal function (not nice, I know).
// Because the precision and scale arguments are extracted from the output type,
// we can't use the generic scalar function conversion mechanism here.
Copy link
Member

Choose a reason for hiding this comment

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

(not nice, I know)

This seems perfectly reasonable tbh.

throw new IllegalArgumentException(msg)
})
expr.declaration.name match {
case "make_decimal" => expr.outputType match {
Copy link
Member

Choose a reason for hiding this comment

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

Being pedantic, this should also check the uri of the declaration if it's feasible to avoid applying special handling to an externally defined make_decimal function.

The Spark query optimiser injects an internal function
(MakeDecimal) when numeric literals appear in a query.
This commit adds support for this, which drastically improves
the pass rate for the TPC-DS test suite.

Signed-off-by: Andrew Coleman <[email protected]>
@vbarua vbarua merged commit eec9727 into substrait-io:main Oct 2, 2024
12 checks passed
@andrew-coleman andrew-coleman deleted the make_decimal branch October 3, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants