Skip to content

Add return_not_null_data_as_optional parameter to read_table - #880

Open
krasnovdm wants to merge 1 commit into
ydb-platform:mainfrom
krasnovdm:feature/read-table-return-not-null-as-optional
Open

Add return_not_null_data_as_optional parameter to read_table#880
krasnovdm wants to merge 1 commit into
ydb-platform:mainfrom
krasnovdm:feature/read-table-return-not-null-as-optional

Conversation

@krasnovdm

Copy link
Copy Markdown

Problem

read_table always returns NOT NULL columns wrapped in Optional, and there is no way to opt out in the Python SDK.

The gRPC ReadTableRequest already has a return_not_null_data_as_optional field, and the C++ SDK exposes it via TReadTableSettings().ReturnNotNullAsOptional(false). The Python SDK simply never set this field, so users reading a table with NOT NULL columns always get Optional values back.

Change

Add a return_not_null_data_as_optional parameter to read_table (sync ydb/table.py and async ydb/aio/table.py) and plumb it through read_table_request_factory. It accepts a bool (mapped to FeatureFlag.ENABLED/DISABLED) or a raw FeatureFlag.Status.

Default behavior is unchanged: when the parameter is not provided, the field is left unset and NOT NULL columns are still returned as Optional (backward compatible).

# opt out of the Optional wrapping for NOT NULL columns:
session.read_table(path, return_not_null_data_as_optional=False)

The gRPC ReadTableRequest already has a return_not_null_data_as_optional
field and the C++ SDK exposes it as ReturnNotNullAsOptional, but the Python
SDK never set it, so read_table always wrapped NOT NULL columns in Optional
with no way to opt out. Plumb the flag through read_table (sync + async) and
read_table_request_factory. Default behavior is unchanged (still Optional).
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.

2 participants