caicancai commented on code in PR #3786:
URL: https://github.com/apache/calcite/pull/3786#discussion_r1590005412


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -5529,9 +5529,23 @@ public static List mapValues(Map map) {
 
   /** Support the MAP_CONTAINS_KEY function. */
   public static Boolean mapContainsKey(Map map, Object key) {
+    for (Object mapKey : map.keySet()) {
+      if (isNumericEqual(mapKey, key)) {
+        return true;
+      }
+    }
     return map.containsKey(key);
   }
 
+  private static boolean isNumericEqual(Object obj1, Object obj2) {
+    if (obj1 instanceof Number && obj2 instanceof Number) {
+      double num1 = ((Number) obj1).doubleValue();

Review Comment:
   Or convert BigDecimal for comparison, what do you think



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -5529,9 +5529,23 @@ public static List mapValues(Map map) {
 
   /** Support the MAP_CONTAINS_KEY function. */
   public static Boolean mapContainsKey(Map map, Object key) {
+    for (Object mapKey : map.keySet()) {
+      if (isNumericEqual(mapKey, key)) {
+        return true;
+      }
+    }
     return map.containsKey(key);
   }
 
+  private static boolean isNumericEqual(Object obj1, Object obj2) {
+    if (obj1 instanceof Number && obj2 instanceof Number) {
+      double num1 = ((Number) obj1).doubleValue();

Review Comment:
   @mihaibudiu Should I add a layer of explicit conversion in case to convert 
the types in map and key to the biggest type



-- 
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: commits-unsubscr...@calcite.apache.org

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

Reply via email to