@@ -354,7 +354,9 @@ TEST_F(RegionBlockReaderTest, MissingColumnRowV2)
354354 encodeColumns (table_info, fields, RowEncodeVersion::RowV2);
355355 auto new_table_info = getTableInfoWithMoreColumns ({MutSup::extra_handle_id}, false );
356356 auto new_decoding_schema = getDecodingStorageSchemaSnapshot (new_table_info);
357- ASSERT_TRUE (decodeAndCheckColumns (new_decoding_schema, false ));
357+ // `decodeAndCheckColumns` will return false because "column1" not_null=true but no_default_value=false
358+ // FIXME: Re check the logic here
359+ ASSERT_FALSE (decodeAndCheckColumns (new_decoding_schema, false ));
358360}
359361
360362TEST_F (RegionBlockReaderTest, MissingColumnRowV1)
@@ -363,7 +365,9 @@ TEST_F(RegionBlockReaderTest, MissingColumnRowV1)
363365 encodeColumns (table_info, fields, RowEncodeVersion::RowV1);
364366 auto new_table_info = getTableInfoWithMoreColumns ({MutSup::extra_handle_id}, false );
365367 auto new_decoding_schema = getDecodingStorageSchemaSnapshot (new_table_info);
366- ASSERT_TRUE (decodeAndCheckColumns (new_decoding_schema, false ));
368+ // `decodeAndCheckColumns` will return false because "column1" not_null=true but no_default_value=false
369+ // FIXME: Re check the logic here
370+ ASSERT_FALSE (decodeAndCheckColumns (new_decoding_schema, false ));
367371}
368372
369373TEST_F (RegionBlockReaderTest, ExtraColumnRowV2)
@@ -696,11 +700,6 @@ CATCH
696700TEST_F (RegionBlockReaderTest, ReadFromRegionDefaultValue)
697701try
698702{
699- // With this table_info, c1 can be decoded to NULL value
700- // TableInfo table_info(
701- // R"({"cols":[{"id":1,"name":{"L":"c0","O":"c0"},"offset":0,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":4,"Tp":1}},{"id":2,"name":{"L":"handle","O":"handle"},"offset":1,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":515,"Flen":11,"Tp":3}},{"id":7,"name":{"L":"c1","O":"c1"},"offset":2,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":20,"Tp":8}},{"id":4,"name":{"L":"c2","O":"c2"},"offset":3,"origin_default":"0.07954397","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":-1,"Flag":4097,"Flen":12,"Tp":4}},{"id":5,"name":{"L":"c5","O":"c5"},"offset":4,"origin_default":"0","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}},{"default":"247262911","id":6,"name":{"L":"c4","O":"c4"},"offset":5,"origin_default":"247262911","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}}],"id":681,"index_info":[],"is_common_handle":false,"keyspace_id":4294967295,"name":{"L":"t0","O":"t0"},"pk_is_handle":true,"state":5,"tiflash_replica":{"Available":true,"Count":1},"update_timestamp":463844343842340870})",
702- // NullspaceID);
703-
704703 // With this table_info, c1 is filled with "0" according to ori_default
705704 TableInfo table_info (
706705 R"({"cols":[{"id":1,"name":{"L":"c0","O":"c0"},"offset":0,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":4,"Tp":1}},{"id":2,"name":{"L":"handle","O":"handle"},"offset":1,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":515,"Flen":11,"Tp":3}},{"default":"-56083770","id":7,"name":{"L":"c1","O":"c1"},"offset":2,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":1,"Flen":20,"Tp":8}},{"id":4,"name":{"L":"c2","O":"c2"},"offset":3,"origin_default":"0.07954397","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":-1,"Flag":4097,"Flen":12,"Tp":4}},{"id":5,"name":{"L":"c5","O":"c5"},"offset":4,"origin_default":"0","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}},{"default":"247262911","id":6,"name":{"L":"c4","O":"c4"},"offset":5,"origin_default":"247262911","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}}],"id":711,"index_info":[],"is_common_handle":false,"keyspace_id":4294967295,"name":{"L":"t0","O":"t0"},"pk_is_handle":true,"state":5,"tiflash_replica":{"Available":true,"Count":1},"update_timestamp":463845180343844895})",
@@ -713,16 +712,16 @@ try
713712 auto region = RegionBench::makeRegionForRange (region_id, region_start_key, region_end_key);
714713 // the hex kv dump from SSTFile
715714 std::vector<std::tuple<std::string_view, std::string_view>> kvs = {
716- {
717- " 7480000000000002FFA95F728000000000FF0000010000000000FAF9901806DEF7FFDA" ,
718- " 50A380A08892FFF9B706762C8000040000000405060708000F0016001A00BFDC4011A00000000A0080000000000A008000003CA339"
719- " 1ABC85" ,
720- },
721- {
722- " 7480000000000002FFA95F728000000000FF0000010000000000FAF9901806DEF7FFD8" ,
723- " 50A680A08892FFF9B706762C8000040000000405060708000F0016001A00BFDC4011A00000000A008033E04D600A008000003CA339"
724- " 1ABC85" ,
725- },
715+ // {
716+ // "7480000000000002FFA95F728000000000FF0000010000000000FAF9901806DEF7FFDA",
717+ // "50A380A08892FFF9B706762C8000040000000405060708000F0016001A00BFDC4011A00000000A0080000000000A008000003CA339"
718+ // "1ABC85",
719+ // },
720+ // {
721+ // "7480000000000002FFA95F728000000000FF0000010000000000FAF9901806DEF7FFD8",
722+ // "50A680A08892FFF9B706762C8000040000000405060708000F0016001A00BFDC4011A00000000A008033E04D600A008000003CA339"
723+ // "1ABC85",
724+ // },
726725 {
727726 " 7480000000000002FFA95F728000000000FF0000020000000000FAF9901806DE33FFE8" ,
728727 " 509680B08E92FFF9B706762580000300000004050608000F001600BF720CDD400000000A0080000000010A00800000393C" ,
@@ -739,10 +738,35 @@ try
739738 auto decoding_schema = getDecodingStorageSchemaSnapshot (table_info);
740739 {
741740 // force_decode=false can not decode because there are
742- // missing value for column with primary key flag.
741+ // missing value for column with not null flag.
742+ auto reader = RegionBlockReader (decoding_schema);
743+ Block res_block = createBlockSortByColumnID (decoding_schema);
744+ ASSERT_FALSE (reader.read (res_block, *data_list_read, false ));
745+ }
746+ {
747+ // force_decode=true can decode the block, and filling the default value for c1
748+ auto reader = RegionBlockReader (decoding_schema);
749+ Block res_block = createBlockSortByColumnID (decoding_schema);
750+ ASSERT_TRUE (reader.read (res_block, *data_list_read, true ));
751+ // TODO: verify the default value is filled correctly
752+ LOG_INFO (
753+ Logger::get (),
754+ " Decoded block:\n {}" ,
755+ DB::tests::getColumnsContent (res_block.getColumnsWithTypeAndName ()));
756+ }
757+
758+ // With this table_info, c1 does not have the "not null" flag
759+ TableInfo table_info_c1_nullable (
760+ R"({"cols":[{"id":1,"name":{"L":"c0","O":"c0"},"offset":0,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":4,"Tp":1}},{"id":2,"name":{"L":"handle","O":"handle"},"offset":1,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":515,"Flen":11,"Tp":3}},{"id":7,"name":{"L":"c1","O":"c1"},"offset":2,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":20,"Tp":8}},{"id":4,"name":{"L":"c2","O":"c2"},"offset":3,"origin_default":"0.07954397","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":-1,"Flag":4097,"Flen":12,"Tp":4}},{"id":5,"name":{"L":"c5","O":"c5"},"offset":4,"origin_default":"0","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}},{"default":"247262911","id":6,"name":{"L":"c4","O":"c4"},"offset":5,"origin_default":"247262911","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}}],"id":681,"index_info":[],"is_common_handle":false,"keyspace_id":4294967295,"name":{"L":"t0","O":"t0"},"pk_is_handle":true,"state":5,"tiflash_replica":{"Available":true,"Count":1},"update_timestamp":463844343842340870})",
761+ NullspaceID);
762+
763+ decoding_schema = getDecodingStorageSchemaSnapshot (table_info_c1_nullable);
764+ {
765+ // force_decode=false should be able to decode because c1 is nullable
743766 auto reader = RegionBlockReader (decoding_schema);
744767 Block res_block = createBlockSortByColumnID (decoding_schema);
745- EXPECT_TRUE (reader.read (res_block, *data_list_read, false ));
768+ ASSERT_TRUE (reader.read (res_block, *data_list_read, false ));
769+ // TODO: verify the default value is filled correctly
746770 LOG_INFO (
747771 Logger::get (),
748772 " Decoded block:\n {}" ,
0 commit comments