# otp.Source.sink

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

Appends `ep` node to this source (inplace by default).
Connects `out_pin` of this source to `ep`.

Can be used to connect onetick.query objects to [`onetick.py.Source`](root.md#onetick.py.Source).

Data schema changes (added or deleted columns) will not be detected automatically
after applying this function, so the user must change the schema himself
by updating [`onetick.py.Source.schema()`](schema.md#onetick.py.Source.schema) property.

* **Parameters:**
  * **ep** (*otq.graph_components.EpBase* *,*            *otq.graph_components.EpBase.PinnedEp* *,*            *Tuple* *[**otq.graph_components.EpBase* *,* *uuid.uuid4* *,* *Optional* *[*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *]* *,* *Optional* *[*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *]* *]*) -- onetick.query EP object to append to source.
  * **out_pin** (*Optional* *[*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *]* *,* *default=None*) -- name of the out pin to connect to `ep`
  * **inplace** ([*bool*](https://docs.python.org/3/library/functions.html#bool) *,* *default=False*) -- if True method will modify current object,
    otherwise it will return modified copy of the object.
* **Returns:**
  Returns `None` if `inplace=True`.
* **Return type:**
  [`Source`](root.md#onetick.py.Source) or `None`

### Examples

Adding column 'B' directly with onetick.query EP.

```pycon
>>> data = otp.Tick(A=1)
>>> 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:

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

We should manually change source's schema:

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

Use parameter `inplace=False` to return modified copy of the source:

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

#### SEE ALSO
[`onetick.py.Source.schema`](schema.md#onetick.py.Source.schema), [`onetick.py.core._source.schema.Schema`](schema.md#onetick.py.core._source.schema.Schema)
