
com.huaweicloud.dws.client.executor.DeleteExecutor Maven / Gradle / Ivy
package com.huaweicloud.dws.client.executor;
import com.huaweicloud.dws.client.DwsConfig;
import com.huaweicloud.dws.client.exception.DwsClientException;
import com.huaweicloud.dws.client.model.Record;
import com.huaweicloud.dws.client.model.TableSchema;
import com.huaweicloud.dws.client.util.JdbcUtil;
import com.huaweicloud.dws.client.util.LogUtil;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
/**
* @ProjectName: dws-connector
* @ClassName: DeleteExecutor
* @Description: 删除操作执行
* @Date: 2023/1/16 17:36
* @Version: 1.0
*/
@Slf4j
public class DeleteExecutor {
public void execute(List records, Connection connection, DwsConfig config) throws DwsClientException {
if (records == null || records.isEmpty()) {
return;
}
Record first = records.get(0);
TableSchema schema = first.getTableSchema();
List keys = schema.getPrimaryKeyNames();
String sql = JdbcUtil.getDeleteStatement(schema.getTableName().getFullName(), keys);
LogUtil.withLogSwitch(config, () -> log.info("delete sql {}", sql));
try {
JdbcUtil.executeBatchRecordSql(records, connection, schema, keys, sql, config);
} catch (SQLException e) {
log.error("delete executor execute fail. sql = {}", sql, e);
throw DwsClientException.fromException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy