Repository navigation
Add REGEXP_SUBSTR as alias of regexpExtract - #105122
Conversation
`REGEXP_SUBSTR` is the standard name used by Oracle, MySQL 8+, and Snowflake for the same operation that ClickHouse already exposes as `regexpExtract` (and as `REGEXP_EXTRACT` for Spark compatibility). Expose `REGEXP_SUBSTR` as a case-insensitive alias to spare these dialects a rewrite. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Workflow [PR], commit [52d4c6e] Summary: ✅
AI ReviewSummaryThis PR adds PR MetadataThe
Missing Context / Blind Spots
Findings
Tests
Final VerdictStatus: Minimum required action: either make |
Recent compatibility PRs added case-insensitive aliases and parser sugar that make several of the SQLStorm rewrites unnecessary: - `STDDEV` -> `stddevPop` (#105120) - `array_to_string` -> `arrayStringConcat` (#105121) - `REGEXP_SUBSTR` -> `regexpExtract` (#105122) - `CARDINALITY` -> `length` (#105123) - `unnest()` function -> `arrayJoin()` (#105124) - `STRING_AGG` -> `groupConcat` (#105125) - `date_part(unit,e)` -> `EXTRACT(unit FROM e)` (#105127) - `expr OP ANY/ALL(array_literal)` (#105129) `ARRAY_AGG`, `TRANSLATE`, and `EXTRACT(EPOCH|DOW|... FROM ...)` were already supported by ClickHouse before these PRs. Removed the corresponding rewrite calls and helper functions (`rewrite_string_agg`, `rewrite_array_agg`, `rewrite_date_part`, `rewrite_stddev`, `rewrite_extract_epoch`, the EXTRACT(DOW) inline rewrite, `rewrite_any_comparison`, and the trailing `unnest(...) -> arrayJoin(...)` substitution). Also dropped the unreferenced no-op helpers (`rewrite_extract_unit`, `rewrite_fetch_offset`, `rewrite_interval`, `rewrite_cast_timestamp`, `rewrite_current_timestamp`, `rewrite_bool_literals`, `rewrite_ilike`, `rewrite_no_supertype`). The PostgreSQL `LATERAL` / `CROSS JOIN UNNEST(...)` table-source forms, `arrayJoin(...)` in JOIN position, PG-specific casts, `AT TIME ZONE`, `STRING_AGGDistinct` (a mangled-name artifact), and the still-unsupported function rewrites (`string_to_array`, `regexp_split_to_array`, `RANDOM`, `TO_TIMESTAMP`, `ARRAY_LENGTH`, `SPLIT_PART`, `age`) are still rewritten. Net change: -329 lines from rewrite_queries.py and -75 lines from the tests (the `TestRewriteAnyComparison` class is removed since the rewrite it covered no longer exists). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
This was fixed by #105146. Let's update the branch. |
|
@groeneai, fix "Logical error: 'Inconsistent AST formatting between 'ExpressionList' and 'ExpressionList' in the query: (STID: 1941-1bfa)" or provide a link to the fix here. |
|
@alexey-milovidov The failing AST fuzzer query on commit The trigger shape is Inside
#104991 suppresses the redundant outer paren on multi-arg Remaining uncovered subvariants of STID 1941-1bfa ( |
|
@groeneai, let's update the branch, so that we will be able to merge this PR. |
|
The fix for STID 1941-1bfa (#104991) is now on master (merged 2026-05-31T08:41:21Z, commit I don't have push access to this branch (it lives on the ClickHouse org repo, |
|
The failures of They were introduced by #104690 ("Add #104690 was merged in violation of the ClickHouse team rules: its own CI already showed these two tests failing (10 times between May 12 and June 1) before it was merged. Please update your branch to pick up the revert; the tests should pass again. |
|
Updated the branch by merging current
Built locally on ARM (clean) and verified |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 2/2 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
Hi @alexey-milovidov — a couple of suggestions to make this PR easier for reviewers and the changelog reader. Description (currently
Ignore this if the current title/body is intentional. |
REGEXP_SUBSTRis the standard name used by Oracle, MySQL 8+, and Snowflake for the same operation that ClickHouse already exposes asregexpExtract(and asREGEXP_EXTRACTfor Spark compatibility). Adding a case-insensitive alias spares those dialects a rewrite.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added
REGEXP_SUBSTRas a case-insensitive alias ofregexpExtractfor Oracle/MySQL/Snowflake compatibility.Documentation entry for user-facing changes
Note
Low Risk
Low risk: adds a new case-insensitive function alias and a stateless query test, without changing
regexpExtractbehavior or data handling.Overview
Adds
REGEXP_SUBSTRas a case-insensitive alias ofregexpExtractfor Oracle/MySQL/Snowflake SQL dialect compatibility.Introduces a new stateless query test (
04241_alias_regexp_substr) verifying the alias works with default and explicit capture group indexes and with lowercaseregexp_substr.Reviewed by Cursor Bugbot for commit 9c7198d. Bugbot is set up for automated code reviews on this repo. Configure here.
Version info
26.6.1.438