[CALCITE-6149] Unparse for CAST Nullable with ClickHouseSqlDialect#3556
Merged
mihaibudiu merged 1 commit intoapache:mainfrom Dec 28, 2023
Merged
Conversation
| @Test void testClickhouseNullableFieldCast() { | ||
| final String query = "SELECT CASE WHEN \"product_name\" IS NULL THEN \"product_name\"+ 1 END\n" | ||
| + "FROM \"foodmart\".\"product\""; | ||
| final String expectedSql = "SELECT CAST(NULL AS `Nullable(Int32)`)\n" |
Contributor
There was a problem hiding this comment.
Do you have not-null case?
Contributor
Author
There was a problem hiding this comment.
Okay, let me add these case.
mihaibudiu
approved these changes
Dec 8, 2023
d1f9cd9 to
c061249
Compare
|
Kudos, SonarCloud Quality Gate passed! |
Contributor
|
If this is ready for merging can you please rebase and resolve the conflicts? |
Contributor
Author
Sure |
c061249 to
89d623f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








In ClickHouse, there is an issue with RelDataType of Nullable type when casting to a non-Nullable type. For example,
SELECT CAST(NULL, 'Int32')will throw an error. In such cases, we should useSELECT CAST(NULL, 'Nullable(Int32)')instead.insert into test(id,a) values(1,1);insert into test(id,a) values(2,null);SELECT CAST(a, 'String') FROM test;DB::Exception: Cannot convert NULL value to non-Nullable type
