Skip to content

Support for ns#1188

Closed
zaryab-ali wants to merge 3 commits into
apache:mainfrom
zaryab-ali:supportForNs
Closed

Support for ns#1188
zaryab-ali wants to merge 3 commits into
apache:mainfrom
zaryab-ali:supportForNs

Conversation

@zaryab-ali

Copy link
Copy Markdown

added support for ns and enabled downcasting similar to the similar to the pa.types.is_timestamp(primitive): , didn't enable upcasting as it wasn't mentioned in the issue

@zaryab-ali

Copy link
Copy Markdown
Author

@kevinjqliu can you please review my PR and let me know if i made a mistake (please check with extra caution as it is my first contribution to any open source project)

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution! Left a few comments

Comment thread pyiceberg/io/pyarrow.py
return DateType()
elif isinstance(primitive, pa.Time64Type) and primitive.unit == "us":
elif isinstance(primitive, pa.Time64Type) and (primitive.unit == "us" or primitive.unit == "ns"):
primitive = cast(pa.TimestampType, primitive)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Time64Type and TimestampType and different, dont need to cast here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread pyiceberg/io/pyarrow.py
elif pa.types.is_date32(primitive):
return DateType()
elif isinstance(primitive, pa.Time64Type) and primitive.unit == "us":
elif isinstance(primitive, pa.Time64Type) and (primitive.unit == "us" or primitive.unit == "ns"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think we can get rid fo the us/ns check here, since Time64Type only supports those 2 https://arrow.apache.org/docs/python/generated/pyarrow.Time64Type.html

Comment thread pyiceberg/io/pyarrow.py
primitive = cast(pa.TimestampType, primitive)
if primitive.unit == "ns":
if self._downcast_ns_timestamp_to_us:
logger.warning("Iceberg does not yet support 'ns' timestamp precision. Downcasting to 'us'.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets add a test to verify that when _downcast_ns_timestamp_to_us is True, the downcasting happens

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