Skip to content

Commit 6db9a47

Browse files
committed
code hygiene fix
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent e0c788a commit 6db9a47

6 files changed

Lines changed: 19 additions & 24 deletions

File tree

core/src/main/java/org/opensearch/sql/analysis/Analyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public LogicalPlan visitRegex(Regex node, AnalysisContext context) {
700700
Expression patternExpr = expressionAnalyzer.analyze(node.getPattern(), context);
701701

702702
// Create the RegexMatch expression directly
703-
// This is our custom PCRE-based implementation
703+
// This is our custom Java regex implementation
704704
Expression regexExpr =
705705
new org.opensearch.sql.expression.operator.predicate.RegexMatch(
706706
fieldExpr, patternExpr, node.isNegated());

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ public RelNode visitFilter(Filter node, CalcitePlanContext context) {
174174
public RelNode visitRegex(Regex node, CalcitePlanContext context) {
175175
visitChildren(node, context);
176176

177-
// Create our PCRE2 RegexMatch expression directly, just like the legacy engine
178-
// This ensures both engines use identical PCRE2 implementation
177+
// Create our Java regex RegexMatch expression directly, just like the legacy engine
178+
// This ensures both engines use identical Java regex implementation
179179

180180
// Analyze the field and pattern expressions in the current context
181181
RexNode fieldRex = rexVisitor.analyze(node.getField(), context);
182182
RexNode patternRex = rexVisitor.analyze(node.getPattern(), context);
183183

184184
// Create a custom RexNode that represents our RegexMatch expression
185-
// This will be handled by the script engine with PCRE2 support
185+
// This will be handled by the script engine with Java regex support
186186
RexNode regexCondition = createRegexMatchRexNode(fieldRex, patternRex, context);
187187

188188
// If negated, wrap with NOT
@@ -197,7 +197,7 @@ public RelNode visitRegex(Regex node, CalcitePlanContext context) {
197197
private RexNode createRegexMatchRexNode(
198198
RexNode field, RexNode pattern, CalcitePlanContext context) {
199199
// Use the UDF version that has proper enumerable implementation support
200-
// This ensures PCRE2 usage for both pushdown and in-memory execution
200+
// This ensures Java regex usage for both pushdown and in-memory execution
201201
return context.rexBuilder.makeCall(
202202
org.opensearch.sql.expression.function.PPLBuiltinOperators.REGEX_MATCH, field, pattern);
203203
}

core/src/main/java/org/opensearch/sql/expression/function/PPLBuiltinOperators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
380380
public static final SqlOperator NUMBER_TO_STRING =
381381
new NumberToStringFunction().toUDF("NUMBER_TO_STRING");
382382

383-
// Custom PCRE2 regex operator for Calcite engine
383+
// Custom regex operator for Calcite engine
384384
public static final SqlOperator REGEX_MATCH =
385385
new org.opensearch.sql.expression.function.udf.RegexMatchFunctionImpl().toUDF("REGEX_MATCH");
386386

core/src/main/java/org/opensearch/sql/expression/function/udf/RegexMatchFunctionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.opensearch.sql.expression.function.UDFOperandMetadata;
2323

2424
/**
25-
* REGEX_MATCH UDF implementation for Calcite engine.
26-
* This function provides Java regex matching via script query pushdown.
25+
* REGEX_MATCH UDF implementation for Calcite engine. This function provides Java regex matching via
26+
* script query pushdown.
2727
*/
2828
public class RegexMatchFunctionImpl extends ImplementorUDF {
2929

core/src/main/java/org/opensearch/sql/expression/operator/predicate/RegexMatch.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,12 @@
2121
import org.opensearch.sql.expression.env.Environment;
2222

2323
/**
24-
* Expression for regex matching using Java's built-in regex engine.
25-
* Supports Java regex features including:
26-
* - Named groups (?<name>...)
27-
* - Lookahead/lookbehind (limited to fixed-width)
28-
* - Backreferences
29-
* - Atomic groups (?>...)
30-
* - Possessive quantifiers (*+, ++, etc.)
31-
* - Inline flags (?i), (?m), (?s), etc.
32-
*
33-
* Note: Does not support PCRE-specific features like recursion (?R) or conditionals.
24+
* Expression for regex matching using Java's built-in regex engine. Supports Java regex features
25+
* including: - Named groups (?<name>...) - Lookahead/lookbehind (limited to fixed-width) -
26+
* Backreferences - Atomic groups (?>...) - Possessive quantifiers (*+, ++, etc.) - Inline flags
27+
* (?i), (?m), (?s), etc.
28+
*
29+
* <p>Note: Does not support PCRE-specific features like recursion (?R) or conditionals.
3430
*/
3531
@ToString
3632
@EqualsAndHashCode
@@ -47,7 +43,6 @@ public class RegexMatch implements Expression {
4743
// Maximum cache size to prevent memory issues
4844
private static final int MAX_CACHE_SIZE = 1000;
4945

50-
5146
public RegexMatch(Expression field, Expression pattern, boolean negated) {
5247
this.field = field;
5348
this.pattern = pattern;

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public QueryBuilder visitFunction(FunctionExpression func, Object context) {
114114
"Invalid syntax used for nested function in WHERE clause: "
115115
+ "nested(field | field, path) OPERATOR LITERAL");
116116
case "REGEX_MATCH":
117-
// Handle our custom PCRE2 regex operator from Calcite engine
117+
// Handle our custom regex operator from Calcite engine
118118
return buildScriptQueryForRegex(createRegexMatchFromFunction(func));
119119
default:
120120
{
@@ -159,7 +159,7 @@ private ScriptQueryBuilder buildScriptQuery(FunctionExpression node) {
159159
}
160160

161161
/**
162-
* Visit RegexMatch expression and convert to script query. This allows PCRE regex evaluation to
162+
* Visit RegexMatch expression and convert to script query. This allows Java regex evaluation to
163163
* be pushed down to OpenSearch data nodes.
164164
*/
165165
public QueryBuilder visitRegex(RegexMatch regexMatch, Object context) {
@@ -183,8 +183,8 @@ private ScriptQueryBuilder buildScriptQueryForRegex(RegexMatch regexMatch) {
183183
}
184184

185185
/**
186-
* Convert a REGEX_MATCH function from Calcite to our PCRE2 RegexMatch expression. This ensures
187-
* the Calcite engine uses the same PCRE2 implementation as the legacy engine.
186+
* Convert a REGEX_MATCH function from Calcite to our Java regex RegexMatch expression. This
187+
* ensures the Calcite engine uses the same Java regex implementation as the legacy engine.
188188
*/
189189
private RegexMatch createRegexMatchFromFunction(FunctionExpression func) {
190190
if (func.getArguments().size() != 2) {
@@ -194,7 +194,7 @@ private RegexMatch createRegexMatchFromFunction(FunctionExpression func) {
194194
Expression fieldExpr = func.getArguments().get(0);
195195
Expression patternExpr = func.getArguments().get(1);
196196

197-
// Create RegexMatch with PCRE2 support
197+
// Create RegexMatch with Java regex support
198198
return new RegexMatch(fieldExpr, patternExpr, false);
199199
}
200200
}

0 commit comments

Comments
 (0)