pydeephaven.session#

class Session(host=None, port=None, never_timeout=True, session_type='python')[source]#

Bases: object

A Session object represents a connection to the Deephaven data server. It contains a number of convenience methods for asking the server to create tables, import Arrow data into tables, merge tables, run Python scripts, and execute queries.

Session objects can be used in Python with statement so that whatever happens in the with statement block, they are guaranteed to be closed upon exit.

tables#

names of the global tables available in the server after running scripts

Type:

list[str]

is_alive#

check if the session is still alive (may refresh the session)

Type:

bool

bind_table(name, table)[source]#

Bind a table to the given name on the server so that it can be referenced by that name.

Parameters:
  • name (str) – name for the table

  • table (Table) – a Table object

Raises:

DHError

Return type:

None

close()[source]#

Close the Session object if it hasn’t timed out already.

Raises:

DHError

Return type:

None

empty_table(size)[source]#

create an empty table on the server.

Parameters:

size (int) – the size of the empty table in number of rows

Return type:

Table

Returns:

a Table object

Raises:

DHError

import_table(data)[source]#

Import the pyarrow table as a new Deephaven table on the server.

Deephaven supports most of the Arrow data types. However, if the pyarrow table contains any field with a data type not supported by Deephaven, the import operation will fail.

Parameters:

data (pyarrow.Table) – a pyarrow Table object

Return type:

Table

Returns:

a Table object

Raises:

DHError

merge_tables(tables, order_by=None)[source]#

Merge several tables into one table on the server.

Parameters:
  • tables (list[Table]) – the list of Table objects to merge

  • order_by (str, optional) – if specified the resultant table will be sorted on this column

Return type:

Table

Returns:

a Table object

Raises:

DHError

open_table(name)[source]#

Open a table in the global scope with the given name on the server.

Parameters:

name (str) – the name of the table

Return type:

Table

Returns:

a Table object

Raises:

DHError

query(table)[source]#

Create a Query object to define a sequence of operations on a Deephaven table.

Parameters:

table (Table) – a Table object

Return type:

Query

Returns:

a Query object

Raises:

DHError

run_script(script)[source]#

Run the supplied Python script on the server.

Parameters:

script (str) – the Python script code

Raises:

DHError

Return type:

None

time_table(period, start_time=None)[source]#

Create a time table on the server.

Parameters:
  • period (int) – the interval (in nano seconds) at which the time table ticks (adds a row)

  • start_time (int, optional) – the start time for the time table in nano seconds, default is None (meaning now)

Return type:

Table

Returns:

a Table object

Raises:

DHError