Skip to content

Commit f9606d8

Browse files
committed
Update doc examples for arrow_cast
1 parent 1e8ddfa commit f9606d8

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

datafusion/functions/src/core/arrow_cast.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,26 @@ use datafusion_macros::user_doc;
6060
description = "Casts a value to a specific Arrow data type.",
6161
syntax_example = "arrow_cast(expression, datatype)",
6262
sql_example = r#"```sql
63-
> select arrow_cast(-5, 'Int8') as a,
63+
> select
64+
arrow_cast(-5, 'Int8') as a,
6465
arrow_cast('foo', 'Dictionary(Int32, Utf8)') as b,
65-
arrow_cast('bar', 'LargeUtf8') as c,
66-
arrow_cast('2023-01-02T12:53:02', 'Timestamp(Microsecond, Some("+08:00"))') as d
67-
;
68-
+----+-----+-----+---------------------------+
69-
| a | b | c | d |
70-
+----+-----+-----+---------------------------+
71-
| -5 | foo | bar | 2023-01-02T12:53:02+08:00 |
72-
+----+-----+-----+---------------------------+
66+
arrow_cast('bar', 'LargeUtf8') as c;
67+
68+
+----+-----+-----+
69+
| a | b | c |
70+
+----+-----+-----+
71+
| -5 | foo | bar |
72+
+----+-----+-----+
73+
74+
> select
75+
arrow_cast('2023-01-02T12:53:02', 'Timestamp(µs, "+08:00")') as d,
76+
arrow_cast('2023-01-02T12:53:02', 'Timestamp(µs)') as e;
77+
78+
+---------------------------+---------------------+
79+
| d | e |
80+
+---------------------------+---------------------+
81+
| 2023-01-02T12:53:02+08:00 | 2023-01-02T12:53:02 |
82+
+---------------------------+---------------------+
7383
```"#,
7484
argument(
7585
name = "expression",

docs/source/user-guide/sql/scalar_functions.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,16 +4972,26 @@ arrow_cast(expression, datatype)
49724972
#### Example
49734973

49744974
```sql
4975-
> select arrow_cast(-5, 'Int8') as a,
4975+
> select
4976+
arrow_cast(-5, 'Int8') as a,
49764977
arrow_cast('foo', 'Dictionary(Int32, Utf8)') as b,
4977-
arrow_cast('bar', 'LargeUtf8') as c,
4978-
arrow_cast('2023-01-02T12:53:02', 'Timestamp(Microsecond, Some("+08:00"))') as d
4979-
;
4980-
+----+-----+-----+---------------------------+
4981-
| a | b | c | d |
4982-
+----+-----+-----+---------------------------+
4983-
| -5 | foo | bar | 2023-01-02T12:53:02+08:00 |
4984-
+----+-----+-----+---------------------------+
4978+
arrow_cast('bar', 'LargeUtf8') as c;
4979+
4980+
+----+-----+-----+
4981+
| a | b | c |
4982+
+----+-----+-----+
4983+
| -5 | foo | bar |
4984+
+----+-----+-----+
4985+
4986+
> select
4987+
arrow_cast('2023-01-02T12:53:02', 'Timestamp(µs, "+08:00")') as d,
4988+
arrow_cast('2023-01-02T12:53:02', 'Timestamp(µs)') as e;
4989+
4990+
+---------------------------+---------------------+
4991+
| d | e |
4992+
+---------------------------+---------------------+
4993+
| 2023-01-02T12:53:02+08:00 | 2023-01-02T12:53:02 |
4994+
+---------------------------+---------------------+
49854995
```
49864996

49874997
### `arrow_typeof`

0 commit comments

Comments
 (0)