Skip to content

Add docstring examples for Scalar temporal functions#1424

Open
ntjohnson1 wants to merge 4 commits intoapache:mainfrom
rerun-io:nick/docstrings-scalar-temporal
Open

Add docstring examples for Scalar temporal functions#1424
ntjohnson1 wants to merge 4 commits intoapache:mainfrom
rerun-io:nick/docstrings-scalar-temporal

Conversation

@ntjohnson1
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Add example usage to docstrings for Scalar temporal functions to improve documentation.

What changes are included in this PR?

The first PR was basically adding a docstring to everything in functions. I broke it apart into a PR (that already merged) for the infra. I then reviewed and merged an example PR of adding the docstrings in parts. This is now the follow up opening a handful of PRs for the remaining functions in functions.py Everything is co-authored with Claude since I used claude to extend the handwritten examples I wrote for reference and to split apart the large PR rather than doing it manually.

I've reviewed all the code prior to PR.

Are there any user-facing changes?

No

Add example usage to docstrings for Scalar temporal functions to improve documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

@ntjohnson1
Thanks for your contribution

'1970-01-01 00:00:00'
"""
return Expr(f.from_unixtime(arg.expr))

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR title is Add docstring examples for scalar temporal functions, but to_date, to_time, and to_local_time still have no examples. Since those are public temporal wrappers in the same section, this feels incomplete.

def extract(part: Expr, date: Expr) -> Expr:
"""Extracts a subfield from the date.

This is an alias for :py:func:`date_part`.
Copy link
Contributor

Choose a reason for hiding this comment

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

datepart, extract, and datetrunc are aliases, but each now carries its own full doctest.

I think setting up one example would risk of docs drift between the canonical function and its alias.

---------
>>> ctx = dfn.SessionContext()
>>> result = ctx.sql(
... "SELECT date_bin(interval '1 day',"
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be more consistent to use
dfn.functions.date_bin
here

@ntjohnson1
Copy link
Contributor Author

ntjohnson1 commented Mar 14, 2026 via email

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