ibis icon indicating copy to clipboard operation
ibis copied to clipboard

feat: Add the ability to pass regex flags

Open SamEdwardes opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

Depending on the backend, regex search my be handled differently. I would like the ability to be able to pass regex flags so that I have complete control over how the regex search is performed.

What is the motivation behind your request?

No response

Describe the solution you'd like

Here is an example of what the API could look like:

con = ibis.postgres.connect()
x = con.table("x")
ibis.to_sql(
    x
    .filter([x.body.re_search('kubernetes', flags='i')])
    .limit(10)

)

In this example, adding the i flag, which would make the search case insensitive.

What version of ibis are you running?

ibis-framework[postgres]==9.0.0

What backend(s) are you using, if any?

postgres, but I think it would be helpful to have this feature for all backends that support regex search.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

SamEdwardes avatar May 30 '24 18:05 SamEdwardes

One option if you must have the flags before we investigate here is to define a builtin UDF.

Something like this:

@ibis.udf.scalar.builtin(name="regexp_search")
def re_search(s, pattern, flags):
    ...

cpcloud avatar May 31 '24 17:05 cpcloud

Thanks for the suggestion @cpcloud! I do implement this I will report back here.

SamEdwardes avatar May 31 '24 21:05 SamEdwardes