Skip to content

A few rewrite rules for regexp functions #81981

@alexey-milovidov

Description

@alexey-milovidov

Company or project name

ClickHouse

Describe the situation

REGEXP_REPLACE can be optimized

  1. If a regular expression starts with ^ or ends with an unescaped $, rewrite replaceRegexpAll with replaceRegexpOne.
  2. If a replaceRegexpOne function has a replacement of nothing other than \1, or \0 and no subpatterns in the regexp, rewrite it with extract.
  3. If an extract function has a regexp starting with ^.* or ending with an unescaped .*$, remove this prefix and/or suffix.

How to reproduce

.

Expected performance

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

performancewarmup taskThe task for new ClickHouse team members. Low risk, moderate complexity, no urgency.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions