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

CASE When: result type should be coercible to a common type #2818

Closed
liukun4515 opened this issue Jun 30, 2022 · 1 comment · Fixed by #2819
Closed

CASE When: result type should be coercible to a common type #2818

liukun4515 opened this issue Jun 30, 2022 · 1 comment · Fixed by #2819
Labels
bug Something isn't working

Comments

@liukun4515
Copy link
Contributor

Describe the bug

❯ select case when 1=1 then true else 1 end;
+--------------------------------------------------------------------+
| CASE WHEN Int64(1) = Int64(1) THEN Boolean(true) ELSE Int64(1) END |
+--------------------------------------------------------------------+
| true                                                               |
+--------------------------------------------------------------------+
1 row in set. Query took 0.042 seconds.
❯ explain select case when 1=1 then true else 1 end;
+---------------+---------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                              |
+---------------+---------------------------------------------------------------------------------------------------+
| logical_plan  | Projection: Boolean(true) AS CASE WHEN Int64(1) = Int64(1) THEN Boolean(true) ELSE Int64(1) END   |
|               |   EmptyRelation                                                                                   |
| physical_plan | ProjectionExec: expr=[true as CASE WHEN Int64(1) = Int64(1) THEN Boolean(true) ELSE Int64(1) END] |
|               |   EmptyExec: produce_one_row=true                                                                 |
|               |                                                                                                   |
+---------------+---------------------------------------------------------------------------------------------------+
2 rows in set. Query took 0.003 seconds.
❯ explain select case when 1>1 then true else 1 end;
+---------------+---------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                              |
+---------------+---------------------------------------------------------------------------------------------------+
| logical_plan  | Projection: Boolean(true) AS CASE WHEN Int64(1) > Int64(1) THEN Boolean(true) ELSE Int64(1) END   |
|               |   EmptyRelation                                                                                   |
| physical_plan | ProjectionExec: expr=[true as CASE WHEN Int64(1) > Int64(1) THEN Boolean(true) ELSE Int64(1) END] |
|               |   EmptyExec: produce_one_row=true                                                                 |
|               |                                                                                                   |
+---------------+---------------------------------------------------------------------------------------------------+
2 rows in set. Query took 0.004 seconds.
❯  select case when 1>1 then true else 1 end;
+--------------------------------------------------------------------+
| CASE WHEN Int64(1) > Int64(1) THEN Boolean(true) ELSE Int64(1) END |
+--------------------------------------------------------------------+
| true                                                               |
+--------------------------------------------------------------------+

One case when sql has two diff result data type.

From other system, case when should have the common data type, but now the result type is the first non-null data type.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

@liukun4515 liukun4515 added the bug Something isn't working label Jun 30, 2022
@liukun4515
Copy link
Contributor Author

I will fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant