Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend literal with date, datetime and time #8282

Closed
Fokko opened this issue Aug 10, 2023 · 4 comments
Closed

Extend literal with date, datetime and time #8282

Fokko opened this issue Aug 10, 2023 · 4 comments
Assignees
Labels
good first issue Good for newcomers python

Comments

@Fokko
Copy link
Contributor

Fokko commented Aug 10, 2023

Feature Request / Improvement

The date, datetime and time is currently not supported as literal value:

>>> from datetime import date
>>> literal(date(2023, 1, 1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/expressions/literals.py", line 148, in literal
    raise TypeError(f"Invalid literal value: {repr(value)}")
TypeError: Invalid literal value: datetime.date(2023, 1, 1)

We need to accept those as literal:

  • datetime If there is a timezone, we want to convert it to a timestamptz. We can convert the datetime to an integer using datetime_to_millis in datetime.py.
  • time We can convert this into an integer using time_to_micros from datetime.py
  • date We can convert this into an integer using date_to_days from datetime.py

And include tests that hit the newly created branches in the if.

Query engine

None

@Fokko
Copy link
Contributor Author

Fokko commented Aug 10, 2023

Are you interested picking this one up @onerishabh?

@onerishabh
Copy link
Contributor

Yes please! Keen on it. 😄

@Fokko
Copy link
Contributor Author

Fokko commented Aug 10, 2023

Awesome! Let me know if you run into anything

@Fokko
Copy link
Contributor Author

Fokko commented Aug 16, 2023

Thanks @onerishabh again for fixing this

@Fokko Fokko closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers python
Projects
None yet
Development

No branches or pull requests

2 participants