Konstantin Orlov created CALCITE-4596: -----------------------------------------
Summary: 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 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.3.4#803005)