Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes and clarifications of star page #4070

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _posts/2024-11-14-optimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ layout: post
title: "Optimizers: The Low-Key MVP"
author: Tom Ebergen
tags: ["deep dive"]
thumb: "/images/blog/thumbs/optimizers.svg"
image: "/images/blog/thumbs/optimizers.png"
excerpt: "The query optimizer is an important part of any analytical database system as it provides considerable performance improvements compared to hand-optimized queries, even as the state of your data changes."
---

Expand Down
12 changes: 6 additions & 6 deletions docs/sql/expressions/star.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ FROM tbl;

### `REPLACE` Clause

`REPLACE` allows us to replace specific columns with different expressions.
`REPLACE` allows us to replace specific values in columns as specified by an expression.

```sql
SELECT * REPLACE (col / 1000 AS col)
SELECT * REPLACE (col / 1_000 AS col)
FROM tbl;
```

## `COLUMNS` Expression

The `COLUMNS` expression can be used to execute the same expression on multiple columns. For example:
The `COLUMNS` expression can be used to execute the same expression on the values in multiple columns. For example:

```sql
CREATE TABLE numbers (id INTEGER, number INTEGER);
Expand Down Expand Up @@ -174,7 +174,7 @@ SELECT COLUMNS('(id|numbers?)') FROM numbers;
| 2 | 20 |
| 3 | NULL |

### Renaming Columns using a `COLUMNS` expression
### Renaming Columns Using a `COLUMNS` Expression

The matches of capture groups can be used to rename columns selected by a regular expression.
The capture groups are one-indexed; `\0` is the original column name.
Expand Down Expand Up @@ -202,7 +202,7 @@ SELECT COLUMNS('(\w*):(\w*)') AS '\1\2' FROM tbl;

## `COLUMNS` Lambda Function

`COLUMNS` also supports passing in a lambda function. The lambda function will be evaluated for all columns present in the `FROM` clause, and only columns that match the lambda function will be returned. This allows the execution of arbitrary expressions in order to select columns.
`COLUMNS` also supports passing in a lambda function. The lambda function will be evaluated for all columns present in the `FROM` clause, and only columns that match the lambda function will be returned. This allows the execution of arbitrary expressions in order to select and rename columns.

```sql
SELECT COLUMNS(c -> c LIKE '%num%') FROM numbers;
Expand All @@ -211,7 +211,7 @@ SELECT COLUMNS(c -> c LIKE '%num%') FROM numbers;
<div class="narrow_table"></div>

| number |
|--------|
|-------:|
| 10 |
| 20 |
| NULL |
Expand Down
Binary file added images/blog/thumbs/optimizers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions images/blog/thumbs/optimizers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.