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-4924] REGR_SXX and similar aggregate functions return the wr… #3928

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

Conversation

NobiGo
Copy link
Contributor

@NobiGo NobiGo commented Aug 22, 2024

…ong data type

@@ -15,9 +15,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
!use post
values 1;
!use scott
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This example is for review.

# [CALCITE-4924] REGR_SXX and similar aggregate functions return the wrong data type
SELECT
MONTH(HIREDATE) as "MONTH",
covar_samp(SAL, COMM) as "COVAR_SAMP(SAL, COMM)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compared to the previous one, this test can remove the cast.

RelDataType arg0Type, RelDataType arg1Type) {
switch (sqlKind) {
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 not sure if this is a reasonable implementation, but from the test cases, it seems feasible.

Copy link

sonarcloud bot commented Aug 22, 2024

@mihaibudiu
Copy link
Contributor

Today all Calcite aggregation functions (except COUNT) return the exact same data type as the data that is being aggregated. This behavior is permitted by the standard, and I think it's a reasonable one. From the Oracle documentation I think that Oracle behaves in the same way. Before I can review this PR we have to agree what you think the "correct" behavior is.

Maybe this should also be a property of the type system if you really want to emulate multiple databases.

@NobiGo
Copy link
Contributor Author

NobiGo commented Aug 23, 2024

Today all Calcite aggregation functions (except COUNT) return the exact same data type as the data that is being aggregated. This behavior is permitted by the standard, and I think it's a reasonable one. From the Oracle documentation I think that Oracle behaves in the same way. Before I can review this PR we have to agree what you think the "correct" behavior is.

Maybe this should also be a property of the type system if you really want to emulate multiple databases.

This is my idea, and I am glad to receive your feedback on this issue. I will also check if other databases adopt a similar approach.

@mihaibudiu
Copy link
Contributor

Maybe we should discuss the design in the JIRA ticket, I think that's the expected way.
You may post on the dev list to attract more attention, this is an important issue I think.

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