> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /create/projection

```
URL: http://<db.host>:<db.port>/create/projection
```

Creates a new [projection](../../concepts/projections/) 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](../../concepts/projections/).  For limitations, see
[Projection Limitations and Cautions](../../concepts/projections/#limitations-and-cautions).

[Window functions](../../concepts/window/), which can perform operations
like moving averages, are available through this endpoint as well as
[/get/records/bycolumn](/content/api/rest/get_records_bycolumn_rest).

A projection can be created with a different
[shard key](../../concepts/tables/#shard-keys) 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.

If input parameter *table\_name* is empty, selection is performed against a
single-row virtual table.  This can be useful in executing temporal
([NOW()](../../concepts/expressions/#date-time-functions)), identity
([USER()](../../concepts/expressions/#user-security-functions)), or
constant-based functions
([GEODIST(-77.11, 38.88, -71.06, 42.36)](../../concepts/expressions/#scalar-functions)).

## Input Parameter Description

<ParamField body="table_name" type="string">
  Name of the existing table on which the projection is to be applied, in \[schema\_name.]table\_name format, using standard [name resolution rules](../../concepts/tables/#table-name-resolution). An empty table name creates a projection from a single-row virtual table, where columns specified should be constants or constant expressions.
</ParamField>

<ParamField body="projection_name" type="string">
  Name of the projection to be created, in \[schema\_name.]table\_name format, using standard [name resolution rules](../../concepts/tables/#table-name-resolution) and meeting [table naming criteria](../../concepts/tables/#table-naming-criteria).
</ParamField>

<ParamField body="column_names" type="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'.
</ParamField>

<ParamField body="options" type="map of string to strings">
  Optional parameters.

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

  <Expandable title="options">
    <ParamField body="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 *projection\_name*. If *persist* is *false* (or unspecified), then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in *qualified\_projection\_name*.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="collection_name">
      \[DEPRECATED--please specify the containing schema for the projection as part of input parameter *projection\_name* and use [/create/schema](/content/api/rest/create_schema_rest) to create the schema if non-existent]  Name of a schema for the projection. If the schema is non-existent, it will be automatically created.

      The default value is ''.
    </ParamField>

    <ParamField body="expression">
      An optional filter [expression](../../concepts/expressions/) to be applied to the source table prior to the projection.

      The default value is ''.
    </ParamField>

    <ParamField body="is_replicated">
      If *true* then the projection will be replicated even if the source table is not.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="offset">
      The number of initial results to skip (this can be useful for paging through the results).

      The default value is `0`.
    </ParamField>

    <ParamField body="limit">
      The number of records to keep.

      The default value is `-9999`.
    </ParamField>

    <ParamField body="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 ''.
    </ParamField>

    <ParamField body="chunk_size">
      Indicates the number of records per chunk to be used for this projection.
    </ParamField>

    <ParamField body="chunk_column_max_memory">
      Indicates the target maximum data size for each column in a chunk to be used for this projection.
    </ParamField>

    <ParamField body="chunk_max_memory">
      Indicates the target maximum data size for all columns in a chunk to be used for this projection.
    </ParamField>

    <ParamField body="create_indexes">
      Comma-separated list of columns on which to create indexes on the projection.  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.
    </ParamField>

    <ParamField body="ttl">
      Sets the [TTL](../../concepts/ttl/) of the projection specified in input parameter *projection\_name*.
    </ParamField>

    <ParamField body="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 ''.
    </ParamField>

    <ParamField body="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 default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="preserve_dict_encoding">
      If *true*, then columns that were dict encoded in the source table will be dict encoded in the projection.

      The default value is `true`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="retain_partitions">
      Determines whether the created projection will retain the partitioning scheme from the source table.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="partition_type">
      [Partitioning](../../concepts/tables/#partitioning) scheme to use.

      * **RANGE**: Use [range partitioning](../../concepts/tables/#partitioning-by-range).
      * **INTERVAL**: Use [interval partitioning](../../concepts/tables/#partitioning-by-interval).
      * **LIST**: Use [list partitioning](../../concepts/tables/#partitioning-by-list).
      * **HASH**: Use [hash partitioning](../../concepts/tables/#partitioning-by-hash).
      * **SERIES**: Use [series partitioning](../../concepts/tables/#partitioning-by-series).
    </ParamField>

    <ParamField body="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*.
    </ParamField>

    <ParamField body="partition_definitions">
      Comma-separated list of partition definitions, whose format depends on the choice of *partition\_type*.  See [range partitioning](../../concepts/tables/#partitioning-by-range), [interval partitioning](../../concepts/tables/#partitioning-by-interval), [list partitioning](../../concepts/tables/#partitioning-by-list), [hash partitioning](../../concepts/tables/#partitioning-by-hash), or [series partitioning](../../concepts/tables/#partitioning-by-series) for example formats.
    </ParamField>

    <ParamField body="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](../../concepts/tables/#partitioning-by-list).

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="view_id">
      ID of view of which this projection is a member.

      The default value is ''.
    </ParamField>

    <ParamField body="strategy_definition">
      The [tier strategy](../../rm/concepts/#tier-strategies) for the table and its columns.
    </ParamField>

    <ParamField body="compression_codec">
      The default [compression codec](../../concepts/column_compression/) for the projection's columns.
    </ParamField>

    <ParamField body="join_window_functions">
      If set, window functions which require a reshard will be computed separately and joined back together, if the width of the projection is greater than the join\_window\_functions\_threshold.

      The default value is `true`.
    </ParamField>

    <ParamField body="join_window_functions_threshold">
      If the projection is greater than this width (in bytes), then window functions which require a reshard will be computed separately and joined back together.

      The default value is ''.
    </ParamField>

    <ParamField body="qualify_filter">
      An optional filter [expression](../../concepts/expressions/) applied to the projection after window function evaluation, equivalent to a SQL QUALIFY clause.  May reference window function aliases as well as any other column in the projection.  Rows for which the expression evaluates to false (or NULL) are removed from the projection.

      The default value is ''.
    </ParamField>
  </Expandable>
</ParamField>

## Output Parameter Description

The Kinetica server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query.  Here is a description of the various fields of the wrapper:

<ResponseField name="status" type="String">
  'OK' or 'ERROR'
</ResponseField>

<ResponseField name="message" type="String">
  Empty if success or an error message
</ResponseField>

<ResponseField name="data_type" type="String">
  'create\_projection\_response' or 'none' in case of an error
</ResponseField>

<ResponseField name="data" type="String">
  Empty string
</ResponseField>

<ResponseField name="data_str" type="JSON or String">
  This embedded JSON represents the result of the /create/projection endpoint:

  <Expandable title="data_str">
    <ResponseField name="projection_name" type="string">
      Value of input parameter *projection\_name*.
    </ResponseField>

    <ResponseField name="info" type="map of string to strings">
      Additional information.

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

      <Expandable title="info">
        <ResponseField name="count">
          Number of records in the final table.
        </ResponseField>

        <ResponseField name="qualified_projection_name">
          The fully qualified name of the projection (i.e. including the schema).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  Empty string in case of an error.
</ResponseField>
