File tree 2 files changed +33
-2
lines changed
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) {
84
84
if (!offsets_->LoadBody (input, rows)) {
85
85
return false ;
86
86
}
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)) {
88
92
return false ;
89
93
}
90
94
return true ;
@@ -96,7 +100,9 @@ void ColumnArray::SavePrefix(OutputStream* output) {
96
100
97
101
void ColumnArray::SaveBody (OutputStream* output) {
98
102
offsets_->SaveBody (output);
99
- data_->SaveBody (output);
103
+ if (data_->Size () > 0 ) {
104
+ data_->SaveBody (output);
105
+ }
100
106
}
101
107
102
108
void ColumnArray::Clear () {
Original file line number Diff line number Diff line change @@ -1037,6 +1037,31 @@ TEST_P(ClientCase, RoundtripArrayTString) {
1037
1037
EXPECT_TRUE (CompareRecursive (*array, *result_typed));
1038
1038
}
1039
1039
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
+
1040
1065
TEST_P (ClientCase, RoundtripMapTUint64String) {
1041
1066
using Map = ColumnMapT<ColumnUInt64, ColumnString>;
1042
1067
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