Skip to content

Commit 4b36e33

Browse files
committed
Move expressions to top-level page
1 parent b1765f7 commit 4b36e33

File tree

3 files changed

+207
-185
lines changed

3 files changed

+207
-185
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Table of Contents
4242
user-guide/library
4343
user-guide/cli
4444
user-guide/dataframe
45+
user-guide/expressions
4546
user-guide/sql/index
4647
user-guide/configs
4748
user-guide/faq

docs/source/user-guide/dataframe.md

Lines changed: 5 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ to build up a query definition.
2929

3030
The query can be executed by calling the `collect` method.
3131

32-
The API is well documented in the [API reference on docs.rs](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html)
33-
3432
The DataFrame struct is part of DataFusion's prelude and can be imported with the following statement.
3533

3634
```rust
@@ -49,6 +47,11 @@ let df = df.filter(col("a").lt_eq(col("b")))?
4947
df.show();
5048
```
5149

50+
The DataFrame API is well documented in the [API reference on docs.rs](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html).
51+
52+
Refer to the [Expressions Refence](expressions) for available functions for building logical expressions for use with the
53+
DataFrame API.
54+
5255
## DataFrame Transformations
5356

5457
These methods create a new DataFrame after applying a transformation to the logical plan that the DataFrame represents.
@@ -99,186 +102,3 @@ These methods execute the logical plan represented by the DataFrame and either c
99102
| registry | Return a `FunctionRegistry` used to plan udf's calls. |
100103
| schema | Returns the schema describing the output of this DataFrame in terms of columns returned, where each column has a name, data type, and nullability attribute. |
101104
| to_logical_plan | Return the logical plan represented by this DataFrame. |
102-
103-
# Expressions
104-
105-
DataFrame methods such as `select` and `filter` accept one or more logical expressions and there are many functions
106-
available for creating logical expressions. These are documented below.
107-
108-
Expressions can be chained together using a fluent-style API:
109-
110-
```rust
111-
// create the expression `(a > 5) AND (b < 7)`
112-
col("a").gt(lit(5)).and(col("b").lt(lit(7)))
113-
```
114-
115-
## Identifiers
116-
117-
| Function | Notes |
118-
| -------- | -------------------------------------------- |
119-
| col | Reference a column in a dataframe `col("a")` |
120-
121-
## Literal Values
122-
123-
| Function | Notes |
124-
| -------- | -------------------------------------------------- |
125-
| lit | Literal value such as `lit(123)` or `lit("hello")` |
126-
127-
## Boolean Expressions
128-
129-
| Function | Notes |
130-
| -------- | ----------------------------------------- |
131-
| and | `and(expr1, expr2)` or `expr1.and(expr2)` |
132-
| or | `or(expr1, expr2)` or `expr1.or(expr2)` |
133-
| not | `not(expr)` or `expr.not()` |
134-
135-
## Comparison Expressions
136-
137-
| Function | Notes |
138-
| -------- | --------------------- |
139-
| eq | `expr1.eq(expr2)` |
140-
| gt | `expr1.gt(expr2)` |
141-
| gt_eq | `expr1.gt_eq(expr2)` |
142-
| lt | `expr1.lt(expr2)` |
143-
| lt_eq | `expr1.lt_eq(expr2)` |
144-
| not_eq | `expr1.not_eq(expr2)` |
145-
146-
## Math Functions
147-
148-
In addition to the math functions listed here, some Rust operators are implemented for expressions, allowing
149-
expressions such as `col("a") + col("b")` to be used.
150-
151-
| Function | Notes |
152-
| --------------------- | ------------------------------------------------- |
153-
| abs(x) | absolute value |
154-
| acos(x) | inverse cosine |
155-
| asin(x) | inverse sine |
156-
| atan(x) | inverse tangent |
157-
| atan2(y, x) | inverse tangent of y / x |
158-
| ceil(x) | nearest integer greater than or equal to argument |
159-
| cos(x) | cosine |
160-
| exp(x) | exponential |
161-
| floor(x) | nearest integer less than or equal to argument |
162-
| ln(x) | natural logarithm |
163-
| log10(x) | base 10 logarithm |
164-
| log2(x) | base 2 logarithm |
165-
| power(base, exponent) | base raised to the power of exponent |
166-
| round(x) | round to nearest integer |
167-
| signum(x) | sign of the argument (-1, 0, +1) |
168-
| sin(x) | sine |
169-
| sqrt(x) | square root |
170-
| tan(x) | tangent |
171-
| trunc(x) | truncate toward zero |
172-
173-
## Conditional Expressions
174-
175-
| Function | Notes |
176-
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
177-
| coalesce | Returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display. |
178-
| case | CASE expression. Example: `case(expr).when(expr, expr).when(expr, expr).otherwise(expr).end()`. |
179-
| nullif | Returns a null value if `value1` equals `value2`; otherwise it returns `value1`. This can be used to perform the inverse operation of the `coalesce` expression. |
180-
181-
## String Expressions
182-
183-
| Function | Notes |
184-
| ---------------- | ----- |
185-
| ascii | |
186-
| bit_length | |
187-
| btrim | |
188-
| char_length | |
189-
| character_length | |
190-
| concat | |
191-
| concat_ws | |
192-
| chr | |
193-
| initcap | |
194-
| left | |
195-
| length | |
196-
| lower | |
197-
| lpad | |
198-
| ltrim | |
199-
| md5 | |
200-
| octet_length | |
201-
| repeat | |
202-
| replace | |
203-
| reverse | |
204-
| right | |
205-
| rpad | |
206-
| rtrim | |
207-
| digest | |
208-
| split_part | |
209-
| starts_with | |
210-
| strpos | |
211-
| substr | |
212-
| translate | |
213-
| trim | |
214-
| upper | |
215-
216-
## Regular Expressions
217-
218-
| Function | Notes |
219-
| -------------- | ----- |
220-
| regexp_match | |
221-
| regexp_replace | |
222-
223-
## Temporal Expressions
224-
225-
| Function | Notes |
226-
| -------------------- | ------------ |
227-
| date_part | |
228-
| date_trunc | |
229-
| from_unixtime | |
230-
| to_timestamp | |
231-
| to_timestamp_millis | |
232-
| to_timestamp_micros | |
233-
| to_timestamp_seconds | |
234-
| now() | current time |
235-
236-
## Other Expressions
237-
238-
| Function | Notes |
239-
| -------- | ----- |
240-
| array | |
241-
| in_list | |
242-
| random | |
243-
| sha224 | |
244-
| sha256 | |
245-
| sha384 | |
246-
| sha512 | |
247-
| struct | |
248-
| to_hex | |
249-
250-
## Aggregate Functions
251-
252-
| Function | Notes |
253-
| ---------------------------------- | ----- |
254-
| avg | |
255-
| approx_distinct | |
256-
| approx_median | |
257-
| approx_percentile_cont | |
258-
| approx_percentile_cont_with_weight | |
259-
| count | |
260-
| count_distinct | |
261-
| cube | |
262-
| grouping_set | |
263-
| max | |
264-
| median | |
265-
| min | |
266-
| rollup | |
267-
| sum | |
268-
269-
## Subquery Expressions
270-
271-
| Function | Notes |
272-
| --------------- | --------------------------------------------------------------------------------------------- |
273-
| exists | |
274-
| in_subquery | `df1.filter(in_subquery(col("foo"), df2))?` is the equivalent of the SQL `WHERE foo IN <df2>` |
275-
| not_exists | |
276-
| not_in_subquery | |
277-
| scalar_subquery | |
278-
279-
## User-Defined Function Expressions
280-
281-
| Function | Notes |
282-
| ----------- | ----- |
283-
| create_udf | |
284-
| create_udaf | |

0 commit comments

Comments
 (0)