diff options
| author | ivanmorozov333 <[email protected]> | 2024-07-30 17:03:46 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-30 17:03:46 +0300 |
| commit | ee419dbcdec5f5bac819a17618598ca2cf13e4c2 (patch) | |
| tree | 34d9b6031eb7386c93d5492e5db6664eee5cfac5 | |
| parent | 5ead379fac334f64891a48dbb82be3f64a8b02ca (diff) | |
fix segfault in case normalization different versions (#7239)
| -rw-r--r-- | ydb/core/formats/arrow/common/container.cpp | 5 | ||||
| -rw-r--r-- | ydb/core/formats/arrow/common/container.h | 8 | ||||
| -rw-r--r-- | ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/ydb/core/formats/arrow/common/container.cpp b/ydb/core/formats/arrow/common/container.cpp index 7e8209dfad5..e910a6837a1 100644 --- a/ydb/core/formats/arrow/common/container.cpp +++ b/ydb/core/formats/arrow/common/container.cpp @@ -123,6 +123,11 @@ TGeneralContainer::TGeneralContainer(const std::shared_ptr<arrow::RecordBatch>& Initialize(); } +TGeneralContainer::TGeneralContainer(const ui32 recordsCount) + : RecordsCount(recordsCount) + , Schema(std::make_shared<NModifier::TSchema>()) { +} + std::shared_ptr<NKikimr::NArrow::NAccessor::IChunkedArray> TGeneralContainer::GetAccessorByNameVerified(const std::string& fieldId) const { auto result = GetAccessorByNameOptional(fieldId); AFL_VERIFY(result)("event", "cannot_find_accessor_in_general_container")("field_id", fieldId)("schema", Schema->ToString()); diff --git a/ydb/core/formats/arrow/common/container.h b/ydb/core/formats/arrow/common/container.h index 90d686ce4e4..823f04821d5 100644 --- a/ydb/core/formats/arrow/common/container.h +++ b/ydb/core/formats/arrow/common/container.h @@ -29,6 +29,13 @@ private: std::vector<std::shared_ptr<NAccessor::IChunkedArray>> Columns; void Initialize(); public: + TGeneralContainer(const ui32 recordsCount); + + ui32 GetRecordsCountVerified() const { + AFL_VERIFY(RecordsCount); + return *RecordsCount; + } + TString DebugString() const; [[nodiscard]] TConclusionStatus SyncSchemaTo(const std::shared_ptr<arrow::Schema>& schema, @@ -67,7 +74,6 @@ public: [[nodiscard]] TConclusionStatus AddField(const std::shared_ptr<arrow::Field>& f, const std::shared_ptr<arrow::ChunkedArray>& data); - TGeneralContainer() = default; TGeneralContainer(const std::shared_ptr<arrow::Table>& table); TGeneralContainer(const std::shared_ptr<arrow::RecordBatch>& table); TGeneralContainer(const std::shared_ptr<arrow::Schema>& schema, std::vector<std::shared_ptr<NAccessor::IChunkedArray>>&& columns); diff --git a/ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp b/ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp index c6efc7a5567..3eeca97bde2 100644 --- a/ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp +++ b/ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.cpp @@ -35,7 +35,7 @@ TConclusion<std::shared_ptr<NArrow::TGeneralContainer>> ISnapshotSchema::Normali AFL_VERIFY(dataSchema.GetSnapshot() < GetSnapshot()); const std::shared_ptr<arrow::Schema>& resultArrowSchema = GetSchema(); - std::shared_ptr<NArrow::TGeneralContainer> result = std::make_shared<NArrow::TGeneralContainer>(); + std::shared_ptr<NArrow::TGeneralContainer> result = std::make_shared<NArrow::TGeneralContainer>(batch->GetRecordsCountVerified()); for (size_t i = 0; i < resultArrowSchema->fields().size(); ++i) { auto& resultField = resultArrowSchema->fields()[i]; auto columnId = GetIndexInfo().GetColumnId(resultField->name()); |
