NB5 Docs► Reference Section► Workload Specification▼ Op Template Variations 🖺

Op Templates Variations

These examples illustrate a variety of valid op template structures.

Op Naming

map of op templates with explicit name

If you use a map of op templates, they can still override the name of the op simply by adding the name key.

yaml:

ops:
  op1:
    name: special-op-name
    op: select * from ks1.tb1;

json:


{
  "ops": {
    "op1": {
      "name": "special-op-name",
      "op": "select * from ks1.tb1;"
    }
  }
}

ops:


[
  {
    "name": "block0--special-op-name",
    "op": {
      "stmt": "select * from ks1.tb1;"
    },
    "tags": {
      "block": "block0",
      "name": "block0--special-op-name"
    }
  }
]

map of op templates without explicit name

This yaml document contains a single named op template op1 which contains a scoped op op with two op fields field1 and field2.

The op template takes its name op1 from the map key under the ops property.

yaml:

ops:
  op1:
    op:
      field1: select * from ks1.tb1;
      field2: field 2 value

json:


{
  "ops": {
    "op1": {
      "op": {
        "field1": "select * from ks1.tb1;",
        "field2": "field 2 value"
      }
    }
  }
}

ops:


[
  {
    "name": "block0--op1",
    "op": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    },
    "tags": {
      "block": "block0",
      "name": "block0--op1"
    }
  }
]

Op Fields

Anonymous fields go to op by default

yaml:

ops:
  op1:
    field1: select * from ks1.tb1;
    field2: field 2 value

json:


{
  "ops": {
    "op1": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    }
  }
}

ops:


[
  {
    "name": "block0--op1",
    "op": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    },
    "tags": {
      "block": "block0",
      "name": "block0--op1"
    }
  }
]

Anonymous fields may include scoped params

yaml:

ops:
  op1:
    field1: select * from ks1.tb1;
    field2: field 2 value
    params:
      paramname1: paramvalue1

json:


{
  "ops": {
    "op1": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value",
      "params": {
        "paramname1": "paramvalue1"
      }
    }
  }
}

ops:


[
  {
    "name": "block0--op1",
    "op": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    },
    params: {
      "paramname1": "paramvalue1"
    },
    "tags": {
      "block": "block0",
      "name": "block0--op1"
    }
  }
]

Scoped op fields allow dangling param values

yaml:

ops:
  op1:
    op:
      field1: select * from ks1.tb1;
      field2: field 2 value
    paramname1: paramval1

json:


{
  "ops": {
    "op1": {
      "op": {
        "field1": "select * from ks1.tb1;",
        "field2": "field 2 value"
      },
      "paramname1": "paramval1"
    }
  }
}

ops:


[
  {
    "name": "block0--op1",
    "op": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    },
    "params": {
      "paramname1": "paramval1"
    },
    "tags": {
      "block": "block0",
      "name": "block0--op1"
    }
  }
]

Scoped op and param fields disallow dangling fields

yaml:

ops:
  op1:
    op:
      field1: select * from ks1.tb1;
      field2: field 2 value
    params:
      paramname1: paramval1
#   dangling1: value
#   ^ NOT ALLOWED HERE

json:


{
  "ops": {
    "op1": {
      "op": {
        "field1": "select * from ks1.tb1;",
        "field2": "field 2 value"
      },
      "params": {
        "paramname1": "paramval1"
      }
    }
  }
}

ops:


[
  {
    "name": "block0--op1",
    "op": {
      "field1": "select * from ks1.tb1;",
      "field2": "field 2 value"
    },
    "params": {
      "paramname1": "paramval1"
    },
    "tags": {
      "block": "block0",
      "name": "block0--op1"
    }
  }
]

params at doc level

yaml:

params:
  pname: pvalue
ops: "my test op"

json:


{
  "params": {
    "pname": "pvalue"
  },
  "ops": "my test op"
}

ops:


[
  {
    "params": {
      "pname": "pvalue"
    },
    "tags": {
      "name": "block0--stmt1",
      "block": "block0"
    },
    "op": {
      "stmt": "my test op"
    },
    "name": "block0--stmt1"
  }
]

params at block level

yaml:

blocks:
  block1:
    params:
      pname: pvalue
    ops: "my test op"

json:


{
  "blocks": {
    "block1": {
      "params": {
        "pname": "pvalue"
      },
      "ops": "my test op"
    }
  }
}

ops:


[
  {
    "params": {
      "pname": "pvalue"
    },
    "tags": {
      "name": "block1--stmt1",
      "block": "block1"
    },
    "op": {
      "stmt": "my test op"
    },
    "name": "block1--stmt1"
  }
]

params at op level

yaml:

blocks:
  block1:
    ops:
      op1:
        op: "my test op"
        params:
          pname: pvalue

json:


{
  "blocks": {
    "block1": {
      "ops": {
        "op1": {
          "op": "my test op",
          "params": {
            "pname": "pvalue"
          }
        }
      }
    }
  }
}

ops:


[
  {
    "params": {
      "pname": "pvalue"
    },
    "tags": {
      "name": "block1--op1",
      "block": "block1"
    },
    "op": {
      "stmt": "my test op"
    },
    "name": "block1--op1"
  }
]

params field at op field level is not treated as special

When you put your params within the op fields by name, alongside the other op fields, it is not treated specially. This is not disallowed, as there may be scenarios where this is otherwise a valid value. Further, params within the op field would not provide any benefit over simply having those named values in the op field directly, as this is consulted first for dynamic and static values.

yaml:

blocks:
  block1:
    ops:
      op1:
        op:
          stmt: "my test op"
          params:
            pname: pvalue

json:


{
  "blocks": {
    "block1": {
      "ops": {
        "op1": {
          "op": {
            "stmt": "my test op",
            "params": {
              "pname": "pvalue"
            }
          }
        }
      }
    }
  }
}

ops:


[
  {
    "tags": {
      "name": "block1--op1",
      "block": "block1"
    },
    "op": {
      "stmt": "my test op",
      "params": {
        "pname": "pvalue"
      }
    },
    "name": "block1--op1"
  }
]

params field at op name level is not treated as special

When you are using map-based op template names, and one of them has a name of 'param', it is treated just as any other op template name. The fields will not be recognized as param names and values, but as op template fields.

yaml:

blocks:
  block1:
    ops:
      op1:
        op:
          stmt: "my test op"
      params:
        pname: pvalue

json:


{
  "blocks": {
    "block1": {
      "ops": {
        "op1": {
          "op": {
            "stmt": "my test op"
          }
        },
        "params": {
          "pname": "pvalue"
        }
      }
    }
  }
}

ops:


[
  {
    "tags": {
      "name": "block1--op1",
      "block": "block1"
    },
    "op": {
      "stmt": "my test op"
    },
    "name": "block1--op1"
  },
  {
    "tags": {
      "name": "block1--params",
      "block": "block1"
    },
    "op": {
      "pname": "pvalue"
    },
    "name": "block1--params"
  }
]

Back to top