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

docs(examples): add temporal strftime examples #10362

Merged
merged 6 commits into from
Oct 24, 2024

Conversation

IndexSeek
Copy link
Member

Description of changes

Adding examples for TimestampValue and DateValue strftime methods.

I wanted to cover what I felt like were common usage patterns.

Issues closed

Resolves #10354

^^ I intend to keep adding more of these, but don't know it it's worthwhile to keep that issue open.

@IndexSeek
Copy link
Member Author

I was going to add strftime examples for TimeValue, but admittedly, was running into difficulties here.

In [1]: from datetime import time

In [2]: from ibis.interactive import *

In [3]: t = ibis.memtable([time(10, 28, 3)], schema=ibis.Schema({"time_col": "time"}))

In [4]: t
Out[4]: 
┏━━━━━━━━━━┓
┃ time_col ┃
┡━━━━━━━━━━┩
│ time     │
├──────────┤
│ 10:28:03 │
└──────────┘

In [5]: t.time_col.strftime("%H:%M")
BinderException: Binder Error: No function matches the given name and argument types 'strftime(TIME, STRING_LITERAL)'. You might need to add explicit type casts.
        Candidate functions:
        strftime(DATE, VARCHAR) -> VARCHAR
        strftime(TIMESTAMP, VARCHAR) -> VARCHAR
        strftime(TIMESTAMP_NS, VARCHAR) -> VARCHAR
        strftime(VARCHAR, DATE) -> VARCHAR
        strftime(VARCHAR, TIMESTAMP) -> VARCHAR
        strftime(VARCHAR, TIMESTAMP_NS) -> VARCHAR
        strftime(TIMESTAMP WITH TIME ZONE, VARCHAR) -> VARCHAR

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

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

Looks great, just some minor suggestions.

@cpcloud cpcloud added this to the 10.0 milestone Oct 24, 2024
@cpcloud cpcloud added docs Documentation related issues or PRs timestamps Issues related to the timestamp API labels Oct 24, 2024
@IndexSeek
Copy link
Member Author

Looks great, just some minor suggestions.

Thank you! Removing the explicit schema does make it more concise. I added those suggestions and linted again.

@cpcloud
Copy link
Member

cpcloud commented Oct 24, 2024

The Trino failures are unrelated and already fixed upstream, merging!

@cpcloud cpcloud changed the title docs: add temporal strftime examples docs(examples): add temporal strftime examples Oct 24, 2024
@cpcloud cpcloud merged commit 11b4e3a into ibis-project:main Oct 24, 2024
75 of 77 checks passed
@IndexSeek IndexSeek deleted the strftime-docs branch October 24, 2024 21:45
@IndexSeek
Copy link
Member Author

The Trino failures are unrelated and already fixed upstream, merging!

Thank you so much! Also, I appreciate the parenthesis fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related issues or PRs timestamps Issues related to the timestamp API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: more temporal expression examples
2 participants