Skip to content

Commit

Permalink
[INLONG-11036][SDK] Transform update ReplicateFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyOVO committed Sep 6, 2024
1 parent 179e478 commit 8409765
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@

import java.util.List;
/**
* ReplicateFunction
* description: replicate(string, numeric)--Repeat the string numeric times and return a new string
* RepeatFunction
* description: repeat(string, numeric)--Repeat the string numeric times and return a new string
*/
@TransformFunction(names = {"replicate"})
public class ReplicateFunction implements ValueParser {
@TransformFunction(names = {"repeat"})
public class RepeatFunction implements ValueParser {

private ValueParser stringParser;

private ValueParser countParser;

public ReplicateFunction(Function expr) {
public RepeatFunction(Function expr) {
List<Expression> expressions = expr.getParameters().getExpressions();
stringParser = OperatorTools.buildParser(expressions.get(0));
countParser = OperatorTools.buildParser(expressions.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import java.util.HashMap;
import java.util.List;

public class TestReplicateFunction extends AbstractFunctionStringTestBase {
public class TestRepeatFunction extends AbstractFunctionStringTestBase {

@Test
public void testReplicateFunction() throws Exception {
String transformSql1 = "select replicate(string1, numeric1) from source";
public void testRepeatFunction() throws Exception {
String transformSql1 = "select repeat(string1, numeric1) from source";
TransformConfig config1 = new TransformConfig(transformSql1);
TransformProcessor<String, String> processor1 = TransformProcessor
.create(config1, SourceDecoderFactory.createCsvDecoder(csvSource),
Expand All @@ -41,7 +41,7 @@ public void testReplicateFunction() throws Exception {
List<String> output1 = processor1.transform("apple|banana|cloud|2|1|3", new HashMap<>());
Assert.assertEquals(1, output1.size());
Assert.assertEquals(output1.get(0), "result=appleapple");
String transformSql2 = "select replicate(string2, numeric2) from source";
String transformSql2 = "select repeat(string2, numeric2) from source";
TransformConfig config2 = new TransformConfig(transformSql2);
TransformProcessor<String, String> processor2 = TransformProcessor
.create(config2, SourceDecoderFactory.createCsvDecoder(csvSource),
Expand All @@ -55,7 +55,7 @@ public void testReplicateFunction() throws Exception {
Assert.assertEquals(1, output2.size());
Assert.assertEquals(output3.get(0), "result=banana");
// case3: replicate('cloud', 0)
String transformSql3 = "select replicate(string3, numeric3) from source";
String transformSql3 = "select repeat(string3, numeric3) from source";
TransformConfig config3 = new TransformConfig(transformSql3);
TransformProcessor<String, String> processor3 = TransformProcessor
.create(config3, SourceDecoderFactory.createCsvDecoder(csvSource),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({TestInsertFunction.class, TestLeftFunction.class, TestLengthFunction.class,
TestLocateFunction.class, TestLowerFunction.class, TestLpadFunction.class, TestReplaceFunction.class,
TestReplicateFunction.class, TestReverseFunction.class, TestRightFunction.class, TestRpadFunction.class,
TestRepeatFunction.class, TestReverseFunction.class, TestRightFunction.class, TestRpadFunction.class,
TestSpaceFunction.class, TestStrcmpFunction.class, TestSubstringFunction.class, TestToBase64Function.class,
TestTranslateFunction.class, TestTrimFunction.class, TestUpperFunction.class, TestContainsFunction.class,
TestFromBase64Function.class
Expand Down

0 comments on commit 8409765

Please sign in to comment.