- do not appear in
SELECT *, - do not appear in
DESCRIBE <table>orSHOW CREATE TABLE <table>, - must be referenced explicitly by name.
Available virtual columns
Column names are case-insensitive:
_tablet_id_ and _TABLET_ID_ refer to the same virtual column.
Together, _tablet_id_, _rowset_id_ (or _rss_id_), _segment_id_, and _row_id_ identify the physical position of a row at the moment it is read.
Usage
Virtual columns are available on native tables in the internal catalog (Duplicate Key, Aggregate, Unique Key, and Primary Key tables) and on materialized views. Tables in external catalogs do not expose virtual columns. You can reference a virtual column anywhere an ordinary column is allowed in a query: in theSELECT list, WHERE, GROUP BY, ORDER BY, aggregate functions, and joins. When a query involves multiple tables, qualify the column with the table name or alias, for example t._tablet_id_.
The following examples use this table:
Query a virtual column
SELECT *:
Analyze data distribution across tablets
Group by_tablet_id_ to see how many rows each tablet holds. This is a quick way to detect data skew caused by an unbalanced bucketing key.
Locate the physical position of a row
Filter on a virtual column
Usage notes
- Virtual columns describe physical storage, not business data. Their values can change when the underlying data is reorganized — for example by compaction, by a new load, by a schema change, or by replica migration. Do not store them as business keys, and do not rely on them to correlate rows across queries.
- Virtual columns are query-only. They cannot be loaded into, updated, or declared in
CREATE TABLE. - The database does not collect column statistics for virtual columns.
- The names of virtual columns are reserved. By default, you cannot create a table column with any of these names, because a table column of the same name shadows the virtual column and makes both impossible to reference in a query. If you need such a column name, set the FE dynamic parameter
allow_system_reserved_namestoTRUE. See CREATE TABLE for details.
Enable or disable virtual columns
Virtual columns are controlled by the FE dynamic parameterenable_virtual_columns, which defaults to true.
To disable them for the whole cluster:
Column '_tablet_id_' cannot be resolved.