CREATE PROJECTION (Live Aggregate Projections)

Creates metadata for live aggregate projections in the Vertica catalog. Top-K projections are a type of live aggregate projection.

Information here focuses on creating live aggregate projections. For details about creating other types of projections, including projections with expressions, see CREATE PROJECTION.

Syntax

Parameters

IF NOT EXISTS

Specifies to generate an informational message if an object already exists under the specified name. If you omit this option and the object exists, Vertica generates a ROLLBACK error message. In both cases, the object is not created.

The IF NOT EXISTS clause is useful for SQL scripts where you want to create an object if it does not already exist, and reuse the existing object if it does.

For related information, see ON_ERROR_STOP.

projection‑name

The name of the projection to create, where projection‑name conforms to conventions described in Identifiers. Vertica creates the projection in the same schema as the anchor table.

projection‑col

The name of a projection column.

If you do not specify projection column names, Vertica uses the anchor table column names in the SELECT statement.

grouped‑clause

See GROUPED Clause.

ENCODING encoding‑type

Specifies the column encoding type, by default set to AUTO.

ACCESSRANK integer

Overrides the default access rank for a column. Use this parameter to increase or decrease the speed at which Vertica accesses a column. For more information, see Overriding Default Column Ranking.

table‑col
expr‑with‑table‑cols
A table column or expression of table columns to be included in the projection. If you specify projection column names, the two lists of projection columns and table columns/expressions must exactly match in number and order.
table‑reference

A schema table with the columns to include in the projection, as follows:

table-name [ AS ] alias [ ( column-alias [,...] ) ] 
GROUP BY column‑expr[,...]

One or more column expressions from the SELECT list. The first column-expr must be the first column expression in the SELECT list, the second column-expr must be the second column expression in the SELECT list, and so on.

LIMIT num‑rows The number of rows to return from the specified partition.
OVER (PARTITION BY column‑expr [,...] Specifies window partitioning by one or more column expressions from the SELECT list. The first column-expr is the first column expression in the SELECT list, the second column-expr is the second column expression in the SELECT list, and so on.
ORDER BY column-expr [,...] [ASC | DESC]

The order in which the top k rows are returned, by default in ascending (ASC) order. All column expressions must be from the SELECT list, where the first column-expr must be the first column expression in the SELECT list to follow the last PARTITION BY column expression.

Top-K projections support ORDER BY NULLS FIRST/LAST.

KSAFE [ k‑num ]

Specifies K-safety for the projection, where k-num must be equal to or greater than system K-safety. Vertica ignores this parameter if set for unsegmented projections. If you omit k-num, Vertica uses system K-safety.

Vertica sets projection K-safety as follows:

  • KSAFE and OFFSET clause omitted: Uses system K-safety.
  • OFFSET clause is omitted and KSAFE is specified: Uses KSAFE setting.
  • KSAFE is omitted and the OFFSET clause is specified: Uses OFFSET setting.

If the CREATE PROJECTION statement specifies KSAFE and the OFFSET clause, Vertica returns an error.

For general information, see K-Safety in Vertica Concepts.

Privileges

See Projection Privileges

Requirements and Restrictions

See:

Examples

See: