Hi,

I'm having trouble successfully validating a SQL query against a postgres
db where one of the selected fields is a postgres type (struct).

Stepping through the code, it appears that the column is successfully
interpreted as being of the type "STRUCTURED" (2002), but
SqlTypeFactoryImpl.createSqlType still always returns a BasicSqlType for
that column, rather than what I think should be returned which is a
RelRecordType instance.

I'm having trouble telling from the documentation, but it seems like
structured types should be supported, so I'm wondering if anyone has any
insight into what I might be doing incorrectly?

Any help would be greatly appreciated!

Example Postgres setup:

create type "my_type" as ("my_text_field" text);
create table "my_table"  (
    my_type my_type
);

Query to be validated/re-written

select (my_type).my_text_field from my_table t;


Parsing with:

private SqlNode parseAndValidate(final String query) throws
SqlParseException, ValidationException, RelConversionException {
    try (final Planner planner = Frameworks.getPlanner(frameworkConfig)) {
        final SqlNode parse = planner.parse(query);
        return planner.validate(parse);
    }
}


Result:

*org.apache.calcite.runtime.CalciteContextException: From line 1, column 9
to line 1, column 15: Incompatible types*


Thanks!
Jim

Reply via email to