Skip to content

Conversation

@mbwhite
Copy link
Contributor

@mbwhite mbwhite commented Oct 16, 2025

Minor change, but useful to add defensive code where possible.
The NamedStruct for a ReadRel shouldn't be nullable. i.e. there must be some form of schema.

Adding in a simple check to the builders API.

- if the struct is marked as NULLABLE raise an error
- if the struct is defaulting to UNSPECIFIED, then make it REQUIRED

Signed-off-by: MBWhite <whitemat@uk.ibm.com>
@mbwhite mbwhite force-pushed the fix_namedstruct_schema branch from f0dad5a to 26f4de0 Compare October 16, 2025 14:55
@tokoko
Copy link
Contributor

tokoko commented Oct 16, 2025

I think named_struct builder should have the same check also if we're adding it here.

@mbwhite
Copy link
Contributor Author

mbwhite commented Oct 17, 2025

@tokoko yes - good idea.. thanks.

Updated with a short test

Signed-off-by: MBWhite <whitemat@uk.ibm.com>
Signed-off-by: MBWhite <whitemat@uk.ibm.com>
Copy link
Contributor

@tokoko tokoko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Copy link
Member

@nielspardon nielspardon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

for the NamedStruct type the struct should always have NULLABILITY_REQUIRED when used for schemas and NamedStruct is currently only used for either the base schema (ReadRel) or the table schema (WriteRel, DdlRel, UpdateRel) within the Substrait specification:

// * When used to represent a relation schema, the outermost struct's
//   nullability should be NULLABILITY_REQUIRED.
message NamedStruct {
  // list of names in dfs order
  repeated string names = 1;
  Type.Struct struct = 2;
}

https://github.com/substrait-io/substrait/blob/b958843bc5cc0df49e99456eea8c9f5391f66636/proto/substrait/type.proto#L291-L292

@nielspardon nielspardon changed the title fix: add defensive check for nullable structs in builder fix: add nullability check for NamedStruct in builder Oct 20, 2025
@nielspardon nielspardon merged commit c909f06 into substrait-io:main Oct 20, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants