Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs): add full examples for multiple jdbc tasks #378

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,37 @@
examples = {
@Example(
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: db_user",
"password: db_passwd",
"sql: select * FROM departments",
"fetch: true",
}
full = true,
code = """
id: arrow_flight_sql_query
namespace: company.team

tasks:
- id: query
type: io.kestra.plugin.jdbc.arrowflight.Query
url: jdbc:arrow-flight-sql://localhost:31010/?useEncryption=false
username: db_user
password: db_password
sql: select * FROM departments
fetch: true
"""
),
@Example(
title = "Send a SQL query to a Dremio coordinator and fetch rows as output using Apache Arrow Flight SQL driver.",
code = {
"url: jdbc:arrow-flight-sql://dremio-coordinator:32010/?schema=postgres.public",
"username: dremio_user",
"password: dremio_passwd",
"sql: select * FROM departments",
"fetch: true",
}
full = true,
code = """
id: arrow_flight_sql_query
namespace: company.team

tasks:
- id: query
type: io.kestra.plugin.jdbc.arrowflight.Query
url: jdbc:arrow-flight-sql://dremio-coordinator:32010/?schema=postgres.public
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 @@ -29,29 +29,29 @@
@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.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ json(taskrun.value) }}\"",
" value: \"{{ trigger.rows }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.jdbc.arrowflight.Trigger",
" username: dremio_user",
" password: dremio_passwd",
" url: jdbc:arrow-flight-sql://dremio-coordinator:32010/?schema=postgres.public",
" interval: \"PT5M\"",
" sql: \"SELECT * FROM my_table\"",
" fetch: true",
}
code = """
id: jdbc_trigger
namespace: company.team

tasks:
- id: each
type: io.kestra.plugin.core.flow.EachSequential
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ json(taskrun.value) }}"
value: "{{ trigger.rows }}"

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"
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@
examples = {
@Example(
title = "Send a SQL query to a AS400 Database and fetch a row as output.",
code = {
"url: jdbc:as400://127.0.0.1:50000/",
"username: as400_user",
"password: as400_passwd",
"sql: select * from as400_types",
"fetchOne: true",
}
full = true,
code = """
id: as400_query
namespace: company.team

tasks:
- id: query
type: io.kestra.plugin.jdbc.as400.Query
url: jdbc:as400://127.0.0.1:50000/
username: as400_user
password: as400_password
sql: select * from as400_types
fetchOne: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
@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.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ json(taskrun.value) }}\"",
" value: \"{{ trigger.rows }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.jdbc.as400.Trigger",
" interval: \"PT5M\"",
" url: jdbc:as400://127.0.0.1:50000/",
" username: as400_user",
" password: as400_passwd",
" sql: \"SELECT * FROM my_table\"",
" fetch: true",
}
code = """
id: jdbc_trigger
namespace: company.team

tasks:
- id: each
type: io.kestra.plugin.core.flow.EachSequential
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ json(taskrun.value) }}"
value: "{{ trigger.rows }}"

