alamb commented on code in PR #11969:
URL: https://github.com/apache/datafusion/pull/11969#discussion_r1718267372


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

Review Comment:
   By my understanding of `duckdb`'s doc the values should be a list not a 
scalar. In other words the result should be  `[1], [], [3], []` not `1, NULL, 
3, NULL`:
   
   ```sql
   D select map_extract(MAP {'a': 1, 'b': NULL, 'c': 3}, 'a');
   
┌─────────────────────────────────────────────────────────────────────────────────────────┐
   │ map_extract(main.map(main.list_value('a', 'b', 'c'), main.list_value(1, 
NULL, 3)), 'a') │
   │                                         int32[]                            
             │
   
├─────────────────────────────────────────────────────────────────────────────────────────┤
   │ [1]                                                                        
             │
   
└─────────────────────────────────────────────────────────────────────────────────────────┘
   D
   D select map_extract(MAP {'a': 1, 'b': NULL, 'c': 3}, 'd');
   
┌─────────────────────────────────────────────────────────────────────────────────────────┐
   │ map_extract(main.map(main.list_value('a', 'b', 'c'), main.list_value(1, 
NULL, 3)), 'd') │
   │                                         int32[]                            
             │
   
├─────────────────────────────────────────────────────────────────────────────────────────┤
   │ []                                                                         
             │
   
└─────────────────────────────────────────────────────────────────────────────────────────┘
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to