legendtkl commented on code in PR #1791:
URL:
https://github.com/apache/incubator-seatunnel/pull/1791#discussion_r865496233
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/jdbc/sink/JdbcSink.java:
##########
@@ -151,4 +178,56 @@ public void outputBatch(FlinkEnvironment env, DataSet<Row>
dataSet) {
.finish();
dataSet.output(format);
}
+
+ @Override
+ public void close() throws Exception {
+ executePostSql();
+ }
+
+ private void executePreSql() {
+ if (!StringUtils.isNotBlank(preSql)) {
+ LOGGER.info("Starting to execute pre sql: \n {}", preSql);
+ try {
+ executeSql(preSql);
+ } catch (SQLException e) {
+ LOGGER.info("Execute pre sql failed", e);
Review Comment:
Should we change the exception log level to warn or error?
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/jdbc/sink/JdbcSink.java:
##########
@@ -151,4 +178,56 @@ public void outputBatch(FlinkEnvironment env, DataSet<Row>
dataSet) {
.finish();
dataSet.output(format);
}
+
+ @Override
+ public void close() throws Exception {
+ executePostSql();
+ }
+
+ private void executePreSql() {
+ if (!StringUtils.isNotBlank(preSql)) {
+ LOGGER.info("Starting to execute pre sql: \n {}", preSql);
+ try {
+ executeSql(preSql);
+ } catch (SQLException e) {
+ LOGGER.info("Execute pre sql failed", e);
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void executePostSql() {
+ if (!StringUtils.isNotBlank(postSql)) {
+ LOGGER.info("Starting to execute post sql: \n {}", postSql);
+ try {
+ executeSql(postSql);
+ } catch (SQLException e) {
+ LOGGER.info("Execute pre sql failed", e);
Review Comment:
Should we change the exception log level to warn or error?
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/jdbc/sink/JdbcSink.java:
##########
@@ -151,4 +178,56 @@ public void outputBatch(FlinkEnvironment env, DataSet<Row>
dataSet) {
.finish();
dataSet.output(format);
}
+
+ @Override
+ public void close() throws Exception {
+ executePostSql();
+ }
+
+ private void executePreSql() {
+ if (!StringUtils.isNotBlank(preSql)) {
+ LOGGER.info("Starting to execute pre sql: \n {}", preSql);
+ try {
+ executeSql(preSql);
+ } catch (SQLException e) {
+ LOGGER.info("Execute pre sql failed", e);
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void executePostSql() {
+ if (!StringUtils.isNotBlank(postSql)) {
+ LOGGER.info("Starting to execute post sql: \n {}", postSql);
+ try {
+ executeSql(postSql);
+ } catch (SQLException e) {
+ LOGGER.info("Execute pre sql failed", e);
Review Comment:
pre -> post
--
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]