triggers:
- id: watch
type: io.kestra.plugin.jdbc.as400.Trigger
interval: "PT5M"
url: jdbc:as400://127.0.0.1:50000/
username: as400_user
password: as400_password
sql: "SELECT * FROM my_table"
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,66 @@
examples = {
@Example(
title = "Insert rows from another table to a Clickhouse database using asynchronous inserts.",
code = {
"from: \"{{ outputs.query.uri }}\"",
"url: jdbc:clickhouse://127.0.0.1:56982/",
"username: ch_user",
"password: ch_passwd",
"sql: INSERT INTO YourTable SETTINGS async_insert=1, wait_for_async_insert=1 values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"
}
full = true,
code = """
id: clickhouse_bulk_insert
namespace: company.team

inputs:
- id: file
type: FILE

tasks:
- id: bulk_insert
type: io.kestra.plugin.jdbc.clickhouse.BulkInsert
from: "{{ inputs.file }}"
url: jdbc:clickhouse://127.0.0.1:56982/
username: ch_user
password: ch_password
sql: INSERT INTO YourTable SETTINGS async_insert=1, wait_for_async_insert=1 values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
"""
),
@Example(
title = "Insert data into specific columns via a SQL query to a ClickHouse database using asynchronous inserts.",
code = {
"from: \"{{ outputs.query.uri }}\"",
"url: jdbc:clickhouse://127.0.0.1:56982/",
"username: ch_user",
"password: ch_passwd",
"sql: INSERT INTO YourTable ( field1, field2, field3 ) SETTINGS async_insert=1, wait_for_async_insert=1 values( ?, ?, ? )"
}
full = true,
code = """
id: clickhouse_bulk_insert
namespace: company.team

inputs:
- id: file
type: FILE

tasks:
- id: bulk_insert
type: io.kestra.plugin.jdbc.clickhouse.BulkInsert
from: "{{ inputs.file }}"
url: jdbc:clickhouse://127.0.0.1:56982/
username: ch_user
password: ch_password
sql: INSERT INTO YourTable ( field1, field2, field3 ) SETTINGS async_insert=1, wait_for_async_insert=1 values( ?, ?, ? )
"""
),
@Example(
title = "Insert data into specific columns via a SQL query to a ClickHouse database using asynchronous inserts.",
code = {
"from: \"{{ outputs.query.uri }}\"",
"url: jdbc:clickhouse://127.0.0.1:56982/",
"username: ch_user",
"password: ch_passwd",
"table: YourTable"
}
full = true,
code = """
id: clickhouse_bulk_insert
namespace: company.team

inputs:
- id: file
type: FILE

tasks:
- id: bulk_insert
type: io.kestra.plugin.jdbc.clickhouse.BulkInsert
from: "{{ inputs.file }}"
url: jdbc:clickhouse://127.0.0.1:56982/
username: ch_user
password: ch_password
table: YourTable
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@
examples = {
@Example(
title = "Query a Clickhouse database.",
code = {
"url: jdbc:clickhouse://127.0.0.1:56982/",
"username: ch_user",
"password: ch_passwd",
"sql: select * from clickhouse_types",
"store: true",
}
full = true,
code = """
id: clickhouse_query
namespace: company.team

tasks:
- id: query
type: io.kestra.plugin.jdbc.clickhouse.Query
url: jdbc:clickhouse://127.0.0.1:56982/
username: ch_user
password: ch_password
sql: select * from clickhouse_types
store: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
@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.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ json(taskrun.value) }}\"",
" value: \"{{ trigger.rows }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.jdbc.clickhouse.Trigger",
" interval: \"PT5M\"",
" url: jdbc:clickhouse://127.0.0.1:56982/",
" username: ch_user",
" password: ch_passwd",
" sql: \"SELECT * FROM my_table\"",
" fetch: true",
}
code = """
id: jdbc_trigger
namespace: company.team

tasks:
- id: each
type: io.kestra.plugin.core.flow.EachSequential
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ json(taskrun.value) }}"
value: "{{ trigger.rows }}"

triggers:
- id: watch
type: io.kestra.plugin.jdbc.clickhouse.Trigger
interval: "PT5M"
url: jdbc:clickhouse://127.0.0.1:56982/
username: ch_user
password: ch_password
sql: "SELECT * FROM my_table"
fetch: true
"""
)
}
)
Expand Down
21 changes: 14 additions & 7 deletions plugin-jdbc-db2/src/main/java/io/kestra/plugin/jdbc/db2/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@
examples = {
@Example(
title = "Send a SQL query to a DB2 Database and fetch a row as output.",
code = {
"url: jdbc:db2://127.0.0.1:50000/",
"username: db2inst",
"password: db2_passwd",
"sql: select * from db2_types",
"fetchOne: true",
}
full = true,
code = """
id: db2_query
namespace: company.team

tasks:
- id: query
type: io.kestra.plugin.jdbc.db2.Query
url: jdbc:db2://127.0.0.1:50000/
username: db2inst
password: db2_password
sql: select * from db2_types
fetchOne: true
"""
)
}
)
Expand Down
Loading
Loading