StarRocks / starrocks

StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
https://starrocks.io
Apache License 2.0
8.62k stars 1.74k forks source link

An exception is thrown when using the if function #42131

Open MicePilot opened 6 months ago

MicePilot commented 6 months ago

Steps to reproduce the behavior (Required)

select if(true, struct('xx','ss'), null);

image

Expected behavior (Required)

The result should be: {"col1":"xx", "col2":"ss"}

Real behavior (Required)

ERROR 1064 (HY000): Getting analyzing error from line 1, column 7 to line 1, column 39. Detail message: No matching function with signature: if(boolean, struct<col1 varchar, col2 varchar>, NULL_TYPE).

StarRocks version (Required)

3.2.0

This may be caused by com.starrocks.sql.analyzer.PolymorphicFunctionAnalyzer.resolveArgTypes as it treats NULL as struct{boolean} type, when the second parameter of the if function is struct{string,string}, in com.starrocks.sql.analyzer.PolymorphicFunctionAnalyzer.IfDeduce, the commonType will be INVALID, and then an error will be reported when searching for functions of this type.

MicePilot commented 6 months ago

It may be solved in the commit https://github.com/StarRocks/starrocks/commit/64faf9074ad6943f72daee23fc6c6d7d8cc5291f, I will try it.

MicePilot commented 6 months ago

It may be solved in the commit 64faf90, I will try it.

No, the problem still exists

github-actions[bot] commented 4 days ago

We have marked this issue as stale because it has been inactive for 6 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 StarRocks!