Column Aliases
Use column aliases to define multiple names for the same column in a Hydrolix table. Aliases can be used interchangeably in queries as alternate names for columns.
Feature availability
Column aliases are available as of Hydrolix v5.1.
Column alias overview⚓︎
- Column aliases are stored in the
aliasesarray in the table schema. - Aliases show up as the
ALIAStype inDESCRIBE TABLEoutput. - The
default_expressionoutput points to the actual column.
Advantages of column aliases⚓︎
- Columns can be renamed without downtime or breaking existing queries, dashboards, or applications that reference them.
- Retain support for legacy applications when transitioning to a new naming convention.
- Support multi-tenant and multi-team naming conventions without duplicating data.
- Use multiple API versions simultaneously without data duplication or transforms.
- Enable integration between systems without transformation overhead.
Use cases⚓︎
See examples of ways to use column aliasing.
Rename columns with aliases⚓︎
Column aliases are managed through the config API. Rename columns using the Hydrolix UI or the API's /add_name endpoint.
Rename a column in the UI⚓︎
- Navigate to your table in the Hydrolix UI.
- Click the Schema tab.
- Locate the column you want to rename.
- In the Aliases field, add the new column name.
- Click Save.
The column can now be queried using either the original name or the new alias.
Rename a column with the API⚓︎
Use the /add_name endpoint to add an alias to an existing column. This adds the new name to the column's aliases array while preserving the original name.
Required path parameters
The /add_name endpoint requires the following path parameters:
org_id,project_id,table_id: Get these from your table configuration or by listing organization resources.column_id: Get the column ID by callingGET /config/v1/orgs/{org_id}/projects/{project_id}/tables/{table_id}/columns/. Each column in the response includes anidfield.
Add an alias to a column⚓︎
This example adds customer_id as an alias for the column user_id.
Both user_id and customer_id are now valid names for querying this column.
Rename a column multiple times⚓︎
You can call the /add_name endpoint multiple times to track rename history. Each call adds another alias to the array.
After these calls, all three names (user_id, customer_id, account_id) remain queryable.
Verify aliases with DESCRIBE TABLE⚓︎
After renaming a column, use DESCRIBE TABLE to verify the aliases are configured correctly.
Example output:
| name | type | default_type | default_expression |
|---|---|---|---|
| user_id | UInt64 | ||
| customer_id | UInt64 | ALIAS | user_id |
| account_id | UInt64 | ALIAS | user_id |
The ALIAS type indicates these are column aliases, and the default_expression shows which actual column they reference.
Where to use aliases⚓︎
Column aliases work with most SQL operations:
- Query clauses: Use aliases in
SELECT,WHERE,JOIN, andGROUP BYclauses - ClickHouse functions: All ClickHouse functions work with aliased column names
- Dictionary lookups: Dictionary functions like
dictGet()work with aliases - Summary tables: Existing summary tables continue working after renaming columns in the parent table
- Aggregate functions: Functions like
SUM(),COUNT(),AVG()work with any alias
Considerations and limitations⚓︎
Some SQL operations aren't supported with aliases.
ALTER operations⚓︎
ALTER TABLE operations like UPDATE and DELETE only work with the actual column name, not the alias.
SELECT * queries⚓︎
SELECT * returns only the actual column names, not aliases. To include aliases in query results, explicitly name them in the SELECT clause.
Output shows user_id but not customer_id:
| user_id | order_total | order_date |
|---|---|---|
| 12345 | 99.99 | 2024-01-15 |
Subqueries and CTEs⚓︎
Subqueries and Common Table Expressions (CTEs) don't preserve aliases. Aliases aren't available in the outer query unless specifically selected.
Subquery examples⚓︎
Common Table Expression examples⚓︎
Column name uniqueness⚓︎
Multiple columns can't be renamed to the same name. The API validates and prevents duplicate column names within a table.