Skip to content

Commit

Permalink
chore: Backport #3295 to web (#3298)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
  • Loading branch information
prql-bot and max-sixty committed Aug 9, 2023
1 parent 66fba61 commit 02a4a3b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
29 changes: 16 additions & 13 deletions web/book/src/reference/stdlib/transforms/from.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@

Specifies a data source.

```prql no-eval
from table_reference
```prql
from artists
```

Table names containing schemas, keywords, or special characters
[need to be contained within backticks](../../syntax/keywords.md#quoting).
`default_db.tablename` can be used if the table name matches a function from the
standard library.
To introduce an alias, use an assign expression:

```prql
default_db.group
take 1
from e = employees
select e.first_name
```

## Examples
Table names containing spaces or special characters
[need to be contained within backticks](../../syntax/keywords.md#quoting):

```prql
from employees
from `artist tracks`
```

To introduce an alias, use an assign expression:
`default_db.tablename` can be used if the table name matches a function from the
standard library.

```admonish note
We realize this is an awkward workaround. Track & 👍 [#3271](https://github.com/PRQL/prql/issues/3271) for resolving this.
```

```prql
from e = employees
select e.first_name
default_db.group # in place of `from group`
take 1
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
---
source: web/book/tests/documentation/book.rs
expression: "default_db.group\ntake 1\n"
expression: "from artists\n"
---
SELECT
*
FROM
"group"
LIMIT
1
artists

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: web/book/tests/documentation/book.rs
expression: "from e = employees\nselect e.first_name\n"
---
SELECT
first_name
FROM
employees AS e

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: web/book/tests/documentation/book.rs
expression: "from `artist tracks`\n"
---
SELECT
*
FROM
"artist tracks"

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: web/book/tests/documentation/book.rs
expression: "default_db.group # in place of `from group`\ntake 1\n"
---
SELECT
*
FROM
"group"
LIMIT
1

0 comments on commit 02a4a3b

Please sign in to comment.