[ 
https://issues.apache.org/jira/browse/CALCITE-4596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112864#comment-18112864
 ] 

Yu Xu commented on CALCITE-4596:
--------------------------------

I had fixed this issue in https://github.com/apache/calcite/pull/5253

> RelFieldTrimmer#trimFields fails if values row type is empty record
> -------------------------------------------------------------------
>
>                 Key: CALCITE-4596
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4596
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: Konstantin Orlov
>            Assignee: Yu Xu
>            Priority: Major
>              Labels: pull-request-available
>
> Currently an exception is thrown when LogicalValues having no fields is 
> passed to {{RelFieldTrimmer#trimFields(LogicalValues, ImmutableBitSet, 
> Set<RelDataTypeField>)}}.
> The reason is while trying to avoid producing an empty record, the code below 
> is not expecting the row type of the input could be already an empty record.
> {code:java}
>   public TrimResult trimFields(
>       LogicalValues values,
>       ImmutableBitSet fieldsUsed,
>       Set<RelDataTypeField> extraFields) {
>     final RelDataType rowType = values.getRowType();
>     final int fieldCount = rowType.getFieldCount();
>     // If they are asking for no fields, we can't give them what they want,
>     // because zero-column records are illegal. Give them the last field,
>     // which is unlikely to be a system field.
>     if (fieldsUsed.isEmpty()) {
>       fieldsUsed = ImmutableBitSet.range(fieldCount - 1, fieldCount);
>     }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to