Skip to main content
create_table(table_name=None, type_id=None, options=)[source]

Creates a new table with the given type (definition of columns). The type is specified in input parameter type_id as either a numerical type ID (as returned by GPUdb.create_type()) or as a list of columns, each specified as a list of the column name, data type, and any column attributes.

Example of a type definition with some parameters:

Each column definition consists of the column name (which should meet the standard column naming criteria), the column’s specific type (int, long, float, double, string, bytes, or any of the properties map values from GPUdb.create_type()), and any data handling, data key, or data replacement properties.

A table may optionally be designated to use a replicated distribution scheme, or be assigned: foreign keys to other tables, a partitioning scheme, and/or a tier strategy.

Parameters

table_name (str) –

Name of the table to be created, in [schema_name.]table_name format, using standard name resolution rules and meeting table naming criteria. Error for requests with existing table of the same name and type ID may be suppressed by using the no_error_if_exists option.

type_id (str) –

The type for the table, specified as either an existing table’s numerical type ID (as returned by GPUdb.create_type()) or a type definition (as described above).

options (dict of str to str) –

Optional parameters. Allowed keys are:

  • no_error_if_exists – If true, prevents an error from occurring if the table already exists and is of the given type. If a table with the same ID but a different type exists, it is still an error. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • create_temp_table – If true, a unique temporary table name will be generated in the sys_temp schema and used in place of input parameter table_name. If is_result_table is true, then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in qualified_table_name. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • collection_name – [DEPRECATED–please specify the containing schema as part of input parameter table_name and use GPUdb.create_schema() to create the schema if non-existent] Name of a schema which is to contain the newly created table. If the schema is non-existent, it will be automatically created.

  • is_collection – [DEPRECATED–please use GPUdb.create_schema() to create a schema instead] Indicates whether to create a schema instead of a table. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • is_replicated – Affects the distribution scheme for the table’s data. If true and the given type has no explicit shard key defined, the table will be replicated. If false, the table will be sharded according to the shard key specified in the given input parameter type_id, or randomly sharded, if no shard key is specified. Note that a type containing a shard key cannot be used to create a replicated table. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • foreign_keys – Semicolon-separated list of foreign keys, of the format ‘(source_column_name [, …]) references target_table_name(primary_key_column_name [, …]) [as foreign_key_name]’.

  • foreign_shard_key – Foreign shard key of the format ‘source_column references shard_by_column from target_table(primary_key_column)’.

  • partition_typePartitioning scheme to use. Allowed values are:

  • partition_keys – Comma-separated list of partition keys, which are the columns or column expressions by which records will be assigned to partitions defined by partition_definitions.

  • partition_definitions – Comma-separated list of partition definitions, whose format depends on the choice of partition_type. See range partitioning, interval partitioning, list partitioning, hash partitioning, or series partitioning for example formats.

  • is_automatic_partition – If true, a new partition will be created for values which don’t fall into an existing partition. Currently only supported for list partitions. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • ttl – Sets the TTL of the table specified in input parameter table_name.

  • chunk_size – Indicates the number of records per chunk to be used for this table.

  • chunk_column_max_memory – Indicates the target maximum data size for each column in a chunk to be used for this table.

  • chunk_max_memory – Indicates the target maximum data size for all columns in a chunk to be used for this table.

  • is_result_table – Indicates whether the table is a memory-only table. A result table cannot contain columns with text_search data-handling, and it will not be retained if the server is restarted. Allowed values are:

    • true

    • false

    The default value is ‘false’.

  • strategy_definition – The tier strategy for the table and its columns.

  • compression_codec – The default compression codec for this table’s columns.

  • load_vectors_policy – Set startup data loading scheme for the table. Allowed values are:

    • always – Load as much vector data as possible into memory before accepting requests.

    • lazy – Load the necessary vector data at start, and load the remainder lazily.

    • on_demand – Load vector data as requests use it.

    • system – Load vector data using the system-configured default.

    The default value is ‘system’.

  • build_pk_index_policy – Set startup primary-key index generation scheme for the table. Allowed values are:

    • always – Generate as much primary key index data as possible before accepting requests.

    • lazy – Generate the necessary primary key index data at start, and load the remainder lazily.

    • on_demand – Generate primary key index data as requests use it.

    • system – Generate primary key index data using the system-configured default.

    The default value is ‘system’.

The default value is an empty dict ( ).

Returns

A dict with the following entries–

table_name (str) –

Value of input parameter table_name.

type_id (str) –

Value of input parameter type_id.

is_collection (bool) –

[DEPRECATED–this will always return false] Indicates if the created entity is a schema.

info (dict of str to str) –

Additional information. Allowed keys are:

  • qualified_table_name – The fully qualified name of the new table (i.e. including the schema).

The default value is an empty dict ( ).