Skip to content

Commit

Permalink
[INLONG-11167][SDK] Transform REGEXP function add usage of regexp_like
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyOVO committed Sep 21, 2024
1 parent 260a12d commit 85e69e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* regular expression string2, otherwise FALSE. Returns NULL if any of arguments is NULL.
* SIMILAR(string1, string2)--Same as above
*/
@TransformFunction(names = {"regex", "similar"})
@TransformFunction(names = {"regex", "similar", "regexp_like"})
public class RegexpFunction implements ValueParser {

private ValueParser inputParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,21 @@ public void testRegexFunction() throws Exception {
List<String> output5 = processor3.transform("The quick brown fox|cold|5|2|1|3", new HashMap<>());
Assert.assertEquals(1, output5.size());
Assert.assertEquals(output5.get(0), "result=false");

String transformSql4 = "select regexp_like(string1, string2) from source";
TransformConfig config4 = new TransformConfig(transformSql4);
TransformProcessor<String, String> processor4 = TransformProcessor
.create(config4, SourceDecoderFactory.createCsvDecoder(csvSource),
SinkEncoderFactory.createKvEncoder(kvSink));

// case6: regexp_like("The quick brown fox", "quick")
List<String> output6 = processor4.transform("The quick brown fox|quick|5|2|1|3", new HashMap<>());
Assert.assertEquals(1, output6.size());
Assert.assertEquals(output6.get(0), "result=true");

// case7: regexp_like("The quick brown fox", "cold")
List<String> output7 = processor4.transform("The quick brown fox|cold|5|2|1|3", new HashMap<>());
Assert.assertEquals(1, output7.size());
Assert.assertEquals(output7.get(0), "result=false");
}
}

0 comments on commit 85e69e0

Please sign in to comment.