atoti.Session.create_table()#

Session.create_table(name, *, data_types={}, default_values={}, keys=frozenset({}), partitioning=None, **kwargs)#

Create an empty table with columns of the given data_types.

Parameters:
  • name (str) – The name of the table to create.

  • data_types (Mapping[str, DataType]) – The table column names and their corresponding data type.

  • default_values (Mapping[str, bool | int | float | date | datetime | time | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[str] | str | None]) – Mapping from column name to column default_value.

  • keys (Set[str] | Sequence[str]) –

    The columns that will become keys of the table.

    If a Set is given, the keys will be ordered as the table columns.

  • partitioning (str | None) –

    The description of how the data will be split across partitions of the table.

    Default rules:

    • Only non-joined tables are automatically partitioned.

    • Tables are automatically partitioned by hashing their key columns. If there are no key columns, all the dictionarized columns are hashed.

    • Joined tables can only use a sub-partitioning of the table referencing them.

    • Automatic partitioning is done modulo the number of available cores.

    For instance, "modulo4(country)" splits the data across 4 partitions based on the country column’s dictionarized value.

  • kwargs (Unpack[_CreateTablePrivateParameters])

Return type:

Table

Example

>>> from datetime import date
>>> table = session.create_table(
...     "Product",
...     data_types={
...         "Date": "LocalDate",
...         "Product": "String",
...         "Quantity": "double",
...     },
...     keys={"Product", "Date"},
... )
>>> table.head()
Empty DataFrame
Columns: [Quantity]
Index: []
>>> {column_name: table[column_name].data_type for column_name in table}
{'Date': 'LocalDate', 'Product': 'String', 'Quantity': 'double'}
>>> table.keys
('Date', 'Product')