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

[CALCITE-6548] Return type of COVAR_SAMP, COVAR_POP and VAR_SAMP shou… #3935

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NobiGo
Copy link
Contributor

@NobiGo NobiGo commented Aug 28, 2024

…ld be nullable

@NobiGo NobiGo requested a review from mihaibudiu August 28, 2024 01:50
@@ -1414,7 +1415,9 @@ private static RelDataType multivalentStringWithSepSumPrecision(
final RelDataType relDataType =
typeFactory.getTypeSystem().deriveCovarType(typeFactory,
opBinding.getOperandType(0), opBinding.getOperandType(1));
if (opBinding.getGroupCount() == 0 || opBinding.hasFilter()) {
if (opBinding.getGroupCount() == 0 || opBinding.hasFilter()
|| opBinding.getOperator().kind == SqlKind.COVAR_POP
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure about COVAR_POP?
Usually SAMP functions have the property that they return NULL for a non-empty set of size 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/COVAR_POP.html. This function return type is nullable.

The function returns a value of type NUMBER. If the function is applied to an empty set, then it returns null.

Copy link
Contributor

Choose a reason for hiding this comment

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

all aggregates return null when applied to an empty set.
but if getGroupCount() != 0 the set can never be empty (because then there would be no aggregate at all)

Copy link
Contributor

Choose a reason for hiding this comment

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

this is about aggregates that are null even when the set is NOT empty

Copy link
Contributor

Choose a reason for hiding this comment

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

empty set = set with all elements null

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 will do some test for this.

Copy link

sonarcloud bot commented Aug 28, 2024

@NobiGo NobiGo marked this pull request as draft August 28, 2024 02:50
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