Skip to content

Commit

Permalink
docs: Improve docs in plugin-jdbc and plugin-jdbc-arrow-flight
Browse files Browse the repository at this point in the history
  • Loading branch information
smantri-moveworks authored and loicmathieu committed Dec 21, 2023
1 parent 810e9b2 commit bfb16a3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
@Plugin(
examples = {
@Example(
title = "Send a SQL query to a database and fetch a row as outputs using Apache Arrow Flight SQL driver",
title = "Send a SQL query to a database and fetch row(s) using Apache Arrow Flight SQL driver",
code = {
"url: jdbc:arrow-flight-sql://localhost:31010/?useEncryption=false",
"username: dremio",
"password: dremio123",
"username: db_user",
"password: db_password",
"sql: select * FROM departments",
"fetch: true",
}
),
@Example(
title = "Send a sql query to a Dremio coordinator and fetch a row as outputs using Apache Arrow Flight SQL driver",
title = "Send a sql query to a Dremio coordinator and fetch rows as outputs using Apache Arrow Flight SQL driver",
code = {
"url: jdbc:arrow-flight-sql://dremio-coordinator:32010/?schema=postgres.public",
"username: $token",
"password: samplePersonalAccessToken",
"username: dremio_user",
"password: dremio_password",
"sql: select * FROM departments",
"fetch: true",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Getter
@NoArgsConstructor
@Schema(
title = "Wait for query on a Arrow Flight database."
title = "Wait for query to a database through Arrow Flight SQL driver."
)
@Plugin(
examples = {
Expand All @@ -45,9 +45,12 @@
"triggers:",
" - id: watch",
" type: io.kestra.plugin.jdbc.arrowflight.Trigger",
" username: dremio_user",
" password: dremio_password",
" url: jdbc:arrow-flight-sql://dremio-coordinator:32010/?schema=postgres.public",
" interval: \"PT5M\"",
" sql: \"SELECT * FROM my_table\""
" sql: \"SELECT * FROM my_table\"",
" fetch: true"
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@ public abstract class AbstractJdbcBatch extends Task implements JdbcStatementInt

@NotNull
@io.swagger.v3.oas.annotations.media.Schema(
title = "Insert query to be executed",
description = "The query must have as much question mark as column in the files." +
"\nExample: 'insert into database values( ? , ? , ? )' for 3 columns" +
"\nIn case you do not want all columns, you need to precise it in the query and in the columns property" +
"\nExample: 'insert into(id,name) database values( ? , ? )' to select 2 columns"
title = "Insert query to be executed.",
description = "The query must have as many question marks as the number of columns in the table." +
"\nExample: 'insert into <table_name> values( ? , ? , ? )' for 3 columns." +
"\nIn case you do not want all columns, you need to specify it in the query in the columns property" +
"\nExample: 'insert into <table_name> (id, name) values( ? , ? )' for inserting data into 2 columns: 'id' and 'name'."
)
@PluginProperty(dynamic = true)
private String sql;

@Schema(
title = "The size of chunk for every bulk request"
title = "The size of chunk for every bulk request."
)
@PluginProperty(dynamic = true)
@Builder.Default
@NotNull
private Integer chunk = 1000;

@Schema(
title = "The columns to be insert",
description = "If not provided, `?` count need to match the `from` number of cols"
title = "The columns to be inserted.",
description = "If not provided, `?` count need to match the `from` number of columns."
)
@PluginProperty(dynamic = true)
private List<String> columns;
Expand Down Expand Up @@ -120,7 +120,7 @@ public Output run(RunContext runContext) throws Exception {
runContext.metric(Counter.of("records", count.get()));
runContext.metric(Counter.of("updated", updated == null ? 0 : updated));

logger.info("Successfully bulk {} queries with {} updated rows", count.get(), updated);
logger.info("Successfully executed {} bulk queries and updated {} rows", count.get(), updated);

return Output
.builder()
Expand Down Expand Up @@ -163,10 +163,10 @@ private PreparedStatement addRows(
@Builder
@Getter
public static class Output implements io.kestra.core.models.tasks.Output {
@Schema(title = "The rows count")
@Schema(title = "The rows count.")
private final Long rowCount;

@Schema(title = "The updated rows count")
@Schema(title = "The updated rows count.")
private final Integer updatedCount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,26 @@ private Object convertCell(int columnIndex, ResultSet rs, AbstractCellConverter
@Getter
public static class Output implements io.kestra.core.models.tasks.Output {
@Schema(
title = "Map containing the first row of fetched data",
title = "Map containing the first row of fetched data.",
description = "Only populated if 'fetchOne' parameter is set to true."
)
@JsonInclude
private final Map<String, Object> row;

@Schema(
title = "Lit of map containing rows of fetched data",
title = "List of map containing rows of fetched data.",
description = "Only populated if 'fetch' parameter is set to true."
)
private final List<Map<String, Object>> rows;

@Schema(
title = "The url of the result file on kestra storage (.ion file / Amazon Ion text format)",
title = "The URI of the result file on Kestra's internal storage (.ion file / Amazon Ion formatted text file).",
description = "Only populated if 'store' is set to true."
)
private final URI uri;

@Schema(
title = "The size of the fetched rows",
title = "The size of the fetched rows.",
description = "Only populated if 'store' or 'fetch' parameter is set to true."
)
private final Long size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

public interface AutoCommitInterface {
@Schema(
title = "If autocommit is enabled",
title = "Whether autocommit is enabled.",
description = "Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit " +
"mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, " +
"its SQL statements are grouped into transactions that are terminated by a call to either the method commit" +
"or the method rollback. By default, new connections are in auto-commit mode except if you are using a " +
"`store` properties that will disabled autocommit whenever this properties values."
"its SQL statements are grouped into transactions that are terminated by a call to either the method commit " +
"or the method rollback. By default, new connections are in auto-commit mode except when you are using " +
"`store` property in which case the auto-commit will be disabled."
)
@PluginProperty(dynamic = false)
Boolean getAutoCommit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@

public interface JdbcConnectionInterface {
@Schema(
title = "The JDBC URL to connect to the database"
title = "The JDBC URL to connect to the database."
)
@PluginProperty(dynamic = true)
@NotNull
String getUrl();

@Schema(
title = "The database user"
title = "The database user."
)
@PluginProperty(dynamic = true)
String getUsername();

@Schema(
title = "The database user's password"
title = "The database user's password."
)
@PluginProperty(dynamic = true)
String getPassword();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

public interface JdbcQueryInterface extends JdbcStatementInterface {
@Schema(
title = "The sql query to run"
title = "The sql query to run."
)
@PluginProperty(dynamic = true)
String getSql();

@Schema(
title = "Whether to fetch the data from the query result to the task output" +
title = "Whether to fetch the data from the query result to the task output." +
" This parameter is evaluated after 'fetchOne' and 'store'."
)
@PluginProperty(dynamic = false)
boolean isFetch();

@Schema(
title = "Whether to fetch data row from the query result to a file in internal storage." +
title = "Whether to fetch data row(s) from the query result to a file in internal storage." +
" File will be saved as Amazon Ion (text format)." +
" \n" +
" See <a href=\"http://amzn.github.io/ion-docs/\">Amazon Ion documentation</a>" +
Expand All @@ -36,7 +36,7 @@ public interface JdbcQueryInterface extends JdbcStatementInterface {
boolean isFetchOne();

@Schema(
title = "Number of rows that should be fetched",
title = "Number of rows that should be fetched.",
description = "Gives the JDBC driver a hint as to the number of rows that should be fetched from the database " +
"when more rows are needed for this ResultSet object. If the fetch size specified is zero, the JDBC driver " +
"ignores the value and is free to make its own best guess as to what the fetch size should be. Ignored if " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public interface JdbcStatementInterface extends JdbcConnectionInterface {
@Schema(
title = "The time zone id to use for date/time manipulation. Default value is the worker default zone id."
title = "The time zone id to use for date/time manipulation. Default value is the worker's default time zone id."
)
@PluginProperty(dynamic = false)
String getTimeZoneId();
Expand Down

0 comments on commit bfb16a3

Please sign in to comment.