Hi all,

Does anyone have an example of a Calcite table with a column with
array type where the elements are "custom" Java classes (not in
JavaToSqlTypeConversionRules)?

I'm running into an issue in Apache NiFi where we have our own type
"Record" and our table model can have a column of type Record and/or a
column of type Array[Record]. For the simple Record case, the SQL type
of Record comes back as OTHER, and since that's the only custom type
in our system, we presume that OTHER means Record and the object we're
looking at is a Record, and we proceed and things seem to work well
for that case.

I thought the same would go for Array[Record], but if I try to SELECT
that column, I get an error:

java.lang.IllegalStateException: Unhandled ARRAY component type:
OBJECT, id: 1111

Looking at the code, it appears that at some point
RelDataTypeFactoryImpl tries to get a SqlTypeName for our Record
class, and since it's not in the mapping in
JavaToSqlTypeConversionRules, it returns SqlTypeName.OTHER. That maps
to java.sql.Types.OTHER (1111), and the AbstractCursor.ArrayAccessor
doesn't like it.

I can wrap the Record.class JavaType in a MultisetType to get things
like CARDINALITY to work, but that's a hack and I still can't SELECT
the Array[Record] column.

Should SqlTypeName.OTHER map to JAVA_OBJECT instead? Am I approaching
this correctly? If so is there a workaround and if not, can you help
me wrap my head around this? :) For reference, [1] is the Jira case
I'm working on.

Thank you,
Matt

[1] https://issues.apache.org/jira/browse/NIFI-7601

Reply via email to