You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Caizhi Weng (Jira)" <ji...@apache.org> on 2020/07/13 03:53:00 UTC

[jira] [Commented] (FLINK-14848) BaseRowSerializer.toBinaryRow wrongly process null for non-compact decimal

    [ https://issues.apache.org/jira/browse/FLINK-14848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17156471#comment-17156471 ] 

Caizhi Weng commented on FLINK-14848:
-------------------------------------

This bug is caused by the special logic when dealing null values for decimal type and timestamp type. As we cannot know the logical type in {{setNullAt}} method, we should stop using this method and use {{ValueSetter}}s and {{NullSetter}}s instead (they're currently used in binary arrays).

After an offline discussion with [~lzljs3620320] we decided to implement {{ValueSetter}}s and {{NullSetter}}s for binary rows and we're not going to reuse {{ValueSetter}}s and {{NullSetter}}s from binary arrays. This is because binary rows and binary arrays have different formats and structures.

I would like to fix this issue. Please assign it to me if the above solution is acceptable.

> BaseRowSerializer.toBinaryRow wrongly process null for non-compact decimal
> ---------------------------------------------------------------------------
>
>                 Key: FLINK-14848
>                 URL: https://issues.apache.org/jira/browse/FLINK-14848
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.9.1
>            Reporter: Zhenghua Gao
>            Priority: Major
>
> Take non-compact decimal(precision > 18 null as an example, the writer not only need to set null bits, but also need to assign bytes of variable-length part for future update. The following test case can reproduce the problem.
>  
>  
> {code:java}
> @Test
> public void test() {
>    Decimal dec = Decimal.fromBigDecimal(new BigDecimal(11), 38, 0);
>    BinaryRow row1 = new BinaryRow(2);
>    BinaryRowWriter writer = new BinaryRowWriter(row1);
>    writer.writeDecimal(0, dec, 38);
>    writer.writeDecimal(1, null, 38);
>    writer.complete();
>    BaseRowSerializer serializer = new BaseRowSerializer(null, RowType.of(new DecimalType(38, 0), new DecimalType(38, 0)));
>    GenericRow row2 = new GenericRow(2);
>    row2.setField(0, dec);
>    row2.setField(1, null);
>    BinaryRow row3 = serializer.toBinaryRow(row2);
>    assertTrue(row1.equalsWithoutHeader(row3));
> }
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)