JingsongLi commented on a change in pull request #8730:
[FLINK-12834][table-planner-blink] Support CharType and BinaryType
URL: https://github.com/apache/flink/pull/8730#discussion_r296080979
##########
File path:
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/calcite/FlinkTypeFactory.scala
##########
@@ -379,14 +380,25 @@ object FlinkTypeFactory {
case BIGINT => new BigIntType()
case FLOAT => new FloatType()
case DOUBLE => new DoubleType()
- case VARCHAR | CHAR =>
- // TODO we use VarCharType to support sql CHAR, VarCharType don't
support 0 length
- new VarCharType(
- if (relDataType.getPrecision == 0) VarCharType.MAX_LENGTH else
relDataType.getPrecision)
- case VARBINARY | BINARY =>
- // TODO we use VarBinaryType to support sql BINARY, VarBinaryType
don't support 0 length
- new VarBinaryType(
- if (relDataType.getPrecision == 0) VarBinaryType.MAX_LENGTH else
relDataType.getPrecision)
+ case CHAR =>
+ if (relDataType.getPrecision == 0) {
+ CharType.ofEmptyLiteral
+ } else {
+ new CharType(relDataType.getPrecision)
+ }
+ case VARCHAR =>
+ // Calcite will return a varchar RelDataType with precision 0, for
example,
+ // SUBSTR('', 2, -1), Calcite infers that the return value must not
exist
+ // (in this case, null will be returned when executed in Blink runner),
+ // so it infers VARCHAR(0). But our `VarcharType` not allow precision
0.
+ new VarCharType(Math.max(1, relDataType.getPrecision))
Review comment:
After https://github.com/apache/flink/pull/8730 , it is ready now.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services