julianhyde commented on code in PR #3173:
URL: https://github.com/apache/calcite/pull/3173#discussion_r1182017941


##########
site/_docs/reference.md:
##########
@@ -1835,6 +1835,7 @@ period:
 | Operator syntax | Description
 |:--------------- |:-----------
 | {fn CONVERT(value, type)} | Cast *value* into *type*
+| {fn CONVERT/TRANSLATE(value using transcodingName)} | Alter *value* from one 
base character set to *transcodingName*

Review Comment:
   Does JDBC syntax (`{fn` ... `}`) allows `USING`? I don't think so.
   
   So, move this line to somewhere else in the SQL reference. Probably to the 
'Explicit Type Conversion' section. Split into separate lines, one for 
`CONVERT(value USION transcodingName)`, and one for `TRANSLATE(value USING 
transcodingName)`
   



##########
core/src/main/java/org/apache/calcite/sql/fun/SqlTranslateFunction.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.fun;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperandCountRange;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlOperandCountRanges;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorScope;
+
+import java.util.List;
+
+import static org.apache.calcite.util.Static.RESOURCE;
+
+/**
+ * Common base for the <code>TRANSLATE</code> function.

Review Comment:
   expand TRANSLATE to TRANSLATE(USING) and CONVERT(USING)
   
   mention that this is not CONVERT (MSSQL's cast)
   and this is not TRANSLATE (SqlTranslate3Function)



##########
core/src/main/java/org/apache/calcite/util/BuiltInMethod.java:
##########
@@ -443,6 +443,7 @@ public enum BuiltInMethod {
       String.class, boolean.class),
   REPLACE(SqlFunctions.class, "replace", String.class, String.class,
       String.class),
+  TRANSLATE(SqlFunctions.class, "translateWithCharset", String.class, 
String.class),

Review Comment:
   Rename this from TRANSLATE to TRANSLATE_WITH_CHARSET. The enum value should 
be similar to the function name.



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