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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to