Skip to content

Add docstring examples for Scalar regex, crypto, struct and other#1422

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

Add docstring examples for Scalar regex, crypto, struct and other#1422
ntjohnson1 wants to merge 2 commits intoapache:mainfrom
rerun-io:nick/docstrings-scalar-other

Conversation

@ntjohnson1
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Add example usage to docstrings for Scalar regex, crypto, struct and other 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

ntjohnson1 and others added 2 commits March 11, 2026 12:47
…ctions

Add example usage to docstrings for Scalar regex, crypto, struct and other 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


Searches ``values`` for the ``n``-th occurrence of ``regex``, starting at position
``start`` (the first position is 1). Returns the starting or ending position based
on ``end_position``. Use ``flags`` to control regex behavior and ``sub_expr`` to
Copy link
Contributor

Choose a reason for hiding this comment

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

end_position is not in the function signature

Comment on lines 1120 to +1121
def sha224(arg: Expr) -> Expr:
"""Computes the SHA-224 hash of a binary string."""
"""Computes the SHA-224 hash of a binary string.
Copy link
Contributor

Choose a reason for hiding this comment

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

These four examples (sha224 through sha512) are almost identical and only assert len(...) > 0. Could we simplify this by showing one representative hash example with a concrete expected value, then cross-reference the sibling helpers or digest()?

That would reduce doc drift and make the examples more informative.

... dfn.col("a"), dfn.col("b")
... ).alias("s")
... )
>>> result.collect_column("s")[0].as_py() == {"c0": 1, "c1": 2}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this example call out why the keys are c0 and c1?

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