JingsongLi commented on code in PR #1109:
URL: https://github.com/apache/incubator-paimon/pull/1109#discussion_r1190751855
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlActionUtils.java:
##########
@@ -262,4 +272,37 @@ private static void validateMySqlConfig(Configuration
mySqlConfig) {
String.format(
"mysql-conf [%s] must be specified.",
MySqlSourceOptions.TABLE_NAME.key()));
}
+
+ static List<ComputedColumn> buildComputedColumns(
+ List<String> computedColumnArgs, Map<String, DataType>
typeMapping) {
+ List<ComputedColumn> computedColumns = new ArrayList<>();
+ for (String columnArg : computedColumnArgs) {
+ String[] kv = columnArg.split("=");
+ if (kv.length != 2) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Invalid computed column argument: %s. Please
use format 'column-name=expr-name(args, ...)'.",
+ columnArg));
+ }
+ String columnName = kv[0].trim();
+ String expression = kv[1].trim();
+ // parse expression
+ int left = expression.indexOf('(');
+ int right = expression.indexOf(')');
+ Preconditions.checkArgument(
+ left > 0 && right > left,
+ String.format(
+ "Invalid expression: %s. Please use format
'expr-name(args, ...)'.",
+ expression));
+
+ String exprName = expression.substring(0, left);
+ String[] args = expression.substring(left + 1, right).split(",");
+ for (int i = 0; i < args.length; i++) {
+ args[i] = args[i].trim();
+ }
+ computedColumns.add(new ComputedColumn(columnName, exprName,
typeMapping, args));
Review Comment:
Just move the codes in `ComputedColumn` to here, and just introduce
`ComputedColumn(String columnName, Expression expression)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]