-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Quality Gate passedIssues Measures |
…ld be nullable