Skip to content

Commit 5d457fe

Browse files
committed
Document branching syntax
1 parent 2fb0bbe commit 5d457fe

12 files changed

Lines changed: 185 additions & 7 deletions

File tree

docs/src/main/sphinx/sql.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Refer to the following sections for further details:
1111
```{toctree}
1212
:maxdepth: 1
1313
14+
sql/alter-branch
1415
sql/alter-materialized-view
1516
sql/alter-schema
1617
sql/alter-table
@@ -19,6 +20,7 @@ sql/analyze
1920
sql/call
2021
sql/comment
2122
sql/commit
23+
sql/create-branch
2224
sql/create-catalog
2325
sql/create-function
2426
sql/create-materialized-view
@@ -33,6 +35,7 @@ sql/deny
3335
sql/describe
3436
sql/describe-input
3537
sql/describe-output
38+
sql/drop-branch
3639
sql/drop-catalog
3740
sql/drop-function
3841
sql/drop-materialized-view
@@ -62,6 +65,7 @@ sql/set-role
6265
sql/set-session
6366
sql/set-session-authorization
6467
sql/set-time-zone
68+
sql/show-branches
6569
sql/show-catalogs
6670
sql/show-columns
6771
sql/show-create-function
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ALTER BRANCH
2+
3+
## Synopsis
4+
5+
```text
6+
ALTER BRANCH source_branch IN TABLE table_name FAST FORWARD TO target_branch
7+
```
8+
9+
## Description
10+
11+
Fast-forward the current snapshot of one branch to the latest snapshot of
12+
another.
13+
14+
## Examples
15+
16+
Fast-forward the `main` branch to the head of `audit` branch in the `orders`
17+
table:
18+
19+
```sql
20+
ALTER BRANCH main IN TABLE orders FAST FORWARD TO audit
21+
```
22+
23+
## See also
24+
25+
- {doc}`create-branch`
26+
- {doc}`drop-branch`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# CREATE BRANCH
2+
3+
## Synopsis
4+
5+
```text
6+
CREATE BRANCH [ OR REPLACE ] [ IF NOT EXISTS ] branch_name
7+
[ WITH ( property_name = expression [, ...] ) ]
8+
IN TABLE table_name
9+
[ FROM source_branch ]
10+
```
11+
12+
## Description
13+
14+
Create a branch.
15+
16+
The optional `OR REPLACE` clause causes an existing branch with the
17+
specified name to be replaced with the new branch definition. Support
18+
for branch replacement varies across connectors. Refer to the
19+
connector documentation for details.
20+
21+
The optional `IF NOT EXISTS` clause causes the error to be
22+
suppressed if the branch already exists.
23+
24+
The optional `WITH` clause can be used to set properties
25+
on the newly created schema. To list all available schema
26+
properties, run the following query:
27+
28+
The optional `FROM` clause can be used to set the source branch from which the
29+
new branch is created.
30+
31+
## Examples
32+
33+
Create a new branch `audit` in the table `orders`:
34+
35+
```sql
36+
CREATE BRANCH audit IN TABLE orders
37+
```
38+
39+
Create a new branch `audit` in the table `orders` from the branch `dev`:
40+
41+
```sql
42+
CREATE BRANCH audit IN TABLE orders FROM dev
43+
```
44+
45+
## See also
46+
47+
{doc}`drop-branch`

docs/src/main/sphinx/sql/delete.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Synopsis
44

55
```text
6-
DELETE FROM table_name [ WHERE condition ]
6+
DELETE FROM table_name [ @ branch_name ] [ WHERE condition ]
77
```
88

99
## Description
@@ -32,6 +32,12 @@ Delete all orders:
3232
DELETE FROM orders;
3333
```
3434

35+
Delete all orders in the `audit` branch:
36+
37+
```sql
38+
DELETE FROM orders @ audit;
39+
```
40+
3541
## Limitations
3642

3743
Some connectors have limited or no support for `DELETE`.

docs/src/main/sphinx/sql/deny.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
```text
66
DENY ( privilege [, ...] | ( ALL PRIVILEGES ) )
7-
ON ( table_name | TABLE table_name | SCHEMA schema_name)
7+
ON [ BRANCH branch_name IN ] ( table_name | TABLE table_name | SCHEMA schema_name)
88
TO ( user | USER user | ROLE role )
99
```
1010

@@ -39,6 +39,12 @@ Deny `SELECT` privilege on the table `orders` to everyone:
3939
DENY SELECT ON orders TO ROLE PUBLIC;
4040
```
4141

42+
Deny `INSERT` privilege on the `audit` branch of the `orders` table:
43+
44+
```sql
45+
DENY INSERT ON BRANCH audit IN orders TO alice;
46+
```
47+
4248
## Limitations
4349

4450
The system access controls as well as the connectors provided by default
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# DROP BRANCH
2+
3+
## Synopsis
4+
5+
```text
6+
DROP BRANCH [ IF EXISTS ] branch_name
7+
IN TABLE table_name
8+
```
9+
10+
## Description
11+
12+
Drops an existing branch.
13+
14+
The optional `IF EXISTS` clause causes the error to be suppressed if the branch
15+
does not exist.
16+
17+
## Examples
18+
19+
Drop the branch `audit` in the table `orders`:
20+
21+
```sql
22+
DROP BRANCH audit
23+
IN TABLE orders
24+
```
25+
26+
## See also
27+
28+
{doc}`create-branch`

docs/src/main/sphinx/sql/grant.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
```text
66
GRANT ( privilege [, ...] | ( ALL PRIVILEGES ) )
7-
ON ( table_name | TABLE table_name | SCHEMA schema_name)
7+
ON [ BRANCH branch_name IN ] ( table_name | TABLE table_name | SCHEMA schema_name)
88
TO ( user | USER user | ROLE role )
99
[ WITH GRANT OPTION ]
1010
```
@@ -51,6 +51,13 @@ Grant `SELECT` privilege on the table `orders` to everyone:
5151
GRANT SELECT ON orders TO ROLE PUBLIC;
5252
```
5353

54+
Grant `INSERT` privileges on the `audit` branch of the `orders` table to user
55+
`alice`:
56+
57+
```sql
58+
GRANT INSERT ON BRANCH audit IN orders TO alice;
59+
```
60+
5461
## Limitations
5562

5663
Some connectors have no support for `GRANT`.

docs/src/main/sphinx/sql/insert.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Synopsis
44

55
```text
6-
INSERT INTO table_name [ ( column [, ... ] ) ] query
6+
INSERT INTO table_name [ @ branch_name ] [ ( column [, ... ] ) ] query
77
```
88

99
## Description
@@ -52,6 +52,12 @@ INSERT INTO nation (nationkey, name, regionkey)
5252
VALUES (26, 'POLAND', 3);
5353
```
5454

55+
Insert a single row into `audit` branch of the `cities` table:
56+
57+
```sql
58+
INSERT INTO cities @ audit VALUES (1, 'San Francisco');
59+
```
60+
5561
## See also
5662

5763
{doc}`values`

docs/src/main/sphinx/sql/merge.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Synopsis
44

55
```text
6-
MERGE INTO target_table [ [ AS ] target_alias ]
6+
MERGE INTO target_table [ @ branch_name ] [ [ AS ] target_alias ]
77
USING { source_table | query } [ [ AS ] source_alias ]
88
ON search_condition
99
when_clause [...]
@@ -98,6 +98,15 @@ MERGE INTO accounts t USING monthly_accounts_update s
9898
VALUES(s.customer, s.purchases, s.address)
9999
```
100100

101+
Delete all customers mentioned in `audit` branch of the source table:
102+
103+
```sql
104+
MERGE INTO accounts @ audit t USING monthly_accounts_update s
105+
ON t.customer = s.customer
106+
WHEN MATCHED
107+
THEN DELETE
108+
```
109+
101110
## Limitations
102111

103112
Any connector can be used as a source table for a `MERGE` statement.

docs/src/main/sphinx/sql/revoke.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```text
66
REVOKE [ GRANT OPTION FOR ]
77
( privilege [, ...] | ALL PRIVILEGES )
8-
ON ( table_name | TABLE table_name | SCHEMA schema_name )
8+
ON [ BRANCH branch_name IN ] ( table_name | TABLE table_name | SCHEMA schema_name )
99
FROM ( user | USER user | ROLE role )
1010
```
1111

@@ -52,6 +52,13 @@ Revoke all privileges on the table `test` from user `alice`:
5252
REVOKE ALL PRIVILEGES ON test FROM alice;
5353
```
5454

55+
Revoke `INSERT` privileges on the `audit` branch of the `orders` table from user
56+
`alice`:
57+
58+
```sql
59+
REVOKE INSERT ON BRANCH audit IN orders FROM alice;
60+
```
61+
5562
## Limitations
5663

5764
Some connectors have no support for `REVOKE`.

0 commit comments

Comments
 (0)