otp.Source.sink#

Source.sink(ep, out_pin=None, move_node=True)#

Appends node inplace to the source. Connect out_pin of this source to ep. Can be used to connect onetick.query objects to onetick.py source. Data schema changes (added or deleted columns) will not be detected automatically after applying sink function, so the user must change the schema himself by updating schema property.

Parameters
  • ep (otq.graph_components.EpBase, otq.graph_components.EpBase.PinnedEp, Tuple[otq.graph_components.EpBase, uuid.uuid4, Optional[str], Optional[str]]) – onetick.query EP object to append to source.

  • out_pin (Optional[str], default=None) – name of the out pin to connect to ep

  • move_node (bool, default=True) –

Returns

result – Last node of the source

Return type

otq.graph_components.EpBase, otq.graph_components.EpBase.PinnedEp

Examples

Adding column ‘B’ directly with onetick.query EP.

>>> data = otp.Tick(A=1)
>>> ep = data.sink(otq.AddField(field='B', value=2))
>>> otp.run(data)
        Time  A  B
0 2003-12-01  1  2

But we can’t use this column with onetick.py methods yet.

>>> data['C'] = data['B']
Traceback (most recent call last):
 ...
AttributeError: There is no 'B' column

We should manually change source’s schema

>>> data.schema.update(B=int)
>>> data['C'] = data['B']
>>> otp.run(data)
        Time  A  B  C
0 2003-12-01  1  2  2