Skip to content

Commit ee419db

Browse files
fix segfault in case normalization different versions (#7239)
1 parent 5ead379 commit ee419db

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ydb/core/formats/arrow/common/container.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ TGeneralContainer::TGeneralContainer(const std::shared_ptr<arrow::RecordBatch>&
123123
Initialize();
124124
}
125125

126+
TGeneralContainer::TGeneralContainer(const ui32 recordsCount)
127+
: RecordsCount(recordsCount)
128+
, Schema(std::make_shared<NModifier::TSchema>()) {
129+
}
130+
126131
std::shared_ptr<NKikimr::NArrow::NAccessor::IChunkedArray> TGeneralContainer::GetAccessorByNameVerified(const std::string& fieldId) const {
127132
auto result = GetAccessorByNameOptional(fieldId);
128133
AFL_VERIFY(result)("event", "cannot_find_accessor_in_general_container")("field_id", fieldId)("schema", Schema->ToString());

ydb/core/formats/arrow/common/container.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ class TGeneralContainer {
2929
std::vector<std::shared_ptr<NAccessor::IChunkedArray>> Columns;
3030
void Initialize();
3131
public:
32+
TGeneralContainer(const ui32 recordsCount);
33+
34+
ui32 GetRecordsCountVerified() const {
35+
AFL_VERIFY(RecordsCount);
36+
return *RecordsCount;
37+
}
38+
3239
TString DebugString() const;
3340

3441
[[nodiscard]] TConclusionStatus SyncSchemaTo(const std::shared_ptr<arrow::Schema>& schema,
@@ -67,7 +74,6 @@ class TGeneralContainer {
6774

6875
[[nodiscard]] TConclusionStatus AddField(const std::shared_ptr<arrow::Field>& f, const std::shared_ptr<arrow::ChunkedArray>& data);
6976

70-
TGeneralContainer() = default;
7177
TGeneralContainer(const std::shared_ptr<arrow::Table>& table);
7278
TGeneralContainer(const std::shared_ptr<arrow::RecordBatch>& table);
7379
TGeneralContainer(const std::shared_ptr<arrow::Schema>& schema, std::vector<std::shared_ptr<NAccessor::IChunkedArray>>&& columns);

ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TConclusion<std::shared_ptr<NArrow::TGeneralContainer>> ISnapshotSchema::Normali
3535
AFL_VERIFY(dataSchema.GetSnapshot() < GetSnapshot());
3636
const std::shared_ptr<arrow::Schema>& resultArrowSchema = GetSchema();
3737

38-
std::shared_ptr<NArrow::TGeneralContainer> result = std::make_shared<NArrow::TGeneralContainer>();
38+
std::shared_ptr<NArrow::TGeneralContainer> result = std::make_shared<NArrow::TGeneralContainer>(batch->GetRecordsCountVerified());
3939
for (size_t i = 0; i < resultArrowSchema->fields().size(); ++i) {
4040
auto& resultField = resultArrowSchema->fields()[i];
4141
auto columnId = GetIndexInfo().GetColumnId(resultField->name());

0 commit comments

Comments
 (0)