Data Operation - Define

Data Operation - Define

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 flow file
  • before a create or fill operation that will create data resource

Arguments

The define operations accept the following arguments.

  • data-resource - to define a inline data resource where:
  • data-resources - to define a list of inline data resources.

Usage

This operation is only available as step in a pipeline flow (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.

flow:
  - 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 flow

tabli flow execute flow/[email protected]

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

flow:
  - 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"]
Powered by ComboStrap