|
72 | 72 | import org.opensearch.sql.ast.tree.Patterns; |
73 | 73 | import org.opensearch.sql.ast.tree.Project; |
74 | 74 | import org.opensearch.sql.ast.tree.RangeBin; |
| 75 | +import org.opensearch.sql.ast.tree.Regex; |
75 | 76 | import org.opensearch.sql.ast.tree.RareTopN; |
76 | 77 | import org.opensearch.sql.ast.tree.Relation; |
77 | 78 | import org.opensearch.sql.ast.tree.Rename; |
@@ -442,6 +443,20 @@ public String visitParse(Parse node, String context) { |
442 | 443 | : StringUtils.format("%s | %s %s '%s'", child, commandName, source, regex); |
443 | 444 | } |
444 | 445 |
|
| 446 | + @Override |
| 447 | + public String visitRegex(Regex node, String context) { |
| 448 | + String child = node.getChild().get(0).accept(this, context); |
| 449 | + String operator = node.isNegated() ? "!=" : "="; |
| 450 | + String pattern = MASK_LITERAL; |
| 451 | + |
| 452 | + if (node.getField() != null) { |
| 453 | + String field = visitExpression(node.getField()); |
| 454 | + return StringUtils.format("%s | regex %s%s%s", child, field, operator, pattern); |
| 455 | + } else { |
| 456 | + return StringUtils.format("%s | regex %s", child, pattern); |
| 457 | + } |
| 458 | + } |
| 459 | + |
445 | 460 | @Override |
446 | 461 | public String visitFlatten(Flatten node, String context) { |
447 | 462 | String child = node.getChild().getFirst().accept(this, context); |
@@ -734,5 +749,11 @@ public String visitCast(Cast node, String context) { |
734 | 749 | String expr = analyze(node.getExpression(), context); |
735 | 750 | return StringUtils.format("cast(%s as %s)", expr, node.getConvertedType().toString()); |
736 | 751 | } |
| 752 | + |
| 753 | + @Override |
| 754 | + public String visitQualifiedName( |
| 755 | + org.opensearch.sql.ast.expression.QualifiedName node, String context) { |
| 756 | + return String.join(".", node.getParts()); |
| 757 | + } |
737 | 758 | } |
738 | 759 | } |
0 commit comments