[ 
https://issues.apache.org/jira/browse/CALCITE-4596?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yu Xu resolved CALCITE-4596.
----------------------------
    Fix Version/s: 1.43.0
       Resolution: Fixed

Fixed in 
[https://github.com/apache/calcite/commit/3b0444d98ab2708a4de503f63ea70006b7efeb58]

Thank you reported the Jira [~korlov] 

Thank you for the review [~mbudiu] 

> 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
>             Fix For: 1.43.0
>
>
> 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