Skip to content

Commit f548bf7

Browse files
committed
style - remove some verbose comments
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 2b3944f commit f548bf7

5 files changed

Lines changed: 4 additions & 13 deletions

File tree

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

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

178-
// Analyze the field and pattern expressions
179178
RexNode fieldRex = rexVisitor.analyze(node.getField(), context);
180179
RexNode patternRex = rexVisitor.analyze(node.getPattern(), context);
181180

182-
// Create RexNode using the REGEX_MATCH UDF
183181
RexNode regexCondition =
184182
context.rexBuilder.makeCall(
185183
org.opensearch.sql.expression.function.PPLBuiltinOperators.REGEX_MATCH,
186184
fieldRex,
187185
patternRex);
188186

189-
// If negated, wrap with NOT
190187
if (node.isNegated()) {
191188
regexCondition = context.rexBuilder.makeCall(SqlStdOperatorTable.NOT, regexCondition);
192189
}

core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.opensearch.sql.expression.conditional.cases.CaseClause;
1111
import org.opensearch.sql.expression.conditional.cases.WhenClause;
1212
import org.opensearch.sql.expression.function.FunctionImplementation;
13+
import org.opensearch.sql.expression.operator.predicate.RegexMatch;
1314
import org.opensearch.sql.expression.parse.ParseExpression;
1415

1516
/**
@@ -102,8 +103,7 @@ public T visitNamedArgument(NamedArgumentExpression node, C context) {
102103
return visitNode(node, context);
103104
}
104105

105-
public T visitRegex(org.opensearch.sql.expression.operator.predicate.RegexMatch node, C context) {
106-
// Visit field and pattern expressions to ensure field extraction works properly
106+
public T visitRegex(RegexMatch node, C context) {
107107
T result = defaultResult();
108108
T fieldResult = node.getField().accept(this, context);
109109
result = aggregateResult(result, fieldResult);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.opensearch.sql.expression.function.jsonUDF.JsonSetFunctionImpl;
4848
import org.opensearch.sql.expression.function.udf.CryptographicFunction;
4949
import org.opensearch.sql.expression.function.udf.GrokFunction;
50+
import org.opensearch.sql.expression.function.udf.RegexMatchFunctionImpl;
5051
import org.opensearch.sql.expression.function.udf.RelevanceQueryFunction;
5152
import org.opensearch.sql.expression.function.udf.SpanFunction;
5253
import org.opensearch.sql.expression.function.udf.condition.EarliestFunction;
@@ -382,8 +383,7 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
382383
new NumberToStringFunction().toUDF("NUMBER_TO_STRING");
383384

384385
// Custom regex operator for Calcite engine
385-
public static final SqlOperator REGEX_MATCH =
386-
new org.opensearch.sql.expression.function.udf.RegexMatchFunctionImpl().toUDF("REGEX_MATCH");
386+
public static final SqlOperator REGEX_MATCH = new RegexMatchFunctionImpl().toUDF("REGEX_MATCH");
387387

388388
/**
389389
* Returns the PPL specific operator table, creating it if necessary.

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
4343
ExprValue fieldValue = field.valueOf(valueEnv);
4444
ExprValue patternValue = pattern.valueOf(valueEnv);
4545

46-
// Handle null/missing values
4746
if (fieldValue.isNull()
4847
|| fieldValue.isMissing()
4948
|| patternValue.isNull()
5049
|| patternValue.isMissing()) {
5150
return ExprValueUtils.booleanValue(false);
5251
}
5352

54-
// Convert field value to string (handles non-string types)
5553
String text = RegexCommonUtils.toStringValue(fieldValue);
5654
String regex = patternValue.stringValue();
5755

@@ -60,10 +58,8 @@ public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
6058
}
6159

6260
try {
63-
// Use shared utility for pattern matching
6461
boolean matches = RegexCommonUtils.matchesPartial(text, regex);
6562

66-
// Apply negation if needed
6763
return ExprValueUtils.booleanValue(negated ? !matches : matches);
6864

6965
} catch (PatternSyntaxException e) {

core/src/main/java/org/opensearch/sql/expression/parse/RegexCommonUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,10 @@ public static String toStringValue(ExprValue value) {
116116
return null;
117117
}
118118

119-
// If already a string, return it directly
120119
if (value.type() == ExprCoreType.STRING) {
121120
return value.stringValue();
122121
}
123122

124-
// Auto-convert non-string types to string
125123
return value.value().toString();
126124
}
127125
}

0 commit comments

Comments
 (0)