Weijun-H commented on code in PR #11969:
URL: https://github.com/apache/datafusion/pull/11969#discussion_r1718206586


##########
datafusion/sqllogictest/test_files/map.slt:
##########
@@ -493,3 +509,68 @@ select cardinality(map([1, 2, 3], ['a', 'b', 'c'])), 
cardinality(MAP {'a': 1, 'b
        cardinality(MAP {'a': MAP {1:'a', 2:'b', 3:'c'}, 'b': MAP {2:'c', 
4:'d'} });
 ----
 3 2 0 2
+
+# map_extract
+# key is string
+query IIII
+select map_extract(MAP {'a': 1, 'b': NULL, 'c': 3}, 'a'), map_extract(MAP 
{'a': 1, 'b': NULL, 'c': 3}, 'b'),
+       map_extract(MAP {'a': 1, 'b': NULL, 'c': 3}, 'c'), map_extract(MAP 
{'a': 1, 'b': NULL, 'c': 3}, 'd');
+----
+1 NULL 3 NULL
+
+# key is integer
+query IIII
+select map_extract(MAP {1: 1, 2: NULL, 3:3}, 1), map_extract(MAP {1: 1, 2: 
NULL, 3:3}, 2),
+       map_extract(MAP {1: 1, 2: NULL, 3:3}, 3), map_extract(MAP {1: 1, 2: 
NULL, 3:3}, 4);
+----
+1 NULL 3 NULL
+
+# value is list
+query ????
+select map_extract(MAP {1: [1, 2], 2: NULL, 3:[3]}, 1), map_extract(MAP {1: 
[1, 2], 2: NULL, 3:[3]}, 2),
+       map_extract(MAP {1: [1, 2], 2: NULL, 3:[3]}, 3), map_extract(MAP {1: 
[1, 2], 2: NULL, 3:[3]}, 4);
+----
+[1, 2] NULL [3] NULL
+
+# key in map and query key are different types
+query IIIII
+select map_extract(MAP {1: 1, 2: 2, 3:3}, '1'), map_extract(MAP {1: 1, 2: 2, 
3:3}, 1.0),
+       map_extract(MAP {1.0: 1, 2: 2, 3:3}, '1'), map_extract(MAP {'1': 1, 
'2': 2, '3':3}, 1.0),
+       map_extract(MAP {arrow_cast('1', 'Utf8View'): 1, arrow_cast('2', 
'Utf8View'): 2, arrow_cast('3', 'Utf8View'):3}, '1');
+----
+1 1 1 NULL 1
+
+# map_extract with columns
+query ???
+select map_extract(column1, 1), map_extract(column1, 4), map_extract(column1, 
5) from map_array_table_1;
+----
+[1, , 3] NULL NULL
+NULL [1, , 3] [4, , 6]
+NULL NULL NULL
+
+query ???
+select map_extract(column1, column2), map_extract(column1, column3), 
map_extract(column1, column4) from map_array_table_1;
+----
+[1, , 3] [1, , 3] [1, , 3]
+[4, , 6] [4, , 6] [4, , 6]
+NULL NULL NULL
+
+query ???
+select map_extract(column1, column2), map_extract(column1, column3), 
map_extract(column1, column4) from map_array_table_2;
+----
+[1, , 3] NULL [1, , 3]
+[4, , 6] NULL [4, , 6]
+NULL NULL NULL
+
+query ???
+select map_extract(column1, 1), map_extract(column1, 4), map_extract(column1, 
5) from map_array_table_2;
+----
+[1, , 3] NULL NULL
+NULL [1, , 3] [4, , 6]
+NULL NULL NULL
+

Review Comment:
   test map_extract in columnar format



-- 
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