Skip to content

Commit 93eb074

Browse files
authored
chore: update sql docs (#319)
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
1 parent 98de88a commit 93eb074

36 files changed

+235
-164
lines changed

sdf/cli/deploy.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ Where:
9090
9191
#### SQL mode
9292
93-
Use the SQL mode in the CLI, to be able to run SQL queries on SDF states. See more details in [sql mode for sdf run]
93+
Please see the section of [sql mode].
9494
9595
### Managing dataflow in interactive shell
9696
9797
Please see the [deployment] section for more details.
9898
99-
[deployment]: /sdf/deployment
100-
[sql mode for sdf run]: /sdf/cli/run.mdx#sql-mode
99+
[deployment]: ../deployment.mdx
100+
[sql mode]: ./run_sql.mdx

sdf/cli/run.mdx

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -128,55 +128,7 @@ Show the detailed information:
128128

129129
#### SQL mode
130130

131-
Use the SQL mode in the CLI, to be able to run SQL queries on SDF states. For a given dataflow, we will have in context for SQL all the dataframe states, which are basically the states with an `arrow-row` value.
131+
Please see the section of [sql mode].
132132

133-
For states that are scoped to a window, we will have access to the last flush state. For states that are not window aware we will have access to the global state.
134133

135-
In order to enter the SQL mode, type `sql` in the SDF interactive shell. In the SQL mode we could perform any sql command supported by the polars engine.
136-
137-
#### Examples:
138-
139-
##### Run command
140-
141-
Navigate to the directory with `dataflow.yaml` file, and run the command:
142-
143-
```bash
144-
$ sdf run
145-
```
146-
147-
##### Enter the SQL mode
148-
149-
Using the sql command:
150-
151-
```bash
152-
>> sql
153-
SDF SQL version sdf-beta5
154-
Type .help for help.
155-
```
156-
157-
#### Show tables in context
158-
```bash
159-
sql>> show tables
160-
shape: (1, 1)
161-
┌────────────────┐
162-
│ name │
163-
│ --- │
164-
│ str │
165-
╞════════════════╡
166-
│ count_per_word │
167-
└────────────────┘
168-
```
169-
170-
#### Perform a query
171-
172-
```bash
173-
sql>> select * from count_per_word;
174-
shape: (0, 2)
175-
┌──────┬─────────────┐
176-
│ _key ┆ occurrences │
177-
│ --- ┆ --- │
178-
│ str ┆ u32 │
179-
╞══════╪═════════════╡
180-
│ abc │ 10 |
181-
└──────┴─────────────┘
182-
```
134+
[sql mode]: ./run_sql.mdx

sdf/cli/run_sql.mdx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
description: SDF SQL subcommand
3+
title: sdf run sql
4+
sidebar_position: 55
5+
---
6+
7+
# `sdf run sql`
8+
9+
Use the SQL mode in the CLI, to be able to run SQL queries on SDF states. For a given dataflow, we will have in context for SQL all the [dataframe states], which are essentially the states with an `arrow-row` value.
10+
11+
For states that are scoped to a window, we will have access to the last flushed state. For states that are not window aware we will have access to the global state.
12+
13+
In order to enter the SQL mode, type `sql` in the SDF interactive shell created through `sdf run` or `sdf deploy`. In the SQL mode we could perform any sql command supported by the polars engine.
14+
15+
We can use the `.help` command to see the available options.
16+
17+
```
18+
sql >> .help
19+
shape: (3, 2)
20+
┌─────────┬─────────────────────────────────┐
21+
│ command ┆ description │
22+
│ --- ┆ --- │
23+
│ str ┆ str │
24+
╞═════════╪═════════════════════════════════╡
25+
│ .exit ┆ Exit this program │
26+
│ .quit ┆ Exit this program │
27+
│ .help ┆ Display this help. │
28+
└─────────┴─────────────────────────────────┘
29+
```
30+
31+
#### Examples:
32+
33+
##### Run command
34+
35+
Navigate to the directory with `dataflow.yaml` file, and run the command:
36+
37+
```bash
38+
$ sdf run
39+
```
40+
41+
##### Enter the SQL mode
42+
43+
Using the sql command:
44+
45+
```bash
46+
>> sql
47+
SDF SQL version sdf-beta5
48+
Type .help for help.
49+
```
50+
51+
#### Show tables in context
52+
```bash
53+
sql >> show tables
54+
shape: (1, 1)
55+
┌────────────────┐
56+
│ name │
57+
│ --- │
58+
│ str │
59+
╞════════════════╡
60+
│ count_per_word │
61+
└────────────────┘
62+
```
63+
64+
#### Perform a query
65+
66+
```bash
67+
sql >> select * from count_per_word;
68+
shape: (0, 2)
69+
┌──────┬─────────────┐
70+
│ _key ┆ occurrences │
71+
│ --- ┆ --- │
72+
│ str ┆ u32 │
73+
╞══════╪═════════════╡
74+
│ abc │ 10 |
75+
└──────┴─────────────┘
76+
```
77+
78+
#### Exit the SQL mode
79+
80+
```bash
81+
sql >> .exit
82+
```
83+
84+
[dataframe states]: ../concepts/sql.mdx#dataframe-states

sdf/cli/test.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: SDF Test Command
3-
sidebar_position: 50
3+
sidebar_position: 98
44
---
55

66
# `sdf test`

sdf/concepts/schema_validation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Schema Validation
33
description: Schema Validation
4-
sidebar_position: 60
4+
sidebar_position: 45
55
---
66

77
import CodeBlock from '@theme/CodeBlock';

sdf/concepts/state-dataframe.mdx renamed to sdf/concepts/sql.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
2-
title: State - Arrow Dataframe
3-
description: Stateful Dataflows Dataframe Integration
2+
title: SQL Interface
3+
description: Stateful Dataflows Dataframe SQL Integration
44
sidebar_position: 60
55
---
66

7+
## Dataframe states
8+
79
States are a key concept in SDF. They hold a simple value or they can be divided into multiple partitions based on a key. Each partition state can have many different types.
810

911
One of the type is `arrow-row`. For example, follow snippet define state `count_per_word` that store each row into arrow dataframe.
@@ -22,8 +24,7 @@ One of the type is `arrow-row`. For example, follow snippet define state `count
2224
type: u32
2325
```
2426
25-
26-
In here, we are defining a state `count_per_word` to track frequency of the words. For each key, we have a row that has a column `count` that store the count of the word.
27+
An `arrow-row` state can be seen as an SQL table. In the previous example, we are defining a state `count_per_word` to track frequency of the words. For each key, we have a row that has a column `count` that store the count of the word.
2728
For example, let's we have following word: `apple`, `orange`, `banana`, `orange`, `grape`, `orange`, `banana`.
2829

2930
Then this will be mapped to arrow dataframe as follows:
@@ -52,9 +53,9 @@ update-state:
5253

5354
Note that state value can be access using `count_per_word` state function which is automatically injected by SDF builder.
5455

55-
This API is invoked by the `update-state` operator, which only returns the value of the partition state.
56+
This API is invoked by the `update-state` operator, which only is able to update the value of the partition state.
5657

57-
In the example, `count_per_word` represents a row value of the dataframe. If operator sees `apple`, it will be first row in the dataframe above.
58+
In the example, `count_per_word` represents a row value of the dataframe. If operator sees `apple`, it will be the first row in the dataframe above.
5859

5960
## SQL function
6061

@@ -83,16 +84,15 @@ flush:
8384
}
8485
```
8586

86-
The output of the `sql` function implements also the following methods that will be described above: sql, rows, col, key, next
87+
The output of the `sql` function implements also the following methods that will be described below: sql, rows, col, key, next
8788

8889
## SQL API
8990

90-
For any state that is dataframe, you can use SQL API to perform dataframe operation. SDF uses polar SQL to perform dataframe operation.
91-
The result of the SQL operation is always dataframe. So you can perform multiple SQL operation to get the desired result.
91+
For any state that is dataframe, you can use SQL API to perform dataframe operation. SDF uses polars SQL to perform dataframe operations.
92+
The result of a SQL operation is always a dataframe. So you can perform multiple SQL operation to get the desired result.
9293

9394
The SQL is executed in the context of all the available dataframes, so you can perform any JOIN or complex SQL operations with them. Each dataframe is represented as a table, and each table name is their state name replacing hyphens(-) with underscores(_) as illustrated below.
9495

95-
9696
```rust
9797
let top3 = sql("select * from count_per_word order by count desc limit 3")?;
9898
```

sdf/concepts/state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ State can be defined in a package [sdf-package.yaml] file. The approach allows y
167167
We'll use an example to show how to implement, test, and import a state from a package file.
168168

169169
[types]: types.mdx
170-
[arrow dataframe]: state-dataframe.mdx
170+
[arrow dataframe]: sql.mdx#dataframe-states
171171
[sdf-package.yaml]: sdf/composition/sdf-package-yaml.mdx
172172
[dataflow.yaml]: sdf/index.mdx
173173
[window processing]: sdf/concepts/window-processing.mdx

sdf/how-to/key_value-chained.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ This how-to focused on using key-values as output as well as the input. The foll
161161

162162

163163
[installation]: /docs/fluvio/quickstart#install-fluvio
164-
[arrow]: /sdf/concepts/state-dataframe
164+
[arrow]: ../concepts/sql.mdx#dataframe-states
165165
[key_value_chain]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/chained

sdf/how-to/key_value-input.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ This how-to focused on using key-values as inputs. The following pages contains
150150

151151

152152
[installation]: /docs/fluvio/quickstart#install-fluvio
153-
[arrow]: /sdf/concepts/state-dataframe
153+
[arrow]: ../concepts/sql.mdx#dataframe-states
154154
[key_value_input]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/input

sdf/how-to/key_value-output.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ This how-to focused on using key-values as out. The following pages contains ano
134134

135135

136136
[installation]: /docs/fluvio/quickstart#install-fluvio
137-
[arrow]: /sdf/concepts/state-dataframe
137+
[arrow]: ../concepts/sql.mdx#dataframe-states
138138
[key_value_output]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/output

sdf/how-to/state_example_arrow_row.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ partition:
7171

7272
States are terminal so no other action will be run.
7373

74-
### Iterface
74+
### Interface
7575
The second service serves as a way to read from the state.
7676

7777
```YAML
@@ -172,5 +172,5 @@ We just implement example using arrow states. The following link contains anothe
172172

