From c9cb605a9d46c041a2022e0bb358a2cbf8355de1 Mon Sep 17 00:00:00 2001 From: Mathieu Gabelle Date: Thu, 28 Nov 2024 15:39:25 +0100 Subject: [PATCH] fix(queries): remove exception when fetchType is NONE remove exception for NONE make STORE default for fetchType --- .../src/test/java/io/kestra/plugin/jdbc/mysql/LoadTest.java | 3 +++ .../main/java/io/kestra/plugin/jdbc/AbstractJdbcBaseQuery.java | 2 +- .../main/java/io/kestra/plugin/jdbc/AbstractJdbcQueries.java | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin-jdbc-mysql/src/test/java/io/kestra/plugin/jdbc/mysql/LoadTest.java b/plugin-jdbc-mysql/src/test/java/io/kestra/plugin/jdbc/mysql/LoadTest.java index 4b45c15c..96f64bbb 100644 --- a/plugin-jdbc-mysql/src/test/java/io/kestra/plugin/jdbc/mysql/LoadTest.java +++ b/plugin-jdbc-mysql/src/test/java/io/kestra/plugin/jdbc/mysql/LoadTest.java @@ -16,6 +16,7 @@ import java.util.Objects; import static io.kestra.core.models.tasks.common.FetchType.FETCH_ONE; +import static io.kestra.core.models.tasks.common.FetchType.NONE; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -52,6 +53,7 @@ void load() throws Exception { " amount DECIMAL(10 , 2 ) NULL,\n" + " PRIMARY KEY (id)\n" + ");") + .fetchType(NONE) .build(); createTable.run(runContext); @@ -61,6 +63,7 @@ void load() throws Exception { .username("root") .password("mysql_passwd") .inputFile(put.toString()) + .fetchType(NONE) .sql("LOAD DATA LOCAL INFILE '{{ inputFile }}' \n" + "INTO TABLE discounts \n" + "FIELDS TERMINATED BY ',' \n" + diff --git a/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcBaseQuery.java b/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcBaseQuery.java index c261e9cc..fecf9e89 100644 --- a/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcBaseQuery.java +++ b/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcBaseQuery.java @@ -65,7 +65,7 @@ public abstract class AbstractJdbcBaseQuery extends Task implements JdbcQueryInt @NotNull @Builder.Default - protected FetchType fetchType = FetchType.NONE; + protected FetchType fetchType = FetchType.STORE; @Builder.Default protected Integer fetchSize = 10000; diff --git a/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcQueries.java b/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcQueries.java index 6e9741b5..63bc8e52 100644 --- a/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcQueries.java +++ b/plugin-jdbc/src/main/java/io/kestra/plugin/jdbc/AbstractJdbcQueries.java @@ -111,6 +111,7 @@ private long extractResultsFromResultSet(RunContext runContext, AbstractCellConv .rows(maps) .size(size); } + case NONE -> runContext.logger().info("fetchType is set to NONE, no output will be returned"); default -> throw new IllegalArgumentException("fetchType must be either FETCH, FETCH_ONE, STORE, or NONE"); } totalSize += size;