Skip to content

Commit

Permalink
Merge pull request #362 from shrutimantri/add-full-examples-1
Browse files Browse the repository at this point in the history
feat(docs): add full-examples for multiple jdbc tasks
  • Loading branch information
wrussell1999 authored Sep 5, 2024
2 parents 674cd38 + 4813f97 commit d9638b5
Show file tree
Hide file tree
Showing 23 changed files with 488 additions and 397 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@
examples = {
@Example(
title = "Send a SQL query to a Redshift database and fetch a row as output.",
code = {
"url: jdbc:redshift://123456789.eu-central-1.redshift-serverless.amazonaws.com:5439/dev",
"username: admin",
"password: admin_passwd",
"sql: select * from redshift_types",
"fetchOne: true",
}
full = true,
code = """
id: redshift_query
namespace: company.team
tasks:
- id: select
type: io.kestra.plugin.jdbc.redshift.Query
url: jdbc:redshift://123456789.eu-central-1.redshift-serverless.amazonaws.com:5439/dev
username: admin
password: admin_password
sql: select * from redshift_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.redshift.Trigger",
" interval: \"PT5M\"",
" url: jdbc:redshift://123456789.eu-central-1.redshift-serverless.amazonaws.com:5439/dev",
" username: admin",
" password: admin_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.redshift.Trigger
interval: "PT5M"
url: jdbc:redshift://123456789.eu-central-1.redshift-serverless.amazonaws.com:5439/dev
username: admin
password: admin_password
sql: "SELECT * FROM my_table"
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@
@Example(
full = true,
title = "Execute a query and fetch results.",
code = {
"tasks:",
" - id: select",
" type: io.kestra.plugin.jdbc.rockset.Query",
" url: jdbc:rockset://",
" apiKey: \"[apiKey]\"",
" apiServer: \"[apiServer]\"",
" sql: |",
" SELECT *",
" FROM nation",
" fetch: true"
}
code = """
id: rockset_query
namespace: company.team
tasks:
- id: select
type: io.kestra.plugin.jdbc.rockset.Query
url: "jdbc:rockset://api.rs2.usw2.rockset.com"
apiKey: "api_key"
apiServer: "api_server"
sql: |
SELECT *
FROM nation
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,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.rockset.Trigger",
" interval: \"PT5M\"",
" url: jdbc:rockset://",
" apiKey: \"[apiKey]\"",
" apiServer: \"[apiServer]\"",
" 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.rockset.Trigger
interval: "PT5M"
url: "jdbc:rockset://api.rs2.usw2.rockset.com"
apiKey: "api_key"
apiServer: "api_server"
sql: "SELECT * FROM my_table"
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@
@Plugin(
examples = {
@Example(
code = {
"url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com",
"username: snowflake_user",
"password: snowflake_passwd",
"stageName: \"@demo_db.public.%myStage\"",
"fileName: prefix/destFile.csv"
}
full = true,
code = """
id: snowflake_download
namespace: company.team
tasks:
- id: download
type: io.kestra.plugin.jdbc.snowflake.Download
url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
username: snowflake_user
password: snowflake_password
stageName: "@demo_db.public.%myStage"
fileName: prefix/destFile.csv
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,26 @@
@Example(
full = true,
title = "Execute a query and fetch results in a task, and update another table with fetched results in a different task.",
code = {
"tasks:",
" - id: select",
" type: io.kestra.plugin.jdbc.snowflake.Query",
" url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com",
" username: snowflake_user",
" password: snowflake_passwd",
" sql: select * from demo_db.public.customers",
" fetch: true",
" - id: generate_update",
" type: io.kestra.plugin.jdbc.snowflake.Query",
" url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com",
" username: snowflake_user",
" password: snowflake_passwd",
" sql: \"INSERT INTO demo_db.public.customers_new (year_month, store_code, update_date) values {% for row in outputs.update.rows %} ({{row.year_month}}, {{row.store_code}}, TO_DATE('{{row.date}}', 'MONTH DD, YYYY') ) {% if not loop.last %}, {% endif %}; {% endfor %}\""}
code = """
id: snowflake_query
namespace: company.team
tasks:
- id: select
type: io.kestra.plugin.jdbc.snowflake.Query
url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
username: snowflake_user
password: snowflake_password
sql: select * from demo_db.public.customers
fetch: true
- id: generate_update
type: io.kestra.plugin.jdbc.snowflake.Query
url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
username: snowflake_user
password: snowflake_password
sql: "INSERT INTO demo_db.public.customers_new (year_month, store_code, update_date) values {% for row in outputs.update.rows %} ({{ row.year_month }}, {{ row.store_code }}, TO_DATE('{{ row.date }}', 'MONTH DD, YYYY') ) {% if not loop.last %}, {% endif %}; {% endfor %}"
"""
)
}
)
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.snowflake.Trigger",
" interval: \"PT5M\"",
" url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com",
" username: snowflake_user",
" password: snowflake_passwd",
" sql: \"SELECT * FROM demo_db.public.customers\"",
" 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.snowflake.Trigger
interval: "PT5M"
url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
username: snowflake_user
password: snowflake_password
sql: "SELECT * FROM demo_db.public.customers"
fetch: true
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@
@Plugin(
examples = {
@Example(
code = {
"url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com",
"username: snowflake_user",
"password: snowflake_passwd",
"from: '{{ outputs.extract.uri }}'",
"fileName: data.csv",
"prefix: raw",
"stageName: \"@demo_db.public.%myStage\"",
}
full = true,
code = """
id: snowflake_upload
namespace: company.team
tasks:
- id: upload
type: io.kestra.plugin.jdbc.snowflake.Upload
url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
username: snowflake_user
password: snowflake_password
from: '{{ outputs.extract.uri }}'
fileName: data.csv
prefix: raw
stageName: "@demo_db.public.%myStage"
"""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,44 @@
@Example(
full = true,
title = "Execute a query and pass the results to another task.",
code = {
"tasks:",
" - id: update",
" type: io.kestra.plugin.jdbc.sqlite.Query",
" url: jdbc:sqlite:myfile.db",
" sql: select concert_id, available, a, b, c, d, play_time, library_record, floatn_test, double_test, real_test, numeric_test, date_type, time_type, timez_type, timestamp_type, timestampz_type, interval_type, pay_by_quarter, schedule, json_type, blob_type from pgsql_types",
" fetch: true",
"",
" - id: use_fetched_data",
" type: io.kestra.plugin.jdbc.sqlite.Query",
" url: jdbc:sqlite:myfile.db",
" sql: \"{% for row in outputs.update.rows %} INSERT INTO pl_store_distribute (year_month,store_code, update_date) values ({{row.play_time}}, {{row.concert_id}}, TO_TIMESTAMP('{{row.timestamp_type}}', 'YYYY-MM-DDTHH:MI:SS.US') ); {% endfor %}\""}
code = """
id: sqlite_query
namespace: company.team
tasks:
- id: update
type: io.kestra.plugin.jdbc.sqlite.Query
url: jdbc:sqlite:myfile.db
sql: select concert_id, available, a, b, c, d, play_time, library_record, floatn_test, double_test, real_test, numeric_test, date_type, time_type, timez_type, timestamp_type, timestampz_type, interval_type, pay_by_quarter, schedule, json_type, blob_type from pgsql_types
fetch: true
- id: use_fetched_data
type: io.kestra.plugin.jdbc.sqlite.Query
url: jdbc:sqlite:myfile.db
sql: "{% for row in outputs.update.rows %} INSERT INTO pl_store_distribute (year_month,store_code, update_date) values ({{row.play_time}}, {{row.concert_id}}, TO_TIMESTAMP('{{row.timestamp_type}}', 'YYYY-MM-DDTHH:MI:SS.US') ); {% endfor %}"
"""
),
@Example(
full = true,
title = "Execute a query, using existing sqlite file, and pass the results to another task.",
code = {
"tasks:",
"- id: update",
" type: io.kestra.plugin.jdbc.sqlite.Query",
" url: jdbc:sqlite:myfile.db",
" sqliteFile: {{ outputs.get.outputFiles['myfile.sqlite'] }}",
" sql: select * from pgsql_types",
" fetch: true",
"",
"- id: use_fetched_data",
" type: io.kestra.plugin.jdbc.sqlite.Query",
" url: jdbc:sqlite:myfile.db",
" sqliteFile: {{ outputs.get.outputFiles['myfile.sqlite'] }}",
" sql: \"{% for row in outputs.update.rows %} INSERT INTO pl_store_distribute (year_month,store_code, update_date) values ({{row.play_time}}, {{row.concert_id}}, TO_TIMESTAMP('{{row.timestamp_type}}', 'YYYY-MM-DDTHH:MI:SS.US') ); {% endfor %}\""
}
code = """
id: sqlite_query_using_file
namespace: company.team
tasks:
- id: update
type: io.kestra.plugin.jdbc.sqlite.Query
url: jdbc:sqlite:myfile.db
sqliteFile: {{ outputs.get.outputFiles['myfile.sqlite'] }}
sql: select * from pgsql_types
fetch: true
- id: use_fetched_data
type: io.kestra.plugin.jdbc.sqlite.Query
url: jdbc:sqlite:myfile.db
sqliteFile: {{ outputs.get.outputFiles['myfile.sqlite'] }}
sql: "{% for row in outputs.update.rows %} INSERT INTO pl_store_distribute (year_month,store_code, update_date) values ({{row.play_time}}, {{row.concert_id}}, TO_TIMESTAMP('{{row.timestamp_type}}', 'YYYY-MM-DDTHH:MI:SS.US') ); {% endfor %}"
"""
)
}
)
Expand Down
Loading

0 comments on commit d9638b5

Please sign in to comment.