Skip to content

[Bug] unnecessary cast will be added on children in CaseExpr sometimes #9599

Description

@morrySnow

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master

What's Wrong?

Unnecessary cast will be added on CaseExpr's children when do analyze on it sometimes.
This results in unequal results being returned when comparing two equal cast expressions.

What You Expected?

Do not add unnecessary cast on its children

How to Reproduce?

  • Create 2 tables
CREATETABLEtbl1(k1 INT, v1 INT) DISTRIBUTED BY hash(k1) PROPERTIES("replication_num"="1");
CREATETABLEtbl2(k2 INT, v2 INT) DISTRIBUTED BY hash(k2) PROPERTIES("replication_num"="1");
  • restart fe
  • execute query
SELECT
k1,
sum(CASE WHEN v2 <10 THEN v1 ELSE 0 END) s
FROM
tbl1,
tbl2
GROUP BY
k1;

query analyzed failed and return

select list expression not produced by aggregation output (missing from GROUP BY clause?): ...

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions