matriv commented on a change in pull request #18221:
URL: https://github.com/apache/flink/pull/18221#discussion_r783122359
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/BinaryToStringCastRule.java
##########
@@ -20,35 +20,137 @@
import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.table.types.logical.LogicalTypeFamily;
+import org.apache.flink.table.types.logical.utils.LogicalTypeChecks;
import java.nio.charset.StandardCharsets;
+import static org.apache.flink.table.planner.codegen.CodeGenUtils.className;
+import static org.apache.flink.table.planner.codegen.CodeGenUtils.newName;
+import static
org.apache.flink.table.planner.codegen.calls.BuiltInMethods.BINARY_STRING_DATA_FROM_STRING;
import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.accessStaticField;
+import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.arrayElement;
+import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.arrayLength;
import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.constructorCall;
-import static org.apache.flink.table.types.logical.VarCharType.STRING_TYPE;
+import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.methodCall;
+import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.staticCall;
+import static
org.apache.flink.table.planner.functions.casting.CastRuleUtils.strLiteral;
+import static
org.apache.flink.table.planner.functions.casting.CharVarCharTrimPadCastRule.couldTrim;
+import static
org.apache.flink.table.planner.functions.casting.CharVarCharTrimPadCastRule.stringExceedsLength;
/**
* {@link LogicalTypeFamily#BINARY_STRING} to {@link
LogicalTypeFamily#CHARACTER_STRING} cast rule.
*/
-class BinaryToStringCastRule extends AbstractCharacterFamilyTargetRule<byte[]>
{
+class BinaryToStringCastRule extends
AbstractNullAwareCodeGeneratorCastRule<byte[], String> {
static final BinaryToStringCastRule INSTANCE = new
BinaryToStringCastRule();
private BinaryToStringCastRule() {
super(
CastRulePredicate.builder()
.input(LogicalTypeFamily.BINARY_STRING)
- .target(STRING_TYPE)
+ .target(LogicalTypeFamily.CHARACTER_STRING)
.build());
}
+ /* Example generated code
+
+ isNull$0 = _myInputIsNull;
+ if (!isNull$0) {
+ builder$1.setLength(0);
+ builder$1.append("[");
Review comment:
No miscommunication, I just thought it's an nicer printout to have it in
an array style, and when doing the inverse cast, the `[`,`]` and `. ` are
replaced before parsing the hex string into bytes (2 by 2). I'm totally fine to
go with full hex, no brackets and delimiter.
--
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]