|
23 | 23 | public class Rex extends UnresolvedPlan { |
24 | 24 |
|
25 | 25 | public enum RexMode { |
26 | | - EXTRACT |
| 26 | + EXTRACT, |
| 27 | + SED |
27 | 28 | } |
28 | 29 |
|
29 | 30 | /** Field to extract from. */ |
30 | 31 | private final UnresolvedExpression field; |
31 | 32 |
|
32 | | - /** Pattern with named capture groups. */ |
| 33 | + /** Pattern with named capture groups or sed expression. */ |
33 | 34 | private final Literal pattern; |
34 | 35 |
|
35 | | - /** Rex mode (only EXTRACT supported). */ |
| 36 | + /** Rex mode (extract or sed). */ |
36 | 37 | private final RexMode mode; |
37 | 38 |
|
38 | 39 | /** Maximum number of matches (optional). */ |
39 | 40 | private final Optional<Integer> maxMatch; |
40 | 41 |
|
| 42 | + /** Offset field name for position tracking (optional). */ |
| 43 | + private final Optional<String> offsetField; |
| 44 | + |
41 | 45 | /** Child Plan. */ |
42 | 46 | @Setter private UnresolvedPlan child; |
43 | 47 |
|
44 | 48 | public Rex(UnresolvedExpression field, Literal pattern) { |
45 | | - this(field, pattern, RexMode.EXTRACT, Optional.empty()); |
| 49 | + this(field, pattern, RexMode.EXTRACT, Optional.empty(), Optional.empty()); |
46 | 50 | } |
47 | 51 |
|
48 | 52 | public Rex(UnresolvedExpression field, Literal pattern, Optional<Integer> maxMatch) { |
49 | | - this(field, pattern, RexMode.EXTRACT, maxMatch); |
| 53 | + this(field, pattern, RexMode.EXTRACT, maxMatch, Optional.empty()); |
50 | 54 | } |
51 | 55 |
|
52 | 56 | public Rex( |
53 | 57 | UnresolvedExpression field, Literal pattern, RexMode mode, Optional<Integer> maxMatch) { |
| 58 | + this(field, pattern, mode, maxMatch, Optional.empty()); |
| 59 | + } |
| 60 | + |
| 61 | + public Rex( |
| 62 | + UnresolvedExpression field, |
| 63 | + Literal pattern, |
| 64 | + RexMode mode, |
| 65 | + Optional<Integer> maxMatch, |
| 66 | + Optional<String> offsetField) { |
54 | 67 | this.field = field; |
55 | 68 | this.pattern = pattern; |
56 | 69 | this.mode = mode; |
57 | 70 | this.maxMatch = maxMatch; |
| 71 | + this.offsetField = offsetField; |
58 | 72 | } |
59 | 73 |
|
60 | 74 | @Override |
|
0 commit comments