Skip to content

isthmus: LiteralConverter casts a ROW literal's fields to RexLiteral and has no case for MAP #1177

Description

@nielspardon

LiteralConverter's case ROW casts a ROW literal's value straight to List<RexLiteral>:

https://github.com/substrait-io/substrait-java/blob/main/isthmus/src/main/java/io/substrait/isthmus/expression/LiteralConverter.java#L272

RexBuilder.makeLiteral's ROW branch builds each element as fieldValue instanceof RexLiteral ? fieldValue : makeLiteral(fieldValue, fieldType, allowCast), and makeLiteral returns a RexCall (an ARRAY_VALUE_CONSTRUCTOR or MAP_VALUE_CONSTRUCTOR) for an ARRAY- or MAP-typed field. A ROW literal Calcite produced itself — from constant reduction over a struct with an array field, say — therefore has a non-literal element, and the cast fails with ClassCastException: RexCall cannot be cast to RexLiteral.

There is also no case MAP, so a MAP-typed literal reaching convert falls through to the "Unable to convert the value" default, while case ARRAY right below handles the array equivalent.

Low priority as it stands: since #1153 dropped the ROW-literal shortcut from visit(Expression.StructLiteral), nothing in this repo emits a ROW literal, so the branch is reachable only from Calcite-produced ones.

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