You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/04/16 06:00:08 UTC
(datafusion) 01/01: docs: Update `map_extract` examples (#21360)
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch gh-readonly-queue/main/pr-21360-8dedd12c836c978aea0463319f80fd335d5a8e74
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit dbe3395ea53d80fb7931514d057350cbc25c4453
Author: Nuno Faria <nu...@gmail.com>
AuthorDate: Thu Apr 16 06:59:43 2026 +0100
docs: Update `map_extract` examples (#21360)
## Which issue does this PR close?
N/A.
## Rationale for this change
While reviewing https://github.com/apache/datafusion-python/pull/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.
---
datafusion/functions-nested/src/map_extract.rs | 5 +++++
docs/source/user-guide/sql/scalar_functions.md | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/datafusion/functions-nested/src/map_extract.rs b/datafusion/functions-nested/src/map_extract.rs
index 1c46bf5e81..aab0d013a4 100644
--- a/datafusion/functions-nested/src/map_extract.rs
+++ b/datafusion/functions-nested/src/map_extract.rs
@@ -57,6 +57,11 @@ SELECT map_extract(MAP {1: 'one', 2: 'two'}, 2);
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y');
----
+[NULL]
+
+-- non-existing key
+SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'a');
+----
[]
```"#,
argument(
diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md
index 9f5814447b..bd7fb22e00 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -5039,6 +5039,11 @@ SELECT map_extract(MAP {1: 'one', 2: 'two'}, 2);
SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'y');
----
+[NULL]
+
+-- non-existing key
+SELECT map_extract(MAP {'x': 10, 'y': NULL, 'z': 30}, 'a');
+----
[]
```
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org