Skip to content

feat(exec): Enforce NOT NULL constraints on table writes - #1810

Open
Yuhta wants to merge 1 commit into
facebookincubator:mainfrom
Yuhta:export-D116681749
Open

feat(exec): Enforce NOT NULL constraints on table writes#1810
Yuhta wants to merge 1 commit into
facebookincubator:mainfrom
Yuhta:export-D116681749

Conversation

@Yuhta

@Yuhta Yuhta commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary:

Why

The native (Prestissimo) worker currently accepts NULLs into NOT NULL columns
silently, while the Java engine rejects them in TableWriterOperator before any
file is written — a data-integrity and Java-parity gap
(prestodb/presto#28156).

What

Table writes can now enforce NOT NULL constraints on selected columns. Writing a
null into a column marked NOT NULL fails with, for example:
NULL value not allowed for NOT NULL column: c1.

InsertTableHandle carries the list of NOT NULL column names (empty means
unconstrained), so the constraint travels with the write-request descriptor and
round-trips through plan serialization. TableWriteNode validates at
construction that each name exists in the target schema. TableWriter maps each
constrained column to its input column and checks it with
DecodedVector::hasNulls(), which catches nulls behind dictionary or constant
encoding as well as flat vectors. The check is opt-in and only scans the listed
columns.

Part of prestodb/presto#28156. E2E protocol changes:
prestodb/presto#28040.

X-link: facebookincubator/velox#18135

Reviewed By: shrinidhijoshi

Differential Revision: D116681749

Pulled By: Yuhta

Summary:
## Why

The native (Prestissimo) worker currently accepts NULLs into NOT NULL columns
silently, while the Java engine rejects them in `TableWriterOperator` before any
file is written — a data-integrity and Java-parity gap
(prestodb/presto#28156).

## What

Table writes can now enforce NOT NULL constraints on selected columns. Writing a
null into a column marked NOT NULL fails with, for example:
`NULL value not allowed for NOT NULL column: c1`.

`InsertTableHandle` carries the list of NOT NULL column names (empty means
unconstrained), so the constraint travels with the write-request descriptor and
round-trips through plan serialization. `TableWriteNode` validates at
construction that each name exists in the target schema. `TableWriter` maps each
constrained column to its input column and checks it with
`DecodedVector::hasNulls()`, which catches nulls behind dictionary or constant
encoding as well as flat vectors. The check is opt-in and only scans the listed
columns.

Part of prestodb/presto#28156. E2E protocol changes:
prestodb/presto#28040.

X-link: facebookincubator/velox#18135

Reviewed By: shrinidhijoshi

Differential Revision: D116681749

Pulled By: Yuhta
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 31, 2026
@meta-codesync

meta-codesync Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Yuhta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116681749.

@Yuhta
Yuhta force-pushed the export-D116681749 branch from a9fc3d9 to bd011ef Compare September 3, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants