File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,11 @@ bool ColumnArray::LoadBody(InputStream* input, size_t rows) {
8484 if (!offsets_->LoadBody (input, rows)) {
8585 return false ;
8686 }
87- if (!data_->LoadBody (input, (*offsets_)[rows - 1 ])) {
87+ const auto nested_rows = (*offsets_)[rows - 1 ];
88+ if (nested_rows == 0 ) {
89+ return true ;
90+ }
91+ if (!data_->LoadBody (input, nested_rows)) {
8892 return false ;
8993 }
9094 return true ;
@@ -96,7 +100,9 @@ void ColumnArray::SavePrefix(OutputStream* output) {
96100
97101void ColumnArray::SaveBody (OutputStream* output) {
98102 offsets_->SaveBody (output);
99- data_->SaveBody (output);
103+ if (data_->Size () > 0 ) {
104+ data_->SaveBody (output);
105+ }
100106}
101107
102108void ColumnArray::Clear () {
Original file line number Diff line number Diff line change @@ -1037,6 +1037,31 @@ TEST_P(ClientCase, RoundtripArrayTString) {
10371037 EXPECT_TRUE (CompareRecursive (*array, *result_typed));
10381038}
10391039
1040+ TEST_P (ClientCase, RoundtripArrayLowCardinalityTString) {
1041+ // TODO replase by Roundtrip test
1042+ using TestColumn = ColumnArrayT<ColumnLowCardinalityT<ColumnString>>;
1043+
1044+ Block block;
1045+ auto array = createTableWithOneColumn<TestColumn>(block);
1046+ array->Append (std::vector<std::string>{});
1047+ array->Append (std::vector<std::string>{});
1048+
1049+ block.RefreshRowCount ();
1050+ client_->Insert (table_name, block);
1051+
1052+ size_t total_rows = 0 ;
1053+ client_->Select (getOneColumnSelectQuery (),
1054+ [&total_rows](const Block& block) {
1055+ total_rows += block.GetRowCount ();
1056+ if (block.GetRowCount () == 0 ) {
1057+ return ;
1058+ }
1059+ }
1060+ );
1061+
1062+ ASSERT_EQ (total_rows, 2u );
1063+ }
1064+
10401065TEST_P (ClientCase, RoundtripMapTUint64String) {
10411066 using Map = ColumnMapT<ColumnUInt64, ColumnString>;
10421067 auto map = std::make_shared<Map>(std::make_shared<ColumnUInt64>(), std::make_shared<ColumnString>());
You can’t perform that action at this time.
0 commit comments