Skip to content

Commit dbe3395

Browse files
authored
docs: Update map_extract examples (#21360)
## Which issue does this PR close? N/A. ## Rationale for this change While reviewing apache/datafusion-python#1461, I noticed that an example in the `map_extract` function was wrong: ```sql -- example SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y'); ---- [] -- datafusion SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y'); ---- [NULL] ``` ## What changes are included in this PR? - Fixed the previous example. - Also added a new example showing a `map_extract` on an empty key. ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
1 parent 8dedd12 commit dbe3395

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

datafusion/functions-nested/src/map_extract.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ SELECT map_extract(MAP {1: 'one', 2: 'two'}, 2);
5757
5858
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y');
5959
----
60+
[NULL]
61+
62+
-- non-existing key
63+
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'a');
64+
----
6065
[]
6166
```"#,
6267
argument(

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,6 +5039,11 @@ SELECT map_extract(MAP {1: 'one', 2: 'two'}, 2);
50395039

50405040
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y');
50415041
----
5042+
[NULL]
5043+
5044+
-- non-existing key
5045+
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'a');
5046+
----
50425047
[]
50435048
```
50445049

0 commit comments

Comments
 (0)