diff --git a/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Query.java b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Query.java index 3e003907..e859646e 100644 --- a/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Query.java +++ b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Query.java @@ -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 + """ ) } ) diff --git a/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Trigger.java b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Trigger.java index 27292e29..f6081817 100644 --- a/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Trigger.java +++ b/plugin-jdbc-redshift/src/main/java/io/kestra/plugin/jdbc/redshift/Trigger.java @@ -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 + """ ) } ) diff --git a/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Query.java b/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Query.java index fc6610e9..8924d856 100644 --- a/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Query.java +++ b/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Query.java @@ -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 + """ ) } ) diff --git a/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Trigger.java b/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Trigger.java index f38bc444..f3fe1a80 100644 --- a/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Trigger.java +++ b/plugin-jdbc-rockset/src/main/java/io/kestra/plugin/jdbc/rockset/Trigger.java @@ -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 + """ ) } ) diff --git a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Download.java b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Download.java index 67667f7f..264c07d6 100644 --- a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Download.java +++ b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Download.java @@ -31,13 +31,20 @@ @Plugin( examples = { @Example( - code = { - "url: jdbc:snowflake://.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://.snowflakecomputing.com + username: snowflake_user + password: snowflake_password + stageName: "@demo_db.public.%myStage" + fileName: prefix/destFile.csv + """ ) } ) diff --git a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Query.java b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Query.java index 5b5b2afa..4ba4111a 100644 --- a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Query.java +++ b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Query.java @@ -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://.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://.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://.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://.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 %}" + """ ) } ) diff --git a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Trigger.java b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Trigger.java index d002d176..d2502afb 100644 --- a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Trigger.java +++ b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Trigger.java @@ -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://.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://.snowflakecomputing.com + username: snowflake_user + password: snowflake_password + sql: "SELECT * FROM demo_db.public.customers" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Upload.java b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Upload.java index 394468c4..03104f50 100644 --- a/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Upload.java +++ b/plugin-jdbc-snowflake/src/main/java/io/kestra/plugin/jdbc/snowflake/Upload.java @@ -28,15 +28,22 @@ @Plugin( examples = { @Example( - code = { - "url: jdbc:snowflake://.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://.snowflakecomputing.com + username: snowflake_user + password: snowflake_password + from: '{{ outputs.extract.uri }}' + fileName: data.csv + prefix: raw + stageName: "@demo_db.public.%myStage" + """ ) } ) diff --git a/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Query.java b/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Query.java index 45227b22..7338df7a 100644 --- a/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Query.java +++ b/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Query.java @@ -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 %}" + """ ) } ) diff --git a/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Trigger.java b/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Trigger.java index 13a7ee02..e9fc4f26 100644 --- a/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Trigger.java +++ b/plugin-jdbc-sqlite/src/main/java/io/kestra/plugin/jdbc/sqlite/Trigger.java @@ -25,27 +25,27 @@ @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.sqlite.Trigger", - " interval: \"PT5M\"", - " url: jdbc:sqlite:myfile.db", - " 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.sqlite.Trigger + interval: "PT5M" + url: jdbc:sqlite:myfile.db + sql: "SELECT * FROM my_table" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Batch.java b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Batch.java index ea071800..22fc7afa 100644 --- a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Batch.java +++ b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Batch.java @@ -29,32 +29,39 @@ @Example( title = "Fetch rows from a table and bulk insert to another one.", full = true, - code = { - "tasks:", - " - id: query", - " type: io.kestra.plugin.jdbc.sqlserver.Query", - " url: jdbc:sqlserver://dev:41433;trustServerCertificate=true", - " username: sql_server_user", - " password: sql_server_passwd", - " sql: |", - " SELECT *", - " FROM xref", - " LIMIT 1500;", - " store: true", - " - id: update", - " type: io.kestra.plugin.jdbc.sqlserver.Batch", - " from: \"{{ outputs.query.uri }}\"", - " url: jdbc:sqlserver://prod:41433;trustServerCertificate=true", - " username: sql_server_user", - " password: sql_server_passwd", - " sql: |", - " insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", - } + code = """ + id: sqlserver_batch_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.sqlserver.Query + url: jdbc:sqlserver://dev:41433;trustServerCertificate=true + username: sql_server_user + password: sql_server_password + sql: | + SELECT * + FROM xref + LIMIT 1500; + store: true + + - id: update + type: io.kestra.plugin.jdbc.sqlserver.Batch + from: "{{ outputs.query.uri }}" + url: jdbc:sqlserver://prod:41433;trustServerCertificate=true + username: sql_server_user + password: sql_server_password + sql: | + insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) + """ ), @Example( title = "Fetch rows from a table and bulk insert to another one, without using sql query.", full = true, code = { + "id: sqlserver_batch_query", + "namespace: company.team", + "", "tasks:", " - id: query", " type: io.kestra.plugin.jdbc.sqlserver.Query", @@ -66,6 +73,7 @@ " FROM xref", " LIMIT 1500;", " store: true", + "", " - id: update", " type: io.kestra.plugin.jdbc.sqlserver.Batch", " from: \"{{ outputs.query.uri }}\"", diff --git a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Query.java b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Query.java index 9f314695..0567b5fc 100644 --- a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Query.java +++ b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Query.java @@ -31,21 +31,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.sqlserver.Query", - " url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true", - " username: sql_server_user", - " password: sql_server_passwd", - " sql: select * from source", - " fetch: true", - " - id: generate_update", - " type: io.kestra.plugin.jdbc.sqlserver.Query", - " url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true", - " username: sql_server_user", - " password: sql_server_passwd", - " sql: \"{% for row in outputs.update.rows %} INSERT INTO destination (year_month, store_code, update_date) values ({{row.year_month}}, {{row.store_code}}, '{{row.date}}'); {% endfor %}\""} + code = """ + id: sqlserver_query + namespace: company.team + + tasks: + - id: select + type: io.kestra.plugin.jdbc.sqlserver.Query + url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true + username: sql_server_user + password: sql_server_password + sql: select * from source + fetch: true + + - id: generate_update + type: io.kestra.plugin.jdbc.sqlserver.Query + url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true + username: sql_server_user + password: sql_server_password + sql: "{% for row in outputs.update.rows %} INSERT INTO destination (year_month, store_code, update_date) values ({{row.year_month}}, {{row.store_code}}, '{{row.date}}'); {% endfor %}" + """ ) } ) diff --git a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Trigger.java b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Trigger.java index 9fcac6f7..67f44551 100644 --- a/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Trigger.java +++ b/plugin-jdbc-sqlserver/src/main/java/io/kestra/plugin/jdbc/sqlserver/Trigger.java @@ -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.sqlserver.Trigger", - " interval: \"PT5M\"", - " url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true", - " username: sql_server_user", - " password: sql_server_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.sqlserver.Trigger + interval: "PT5M" + url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true + username: sql_server_user + password: sql_server_password + sql: "SELECT * FROM my_table" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Query.java b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Query.java index 4f7d90d3..b33e45aa 100644 --- a/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Query.java +++ b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Query.java @@ -28,13 +28,20 @@ examples = { @Example( title = "Send a SQL query to a Sybase Database and fetch a row as output.", - code = { - "url: jdbc:sybase:Tds:127.0.0.1:5000/", - "username: syb_user", - "password: syb_passwd", - "sql: select * from syb_types", - "fetchOne: true", - } + full = true, + code = """ + id: sybase_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.sybase.Query + url: jdbc:sybase:Tds:127.0.0.1:5000/ + username: syb_user + password: syb_password + sql: select * from syb_types + fetchOne: true + """ ) } ) diff --git a/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Trigger.java b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Trigger.java index 6fcbb505..54a79ed4 100644 --- a/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Trigger.java +++ b/plugin-jdbc-sybase/src/main/java/io/kestra/plugin/jdbc/sybase/Trigger.java @@ -26,29 +26,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.sybase.Trigger", - " interval: \"PT5M\"", - " url: jdbc:sybase:Tds:127.0.0.1:5000/", - " username: syb_user", - " password: syb_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.sybase.Trigger + interval: "PT5M" + url: jdbc:sybase:Tds:127.0.0.1:5000/ + username: syb_user + password: syb_password + sql: "SELECT * FROM my_table" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Query.java b/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Query.java index 0fa35d91..e27283e6 100644 --- a/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Query.java +++ b/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Query.java @@ -31,23 +31,28 @@ @Example( full = true, title = "Execute a query and fetch results to pass it to downstream tasks.", - code = { - "tasks:", - " - id: analyze_orders", - " type: io.kestra.plugin.jdbc.trino.Query", - " url: jdbc:trino://localhost:8080/tpch", - " username: trino_user", - " password: trino_passwd", - " sql: |", - " select orderpriority as priority, sum(totalprice) as total", - " from tpch.tiny.orders", - " group by orderpriority", - " order by orderpriority", - " fetch: true", - " store: true", - " - id: csv_report", - " type: io.kestra.plugin.serdes.csv.IonToCsv", - " from: \"{{ outputs.analyze_orders.uri }}\""} + code = """ + id: trino_query + namespace: company.team + + tasks: + - id: analyze_orders + type: io.kestra.plugin.jdbc.trino.Query + url: jdbc:trino://localhost:8080/tpch + username: trino_user + password: trino_password + sql: | + select orderpriority as priority, sum(totalprice) as total + from tpch.tiny.orders + group by orderpriority + order by orderpriority + fetch: true + store: true + + - id: csv_report + type: io.kestra.plugin.serdes.csv.IonToCsv + from: "{{ outputs.analyze_orders.uri }}" + """ ) } ) diff --git a/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Trigger.java b/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Trigger.java index 786e2aa6..6696edd2 100644 --- a/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Trigger.java +++ b/plugin-jdbc-trino/src/main/java/io/kestra/plugin/jdbc/trino/Trigger.java @@ -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.trino.Trigger", - " interval: \"PT5M\"", - " url: jdbc:trino://localhost:8080/tpch", - " username: trino_user", - " password: trino_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.trino.Trigger + interval: "PT5M" + url: jdbc:trino://localhost:8080/tpch + username: trino_user + password: trino_password + sql: "SELECT * FROM my_table" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Batch.java b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Batch.java index 6acdfc0e..2a249273 100644 --- a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Batch.java +++ b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Batch.java @@ -29,31 +29,38 @@ @Example( title = "Fetch rows from a table and bulk insert to another one.", full = true, - code = { - "tasks:", - " - id: query", - " type: io.kestra.plugin.jdbc.vectorwise.Query", - " url: jdbc:vectorwise://dev:port/base", - " username: admin", - " password: admin_passwd", - " sql: |", - " SELECT *", - " FROM xref", - " LIMIT 1500;", - " store: true", - " - id: update", - " type: io.kestra.plugin.jdbc.vectorwise.Batch", - " from: \"{{ outputs.query.uri }}\"", - " url: jdbc:vectorwise://prod:port/base", - " username: admin", - " password: admin_passwd", - " sql: insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", - } + code = """ + id: vectorwise_batch_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.vectorwise.Query + url: jdbc:vectorwise://dev:port/base + username: admin + password: admin_password + sql: | + SELECT * + FROM xref + LIMIT 1500; + store: true + + - id: update + type: io.kestra.plugin.jdbc.vectorwise.Batch + from: \"{{ outputs.query.uri }}" + url: jdbc:vectorwise://prod:port/base + username: admin + password: admin_password + sql: insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) + """ ), @Example( title = "Fetch rows from a table and bulk insert to another one without using sql query.", full = true, code = { + "id: vectorwise_batch_query", + "namespace: company.team", + "", "tasks:", " - id: query", " type: io.kestra.plugin.jdbc.vectorwise.Query", @@ -65,6 +72,7 @@ " FROM xref", " LIMIT 1500;", " store: true", + "", " - id: update", " type: io.kestra.plugin.jdbc.vectorwise.Batch", " from: \"{{ outputs.query.uri }}\"", diff --git a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Query.java b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Query.java index 51465c5a..99c892b5 100644 --- a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Query.java +++ b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Query.java @@ -30,13 +30,20 @@ examples = { @Example( title = "Send a SQL query to a Vectorwise database and fetch a row as output.", - code = { - "url: jdbc:vectorwise://url:port/base", - "username: admin", - "password: admin_passwd", - "sql: select * from vectorwise_types", - "fetchOne: true", - } + full = true, + code = """ + id: vectorwise_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.vectorwise.Query + url: jdbc:vectorwise://url:port/base + username: admin + password: admin_password + sql: select * from vectorwise_types + fetchOne: true + """ ) } ) diff --git a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Trigger.java b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Trigger.java index 963d1fba..751f15ca 100644 --- a/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Trigger.java +++ b/plugin-jdbc-vectorwise/src/main/java/io/kestra/plugin/jdbc/vectorwise/Trigger.java @@ -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.vectorwise.Trigger", - " interval: \"PT5M\"", - " url: jdbc:vectorwise://url:port/base", - " 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.vectorwise.Trigger + interval: "PT5M" + url: jdbc:vectorwise://url:port/base + username: admin + password: admin_password + sql: "SELECT * FROM my_table" + fetch: true + """ ) } ) diff --git a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Batch.java b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Batch.java index 85fa4aff..110808be 100644 --- a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Batch.java +++ b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Batch.java @@ -29,32 +29,39 @@ @Example( title = "Fetch rows from a table and bulk insert to another one.", full = true, - code = { - "tasks:", - " - id: query", - " type: io.kestra.plugin.jdbc.vertica.Query", - " url: jdbc:vertica://dev:56982/db", - " username: vertica_user", - " password: vertica_passwd", - " sql: |", - " SELECT *", - " FROM xref", - " LIMIT 1500;", - " fetch: true", - " store: true", - " - id: update", - " type: io.kestra.plugin.jdbc.vertica.Batch", - " from: \"{{ outputs.query.uri }}\"", - " url: jdbc:vertica://prod:56982/db", - " username: vertica_user", - " password: vertica_passwd", - " sql: insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", - } + code = """ + id: vertica_batch_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.vertica.Query + url: jdbc:vertica://dev:56982/db + username: vertica_user + password: vertica_password + sql: | + SELECT * + FROM xref + LIMIT 1500; + fetch: true + store: true + + - id: update + type: io.kestra.plugin.jdbc.vertica.Batch + from: "{{ outputs.query.uri }}" + url: jdbc:vertica://prod:56982/db + username: vertica_user + password: vertica_password + sql: insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) + """ ), @Example( title = "Fetch rows from a table and bulk insert to another one, without using sql query.", full = true, code = { + "id: vertica_batch_query", + "namespace: company.team", + "", "tasks:", " - id: query", " type: io.kestra.plugin.jdbc.vertica.Query", @@ -67,6 +74,7 @@ " LIMIT 1500;", " fetch: true", " store: true", + "", " - id: update", " type: io.kestra.plugin.jdbc.vertica.Batch", " from: \"{{ outputs.query.uri }}\"", diff --git a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Query.java b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Query.java index 6ae255f1..9ce1e91c 100644 --- a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Query.java +++ b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Query.java @@ -30,13 +30,20 @@ examples = { @Example( title = "Send a SQL query to a Vertica database, and fetch a row as output.", - code = { - "url: jdbc:vertica://127.0.0.1:56982/db", - "username: vertica_user", - "password: vertica_passwd", - "sql: select * from customer", - "fetchOne: true", - } + full = true, + code = """ + id: vertica_query + namespace: company.team + + tasks: + - id: query + type: io.kestra.plugin.jdbc.vertica.Query + url: jdbc:vertica://127.0.0.1:56982/db + username: vertica_user + password: vertica_password + sql: select * from customer + fetchOne: true + """ ) } ) diff --git a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Trigger.java b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Trigger.java index 99f030f2..6be27b77 100644 --- a/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Trigger.java +++ b/plugin-jdbc-vertica/src/main/java/io/kestra/plugin/jdbc/vertica/Trigger.java @@ -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.vertica.Trigger", - " interval: \"PT5M\"", - " url: jdbc:vertica://127.0.0.1:56982/db", - " username: vertica_user", - " password: vertica_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.vertica.Trigger + interval: "PT5M" + url: jdbc:vertica://127.0.0.1:56982/db + username: vertica_user + password: vertica_password + sql: "SELECT * FROM my_table" + fetch: true + """ ) } )