generated from kestra-io/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add queries : redshift, snowflake, sybase, vectorwise, vertica (#…
…424)
- Loading branch information
Showing
5 changed files
with
311 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Queries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AbstractJdbcQueries.MultiQueryOutput> { | ||
@Override | ||
protected AbstractCellConverter getCellConverter(ZoneId zoneId) { | ||
return new RedshiftCellConverter(zoneId); | ||
} | ||
|
||
@Override | ||
public void registerDriver() throws SQLException { | ||
DriverManager.registerDriver(new com.amazon.redshift.jdbc.Driver()); | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Queries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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://<account_identifier>.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<AbstractJdbcQueries.MultiQueryOutput>, 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()); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Queries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AbstractJdbcQueries.MultiQueryOutput> { | ||
@Override | ||
protected AbstractCellConverter getCellConverter(ZoneId zoneId) { | ||
return new SybaseCellConverter(zoneId); | ||
} | ||
|
||
@Override | ||
public void registerDriver() throws SQLException { | ||
DriverManager.registerDriver(new com.sybase.jdbc4.jdbc.SybDriver()); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Queries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AbstractJdbcQueries.MultiQueryOutput> { | ||
@Override | ||
protected AbstractCellConverter getCellConverter(ZoneId zoneId) { | ||
return new VectorwiseCellConverter(zoneId); | ||
} | ||
|
||
@Override | ||
public void registerDriver() throws SQLException { | ||
DriverManager.registerDriver(new com.ingres.jdbc.IngresDriver()); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Queries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AbstractJdbcQueries.MultiQueryOutput> { | ||
@Override | ||
protected AbstractCellConverter getCellConverter(ZoneId zoneId) { | ||
return new VerticaCellConverter(zoneId); | ||
} | ||
|
||
@Override | ||
public void registerDriver() throws SQLException { | ||
DriverManager.registerDriver(new com.vertica.jdbc.Driver()); | ||
} | ||
} |