Re:Re: length value for some classes extending LogicalType.
I think the length is also used for implicit conversion between same logical types that are with different length or just to merge them to a bigger one when . For example in your code, if `RowType.of("col1", new CharType())` is in a sink table schema, the real data of which the length is more than 1 will be implicitly converted to the target length. You can find more details here[1][2]. [1] https://github.com/apache/flink/blob/0b139a12c2c24e07cedb43bbad6ee1ff634bcfcb/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/BinaryToBinaryCastRule.java#L60 [2] https://github.com/apache/flink/blob/0b139a12c2c24e07cedb43bbad6ee1ff634bcfcb/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeMerging.java#L407 -- Best! Xuyang 在 2022-05-26 10:20:07,"Shengkai Fang" 写道: Hi. It will also influence how Flink serialize/deserialize the RowData. For example, Flink will build the TimestampDataSerializer with specified precision in the type. You can see it only extract the expected part to serialize[1]. But for char/varchar type, the serializer will not truncate the string if it exceeds the specified length when serialize/deserialize the RowData. Best, Shengkai [1]https://github.com/apache/flink/blob/master/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/typeutils/TimestampDataSerializer.java#L108 yuxia 于2022年5月25日周三 20:58写道: IMO, the behaviors depends on how you convert your string data from extern system to Flink's intern data or, conversely. I think it's more like a hint to tell how to convert the string data between extern system including source and sink. Best regards, Yuxia 发件人: "Krzysztof Chmielewski" 收件人: "User" 发送时间: 星期三, 2022年 5 月 25日 下午 5:29:10 主题: length value for some classes extending LogicalType. Hi, some classes extending LogicalType.java such as VarCharType, BinaryType, CharType and few others have an optional argument "length". If not specified, length is set to default value which is 1. I would like to ask, what are the implications of that? What can happen if I use the default length value 1 but the actual length of the data will be bigger than 1? For example: RowType.of("col1", new CharType()) <- this will use default length value 1. Regards, Krzysztof Chmielewski
Re: length value for some classes extending LogicalType.
Hi. It will also influence how Flink serialize/deserialize the RowData. For example, Flink will build the TimestampDataSerializer with specified precision in the type. You can see it only extract the expected part to serialize[1]. But for char/varchar type, the serializer will not truncate the string if it exceeds the specified length when serialize/deserialize the RowData. Best, Shengkai [1] https://github.com/apache/flink/blob/master/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/typeutils/TimestampDataSerializer.java#L108 yuxia 于2022年5月25日周三 20:58写道: > IMO, the behaviors depends on how you convert your string data from extern > system to Flink's intern data or, conversely. > > I think it's more like a hint to tell how to convert the string data > between extern system including source and sink. > > > Best regards, > Yuxia > > -- > *发件人: *"Krzysztof Chmielewski" > *收件人: *"User" > *发送时间: *星期三, 2022年 5 月 25日 下午 5:29:10 > *主题: *length value for some classes extending LogicalType. > > Hi, > some classes extending LogicalType.java such as VarCharType, BinaryType, > CharType and few others have an optional argument "length". If not > specified, length is set to default value which is 1. > > I would like to ask, what are the implications of that? What can happen if > I use the default length value 1 but the actual length of the data will be > bigger than 1? > > For example: > RowType.of("col1", new CharType()) <- this will use default length value 1. > > Regards, > Krzysztof Chmielewski > >
Re: length value for some classes extending LogicalType.
IMO, the behaviors depends on how you convert your string data from extern system to Flink's intern data or, conversely. I think it's more like a hint to tell how to convert the string data between extern system including source and sink. Best regards, Yuxia 发件人: "Krzysztof Chmielewski" 收件人: "User" 发送时间: 星期三, 2022年 5 月 25日 下午 5:29:10 主题: length value for some classes extending LogicalType. Hi, some classes extending LogicalType.java such as VarCharType, BinaryType, CharType and few others have an optional argument "length". If not specified, length is set to default value which is 1. I would like to ask, what are the implications of that? What can happen if I use the default length value 1 but the actual length of the data will be bigger than 1? For example: RowType.of("col1", new CharType()) <- this will use default length value 1. Regards, Krzysztof Chmielewski
length value for some classes extending LogicalType.
Hi, some classes extending LogicalType.java such as VarCharType, BinaryType, CharType and few others have an optional argument "length". If not specified, length is set to default value which is 1. I would like to ask, what are the implications of that? What can happen if I use the default length value 1 but the actual length of the data will be bigger than 1? For example: RowType.of("col1", new CharType()) <- this will use default length value 1. Regards, Krzysztof Chmielewski