fix(isthmus)!: use schema types for virtual table literals - #1065
fix(isthmus)!: use schema types for virtual table literals#1065alexandrefimov wants to merge 2 commits into
Conversation
|
@nielspardon would you mind taking a look at this one? Small isthmus fix for #1064: |
| @@ -108,14 +107,34 @@ public Expression.Literal convert(RexLiteral literal) { | |||
| * @return the converted Substrait Literal | |||
| */ | |||
| public Expression.Literal convert(RexLiteral literal, boolean nullable) { | |||
There was a problem hiding this comment.
I would advocate for getting rid of this method entirely actually.
It's not used internally after your changes, and any user that wants to set the nullability explicitly on the Calcite type can use the RelDataTypeFactory#createTypeWithNullability to set it, and then pass it to the new method below.
There was a problem hiding this comment.
Removed. It has been public since #684, so the PR is now fix(isthmus)! with a footer pointing at convert(RexLiteral, RelDataType).
|
To confirm two things. In your test, you construct a LogicalValue containing literals with different but compatible(?) types than the row type of the LogicalValue relation, and that ends up being valid because Calcite checks if the type can be assigned to value? In Substrait, we assume that all literals in VirtualTables have the same types as given in the schema. When we convert from Substrait to Calcite, do the tuple values in the Calcite LogicalValues relation this, or is that conversion also potentially lossy? |
|
@vbarua both confirmed. On strictness — the asymmetry is The reverse direction isn't lossy, and structurally so: that same check makes a mismatched Both inline suggestions applied; the javadoc now points at |
|
@vbarua ping when you get a chance. The overload is gone, so the PR is now |
Use the complete LogicalValues row-schema field type when converting tuple literals so virtual table rows match their schema. Preserve literal-derived behavior for other conversions and cover TINYINT-to-INTEGER widening. Fixes substrait-io#1064
convert(RexLiteral, boolean) has no callers left now that virtual table literals carry the schema type, and its nullability argument duplicates what the Calcite result type already expresses. BREAKING CHANGE: io.substrait.isthmus.expression.LiteralConverter#convert(RexLiteral, boolean) is removed. Use convert(RexLiteral, RelDataType), which takes nullability from the supplied Calcite type; callers needing a nullability other than the literal's own should widen the type with RelDataTypeFactory#createTypeWithNullability first.
697ad4e to
4940dd8
Compare
Summary
LogicalValuestuple literals using the complete row-schema field type;TINYINTtuple literal in anINTEGERfield.VirtualTableScanrequires row field types to exactly match its schema. Calcitemay infer a narrower type for a tuple literal than for the corresponding
LogicalValuesrow field —Values.assertRowType()only asserts that the fieldtype
canAssignFromthe literal type, so aTINYINTliteral is a legal member ofan
INTEGERrow. Previously Isthmus copied only schema nullability, so theconversion could construct an
I8row under anI32schema and fail its ownvalidation.
LiteralConverter.convertnow takes the schemaRelDataType, and derivesnullability from it rather than from a separate flag. Existing callers continue to
derive the result type from the literal itself.
Fixes #1064
BREAKING CHANGE:
io.substrait.isthmus.expression.LiteralConverter#convert(RexLiteral, boolean)is removed. Useconvert(RexLiteral, RelDataType), which takes nullability from the supplied Calcite type; callers needing a nullability other than the literal's own should widen the type withRelDataTypeFactory#createTypeWithNullabilityfirst.