diff --git a/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Queries.java b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Queries.java new file mode 100644 index 00000000..2ade4b4c --- /dev/null +++ b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Queries.java @@ -0,0 +1,59 @@ +package io.kestra.plugin.jdbc.redshift; + +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.tasks.RunnableTask; +import io.kestra.plugin.jdbc.AbstractCellConverter; +import io.kestra.plugin.jdbc.AbstractJdbcQueries; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.ZoneId; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Perform multiple queries on a Redshift server." +) +@Plugin( + examples = { + @Example( + title = "Send SQL queries to a Redshift database and fetch the outputs.", + full = true, + code = """ + id: redshift_queries + namespace: company.team + + tasks: + - id: select + type: io.kestra.plugin.jdbc.redshift.Queries + url: jdbc:redshift://123456789.eu-central-1.redshift-serverless.amazonaws.com:5439/dev + username: admin + password: admin_password + sql: select count(*) from employee; select count(*) from laptop; + fetchType: FETCH_ONE + """ + ) + } +) +public class Queries extends AbstractJdbcQueries implements RunnableTask { + @Override + protected AbstractCellConverter getCellConverter(ZoneId zoneId) { + return new RedshiftCellConverter(zoneId); + } + + @Override + public void registerDriver() throws SQLException { + DriverManager.registerDriver(new com.amazon.redshift.jdbc.Driver()); + } + +} diff --git a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Queries.java b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Queries.java new file mode 100644 index 00000000..14959c6f --- /dev/null +++ b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Queries.java @@ -0,0 +1,77 @@ +package io.kestra.plugin.jdbc.snowflake; + +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.tasks.RunnableTask; +import io.kestra.core.runners.RunContext; +import io.kestra.plugin.jdbc.AbstractCellConverter; +import io.kestra.plugin.jdbc.AbstractJdbcQueries; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.ZoneId; +import java.util.Properties; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Perform multiple queries on a Snowflake server." +) +@Plugin( + examples = { + @Example( + full = true, + title = "Execute queries and fetch results in a task, and update another table with fetched results in a different task.", + code = """ + id: snowflake_queries + namespace: company.team + + tasks: + - id: select + type: io.kestra.plugin.jdbc.snowflake.Queries + url: jdbc:snowflake://.snowflakecomputing.com + username: snowflake_user + password: snowflake_password + sql: select * from demo_db.public.customers; select * from demo_db.public.emplyees; + fetchType: FETCH + """ + ) + } +) +public class Queries extends AbstractJdbcQueries implements RunnableTask, SnowflakeInterface { + private String privateKey; + private String privateKeyFile; + private String privateKeyFilePassword; + private String database; + private String warehouse; + private String schema; + private String role; + + @Override + public Properties connectionProperties(RunContext runContext) throws Exception { + Properties properties = super.connectionProperties(runContext); + + this.renderProperties(runContext, properties); + + return properties; + } + + @Override + protected AbstractCellConverter getCellConverter(ZoneId zoneId) { + return new SnowflakeCellConverter(zoneId); + } + + @Override + public void registerDriver() throws SQLException { + DriverManager.registerDriver(new net.snowflake.client.jdbc.SnowflakeDriver()); + } +} diff --git a/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Queries.java b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Queries.java new file mode 100644 index 00000000..3a869ff2 --- /dev/null +++ b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Queries.java @@ -0,0 +1,58 @@ +package io.kestra.plugin.jdbc.sybase; + +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.tasks.RunnableTask; +import io.kestra.plugin.jdbc.AbstractCellConverter; +import io.kestra.plugin.jdbc.AbstractJdbcQueries; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.ZoneId; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Perform multiple queries on a Sybase database." +) +@Plugin( + examples = { + @Example( + title = "Send SQL queries to a Sybase Database and fetch a row as output.", + full = true, + code = """ + id: sybase_queries + namespace: company.team + + tasks: + - id: queries + type: io.kestra.plugin.jdbc.sybase.Queries + url: jdbc:sybase:Tds:127.0.0.1:5000/ + username: syb_user + password: syb_password + sql: select count(*) from employee, select count(*) from laptop; + fetchType: FETCH_ONE + """ + ) + } +) +public class Queries extends AbstractJdbcQueries implements RunnableTask { + @Override + protected AbstractCellConverter getCellConverter(ZoneId zoneId) { + return new SybaseCellConverter(zoneId); + } + + @Override + public void registerDriver() throws SQLException { + DriverManager.registerDriver(new com.sybase.jdbc4.jdbc.SybDriver()); + } +} diff --git a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Queries.java b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Queries.java new file mode 100644 index 00000000..2000e36d --- /dev/null +++ b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Queries.java @@ -0,0 +1,59 @@ +package io.kestra.plugin.jdbc.vectorwise; + +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.tasks.RunnableTask; +import io.kestra.plugin.jdbc.AbstractCellConverter; +import io.kestra.plugin.jdbc.AbstractJdbcQueries; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.ZoneId; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Perform multiple queries on a Vectorwise database." +) +@Plugin( + examples = { + @Example( + title = "Send SQL queries to a Vectorwise database and fetch a row as output.", + full = true, + code = """ + id: vectorwise_queries + namespace: company.team + + tasks: + - id: queries + type: io.kestra.plugin.jdbc.vectorwise.Queries + url: jdbc:vectorwise://url:port/base + username: admin + password: admin_password + sql: select count(*) from employee; select count(*) from laptop; + fetchType: FETCH_ONE + """ + ) + } +) +public class Queries extends AbstractJdbcQueries implements RunnableTask { + @Override + protected AbstractCellConverter getCellConverter(ZoneId zoneId) { + return new VectorwiseCellConverter(zoneId); + } + + @Override + public void registerDriver() throws SQLException { + DriverManager.registerDriver(new com.ingres.jdbc.IngresDriver()); + } + +} diff --git a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Queries.java b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Queries.java new file mode 100644 index 00000000..f1521808 --- /dev/null +++ b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Queries.java @@ -0,0 +1,58 @@ +package io.kestra.plugin.jdbc.vertica; + +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.tasks.RunnableTask; +import io.kestra.plugin.jdbc.AbstractCellConverter; +import io.kestra.plugin.jdbc.AbstractJdbcQueries; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.ZoneId; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Perform multiple queries on a Vertica server." +) +@Plugin( + examples = { + @Example( + title = "Send SQL queries to a Vertica database, and fetch a row as output.", + full = true, + code = """ + id: vertica_queries + namespace: company.team + + tasks: + - id: queries + type: io.kestra.plugin.jdbc.vertica.Queries + url: jdbc:vertica://127.0.0.1:56982/db + username: vertica_user + password: vertica_password + sql: select * from customer + fetchType: FETCH_ONE + """ + ) + } +) +public class Queries extends AbstractJdbcQueries implements RunnableTask { + @Override + protected AbstractCellConverter getCellConverter(ZoneId zoneId) { + return new VerticaCellConverter(zoneId); + } + + @Override + public void registerDriver() throws SQLException { + DriverManager.registerDriver(new com.vertica.jdbc.Driver()); + } +}