FileTransform FileTransform

yaml
type: "io.kestra.plugin.scripts.nashorn.FileTransform"

Transform ion format file from Kestra's internal storage with a Nashorn (JavaScript) script.

Examples

Transform with file from internal storage

yaml
id: nashorn_file_transform
namespace: company.team

tasks:
  - id: file_transform
    type: io.kestra.plugin.scripts.nashorn.FileTransform
    from: "{{ outputs['avro-to-gcs'] }}"
    script: |
      logger.info('row: {}', row)

      if (row['name'] === 'richard') {
        row = null
      } else {
        row['email'] = row['name'] + '@kestra.io'
      }

Create multiple rows from one row.

yaml
id: nashorn_file_transform
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: file_transform
    type: io.kestra.plugin.scripts.nashorn.FileTransform
    from: "{{ inputs.file }}"
    script: |
      logger.info('row: {}', row)
      rows = [{"action": "insert"}, row]

Transform JSON string input with a Nashorn script.

yaml
id: nashorn_file_transform
namespace: company.team

tasks:
  - id: file_transform
    type: io.kestra.plugin.scripts.nashorn.FileTransform
    from: "[{"name":"jane"}, {"name":"richard"}]"
    script: |
      logger.info('row: {}', row)

      if (row['name'] === 'richard') {
        row = null
      } else {
        row['email'] = row['name'] + '@kestra.io'
      }

Properties

from

  • Type: string
  • Dynamic: ✔️
  • Required: ✔️

Source file containing rows to transform.

Can be Kestra's internal storage URI, a map or a list.

concurrent

  • Type: integer
  • Dynamic:
  • Required:
  • Minimum: >= 2

Number of concurrent parallel transformations to execute.

Take care that the order is not respected if you use parallelism.

script

  • Type: string
  • Dynamic: ✔️
  • Required:

A full script.

Outputs

uri

  • Type: string
  • Required:
  • Format: uri

URI of a temporary result file.

The file will be serialized as ion file.

Definitions

Was this page helpful?