diff --git a/chunjun-connectors/chunjun-connector-jdbc-base/src/main/java/com/dtstack/chunjun/connector/jdbc/source/JdbcInputFormat.java b/chunjun-connectors/chunjun-connector-jdbc-base/src/main/java/com/dtstack/chunjun/connector/jdbc/source/JdbcInputFormat.java index 2d3cfd967f..feeb08ecdb 100644 --- a/chunjun-connectors/chunjun-connector-jdbc-base/src/main/java/com/dtstack/chunjun/connector/jdbc/source/JdbcInputFormat.java +++ b/chunjun-connectors/chunjun-connector-jdbc-base/src/main/java/com/dtstack/chunjun/connector/jdbc/source/JdbcInputFormat.java @@ -692,7 +692,6 @@ protected void queryForPolling(String startLocation) throws SQLException { /** 构建基于startLocation&endLocation的过滤条件 * */ protected void buildLocationFilter(JdbcInputSplit jdbcInputSplit, List whereList) { - String sql = null; String startLocation = jdbcInputSplit.getStartLocation(); if (formatState.getState() != null && StringUtils.isNotBlank(jdbcConf.getRestoreColumn())) { startLocation = String.valueOf(formatState.getState()); @@ -702,20 +701,20 @@ protected void buildLocationFilter(JdbcInputSplit jdbcInputSplit, List w jdbcInputSplit.getStartLocation(), startLocation); jdbcInputSplit.setStartLocation(startLocation); - sql = + whereList.add( SqlUtil.buildFilterSql( jdbcConf.getCustomSql(), ">", startLocation, jdbcDialect.quoteIdentifier(jdbcConf.getRestoreColumn()), jdbcConf.getRestoreColumnType(), - jdbcConf.isPolling(), - this::getTimeStr); + jdbcInputSplit.isPolling(), + this::getTimeStr)); } } else if (jdbcConf.isIncrement()) { if (StringUtils.isNotBlank(startLocation)) { String operator = jdbcConf.isUseMaxFunc() ? " >= " : " > "; - sql = + whereList.add( SqlUtil.buildFilterSql( jdbcConf.getCustomSql(), operator, @@ -723,22 +722,19 @@ protected void buildLocationFilter(JdbcInputSplit jdbcInputSplit, List w jdbcDialect.quoteIdentifier(jdbcConf.getIncreColumn()), jdbcConf.getIncreColumnType(), jdbcInputSplit.isPolling(), - this::getTimeStr); - } - if (StringUtils.isNotBlank(jdbcInputSplit.getEndLocation())) { - sql = - SqlUtil.buildFilterSql( - jdbcConf.getCustomSql(), - "<", - jdbcInputSplit.getEndLocation(), - jdbcDialect.quoteIdentifier(jdbcConf.getIncreColumn()), - jdbcConf.getIncreColumnType(), - false, - this::getTimeStr); + this::getTimeStr)); } } - if (sql != null) { - whereList.add(sql); + if (StringUtils.isNotBlank(jdbcInputSplit.getEndLocation())) { + whereList.add( + SqlUtil.buildFilterSql( + jdbcConf.getCustomSql(), + "<", + jdbcInputSplit.getEndLocation(), + jdbcDialect.quoteIdentifier(jdbcConf.getIncreColumn()), + jdbcConf.getIncreColumnType(), + false, + this::getTimeStr)); } }