[ https://issues.apache.org/jira/browse/CALCITE-5674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725818#comment-17725818 ]
Ruben Q L commented on CALCITE-5674: ------------------------------------ Just for the record: a minor [regression was discovered|https://github.com/apache/calcite/commit/289d08205584efefa7b399318e7bb81c4f7f11aa#r114762581] on the original commit of this ticket, it has been fixed via https://github.com/apache/calcite/commit/3843ede3d28783235780c0f81f725dc7e64a7828 > Cast expr to target type should respect nullable when it is complex type > ------------------------------------------------------------------------ > > Key: CALCITE-5674 > URL: https://issues.apache.org/jira/browse/CALCITE-5674 > Project: Calcite > Issue Type: Improvement > Components: core > Affects Versions: 1.34.0 > Reporter: jackylau > Assignee: jackylau > Priority: Major > Labels: pull-request-available > Fix For: 1.35.0 > > > {code:java} > // code placeholder > > // code placeholder > sql("select cast(array[1,null,2] as int array) from (values (1))") > .columnType("INTEGER NOT NULL ARRAY NOT NULL"); > it is not correct, it should return INTEGER ARRAY NOT NULL {code} > > according the sql standard, cast to type, which can not be nulable and > nullable is tabel level attribute which can not changed by cast. > current the calcite cast will using nullable of expr to replace target type , > it is true. but it shoud also set array element type > {code:java} > // code placeholder > /** Derives the type of "CAST(expression AS targetType)". */ > public static RelDataType deriveType(RelDataTypeFactory typeFactory, > RelDataType expressionType, RelDataType targetType, boolean safe) { > return typeFactory.createTypeWithNullability(targetType, > expressionType.isNullable() || safe); > } {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)