Data Operation - Define

Undraw Data Processing

Define

define is an operation that defines a data resource.

A select operation may not return any data resources but the define operation returns always the data resource that it defines.

This operation is used:

  • to define inline data resource in a pipeline file
  • before a create or fill operation that will create data resource

Arguments

The define operations accept the following arguments.

Arguments Mandatory Definition
data-uri only if data is not defined The data uri is the location of the resource
data only if data-uri is not defined The data as a list of records (the data are in the inline)
data-definition no The data definition
data-resources to define more than one data resource (a list of inline data resources)

Usage

This operation is only available as step in a pipeline pipeline (ie not in a tabli data command)

This is a first step (known as the supplier step) because it supplies data resources to the others operations in the pipeline.

Single Data Resource

Example: A color data resource with two columns and 3 records.

pipeline:
  - name: "Define"
    comment: "This operation define the tabular data resource named 'colors' with two columns"
    operation: "define"
    args:
      data-resource:
        data-definition:
          logicalName: "colors"
          columns: ["id","color"]
        data:
          - ["1", "blue"]
          - ["2", "red"]
          - ["3", "yellow"]
  - name: "Print"
    comment: "Print the colors resource"
    operation: "print"


If you execute this pipeline

tabli flow execute pipeline/define_single.yml@howto

you will get the data of the colors data resource printed in a tabular format.

id   color
--   ------
1    blue
2    red
3    yellow

Multiple Inline Data Resources

Two inline data resources colors and characters

pipeline:
  - name: 'Define'
    operation: 'define'
    args:
      data-resources:
        - data-definition:
            logicalName: "colors"
            columns: ["id","color"]
          data:
            - ["1", "blue"]
            - ["2", "red"]
            - ["3", "yellow"]
        - data-definition:
            logicalName: "characters"
            columns:
              - name: "id"
                type: integer
              - name: "name"
              - name: "last_name"
          data:
            - [1, "Arnold","Schwarzy"]
            - [2, "Don","Norman"]
            - [3, "Dale","Carnegie"]
            - [4, "Daniel","Kahneman"]
Task Runner