Skip to content

isthmus: a hint's output names are dropped whenever a column is a struct, because nested field names are compared #1214

Description

@nielspardon

applyOutputNames drops a hint's names unless the projection's columns are the relation's columns type by type, which describesColumnsOf decides:

private boolean describesColumnsOf(List<Type> fields, RelDataType rowType) {
for (int field = 0; field < fields.size(); field++) {
RelDataType declared = typeConverter.toCalcite(typeFactory, fields.get(field));
if (!SqlTypeUtil.equalSansNullability(
declared, rowType.getFieldList().get(field).getType())) {
return false;
}
}
return true;
}

SqlTypeUtil.equalSansNullability compares nested ROW field names, and typeConverter.toCalcite(typeFactory, fields.get(field)) is called without a name list, so a struct column's declared type carries placeholder nested names while the row type built from the schema carries the real ones. The two never match, and every name is dropped.

A virtual table with the schema [plain i32, outer struct(a i32, b fp64)], emit = [1] and hint names (LABEL, a, b) comes back named [outer]; the same table with a flat second column comes back named [label].

applyOutputNames only ever restates top-level names -- its own Javadoc says so -- so comparing sans field names for nested structs is enough.

Found while reviewing #1189.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions