silundong commented on code in PR #4729:
URL: https://github.com/apache/calcite/pull/4729#discussion_r2671010938
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java:
##########
@@ -163,6 +164,20 @@ private static SqlSingleOperandTypeChecker
getChecker(SqlCallBinding callBinding
if (sqlTypeName == SqlTypeName.VARIANT) {
// Allow any key type to be used when the map keys have a VARIANT type
return OperandTypes.family(SqlTypeFamily.ANY);
+ } else if (sqlTypeName == SqlTypeName.ROW) {
+ // Check that the type of the argument is exactly the key type
+ return new SqlSingleOperandTypeChecker() {
+ @Override public boolean checkSingleOperandType(
+ SqlCallBinding callBinding, SqlNode operand,
+ int iFormalOperand, boolean throwOnFailure) {
+ RelDataType operandType = callBinding.getOperandType(0);
+ return operandType.equals(keyType);
Review Comment:
```
// For mapp1[user_def(1, 'a')]
final SqlNode left = callBinding.operand(0); // mapp1
final SqlNode right = callBinding.operand(1); // user_def(1, 'a')
......
final SqlSingleOperandTypeChecker checker = getChecker(callBinding);
if (!checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure)) {
return false;
}
......
```
Based on the context, `operand` is the parameter, so it seems we should
compare the type of `operand` with `keyType`.
--
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]