

# Star expressions

`*` expands to every column of the `FROM` clause, and `table``.*` expands to every column of one table or table alias. Add modifiers to change the expansion. `EXCLUDE` leaves out the listed columns. `REPLACE` keeps every column but replaces the values of the listed columns with expressions. `RENAME` keeps the values and changes the column names. `LIKE`, `ILIKE`, `GLOB`, and `SIMILAR TO` keep only the columns whose names match a pattern.

`COLUMNS(``selector``)` expands to the columns that the selector chooses. The selector can be a regular expression that the column names must match, a list of column names, a lambda that tests each column name, or a star expression. When you pass `COLUMNS` to a function, the function is applied to each chosen column, and the result has one column for each. In an alias for such an expression, `\0` stands for the name of the original column.

To pass the chosen columns to one function call as separate arguments, write `*COLUMNS(``selector``)`.

## Syntax
<a name="athena-duckdb-statement-select-star-expressions-syntax"></a>

```sql
[ {{table}}. ]* [ EXCLUDE ( {{column}} [, ...] ) ]
    [ REPLACE ( {{expression}} AS {{column}} [, ...] ) ]
    [ RENAME ( {{column}} AS {{new_name}} [, ...] ) ]
* { LIKE | ILIKE | GLOB | SIMILAR TO } '{{pattern}}'
COLUMNS( { '{{regex}}' | [ '{{column}}'
    [, ...] ] | lambda {{c}}: {{condition}}
    | {{star_expression}} } )
*COLUMNS( {{selector}} )
```

## Examples
<a name="athena-duckdb-statement-select-star-expressions-examples"></a>

For a description of the sample tables that the examples on this page use, see [SELECT statement in DuckDB](duckdb-statement-select.md).

The following SQL query returns every column except `customer` and `order_date`.

```sql
SELECT * EXCLUDE (customer, order_date)
FROM sales_db.sales_parquet
WHERE order_id <= 2
ORDER BY order_id
```

The query returns the following results.


| order\_id | region | amount | 
| --- | --- | --- | 
| `1` | `east` | `120.50` | 
| `2` | `west` | `75.00` | 

The following SQL query returns every column, with the `region` values in uppercase.

```sql
SELECT * REPLACE (upper(region) AS region)
FROM sales_db.sales_parquet
WHERE order_id <= 2
ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | region | amount | order\_date | 
| --- | --- | --- | --- | --- | 
| `1` | `alice` | `EAST` | `120.50` | `2026-10-01` | 
| `2` | `bob` | `WEST` | `75.00` | `2026-10-01` | 

The following SQL query returns every column and renames `customer` to `buyer`.

```sql
SELECT * RENAME (customer AS buyer)
FROM sales_db.sales_parquet
WHERE order_id = 1
```

The query returns the following result.


| order\_id | buyer | region | amount | order\_date | 
| --- | --- | --- | --- | --- | 
| `1` | `alice` | `east` | `120.50` | `2026-10-01` | 

The following SQL query returns only the columns whose names start with `order`.

```sql
SELECT * LIKE 'order%'
FROM sales_db.sales_parquet
WHERE order_id = 1
```

The query returns the following result.


| order\_id | order\_date | 
| --- | --- | 
| `1` | `2026-10-01` | 

The following SQL query applies `max` to two columns that a regular expression chooses, and names each result after its column.

```sql
SELECT max(COLUMNS('order_id|amount')) AS 'max_\0'
FROM sales_db.sales_parquet
```

The query returns the following result.


| max\_order\_id | max\_amount | 
| --- | --- | 
| `6` | `310.00` | 

The following SQL query uses a lambda to keep the columns whose names match the pattern `'%_id'`, plus the `amount` column.

```sql
SELECT COLUMNS(lambda c: c LIKE '%_id' OR c = 'amount')
FROM sales_db.sales_parquet
WHERE order_id = 1
```

The query returns the following result.


| order\_id | amount | 
| --- | --- | 
| `1` | `120.50` | 

The following SQL query passes the `customer` and `region` columns to `concat_ws` as separate arguments, so that `concat_ws` joins them with a hyphen.

```sql
SELECT
    concat_ws(
        '-', *COLUMNS(['customer', 'region'])
    ) AS label
FROM sales_db.sales_parquet
WHERE order_id = 1
```

The query returns the following result.


| label | 
| --- | 
| `alice-east` | 

## Considerations
<a name="athena-duckdb-statement-select-star-expressions-considerations"></a>

Write a lambda selector with the `lambda` keyword, as in `COLUMNS(lambda c: c LIKE '%_id')`. DuckDB does not accept the arrow form, `c -> ``condition`.

A column named in `EXCLUDE` or `REPLACE` must exist in the `FROM` clause. `RENAME` ignores a column name that does not exist, so check the names that you rename.