macroguo-ghy commented on code in PR #3655:
URL: https://github.com/apache/calcite/pull/3655#discussion_r1469019414


##########
core/src/main/java/org/apache/calcite/sql/type/NonNullableAccessors.java:
##########
@@ -52,4 +52,10 @@ public static RelDataType 
getComponentTypeOrThrow(RelDataType type) {
     return requireNonNull(type.getComponentType(),
         () -> "componentType is null for " + type);
   }
+
+  @API(since = "1.27", status = API.Status.EXPERIMENTAL)

Review Comment:
   since 1.37 ?



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -7189,6 +7189,33 @@ void checkRegexpExtract(SqlOperatorFixture f0, 
FunctionAlias functionAlias) {
         "INTEGER ARRAY NOT NULL");
   }
 
+  @Test void testMapContainsKeyFunc() {

Review Comment:
   Make sure result as same as spark-sql. 
   And can you add more negative tests? 



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -7189,6 +7189,33 @@ void checkRegexpExtract(SqlOperatorFixture f0, 
FunctionAlias functionAlias) {
         "INTEGER ARRAY NOT NULL");
   }
 
+  @Test void testMapContainsKeyFunc() {

Review Comment:
   Add docs for this test



##########
core/src/main/java/org/apache/calcite/sql/type/NonNullableAccessors.java:
##########
@@ -52,4 +52,10 @@ public static RelDataType 
getComponentTypeOrThrow(RelDataType type) {
     return requireNonNull(type.getComponentType(),
         () -> "componentType is null for " + type);
   }
+
+  @API(since = "1.27", status = API.Status.EXPERIMENTAL)
+  public static RelDataType getKeyTypeOrThrow(RelDataType type) {
+    return requireNonNull(type.getKeyType(),
+        () -> "componentType is null for " + type);

Review Comment:
   not componentType



##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -603,6 +603,9 @@ public static SqlOperandTypeChecker variadic(
   public static final SqlSingleOperandTypeChecker MAP_FUNCTION =
       new MapFunctionOperandTypeChecker();
 
+  public static final SqlOperandTypeChecker MAP_ELEEMNT =

Review Comment:
   not element



##########
core/src/main/java/org/apache/calcite/sql/type/MapElementOperandTypeChecker.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql.type;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperandCountRange;
+import org.apache.calcite.sql.SqlOperator;
+
+import com.google.common.collect.ImmutableList;
+
+import static 
org.apache.calcite.sql.type.NonNullableAccessors.getKeyTypeOrThrow;
+import static org.apache.calcite.util.Static.RESOURCE;
+
+/**
+ * Parameter type-checking strategy where types must be Map and Map element 
type.

Review Comment:
   There is no element type for MAP. I think you mean the key type. 
   Please fix the javadoc and rename this class.



##########
core/src/main/java/org/apache/calcite/sql/type/MapElementOperandTypeChecker.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql.type;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperandCountRange;
+import org.apache.calcite.sql.SqlOperator;
+
+import com.google.common.collect.ImmutableList;
+
+import static 
org.apache.calcite.sql.type.NonNullableAccessors.getKeyTypeOrThrow;
+import static org.apache.calcite.util.Static.RESOURCE;
+
+/**
+ * Parameter type-checking strategy where types must be Map and Map element 
type.
+ */
+public class MapElementOperandTypeChecker implements SqlOperandTypeChecker {
+  @Override public boolean checkOperandTypes(
+      SqlCallBinding callBinding,
+      boolean throwOnFailure) {
+    final SqlNode op0 = callBinding.operand(0);
+    if (!OperandTypes.MAP.checkSingleOperandType(
+        callBinding,
+        op0,
+        0,
+        throwOnFailure)) {
+      return false;
+    }
+
+    RelDataType mapComponentType =

Review Comment:
   Use `final` as much as possible



##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -847,6 +848,7 @@ Builder populate2() {
       defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method, 
NullPolicy.STRICT);
       defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT);
       defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method, 
NullPolicy.STRICT);
+      defineMethod(MAP_CONTAINS_KEYS, BuiltInMethod.MAP_CONTAINS_KEY.method, 
NullPolicy.ANY);

Review Comment:
   alphabetical



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

Reply via email to