You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/12/09 02:15:29 UTC

[GitHub] [spark] allisonwang-db commented on a change in pull request #34836: [SPARK-37584][SQL] New SQL function: map_contains_key

allisonwang-db commented on a change in pull request #34836:
URL: https://github.com/apache/spark/pull/34836#discussion_r765383211



##########
File path: sql/core/src/test/resources/sql-tests/results/map.sql.out
##########
@@ -16,3 +16,69 @@ select map(1, 'a', 2, 'b')[5]
 struct<map(1, a, 2, b)[5]:string>
 -- !query output
 NULL
+
+
+-- !query
+select map_contains_key(map(1, 'a', 2, 'b'), 5)
+-- !query schema
+struct<mapcontainskey(map(1, a, 2, b), 5):boolean>
+-- !query output
+false
+
+
+-- !query
+select map_contains_key(map(1, 'a', 2, 'b'), 1)
+-- !query schema
+struct<mapcontainskey(map(1, a, 2, b), 1):boolean>
+-- !query output
+true
+
+
+-- !query
+select map_contains_key(map(1, 'a', 2, 'b'), 5.0)
+-- !query schema
+struct<mapcontainskey(map(1, a, 2, b), 5.0):boolean>
+-- !query output
+false
+
+
+-- !query
+select map_contains_key(map(1, 'a', 2, 'b'), 1.0)
+-- !query schema
+struct<mapcontainskey(map(1, a, 2, b), 1.0):boolean>
+-- !query output
+true
+
+
+-- !query
+select map_contains_key(map(1.0, 'a', 2, 'b'), 5)
+-- !query schema
+struct<mapcontainskey(map(1.0, a, 2, b), 5):boolean>
+-- !query output
+false
+
+
+-- !query
+select map_contains_key(map(1.0, 'a', 2, 'b'), 1)
+-- !query schema
+struct<mapcontainskey(map(1.0, a, 2, b), 1):boolean>
+-- !query output
+true
+
+
+-- !query
+select map_contains_key(map('1', 'a', '2', 'b'), 1)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'mapcontainskey(map('1', 'a', '2', 'b'), 1)' due to data type mismatch: Input to function mapcontainskey should have been map followed by a value with same element type, but it's [map<string,string>, int].; line 1 pos 7

Review comment:
       Would it be more intuitive if the function returns false instead of throwing exceptions in this case? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org