public class ConvFunction extends BuiltInScalarFunction {
public ConvFunction(SpecializedFunction.SpecializedContext context) {
super(BuiltInFunctionDefinitions.CONV, context);
}
public static StringData eval(StringData input, Integer fromBase, Integer toBase) {
if (input == null || fromBase == null || toBase == null) {
return null;
}
return StringData.fromString(BaseConversionUtils.conv(input.toBytes(), fromBase, toBase));
}
public static StringData eval(long input, Integer fromBase, Integer toBase) {
return eval(StringData.fromString(String.valueOf(input)), fromBase, toBase);
}
}
@Test
public void testRowScalarFunction1() throws Exception {
tEnv().executeSql(
"CREATE TABLE TestTable(s STRING) " + "WITH ('connector' = 'COLLECTION')");
tEnv().executeSql("INSERT INTO TestTable select conv(3, cast(1 AS TINYINT), 4)").await();
}