URL: http://<db.host>:<db.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
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
table_name | 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. An empty table name creates a projection from a single-row virtual table, where columns specified should be constants or constant expressions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
projection_name | string | Name of the projection to be created, in [schema_name.]table_name format, using standard name resolution rules and meeting table naming criteria. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 ( {} ).
|
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_response' 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:
Empty string in case of an error. |