io.kestra.plugin.jdbc.vertica.Trigger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin-jdbc-vertica Show documentation
Show all versions of plugin-jdbc-vertica Show documentation
Manage data in Vertica databases with Kestra's JDBC plugin.
package io.kestra.plugin.jdbc.vertica;
import io.kestra.core.models.annotations.Example;
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.runners.RunContext;
import io.kestra.plugin.jdbc.AbstractJdbcQuery;
import io.kestra.plugin.jdbc.AbstractJdbcTrigger;
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;
@SuperBuilder
@ToString
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
title = "Wait for query on a Vertica database."
)
@Plugin(
examples = {
@Example(
title = "Wait for a SQL query to return results, and then iterate through rows.",
full = true,
code = """
id: jdbc_trigger
namespace: company.team
tasks:
- id: each
type: io.kestra.plugin.core.flow.ForEach
values: "{{ trigger.rows }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ json(taskrun.value) }}"
triggers:
- id: watch
type: io.kestra.plugin.jdbc.vertica.Trigger
interval: "PT5M"
url: jdbc:vertica://127.0.0.1:56982/db
username: vertica_user
password: vertica_password
sql: "SELECT * FROM my_table"
fetchType: FETCH
"""
)
}
)
public class Trigger extends AbstractJdbcTrigger {
@Override
protected AbstractJdbcQuery.Output runQuery(RunContext runContext) throws Exception {
var query = Query.builder()
.id(this.id)
.type(Query.class.getName())
.url(this.getUrl())
.username(this.getUsername())
.password(this.getPassword())
.timeZoneId(this.getTimeZoneId())
.sql(this.getSql())
.fetch(this.isFetch())
.store(this.isStore())
.fetchOne(this.isFetchOne())
.fetchType(this.getFetchType())
.additionalVars(this.additionalVars)
.build();
return query.run(runContext);
}
@Override
public void registerDriver() throws SQLException {
DriverManager.registerDriver(new com.vertica.jdbc.Driver());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy