Skip to content

feat: Analyze VALUES for nullability#22089

Open
neilconway wants to merge 2 commits intoapache:mainfrom
neilconway:neilc/feat-nullability-values
Open

feat: Analyze VALUES for nullability#22089
neilconway wants to merge 2 commits intoapache:mainfrom
neilconway:neilc/feat-nullability-values

Conversation

@neilconway
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

LogicalPlanBuilder::infer_data (the inference path for VALUES clauses without a target schema) hard-coded every inferred column's nullability to true, regardless of whether any row actually contained a NULL. This is inconsistent with how nullability is computed for other, similar situations (e.g., SELECT 1).

In addition to improving internal consistency (and theoretically allowing better query optimization), this also makes it easier to write tests for nullability-related behavior without using a scratch table.

What changes are included in this PR?

  • LogicalPlanBuilder::infer_data now tracks per-column nullability while iterating values, marking the column nullable iff any row's value expression returns nullable() == true. Note that this only changes behavior for VALUES without a schema; INSERT INTO VALUES, for example, already computed nullability.
  • Add SLT tests for this behavior
  • Update expected SLT tests where this change results in updating a schema. Note that some Parquet files are slightly smaller now, which caused byte-count metrics in a few places to change.

Are these changes tested?

Yes, with new tests added.

Are there any user-facing changes?

The inferred schema for CREATE TABLE AS VALUES (...) will now change, although if we also fix #22087 then the original behavior will be preserved.

@github-actions github-actions Bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VALUES is never considered non-nullable CREATE TABLE AS should not inherit nullability

1 participant