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.
applyOutputNamesdrops a hint's names unless the projection's columns are the relation's columns type by type, whichdescribesColumnsOfdecides:substrait-java/isthmus/src/main/java/io/substrait/isthmus/SubstraitRelNodeConverter.java
Lines 1264 to 1273 in 934a60e
SqlTypeUtil.equalSansNullabilitycompares nestedROWfield names, andtypeConverter.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].applyOutputNamesonly ever restates top-level names -- its own Javadoc says so -- so comparing sans field names for nested structs is enough.Found while reviewing #1189.