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

<div className="kinetica-pydoc">
  <div className="dl py method">
    <div className="dt sig sig-object py" id="gpudb.GPUdb.create_projection"> <span className="sig-name descname"><span className="pre">create\_projection</span></span><span className="sig-paren">(</span><span className="em sig-param"><span className="n"><span className="pre">table\_name</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">projection\_name</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">column\_names</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">options</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">{"{"}{"}"}</span></span></span><span className="sig-paren">)</span><a href="https://github.com/kineticadb/kinetica-api-python/blob/master/gpudb/gpudb.py#L23360"><span className="viewcode-link"><span className="pre">\[source]</span></span></a></div>

    <div className="dd">
      <p>Creates a new <a className="reference external" href="/content/concepts/projections/">projection</a> of an existing table. A projection represents a subset of the columns (potentially including derived columns) of a table.</p>
      <p>For projection details and examples, see <a className="reference external" href="/content/concepts/projections/">Projections</a>. For limitations, see <a className="reference external" href="/content/concepts/projections/#limitations-and-cautions">Projection Limitations and Cautions</a>.</p>
      <p><a className="reference external" href="/content/concepts/window/">Window functions</a>, which can perform operations like moving averages, are available through this endpoint as well as <a className="reference internal" href="#gpudb.GPUdb.get_records_by_column" title="gpudb.GPUdb.get_records_by_column"><code className="xref py py-meth docutils literal notranslate"><span className="pre">GPUdb.get\_records\_by\_column()</span></code></a>.</p>
      <p>A projection can be created with a different <a className="reference external" href="/content/concepts/tables/#shard-keys">shard key</a> than the source table. By specifying <span className="em">shard\_key</span>, 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.</p>
      <p>If input parameter <span className="em">table\_name</span> is empty, selection is performed against a single-row virtual table. This can be useful in executing temporal (<a className="reference external" href="/content/concepts/expressions/#date-time-functions">NOW()</a>), identity (<a className="reference external" href="/content/concepts/expressions/#user-security-functions">USER()</a>), or constant-based functions (<a className="reference external" href="/content/concepts/expressions/#scalar-functions">GEODIST(-77.11, 38.88, -71.06, 42.36)</a>).</p>
      <p><strong>Parameters</strong></p>

      <div className="blockquote">
        <div>
          <div className="dl">
            <div className="dt">table\_name (<span className="em">str</span>) –</div>

            <div className="dd">
              <p>Name of the existing table on which the projection is to be applied, in \[schema\_name.]table\_name format, using standard <a className="reference external" href="/content/concepts/tables/#table-name-resolution">name resolution rules</a>. An empty table name creates a projection from a single-row virtual table, where columns specified should be constants or constant expressions.</p>
            </div>

            <div className="dt">projection\_name (<span className="em">str</span>) –</div>

            <div className="dd">
              <p>Name of the projection to be created, in \[schema\_name.]table\_name format, using standard <a className="reference external" href="/content/concepts/tables/#table-name-resolution">name resolution rules</a> and meeting <a className="reference external" href="/content/concepts/tables/#table-naming-criteria">table naming criteria</a>.</p>
            </div>

            <div className="dt">column\_names (<span className="em">list of str</span>) –</div>

            <div className="dd">
              <p>List of columns from input parameter <span className="em">table\_name</span> to be included in the projection. Can include derived columns. Can be specified as aliased via the syntax ‘column\_name as alias’. The user can provide a single element (which will be automatically promoted to a list internally) or a list.</p>
            </div>

            <div className="dt">options (<span className="em">dict of str to str</span>) –</div>

            <div className="dd">
              <p>Optional parameters. Allowed keys are:</p>

              <ul>
                <li>
                  <p><strong>create\_temp\_table</strong> – If <span className="em">true</span>, a unique temporary table name will be generated in the sys\_temp schema and used in place of input parameter <span className="em">projection\_name</span>. If <span className="em">persist</span> is <span className="em">false</span> (or unspecified), then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in <span className="em">qualified\_projection\_name</span>. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>collection\_name</strong> – \[DEPRECATED–please specify the containing schema for the projection as part of input parameter <span className="em">projection\_name</span> and use <a className="reference internal" href="#gpudb.GPUdb.create_schema" title="gpudb.GPUdb.create_schema"><code className="xref py py-meth docutils literal notranslate"><span className="pre">GPUdb.create\_schema()</span></code></a> 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 ‘’.</p>
                </li>

                <li>
                  <p><strong>expression</strong> – An optional filter <a className="reference external" href="/content/concepts/expressions/">expression</a> to be applied to the source table prior to the projection. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>is\_replicated</strong> – If <span className="em">true</span> then the projection will be replicated even if the source table is not. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>offset</strong> – The number of initial results to skip (this can be useful for paging through the results). The default value is ‘0’.</p>
                </li>

                <li>
                  <p><strong>limit</strong> – The number of records to keep. The default value is ‘-9999’.</p>
                </li>

                <li>
                  <p><strong>order\_by</strong> – 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 <span className="em">column\_names</span>. If any alias is given for any column name, the alias must be used, rather than the original column name. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>chunk\_size</strong> – Indicates the number of records per chunk to be used for this projection.</p>
                </li>

                <li>
                  <p><strong>chunk\_column\_max\_memory</strong> – Indicates the target maximum data size for each column in a chunk to be used for this projection.</p>
                </li>

                <li>
                  <p><strong>chunk\_max\_memory</strong> – Indicates the target maximum data size for all columns in a chunk to be used for this projection.</p>
                </li>

                <li>
                  <p><strong>create\_indexes</strong> – Comma-separated list of columns on which to create indexes on the projection. The columns specified must be present in input parameter <span className="em">column\_names</span>. If any alias is given for any column name, the alias must be used, rather than the original column name.</p>
                </li>

                <li>
                  <p><strong>ttl</strong> – Sets the <a className="reference external" href="/content/concepts/ttl/">TTL</a> of the projection specified in input parameter <span className="em">projection\_name</span>.</p>
                </li>

                <li>
                  <p><strong>shard\_key</strong> – Comma-separated list of the columns to be sharded on; e.g. ‘column1, column2’. The columns specified must be present in input parameter <span className="em">column\_names</span>. If any alias is given for any column name, the alias must be used, rather than the original column name. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>persist</strong> – If <span className="em">true</span>, then the projection specified in input parameter <span className="em">projection\_name</span> will be persisted and will not expire unless a <span className="em">ttl</span> is specified. If <span className="em">false</span>, then the projection will be an in-memory table and will expire unless a <span className="em">ttl</span> is specified otherwise. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>preserve\_dict\_encoding</strong> – If <span className="em">true</span>, then columns that were dict encoded in the source table will be dict encoded in the projection. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘true’.</p>
                </li>

                <li>
                  <p><strong>retain\_partitions</strong> – Determines whether the created projection will retain the partitioning scheme from the source table. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>partition\_type</strong> – <a className="reference external" href="/content/concepts/tables/#partitioning">Partitioning</a> scheme to use. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p><strong>RANGE</strong> – Use <a className="reference external" href="/content/concepts/tables/#partitioning-by-range">range partitioning</a>.</p>
                    </li>

                    <li>
                      <p><strong>INTERVAL</strong> – Use <a className="reference external" href="/content/concepts/tables/#partitioning-by-interval">interval partitioning</a>.</p>
                    </li>

                    <li>
                      <p><strong>LIST</strong> – Use <a className="reference external" href="/content/concepts/tables/#partitioning-by-list">list partitioning</a>.</p>
                    </li>

                    <li>
                      <p><strong>HASH</strong> – Use <a className="reference external" href="/content/concepts/tables/#partitioning-by-hash">hash partitioning</a>.</p>
                    </li>

                    <li>
                      <p><strong>SERIES</strong> – Use <a className="reference external" href="/content/concepts/tables/#partitioning-by-series">series partitioning</a>.</p>
                    </li>
                  </ul>
                </li>

                <li>
                  <p><strong>partition\_keys</strong> – Comma-separated list of partition keys, which are the columns or column expressions by which records will be assigned to partitions defined by <span className="em">partition\_definitions</span>.</p>
                </li>

                <li>
                  <p><strong>partition\_definitions</strong> – Comma-separated list of partition definitions, whose format depends on the choice of <span className="em">partition\_type</span>. See <a className="reference external" href="/content/concepts/tables/#partitioning-by-range">range partitioning</a>, <a className="reference external" href="/content/concepts/tables/#partitioning-by-interval">interval partitioning</a>, <a className="reference external" href="/content/concepts/tables/#partitioning-by-list">list partitioning</a>, <a className="reference external" href="/content/concepts/tables/#partitioning-by-hash">hash partitioning</a>, or <a className="reference external" href="/content/concepts/tables/#partitioning-by-series">series partitioning</a> for example formats.</p>
                </li>

                <li>
                  <p><strong>is\_automatic\_partition</strong> – If <span className="em">true</span>, a new partition will be created for values which don’t fall into an existing partition. Currently only supported for <a className="reference external" href="/content/concepts/tables/#partitioning-by-list">list partitions</a>. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>view\_id</strong> – ID of view of which this projection is a member. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>strategy\_definition</strong> – The <a className="reference external" href="/content/rm/concepts/#tier-strategies">tier strategy</a> for the table and its columns.</p>
                </li>

                <li>
                  <p><strong>compression\_codec</strong> – The default <a className="reference external" href="/content/concepts/column_compression/">compression codec</a> for the projection’s columns.</p>
                </li>

                <li>
                  <p><strong>join\_window\_functions</strong> – 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’.</p>
                </li>

                <li>
                  <p><strong>join\_window\_functions\_threshold</strong> – 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 ‘’.</p>
                </li>

                <li>
                  <p><strong>qualify\_filter</strong> – An optional filter <a className="reference external" href="/content/concepts/expressions/">expression</a> 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 ‘’.</p>
                </li>
              </ul>

              <p>The default value is an empty dict ( {"{"}{"}"} ).</p>
            </div>
          </div>
        </div>
      </div>

      <p><strong>Returns</strong></p>

      <div className="blockquote">
        <div>
          <p>A dict with the following entries–</p>

          <div className="dl">
            <div className="dt">projection\_name (<span className="em">str</span>) –</div>

            <div className="dd">
              <p>Value of input parameter <span className="em">projection\_name</span>.</p>
            </div>

            <div className="dt">info (<span className="em">dict of str to str</span>) –</div>

            <div className="dd">
              <p>Additional information. Allowed keys are:</p>

              <ul className="simple">
                <li>
                  <p><strong>count</strong> – Number of records in the final table.</p>
                </li>

                <li>
                  <p><strong>qualified\_projection\_name</strong> – The fully qualified name of the projection (i.e. including the schema).</p>
                </li>
              </ul>

              <p>The default value is an empty dict ( {"{"}{"}"} ).</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
