Skip to content

Core: Deprecate 'downcast-ns-timestamp-to-us-on-write' config key - #3596

Open
qzyu999 wants to merge 3 commits into
apache:mainfrom
qzyu999:deprecate-downcast-on-write-config-key
Open

Core: Deprecate 'downcast-ns-timestamp-to-us-on-write' config key#3596
qzyu999 wants to merge 3 commits into
apache:mainfrom
qzyu999:deprecate-downcast-on-write-config-key

Conversation

@qzyu999

@qzyu999 qzyu999 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Minor config naming issue raised in #3594 (review)

Rationale for this change

The config key downcast-ns-timestamp-to-us-on-write (env: PYICEBERG_DOWNCAST_NS_TIMESTAMP_TO_US_ON_WRITE) says 'on-write' but is also used in the read path (ArrowScan) to downcast nanosecond timestamps to microseconds. The name is misleading.

What changes are included in this PR?

  • Introduce a new canonical config key downcast-ns-timestamp-to-us (env: PYICEBERG_DOWNCAST_NS_TIMESTAMP_TO_US)
  • Add _get_downcast_ns_timestamp_to_us() helper that checks the new key first, falls back to the old key with a DeprecationWarning\
  • Migrate all call sites to use the helper
  • Update docs and error messages
  • Add 3 unit tests for backwards compatibility (legacy key alone, new key alone, both set)

Are there any user-facing changes?

  • New config key: downcast-ns-timestamp-to-us / PYICEBERG_DOWNCAST_NS_TIMESTAMP_TO_US\
  • Backwards compatible: the old key still works but emits a DeprecationWarning\
  • Error message updated: the TypeError for unsupported 'ns' precision now references the new key name

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Aug 19, 2026
@qzyu999

qzyu999 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sungwy, PTAL when available

@github-actions github-actions Bot removed the stale label Aug 20, 2026

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is fine. I've got one thing around the deprecation message, but this looks fine otherwise. Thanks for doing this!

Comment thread pyiceberg/catalog/__init__.py Outdated
StagedTable,
Table,
TableProperties,
_get_downcast_ns_timestamp_to_us,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we make this a public method?

I personally don't like importing private methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pyiceberg/table/__init__.py Outdated

legacy = config.get_bool(DOWNCAST_NS_TIMESTAMP_TO_US_ON_WRITE)
if legacy is not None:
warnings.warn(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use our built-in deprecation message instead. It helps release managers know when to remove things:

From docs:

from pyiceberg.utils.deprecated import deprecation_message

deprecation_message(
    deprecated_in="0.1.0",
    removed_in="0.2.0",
    help_message="The old_property is deprecated. Please use the something_else property instead.",
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@qzyu999

qzyu999 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @rambleraptor, thanks for the review, all the changes have been made.

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One quick nit on the versions. Thanks again!

Comment thread pyiceberg/table/__init__.py Outdated

ALWAYS_TRUE = AlwaysTrue()
DOWNCAST_NS_TIMESTAMP_TO_US = "downcast-ns-timestamp-to-us"
# Deprecated: use DOWNCAST_NS_TIMESTAMP_TO_US. The old key said "on-write" but the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't need this full comment. Just Deprecated: use DOWNCAST_NS_TIMESTAMP_TO_US

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pyiceberg/table/__init__.py Outdated
if legacy is not None:
deprecation_message(
deprecated_in="0.9.0",
removed_in="0.10.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't the right version. We should deprecate in 0.12.0 (assuming this goes in this release) and remove in 0.13.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for confirming, I should've double-checked previously, made the changes.

…of 'downcast-ns-timestamp-to-us'

The config key 'downcast-ns-timestamp-to-us-on-write' says 'on-write' but is also used in the read path (ArrowScan). Rename the canonical key to 'downcast-ns-timestamp-to-us' which accurately describes the behavior regardless of direction.

The old key still works but emits a DeprecationWarning. The new key takes precedence when both are set.
@qzyu999
qzyu999 force-pushed the deprecate-downcast-on-write-config-key branch from 735d408 to c541c98 Compare August 25, 2026 05:13

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great. Especially love the docs. Thanks for doing this!

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