|
27 | 27 | import org.opensearch.sql.expression.ReferenceExpression; |
28 | 28 | import org.opensearch.sql.expression.function.BuiltinFunctionName; |
29 | 29 | import org.opensearch.sql.expression.function.FunctionName; |
30 | | -import org.opensearch.sql.expression.operator.predicate.RegexMatch; |
31 | 30 | import org.opensearch.sql.opensearch.storage.script.CompoundedScriptEngine.ScriptEngineType; |
32 | 31 | import org.opensearch.sql.opensearch.storage.script.core.ExpressionScript; |
33 | 32 | import org.opensearch.sql.opensearch.storage.script.filter.lucene.LikeQuery; |
@@ -113,9 +112,6 @@ public QueryBuilder visitFunction(FunctionExpression func, Object context) { |
113 | 112 | throw new SyntaxCheckException( |
114 | 113 | "Invalid syntax used for nested function in WHERE clause: " |
115 | 114 | + "nested(field | field, path) OPERATOR LITERAL"); |
116 | | - case "REGEX_MATCH": |
117 | | - // Handle our custom regex operator from Calcite engine |
118 | | - return buildScriptQueryForRegex(createRegexMatchFromFunction(func)); |
119 | 115 | default: |
120 | 116 | { |
121 | 117 | LuceneQuery query = luceneQueries.get(name); |
@@ -157,44 +153,4 @@ private ScriptQueryBuilder buildScriptQuery(FunctionExpression node) { |
157 | 153 | SerializationWrapper.wrapWithLangType(ScriptEngineType.V2, serializer.serialize(node)), |
158 | 154 | emptyMap())); |
159 | 155 | } |
160 | | - |
161 | | - /** |
162 | | - * Visit RegexMatch expression and convert to script query. This allows Java regex evaluation to |
163 | | - * be pushed down to OpenSearch data nodes. |
164 | | - */ |
165 | | - public QueryBuilder visitRegex(RegexMatch regexMatch, Object context) { |
166 | | - return buildScriptQueryForRegex(regexMatch); |
167 | | - } |
168 | | - |
169 | | - private ScriptQueryBuilder buildScriptQueryForRegex(RegexMatch regexMatch) { |
170 | | - Set<ReferenceExpression> fields = ExpressionScript.extractFields(regexMatch); |
171 | | - if (fields.stream().anyMatch(field -> field.getType() == ExprCoreType.STRUCT)) { |
172 | | - throw new ScriptQueryUnSupportedException( |
173 | | - "Script query does not support fields of struct type in OpenSearch."); |
174 | | - } |
175 | | - |
176 | | - return new ScriptQueryBuilder( |
177 | | - new Script( |
178 | | - DEFAULT_SCRIPT_TYPE, |
179 | | - COMPOUNDED_LANG_NAME, |
180 | | - SerializationWrapper.wrapWithLangType( |
181 | | - ScriptEngineType.V2, serializer.serialize(regexMatch)), |
182 | | - emptyMap())); |
183 | | - } |
184 | | - |
185 | | - /** |
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. |
188 | | - */ |
189 | | - private RegexMatch createRegexMatchFromFunction(FunctionExpression func) { |
190 | | - if (func.getArguments().size() != 2) { |
191 | | - throw new IllegalArgumentException("REGEX_MATCH function requires exactly 2 arguments"); |
192 | | - } |
193 | | - |
194 | | - Expression fieldExpr = func.getArguments().get(0); |
195 | | - Expression patternExpr = func.getArguments().get(1); |
196 | | - |
197 | | - // Create RegexMatch with Java regex support |
198 | | - return new RegexMatch(fieldExpr, patternExpr, false); |
199 | | - } |
200 | 156 | } |
0 commit comments