Version:

Create Projection

Creates a new projection of an existing table. A projection represents a subset of the columns (potentially including derived columns) of a table.

For projection details and examples, see Projections. For limitations, see Projection Limitations and Cautions.

Window functions, which can perform operations like moving averages, are available through this endpoint as well as Get Records by Column.

A projection can be created with a different shard key than the source table. By specifying shard_key, the projection will be sharded according to the specified columns, regardless of how the source table is sharded. The source table can even be unsharded or replicated.

Input Parameter Description

Name Type Description
table_name string Name of the existing table on which the projection is to be applied.
projection_name string Name of the projection to be created. Has the same naming restrictions as tables.
column_names array of strings List of columns from input parameter table_name to be included in the projection. Can include derived columns. Can be specified as aliased via the syntax 'column_name as alias'.
options map of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
collection_name Name of a collection to which the projection is to be assigned as a child. If the collection provided is non-existent, the collection will be automatically created. If empty, then the projection will be at the top level. The default value is ''.
expression An optional filter expression to be applied to the source table prior to the projection. The default value is ''.
is_replicated

If true then the projection will be replicated even if the source table is not. The supported values are:

  • true
  • false
limit The number of records to keep. The default value is ''.
order_by Comma-separated list of the columns to be sorted by; e.g. 'timestamp asc, x desc'. The columns specified must be present in input parameter column_names. If any alias is given for any column name, the alias must be used, rather than the original column name. The default value is ''.
materialize_on_gpu

If true then the columns of the projection will be cached on the GPU. The supported values are:

  • true
  • false
chunk_size Indicates the chunk size to be used for this table.
create_indexes Comma-separated list of columns on which to create indexes on the output table. The columns specified must be present in input parameter column_names. If any alias is given for any column name, the alias must be used, rather than the original column name.
ttl Sets the TTL of the projection specified in input parameter projection_name.
shard_key Comma-separated list of the columns to be sharded on; e.g. 'column1, column2'. The columns specified must be present in input parameter column_names. If any alias is given for any column name, the alias must be used, rather than the original column name. The default value is ''.
persist

If true, then the projection specified in input parameter projection_name will be persisted and will not expire unless a ttl is specified. If false, then the projection will be an in-memory table and will expire unless a ttl is specified otherwise. The supported values are:

  • true
  • false
preserve_dict_encoding

If true, then columns that were dict encoded in the source table will be dict encoded in the projection table. The supported values are:

  • true
  • false
view_id view this projection is part of. The default value is ''.

Output Parameter Description

Name Type Description
projection_name string Value of input parameter projection_name.