Skip to content

Resolve type mismatch when WHEN result type differs from ELSE (INT32 vs INT64)#17415

Merged
JackieTien97 merged 5 commits intomasterfrom
fixCastTypeForDefaultValue
Apr 3, 2026
Merged

Resolve type mismatch when WHEN result type differs from ELSE (INT32 vs INT64)#17415
JackieTien97 merged 5 commits intomasterfrom
fixCastTypeForDefaultValue

Conversation

@shuwenwei
Copy link
Copy Markdown
Member

Description

When executing:

SELECT if(col_int64>0, col_int64,cast(0 as int64)) FROM test.if_test;
In table model, if(...) is converted to SearchedCaseExpression. During type analysis:

WHEN clause result type is inferred as INT64 (from col_int64)
ELSE clause cast(0 as int64) has internal LongLiteral(0) inferred as INT32 (since 0 is within Integer range)
This causes visitSearchedCaseExpression to throw:

Default result type must be the same as WHEN result types: INT32 vs INT64

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 62.06897% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.75%. Comparing base (68fc992) to head (449cd42).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...engine/plan/relational/planner/IrTypeAnalyzer.java 61.53% 20 Missing ⚠️
...engine/plan/relational/type/TypeCoercionUtils.java 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             master   #17415    +/-   ##
==========================================
  Coverage     39.75%   39.75%            
  Complexity      312      312            
==========================================
  Files          5134     5135     +1     
  Lines        346874   346986   +112     
  Branches      44186    44209    +23     
==========================================
+ Hits         137906   137952    +46     
- Misses       208968   209034    +66     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

shuwenwei and others added 2 commits April 1, 2026 18:11
…lational/it/query/recent/copyto/IoTDBCopyToTsFileIT.java
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

@JackieTien97 JackieTien97 merged commit 3931c05 into master Apr 3, 2026
30 checks passed
@JackieTien97 JackieTien97 deleted the fixCastTypeForDefaultValue branch April 3, 2026 06:49
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