ILuffZhe commented on code in PR #3558:
URL: https://github.com/apache/calcite/pull/3558#discussion_r1874630301


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlTranslateFunction.java:
##########
@@ -78,6 +85,40 @@ protected SqlTranslateFunction(String name) {
     super.validateQuantifier(validator, call);
   }
 
+  @Override public RelDataType inferReturnType(
+      SqlOperatorBinding opBinding) {
+    final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+    final RelDataType ret = opBinding.getOperandType(0);
+    if (SqlTypeUtil.isNull(ret)) {
+      return ret;
+    }
+    final String descCharsetName;
+    if (opBinding instanceof SqlCallBinding) {
+      descCharsetName = ((SqlCallBinding) 
opBinding).getCall().operand(1).toString();
+    } else {
+      descCharsetName = ((RexCallBinding) 
opBinding).getStringLiteralOperand(1);
+    }
+    assert descCharsetName != null;
+    Charset descCharset = SqlUtil.getCharset(descCharsetName);
+    return typeFactory.createTypeWithCharsetAndCollation(ret, descCharset, 
getCollation(ret));
+  }
+
+  @Override public RelDataType deriveType(SqlValidator validator,
+      SqlValidatorScope scope, SqlCall call) {
+    // special case for TRANSLATE: don't need to derive type for Charsets

Review Comment:
   Got your point, I'll change it to `don't need to derive type for Charsets` 
in both CONVERT and TRANSLATE. WDYT?



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