You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2022/07/14 23:49:36 UTC
[spark] branch master updated: [SPARK-39780][SQL][DOCS] Add an additional usage example for the map_zip_with function
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 0076bc1b8d0 [SPARK-39780][SQL][DOCS] Add an additional usage example for the map_zip_with function
0076bc1b8d0 is described below
commit 0076bc1b8d0b21e7463f1fffc7266a014c917ac4
Author: Brian Yue <co...@gmail.com>
AuthorDate: Fri Jul 15 08:49:19 2022 +0900
[SPARK-39780][SQL][DOCS] Add an additional usage example for the map_zip_with function
### What changes were proposed in this pull request?
Add an additional usage example for the map_zip_with function in Spark SQL to demonstrate how it handles maps with different keys.
### Why are the changes needed?
Combined with other methods like `aggregate` and `transform`, it can help users avoid using `explode` or UDF in specific cases, which will lead to significant performance improvement.
### Does this PR introduce _any_ user-facing change?
It will enrich the documentation of Spark SQL, Built-in Functions.
### How was this patch tested?
The added example shows the real query result.
Closes #37192 from byyue/dev-39780.
Authored-by: Brian Yue <co...@gmail.com>
Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
.../apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
index 135a423b38a..93f9e4c59db 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
@@ -976,6 +976,7 @@ case class TransformValues(
* Merges two given maps into a single map by applying function to the pair of values with
* the same key.
*/
+// scalastyle:off line.size.limit
@ExpressionDescription(
usage =
"""
@@ -988,6 +989,8 @@ case class TransformValues(
Examples:
> SELECT _FUNC_(map(1, 'a', 2, 'b'), map(1, 'x', 2, 'y'), (k, v1, v2) -> concat(v1, v2));
{1:"ax",2:"by"}
+ > SELECT _FUNC_(map('a', 1, 'b', 2), map('b', 3, 'c', 4), (k, v1, v2) -> coalesce(v1, 0) + coalesce(v2, 0));
+ {"a":1,"b":5,"c":4}
""",
since = "3.0.0",
group = "lambda_funcs")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org