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

Fix to #12657 - Query: logic protecting SUM from returning null doesn't work for complex scenarios #21203

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Jun 10, 2020

Adding COALESCE around SUM sql function expression

Fixes #12657

@maumar maumar requested review from smitpatel and roji June 10, 2020 06:19
@@ -918,8 +918,13 @@ SqlExpression AddNullConcatenationProtection(SqlExpression argument, RelationalT
arguments[i] = Visit(sqlFunctionExpression.Arguments[i], out _);
}


return sqlFunctionExpression.Update(instance, arguments);
return sqlFunctionExpression.IsBuiltIn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm on the fence here - we do provide Sum translation into SqlFunction "SUM" in relational, but if there is a provider that translates it to a different function it would have to rewrite the entire visit sql function method, so that SUM doesn't get coalesce wrapped around it incorrectly. thoughts? @roji @smitpatel

Copy link
Contributor

Choose a reason for hiding this comment

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

For best solution it would be good to put at translation of sum but there is going to be some refactoring coming in when implementing more group by operation and #20633 may be needed for it.

I think this is ok compromise for now, it may not be the best solution but avoids wrong results for customers.

Copy link
Member

Choose a reason for hiding this comment

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

Of a provider translates to different function, wouldn't they just be responsible for applying the same coalscing in their own nullability processor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, its just harder than it needs to be (do the translation + call base vs rewrite entire visit sql function method) but maybe its fine

@maumar
Copy link
Contributor Author

maumar commented Jun 10, 2020

updated

…'t work for complex scenarios

Adding COALESCE around SUM sql function expression

Fixes #12657
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.

Query: logic protecting SUM from returning null doesn't work for complex scenarios
3 participants