macroguo-ghy commented on code in PR #3647:
URL: https://github.com/apache/calcite/pull/3647#discussion_r1467313307
##########
core/src/main/java/org/apache/calcite/util/BuiltInMethod.java:
##########
@@ -781,6 +781,7 @@ public enum BuiltInMethod {
MAP_ENTRIES(SqlFunctions.class, "mapEntries", Map.class),
MAP_KEYS(SqlFunctions.class, "mapKeys", Map.class),
MAP_VALUES(SqlFunctions.class, "mapValues", Map.class),
+ MAP_CONTAINS_KEY(SqlFunctions.class, "mapContainsKey", Map.class,
Object.class),
Review Comment:
Alphabetical order
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -7189,6 +7189,29 @@ void checkRegexpExtract(SqlOperatorFixture f0,
FunctionAlias functionAlias) {
"INTEGER ARRAY NOT NULL");
}
+ @Test void testMapContainsKeyFunc() {
Review Comment:
Add more test for
- NULL
- Complex types
- Empty map
- Type coercion(include function without type coercion)
- Unmatched types
For example:
```sql
map_contains_key(map(null, null), 1);
map_contains_key(map(null, null), null);
map_contains_key(map(array(1), array(2)), array(1));
map_contains_key(map(), 1);
map_contains_key(map(1, 2), cast(1 as double));
map_contains_key(map(1, 2), 'abc');
```
I'm not sure if these examples are valid, you need to give them a try and
add more tests.
##########
site/_docs/reference.md:
##########
@@ -2789,6 +2789,7 @@ In the following:
| s | MAP_ENTRIES(map) | Returns the entries of
the *map* as an array, the order of the entries is not defined
| s | MAP_KEYS(map) | Returns the keys of the
*map* as an array, the order of the entries is not defined
| s | MAP_VALUES(map) | Returns the values of
the *map* as an array, the order of the entries is not defined
+| s | MAP_CONTAINS_KEY(map, key) | Returns true if the
*map* contains the *key*
Review Comment:
Alphabetical order
--
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]