Skip to content

Commit

Permalink
doc(FileTransform): improved examples for FileTransform task
Browse files Browse the repository at this point in the history
  • Loading branch information
Skraye committed Mar 12, 2024
1 parent 4586ca7 commit 98974ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.kestra.plugin.scripts.groovy;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -14,6 +15,9 @@
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
title = "Transform ion format file from Kestra's internal storage with a Groovy script."
)
@Plugin(
examples = {
@Example(
Expand All @@ -23,11 +27,12 @@
"script: |",
" logger.info('row: {}', row)",
"",
" if (row.get('name') == 'richard') {",
" row = null",
" } else {",
" row.put('email', row.get('name') + '@kestra.io')",
" }"
" // remove a column",
" row.remove('useless_column')",
" // update a column",
" row['email'] = row['name'] + '@kestra.io'",
" // set a column to null",
" row['last_update'] = null"
}
),
@Example(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.kestra.plugin.scripts.jython;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -14,6 +15,9 @@
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
title = "Transform ion format file from Kestra's internal storage with a Jython script."
)
@Plugin(
examples = {
@Example(
Expand Down Expand Up @@ -51,16 +55,18 @@
"""
),
@Example(
title = "Transform with file from internal storage.",
title = "Convert row by row of a file from Kestra's internal storage.",
code = {
"from: \"{{ outputs['avro-to-gcs'] }}\"",
"script: |",
" logger.info('row: {}', row)",
"",
" if row['name'] == 'richard': ",
" row = None",
" else: ",
" row['email'] = row['name'] + '@kestra.io'\n"
" // remove a column",
" del row['useless_column']",
" // update a column",
" row['email'] = row['name'] + '@kestra.io'",
" // set a column to null",
" row['last_update'] = None"
}
),
@Example(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
@Plugin(
examples = {
@Example(
title = "Transform with file from internal storage",
title = "Convert row by row of a file from Kestra's internal storage.",
code = {
"from: \"{{ outputs['avro-to-gcs'] }}\"",
"script: |",
" logger.info('row: {}', row)",
"",
" if (row['name'] === 'richard') {",
" row = null",
" } else {",
" row['email'] = row['name'] + '@kestra.io'",
" }"
" # remove a column",
" delete row['useless_column']",
" # update a column",
" row['email'] = row['name'] + '@kestra.io'",
" # set a column to null",
" row['last_update'] = null"
}
),
@Example(
Expand Down

0 comments on commit 98974ea

Please sign in to comment.