Version:

/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.

Notes:

A moving average can be calculated on a given column using the following syntax in the input parameter column_names parameter:

'moving_average(column_name,num_points_before,num_points_after) as new_column_name'

For each record in the moving_average function's 'column_name' parameter, it computes the average over the previous 'num_points_before' records and the subsequent 'num_points_after' records.

Note that moving average relies on order_by, and order_by requires that all the data being ordered resides on the same processing node, so it won't make sense to use order_by without moving average.

Also, 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 strings

Optional parameters. 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. Default value is ''.
expression An optional filter expression to be applied to the source table prior to the projection. Default value is ''.
limit The number of records to keep. 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. Default value is ''.
materialize_on_gpu

If true then the columns of the projection will be cached on the GPU. Default value is 'false'. The allowed values are:

  • true
  • false
ttl Sets the TTL of the table, view, or collection specified in input parameter projection_name. The value must be the desired TTL in minutes.
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. Default value is ''.
persist

If true then the projection will be persisted as a regular table (it will not be automatically cleared unless a ttl is provided, and the table data can be modified in subsequent operations). If false then the projection will be a read-only, memory-only temporary table. Default value is 'false'. The allowed values are:

  • true
  • false

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:

Name Type Description
status String 'OK' or 'ERROR'
message String Empty if success or an error message
data_type String 'create_projection_request' or 'none' in case of an error
data String Empty string
data_str JSON or String

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

Name Type Description
projection_name string Value of input parameter projection_name.

Empty string in case of an error.