> ## 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

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_projection.rs#L47-L60)
pub async fn [create\_projection](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-projection.md#method.create_projection)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), projection\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_names: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateProjectionResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Create a projection of an existing tableCreates 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 `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)).

##### Arguments

<ul>
  <li>`table_name` - 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.</li>
  <li>`projection_name` - Name of the projection to be created, in \[schema\_name.]table\_name format, using standard name resolution rules and meeting table naming criteria.</li>
  <li>`column_names` - List of columns from `table_name` to be included in the projection. Can include derived columns. Can be specified as aliased via the syntax ‘column\_name as alias’.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_projection.rs#L99-L119)
pub async fn [create\_projection\_with\_opts](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-projection.md#method.create_projection_with_opts)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), projection\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_names: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, options: [CreateProjectionRequestOptions](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionRequestOptions.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateProjectionResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Create a projection of an existing tableCreates 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 `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)).

##### Arguments

<ul>
  <li>`table_name` - 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.</li>
  <li>`projection_name` - Name of the projection to be created, in \[schema\_name.]table\_name format, using standard name resolution rules and meeting table naming criteria.</li>
  <li>`column_names` - List of columns from `table_name` to be included in the projection. Can include derived columns. Can be specified as aliased via the syntax ‘column\_name as alias’.</li>
  <li>`options` - The optional parameters; any left unset take the server’s defaults.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_projection.rs#L122-L133)
pub async fn [create\_projection\_raw](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-projection.md#method.create_projection_raw)( \&self, request: &[CreateProjectionRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateProjectionResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`CreateProjectionRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionRequest) to the `/create/projection` endpoint.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_projection.rs#L137-L149)
pub async fn [create\_projection\_from\_url](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-projection.md#method.create_projection_from_url)( \&self, url: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), request: &[CreateProjectionRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateProjectionResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`CreateProjectionRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateProjectionRequest) to a specific worker URL, bypassing HA head-node selection. Used for multi-head access.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.