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:
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:
Op Fields
Anonymous fields go to op by default
yaml:
ops:
op1:
field1: select * from ks1.tb1;
field2: field 2 value
json:
ops:
Anonymous fields may include scoped params
yaml:
ops:
op1:
field1: select * from ks1.tb1;
field2: field 2 value
params:
paramname1: paramvalue1
json:
ops:
Scoped op fields allow dangling param values
yaml:
ops:
op1:
op:
field1: select * from ks1.tb1;
field2: field 2 value
paramname1: paramval1
json:
ops:
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:
params at doc level
yaml:
params:
pname: pvalue
ops: "my test op"
json:
ops:
params at block level
yaml:
blocks:
block1:
params:
pname: pvalue
ops: "my test op"
json:
ops:
params at op level
yaml:
blocks:
block1:
ops:
op1:
op: "my test op"
params:
pname: pvalue
json:
ops:
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:
ops:
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:
ops: