@@ -174,16 +174,16 @@ public RelNode visitFilter(Filter node, CalcitePlanContext context) {
174174 public RelNode visitRegex (Regex node , CalcitePlanContext context ) {
175175 visitChildren (node , context );
176176
177- // Create our Java regex RegexMatch expression directly, just like the legacy engine
178- // This ensures both engines use identical Java regex implementation
179-
180- // Analyze the field and pattern expressions in the current context
177+ // Analyze the field and pattern expressions
181178 RexNode fieldRex = rexVisitor .analyze (node .getField (), context );
182179 RexNode patternRex = rexVisitor .analyze (node .getPattern (), context );
183180
184- // Create a custom RexNode that represents our RegexMatch expression
185- // This will be handled by the script engine with Java regex support
186- RexNode regexCondition = createRegexMatchRexNode (fieldRex , patternRex , context );
181+ // Create RexNode using the REGEX_MATCH UDF
182+ RexNode regexCondition =
183+ context .rexBuilder .makeCall (
184+ org .opensearch .sql .expression .function .PPLBuiltinOperators .REGEX_MATCH ,
185+ fieldRex ,
186+ patternRex );
187187
188188 // If negated, wrap with NOT
189189 if (node .isNegated ()) {
@@ -194,14 +194,6 @@ public RelNode visitRegex(Regex node, CalcitePlanContext context) {
194194 return context .relBuilder .peek ();
195195 }
196196
197- private RexNode createRegexMatchRexNode (
198- RexNode field , RexNode pattern , CalcitePlanContext context ) {
199- // Use the UDF version that has proper enumerable implementation support
200- // This ensures Java regex usage for both pushdown and in-memory execution
201- return context .rexBuilder .makeCall (
202- org .opensearch .sql .expression .function .PPLBuiltinOperators .REGEX_MATCH , field , pattern );
203- }
204-
205197 private boolean containsSubqueryExpression (Node expr ) {
206198 if (expr == null ) {
207199 return false ;
0 commit comments