Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addendum][Bug] [Seatunnel-web] Error when conditional column is not used in SE #239

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading