timsaucer commented on code in PR #1493:
URL:
https://github.com/apache/datafusion-python/pull/1493#discussion_r3078911614
##########
python/datafusion/functions.py:
##########
@@ -1575,19 +1585,20 @@ def regexp_count(
>>> result.collect_column("c")[0].as_py()
1
"""
- if flags is not None:
- flags = flags.expr
- start = start.expr if start is not None else start
- return Expr(f.regexp_count(string.expr, pattern.expr, start, flags))
+ flags = _to_raw_literal_expr(flags) if flags is not None else None
+ start = _to_raw_literal_expr(start) if start is not None else None
+ return Expr(
+ f.regexp_count(string.expr, _to_raw_literal_expr(pattern), start,
flags)
+ )
def regexp_instr(
values: Expr,
- regex: Expr,
- start: Expr | None = None,
- n: Expr | None = None,
- flags: Expr | None = None,
- sub_expr: Expr | None = None,
+ regex: Expr | str,
+ start: Expr | str | None = None,
+ n: Expr | str | None = None,
Review Comment:
I think we want these as `int` not `str`
##########
python/datafusion/functions.py:
##########
@@ -1541,13 +1547,17 @@ def regexp_replace(
>>> result.collect_column("r")[0].as_py()
'aX bX cX'
"""
- if flags is not None:
- flags = flags.expr
- return Expr(f.regexp_replace(string.expr, pattern.expr, replacement.expr,
flags))
+ flags = _to_raw_literal_expr(flags) if flags is not None else None
+ pattern = _to_raw_literal_expr(pattern)
+ replacement = _to_raw_literal_expr(replacement)
+ return Expr(f.regexp_replace(string.expr, pattern, replacement, flags))
def regexp_count(
- string: Expr, pattern: Expr, start: Expr | None = None, flags: Expr | None
= None
+ string: Expr,
+ pattern: Expr | str,
+ start: Expr | str | None = None,
Review Comment:
I think `start` should be `Expr | int | None` not `str`
##########
python/datafusion/functions.py:
##########
@@ -1575,19 +1585,20 @@ def regexp_count(
>>> result.collect_column("c")[0].as_py()
1
"""
- if flags is not None:
- flags = flags.expr
- start = start.expr if start is not None else start
- return Expr(f.regexp_count(string.expr, pattern.expr, start, flags))
+ flags = _to_raw_literal_expr(flags) if flags is not None else None
+ start = _to_raw_literal_expr(start) if start is not None else None
+ return Expr(
+ f.regexp_count(string.expr, _to_raw_literal_expr(pattern), start,
flags)
+ )
def regexp_instr(
values: Expr,
- regex: Expr,
- start: Expr | None = None,
- n: Expr | None = None,
- flags: Expr | None = None,
- sub_expr: Expr | None = None,
+ regex: Expr | str,
+ start: Expr | str | None = None,
+ n: Expr | str | None = None,
+ flags: Expr | str | None = None,
+ sub_expr: Expr | str | None = None,
Review Comment:
I think the capture group (sub_expr) is also an `int`. We should verify
--
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]