Skip to content

Commit

Permalink
[Addendum][Bug] [Seatunnel-web] Error when conditional column is not …
Browse files Browse the repository at this point in the history
…used in SE (#239)
  • Loading branch information
BilwaST authored Nov 7, 2024
1 parent d862b61 commit 53b5de8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public class JobInstanceServiceImpl extends SeatunnelBaseServiceImpl

private static final String DAG_PARSING_MODE = "dag-parsing.mode";

private static final String WHERE_CONDITION = "where_condition";

private static final String QUERY = "query";

@Resource private ConnectorDataSourceMapperConfig dataSourceMapperConfig;

@Resource private IDatasourceService datasourceService;
Expand Down Expand Up @@ -237,7 +233,6 @@ public String generateJobConfig(
businessMode,
config,
optionRule);
mergeConfig = appendWhereClauseToQuery(mergeConfig);
sourceMap
.get(task.getConnectorType())
.add(filterEmptyValue(mergeConfig));
Expand Down Expand Up @@ -335,19 +330,6 @@ public String generateJobConfig(
return JobUtils.replaceJobConfigPlaceholders(jobConfig, executeParam);
}

private Config appendWhereClauseToQuery(Config mergeConfig) {
String where_condition = mergeConfig.getString(WHERE_CONDITION);
if (where_condition != null && !where_condition.isEmpty()) {
String query = mergeConfig.getString(QUERY);
String queryWithWhereClause = query + " " + where_condition;
mergeConfig =
mergeConfig.withValue(
QUERY, ConfigValueFactory.fromAnyRef(queryWithWhereClause));
mergeConfig = mergeConfig.withoutPath(WHERE_CONDITION);
}
return mergeConfig;
}

@Override
public JobExecutorRes getExecuteResource(@NonNull Long jobEngineId) {
funcPermissionCheck(SeatunnelFuncPermissionKeyConstant.JOB_EXECUTOR_INSTANCE, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public abstract class BaseJdbcDataSourceConfigSwitcher extends AbstractDataSourc
private static final String BASE_URL = "base-url";
private static final String CATALOG_SCHEMA = "schema";

private static final String WHERE_CONDITION = "where_condition";

private static final Option<String> DATABASE_SCHEMA =
Options.key("database_schema")
.stringType()
Expand Down Expand Up @@ -138,6 +140,13 @@ public Config mergeDatasourceConfig(

String sql = tableFieldsToSql(tableFields, databaseName, tableName);

String where_condition = connectorConfig.getString(WHERE_CONDITION);

if (where_condition != null && !where_condition.isEmpty()) {
sql = sql + " " + where_condition;
connectorConfig = connectorConfig.withoutPath(WHERE_CONDITION);
}

connectorConfig =
connectorConfig.withValue(QUERY_KEY, ConfigValueFactory.fromAnyRef(sql));
} else if (pluginType.equals(PluginType.SINK)) {
Expand Down

0 comments on commit 53b5de8

Please sign in to comment.