kosiew commented on code in PR #1422:
URL:
https://github.com/apache/datafusion-python/pull/1422#discussion_r2930206959
##########
python/datafusion/functions.py:
##########
@@ -958,12 +1034,24 @@ def regexp_instr(
flags: Expr | None = None,
sub_expr: Expr | None = None,
) -> Expr:
- """Returns the position of a regular expression match in a string.
+ r"""Returns the position of a regular expression match in a string.
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
Review Comment:
`end_position` is not in the function signature
##########
python/datafusion/functions.py:
##########
@@ -1370,18 +1502,55 @@ def range(start: Expr, stop: Expr, step: Expr) -> Expr:
def uuid() -> Expr:
- """Returns uuid v4 as a string value."""
+ """Returns uuid v4 as a string value.
+
+ Examples:
+ ---------
+ >>> ctx = dfn.SessionContext()
+ >>> df = ctx.from_pydict({"a": [1]})
+ >>> result = df.select(
+ ... dfn.functions.uuid().alias("u")
+ ... )
+ >>> len(result.collect_column("u")[0].as_py()) == 36
+ True
+ """
return Expr(f.uuid())
def struct(*args: Expr) -> Expr:
- """Returns a struct with the given arguments."""
+ """Returns a struct with the given arguments.
+
+ Examples:
+ ---------
+ >>> ctx = dfn.SessionContext()
+ >>> df = ctx.from_pydict({"a": [1], "b": [2]})
+ >>> result = df.select(
+ ... dfn.functions.struct(
+ ... dfn.col("a"), dfn.col("b")
+ ... ).alias("s")
+ ... )
+ >>> result.collect_column("s")[0].as_py() == {"c0": 1, "c1": 2}
Review Comment:
Could this example call out why the keys are `c0` and `c1`?
##########
python/datafusion/functions.py:
##########
@@ -1030,22 +1118,66 @@ def rtrim(arg: Expr) -> Expr:
def sha224(arg: Expr) -> Expr:
- """Computes the SHA-224 hash of a binary string."""
+ """Computes the SHA-224 hash of a binary string.
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]