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

Timestamp-Methods fail #8990

Closed
1 task done
kajen3 opened this issue Apr 17, 2024 · 2 comments
Closed
1 task done

Timestamp-Methods fail #8990

kajen3 opened this issue Apr 17, 2024 · 2 comments
Labels
bug Incorrect behavior inside of ibis

Comments

@kajen3
Copy link

kajen3 commented Apr 17, 2024

What happened?

While creating a minimum working example to experiment with timestamp methods (code below), calling any of the timestamp-methods raises an error.

import ibis
import datetime as dt

con = ibis.duckdb.connect()
table = ibis.memtable({"date": [dt.datetime(2021, 12, 31), dt.datetime(2022, 1, 1)]}, name="t")
table.date.year()

What version of ibis are you using?

8.0.0

What backend(s) are you using, if any?

DuckDB (0.10.1)

Relevant log output

duckdb.duckdb.BinderException: Binder Error: No function matches the given name and argument types 'date_part(STRING_LITERAL, VARCHAR)'. You might need to add explicit type casts.
        Candidate functions:
        date_part(VARCHAR, DATE) -> BIGINT
        date_part(VARCHAR, TIMESTAMP) -> BIGINT
        date_part(VARCHAR, TIME) -> BIGINT
        date_part(VARCHAR, INTERVAL) -> BIGINT
        date_part(VARCHAR, TIME WITH TIME ZONE) -> BIGINT
        date_part(VARCHAR[], DATE) -> STRUCT()
        date_part(VARCHAR[], TIMESTAMP) -> STRUCT()
        date_part(VARCHAR[], TIME) -> STRUCT()
        date_part(VARCHAR[], INTERVAL) -> STRUCT()
        date_part(VARCHAR[], TIME WITH TIME ZONE) -> STRUCT()
        date_part(VARCHAR, TIMESTAMP WITH TIME ZONE) -> BIGINT
        date_part(VARCHAR[], TIMESTAMP WITH TIME ZONE) -> STRUCT()

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kajen3 kajen3 added the bug Incorrect behavior inside of ibis label Apr 17, 2024
@cpcloud
Copy link
Member

cpcloud commented Apr 17, 2024

Can you try with a prerelease?

pip install 'ibis-framework[duckdb]' --pre --upgrade

This appears to be fixed on main:

In [1]: import ibis
   ...: import datetime as dt
   ...:
   ...: con = ibis.duckdb.connect()
   ...: table = ibis.memtable(
   ...:     {"date": [dt.datetime(2021, 12, 31), dt.datetime(2022, 1, 1)]}, name="t"
   ...: )
   ...: table.date.year()
Out[1]:
r0 := InMemoryTable
  data:
    PandasDataFrameProxy:
              date
      0 2021-12-31
      1 2022-01-01

ExtractYear(date): ExtractYear(r0.date)

In [2]: ibis.options.interactive = True

In [3]: table.date.year()
Out[3]:
┏━━━━━━━━━━━━━━━━━━━┓
┃ ExtractYear(date) ┃
┡━━━━━━━━━━━━━━━━━━━┩
│ int32             │
├───────────────────┤
│              2021 │
│              2022 │
└───────────────────┘

@kajen3
Copy link
Author

kajen3 commented Apr 17, 2024

Solved the issue. Thanks.

@cpcloud cpcloud closed this as completed Apr 17, 2024
@github-project-automation github-project-automation bot moved this from backlog to done in Ibis planning and roadmap Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
Archived in project
Development

No branches or pull requests

2 participants