Commit b207233
authored
Support quantified \D and \W in regex patterns (#15355)
`regexp_extract` (and `rlike` / `regexp_replace`) fell back to the CPU
whenever the pattern contained a quantified `\D` or `\W` — e.g.
`regexp_extract(col, '(\\D+)', 1)` — because the pattern failed to
transpile with "Preceding token cannot be quantified".
The set of predefined character classes allowed as a repetition base in
`CudfRegexTranspiler` was missing `\D` and `\W`, even though it
contained the lowercase `\d` and `\w` (and other negation classes like
`\H`). Since `\D` and `\W` otherwise transpile into valid patterns, they
are fine as a repetition base. Quantified forms (`\D+`, `\W*`,
`\D{2,3}`, `(\D+)`, …) now transpile and run on the GPU. Results are
unchanged (identical to the CPU); only the execution location changes
(GPU instead of CPU fallback).
Added a unit test for quantified `\D` and `\W` that transpiles and
compares cuDF vs Java for both find and replace.
Also added an integration test that exercises `rlike`, `regexp_extract`,
and `regexp_replace` for quantified `\D`/`\W`, plus previously-missing
coverage for quantified `\d`/`\w`.
Signed-off-by: Igor Peshansky <ipeshansky@nvidia.com>1 parent 8e6bcbf commit b207233
3 files changed
Lines changed: 38 additions & 1 deletion
File tree
- integration_tests/src/main/python
- sql-plugin/src/main/scala/com/nvidia/spark/rapids
- tests/src/test/scala/com/nvidia/spark/rapids
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
924 | 948 | | |
925 | 949 | | |
926 | 950 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
814 | | - | |
| 814 | + | |
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
475 | 488 | | |
476 | 489 | | |
477 | 490 | | |
| |||
0 commit comments