Consider creating ObjectSqlType like Fixture.addressType, which is STRUCTURED type. typeFactory.createStructType() actually creates a ROW type, which is not supported to reconstruct fields at the moment, see method RelStructuredTypeFlattener.restructureFields.
But even with ObjectSqlType, you will still see an assert error. The assertion should be removed. - Haisheng ------------------------------------------------------------------ 发件人:Igor Guzenko<ihor.huzenko....@gmail.com> 日 期:2019年06月20日 15:14:47 收件人:<dev@calcite.apache.org> 主 题:[DISCUSSION] Problem caused by flattening of struct fields Hello everyone, I've got issue while converting query with struct column. Struct's fields are flattened while conversion to rel is performed. But later they aren't collected back so query plan may produce incorrect result. For example [1], consider table *str_table* with just one column *str* of type STRUCT<name VARCHAR(10), age INTEGER>, then query SELECT *str* FROM *str_table* produces plan LogicalProject(STR=[$0]) LogicalProject(STR=[$0.name], STR1=[$0.age]) LogicalTableScan(table=[[CATALOG, STRUCT, STR_TABLE]]) where top level project returns nested field `name` as `str` instead of original struct column. My question is, what is the correct way to collect back the flattened fields and produce correct result for the query ? [1] - https://github.com/ihuzenko/calcite/commit/e24eaa22fbb5c950a0bd5290cc09ca56ea7f1e44 Thank you in advance, Igor Guzenko