|
21 | 21 | import org.apache.doris.common.Config;
|
22 | 22 | import org.apache.doris.nereids.analyzer.UnboundRelation;
|
23 | 23 | import org.apache.doris.nereids.exceptions.AnalysisException;
|
| 24 | +import org.apache.doris.nereids.exceptions.NotSupportedException; |
24 | 25 | import org.apache.doris.nereids.parser.NereidsParser;
|
25 | 26 | import org.apache.doris.nereids.rules.analysis.ExpressionAnalyzer;
|
26 | 27 | import org.apache.doris.nereids.rules.expression.rules.FoldConstantRule;
|
|
90 | 91 | import org.apache.doris.nereids.trees.expressions.functions.scalar.Sign;
|
91 | 92 | import org.apache.doris.nereids.trees.expressions.functions.scalar.Sin;
|
92 | 93 | import org.apache.doris.nereids.trees.expressions.functions.scalar.Sinh;
|
| 94 | +import org.apache.doris.nereids.trees.expressions.functions.scalar.Soundex; |
93 | 95 | import org.apache.doris.nereids.trees.expressions.functions.scalar.Sqrt;
|
94 | 96 | import org.apache.doris.nereids.trees.expressions.functions.scalar.StrToDate;
|
95 | 97 | import org.apache.doris.nereids.trees.expressions.functions.scalar.Substring;
|
@@ -555,6 +557,30 @@ void testFoldString() {
|
555 | 557 | );
|
556 | 558 | rewritten = executor.rewrite(replace, context);
|
557 | 559 | Assertions.assertEquals(new StringLiteral("default"), rewritten);
|
| 560 | + |
| 561 | + Soundex soundex = new Soundex(StringLiteral.of("Ashcraft")); |
| 562 | + rewritten = executor.rewrite(soundex, context); |
| 563 | + Assertions.assertEquals(new StringLiteral("A261"), rewritten); |
| 564 | + soundex = new Soundex(StringLiteral.of("Robert")); |
| 565 | + rewritten = executor.rewrite(soundex, context); |
| 566 | + Assertions.assertEquals(new StringLiteral("R163"), rewritten); |
| 567 | + soundex = new Soundex(StringLiteral.of("R@bert")); |
| 568 | + rewritten = executor.rewrite(soundex, context); |
| 569 | + Assertions.assertEquals(new StringLiteral("R163"), rewritten); |
| 570 | + soundex = new Soundex(StringLiteral.of("Honeyman")); |
| 571 | + rewritten = executor.rewrite(soundex, context); |
| 572 | + Assertions.assertEquals(new StringLiteral("H555"), rewritten); |
| 573 | + soundex = new Soundex(StringLiteral.of("Apache Doris你好")); |
| 574 | + rewritten = executor.rewrite(soundex, context); |
| 575 | + Assertions.assertEquals(new StringLiteral("A123"), rewritten); |
| 576 | + soundex = new Soundex(StringLiteral.of("")); |
| 577 | + rewritten = executor.rewrite(soundex, context); |
| 578 | + Assertions.assertEquals(new StringLiteral(""), rewritten); |
| 579 | + |
| 580 | + Assertions.assertThrows(NotSupportedException.class, () -> { |
| 581 | + Soundex soundexThrow = new Soundex(new StringLiteral("Doris你好")); |
| 582 | + executor.rewrite(soundexThrow, context); |
| 583 | + }, "soundex only supports ASCII"); |
558 | 584 | }
|
559 | 585 |
|
560 | 586 | @Test
|
|
0 commit comments