173173

174174
[installation]: /docs/fluvio/quickstart#install-fluvio
175-
[arrow]: /sdf/concepts/state-dataframe
175+
[arrow]: ../concepts/sql.mdx#dataframe-states
176176
[github_arrow_1]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/update-state

sdf/whatsnew.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For upgrading cloud workers, please contact [InfinyOn support](#infinyon-support
3030

3131
### CLI changes
3232

33-
- `sdf run` not longer accepts `--dev`. Develoment mode is now the default for `sdf run`. If you want to run in non-development mode use `--prod`.
33+
- `sdf run` not longer accepts `--dev`. Development mode is now the default for `sdf run`. If you want to run in non-development mode use `--prod`.
3434

3535
### Improvements
3636

@@ -46,5 +46,5 @@ For upgrading cloud workers, please contact [InfinyOn support](#infinyon-support
4646
For any questions or issues, please contact InfinyOn support at support@infinyon.com or https://discordapp.com/invite/bBG2dTz
4747

4848
[sql mode]: cli/run.mdx#sql-mode
49-
[sql function]: concepts/state-dataframe.mdx#sql-function
50-
[dataframe states]: concepts/state-dataframe.mdx
49+
[sql function]: concepts/sql.mdx#sql-function
50+
[dataframe states]: concepts/sql.mdx#dataframe-states

sdf_versioned_docs/version-sdf-beta2/how-to/key_value-chained.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ This how-to focused on using key-values as output as well as the input. The foll
161161

162162

163163
[installation]: /docs/fluvio/quickstart#install-fluvio
164-
[arrow]: /sdf/concepts/state-dataframe
164+
[arrow]: ../concepts/state-dataframe.mdx
165165
[key_value_chain]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/chained

sdf_versioned_docs/version-sdf-beta2/how-to/key_value-input.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ This how-to focused on using key-values as inputs. The following pages contains
150150

151151

152152
[installation]: /docs/fluvio/quickstart#install-fluvio
153-
[arrow]: /sdf/concepts/state-dataframe
153+
[arrow]: ../concepts/state-dataframe.mdx
154154
[key_value_input]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/input

sdf_versioned_docs/version-sdf-beta2/how-to/key_value-output.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ This how-to focused on using key-values as out. The following pages contains ano
134134

135135

136136
[installation]: /docs/fluvio/quickstart#install-fluvio
137-
[arrow]: /sdf/concepts/state-dataframe
137+
[arrow]: ../concepts/state-dataframe.mdx
138138
[key_value_output]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/output

sdf_versioned_docs/version-sdf-beta2/how-to/state_example_arrow_row.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ partition:
7171

7272
States are terminal so no other action will be run.
7373

74-
### Iterface
74+
### Interface
7575
The second service serves as a way to read from the state.
7676

7777
```YAML
@@ -172,5 +172,5 @@ We just implement example using arrow states. The following link contains anothe
172172

173173

174174
[installation]: /docs/fluvio/quickstart#install-fluvio
175-
[arrow]: /sdf/concepts/state-dataframe
175+
[arrow]: ../concepts/state-dataframe.mdx
176176
[github_arrow_1]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/update-state

sdf_versioned_docs/version-sdf-beta3/how-to/key_value-chained.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ This how-to focused on using key-values as output as well as the input. The foll
161161

162162

163163
[installation]: /docs/fluvio/quickstart#install-fluvio
164-
[arrow]: /sdf/concepts/state-dataframe
164+
[arrow]: ../concepts/state-dataframe.mdx
165165
[key_value_chain]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/chained

sdf_versioned_docs/version-sdf-beta3/how-to/key_value-input.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ This how-to focused on using key-values as inputs. The following pages contains
150150

151151

152152
[installation]: /docs/fluvio/quickstart#install-fluvio
153-
[arrow]: /sdf/concepts/state-dataframe
153+
[arrow]: ../concepts/state-dataframe.mdx
154154
[key_value_input]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/input

sdf_versioned_docs/version-sdf-beta3/how-to/key_value-output.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ This how-to focused on using key-values as out. The following pages contains ano
134134

135135

136136
[installation]: /docs/fluvio/quickstart#install-fluvio
137-
[arrow]: /sdf/concepts/state-dataframe
137+
[arrow]: ../concepts/state-dataframe.mdx
138138
[key_value_output]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/output

sdf_versioned_docs/version-sdf-beta3/how-to/state_example_arrow_row.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ partition:
7171

7272
States are terminal so no other action will be run.
7373

74-
### Iterface
74+
### Interface
7575
The second service serves as a way to read from the state.
7676

7777
```YAML
@@ -172,5 +172,5 @@ We just implement example using arrow states. The following link contains anothe
172172

173173

174174
[installation]: /docs/fluvio/quickstart#install-fluvio
175-
[arrow]: /sdf/concepts/state-dataframe
175+
[arrow]: ../concepts/state-dataframe.mdx
176176
[github_arrow_1]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/update-state

sdf_versioned_docs/version-sdf-beta4/how-to/key_value-chained.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ This how-to focused on using key-values as output as well as the input. The foll
161161

162162

163163
[installation]: /docs/fluvio/quickstart#install-fluvio
164-
[arrow]: /sdf/concepts/state-dataframe
164+
[arrow]: ../concepts/state-dataframe.mdx
165165
[key_value_chain]: https://github.com/infinyon/stateful-dataflows-examples/tree/main/primitives/key-value/chained

0 commit comments

Comments
 (0)