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

sql: incompatible COALESCE expressions: unsupported binary operator: <int> * <int> (desired <decimal>) #73587

Open
timgraham opened this issue Dec 8, 2021 · 7 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner

Comments

@timgraham
Copy link
Contributor

timgraham commented Dec 8, 2021

To Reproduce

> SELECT COALESCE(AVG(5), (5*7));
ERROR: incompatible COALESCE expressions: unsupported binary operator: <int> * <int> (desired <decimal>)
SQLSTATE: 22023

Expected behavior
No error.

Environment:

  • CockroachDB version 21.2.2

Additional context

This comes from Django's test_aggregation_default_expression which makes the following queries:

SELECT COALESCE(AVG("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;
SELECT COALESCE(MAX("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;
SELECT COALESCE(MIN("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;
SELECT COALESCE(STDDEV_POP("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;
SELECT COALESCE(SUM("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;
SELECT COALESCE(VAR_POP("aggregation_author"."age"), (5 * 7)) AS "value" FROM "aggregation_author" WHERE "aggregation_author"."age" > 100;

The error happens for all queries except MAX and MIN.

Jira issue: CRDB-11653

@timgraham timgraham added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Dec 8, 2021
@blathers-crl
Copy link

blathers-crl bot commented Dec 8, 2021

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/sql-experience (found keywords: Django)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Dec 8, 2021
@timgraham
Copy link
Contributor Author

A similar error is:

> SELECT COALESCE(SUM(5), PI());
ERROR: incompatible COALESCE expressions: expected pi() to be of type decimal, found type float
SQLSTATE: 2202

Let me know if it should be ticketed separately.

@otan
Copy link
Contributor

otan commented Dec 8, 2021

pi is probably a separate issue

what's the type of "aggregation_author"."age"?

@timgraham
Copy link
Contributor Author

age is an integer.

@otan
Copy link
Contributor

otan commented Dec 8, 2021

yeah this is implicit casts rearing it's ugly head again, unfortunately tricky to change atm.
(the pi issue is similar but we can work around it right now)

@github-actions
Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@timgraham
Copy link
Contributor Author

Still a valid issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

No branches or pull requests

2 participants