Skip to content

[FEAT] Support (?s) regex from SQL LIKE in cudf-polars #24759

Closed

Description

@mroeschke

Polars SQL turns LIKE '%a%b%' into str.contains("(?s)a.*b"), and libcudf can't compile regexes with the inline (?s) flag

Affects q13

lf = pl.LazyFrame({"comment": ["no special requests", "special\nrequests", "plain"]})
q = lf.sql("SELECT * FROM self WHERE comment NOT LIKE '%special%requests%'")
q.collect()  # only "plain"; the "\n" row is matched because of (?s)
q.collect(engine=pl.GPUEngine(raise_on_fail=True))
# NotImplementedError: Unsupported regex (?s)special.*requests for GPU engine.

Areas to fix

In dsl/expressions/string.py

  • StringFunction._create_regex_program (line 329): strip a leading (?s) and pass plc.strings.regex_flags.RegexFlags.DOTALL instead. pylibcudf already exposes DOTALL.
  • Other inline flags such as (?i) and (?m) could be handled the same way, through IGNORECASE and MULTILINE.
  • The Contains branch of init (line 196) is where the pattern is passed in.

Metadata

Metadata

Assignees

Labels

cudf-polarsIssues specific to cudf-polarsfeature requestNew feature or requestlibcudfAffects libcudf (C++/CUDA) code.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions