/create/projection

URL: http://GPUDB_IP_ADDRESS:GPUDB_PORT/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/bycolumn.

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.

If input parameter table_name is empty, selection is performed against a single-row virtual table. This can be useful in executing temporal (NOW()), identity (USER()), or constant-based functions (GEODIST(-77.11, 38.88, -71.06, 42.36)).

Input Parameter Description

NameTypeDescription
table_namestringName of the existing table on which the projection is to be applied, in [schema_name.]table_name format, using standard name resolution rules. An empty table name creates a projection from a single-row virtual table, where columns specified should be constants or constant expressions.
projection_namestringName of the projection to be created, in [schema_name.]table_name format, using standard name resolution rules and meeting table naming criteria.
column_namesarray of stringsList 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'.
optionsmap of string to strings

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

Supported Parameters (keys)Parameter Description
collection_name[DEPRECATED--please specify the containing schema for the projection as part of input parameter projection_name and use /create/schema 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 ''.
expressionAn 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 default value is false. The supported values are:

  • true
  • false
limitThe number of records to keep. The default value is ''.
order_byComma-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 ''.
chunk_sizeIndicates the number of records per chunk to be used for this projection.
create_indexesComma-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.
ttlSets the TTL of the projection specified in input parameter projection_name.
shard_keyComma-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 default value is false. 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. The default value is true. The supported values are:

  • true
  • false
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
view_idID of view of which this projection is a member. The default value is ''.

Output Parameter Description

The GPUdb 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:

NameTypeDescription
statusString'OK' or 'ERROR'
messageStringEmpty if success or an error message
data_typeString'create_projection_request' or 'none' in case of an error
dataStringEmpty string
data_strJSON or String

This embedded JSON represents the result of the /create/projection endpoint:

NameTypeDescription
projection_namestringValue of input parameter projection_name.
infomap of string to strings

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

Possible Parameters (keys)Parameter Description
countNumber of records in the final table
qualified_projection_nameThe fully qualified name of the projection (i.e. including the schema).

Empty string in case of an error.