Skip to content

Lost Nullability in Calcite Roundtrip #683

@gord02

Description

@gord02

When a nullable field type is defined in the schema of a virtualTableScan, the fields are enforced to also be nullable. Calcite's logicalValues does not enforce this match of the schema and actual field implementation. The following failing test case exposes this bug.

@Test
  void lostNullabilityInVirtualTableOnRoundTrip() {
      NamedStruct schema = NamedStruct.of(List.of("col1", "col2"), R.struct(N.I32, R.FP64));
      Expression nullableI32 = Expression.I32Literal.builder().value(6).nullable(true).build();
      VirtualTableScan virtualTableScan = createVirtualTableScan(schema, List.of(nullableI32, sb.fp64(8)));
      assertFullRoundTrip(virtualTableScan);
  }

A workaround should either be implemented in substrait-java(potentially loosening the schema matching), or a fix in Calcite should be implemented(logicalValues should update the field list type definition when making its fields non-null).

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