Skip to content

Commit 8f0e7a6

Browse files
neyroxydbot
authored andcommitted
Mark sorting when we made it up as fake (#26340)
1 parent d25627c commit 8f0e7a6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ydb/core/tx/columnshard/engines/reader/abstract/read_metadata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TReadMetadataBase {
2424

2525
private:
2626
YDB_ACCESSOR_DEF(TString, ScanIdentifier);
27+
YDB_ACCESSOR_DEF(bool, FakeSort);
2728
std::optional<ui64> FilteredCountLimit;
2829
std::optional<ui64> RequestedLimit;
2930
const ESorting Sorting = ESorting::ASC; // Sorting inside returned batches

ydb/core/tx/columnshard/engines/reader/simple_reader/iterator/scanner.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ TConclusionStatus TScanHead::Start() {
2121

2222
TScanHead::TScanHead(std::unique_ptr<NCommon::ISourcesConstructor>&& sourcesConstructor, const std::shared_ptr<TSpecialReadContext>& context)
2323
: Context(context) {
24+
auto readMetadataContext = context->GetReadMetadata();
2425
if (auto script = Context->GetSourcesAggregationScript()) {
2526
SourcesCollection =
26-
std::make_shared<TNotSortedCollection>(Context, std::move(sourcesConstructor), Context->GetReadMetadata()->GetLimitRobustOptional());
27+
std::make_shared<TNotSortedCollection>(Context, std::move(sourcesConstructor), readMetadataContext->GetLimitRobustOptional());
2728
SyncPoints.emplace_back(std::make_shared<TSyncPointResult>(SyncPoints.size(), context, SourcesCollection));
2829
SyncPoints.emplace_back(std::make_shared<TSyncPointResultsAggregationControl>(
2930
SourcesCollection, Context->GetSourcesAggregationScript(), Context->GetRestoreResultScript(), SyncPoints.size(), context));
30-
} else if (Context->GetReadMetadata()->IsSorted()) {
31-
if (Context->GetReadMetadata()->HasLimit()) {
31+
} else if (readMetadataContext->IsSorted()) {
32+
if (readMetadataContext->HasLimit() && !readMetadataContext->GetFakeSort()) {
3233
auto collection = std::make_shared<TScanWithLimitCollection>(Context, std::move(sourcesConstructor));
3334
SourcesCollection = collection;
3435
SyncPoints.emplace_back(std::make_shared<TSyncPointLimitControl>(
@@ -39,7 +40,7 @@ TScanHead::TScanHead(std::unique_ptr<NCommon::ISourcesConstructor>&& sourcesCons
3940
SyncPoints.emplace_back(std::make_shared<TSyncPointResult>(SyncPoints.size(), context, SourcesCollection));
4041
} else {
4142
SourcesCollection =
42-
std::make_shared<TNotSortedCollection>(Context, std::move(sourcesConstructor), Context->GetReadMetadata()->GetLimitRobustOptional());
43+
std::make_shared<TNotSortedCollection>(Context, std::move(sourcesConstructor), readMetadataContext->GetLimitRobustOptional());
4344
SyncPoints.emplace_back(std::make_shared<TSyncPointResult>(SyncPoints.size(), context, SourcesCollection));
4445
}
4546
for (ui32 i = 0; i + 1 < SyncPoints.size(); ++i) {

ydb/core/tx/columnshard/engines/reader/transaction/tx_scan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ void TTxScan::Complete(const TActorContext& ctx) {
147147
}
148148
auto newRange = scannerConstructor->BuildReadMetadata(Self, read);
149149
if (newRange.IsSuccess()) {
150+
if (!request.HasReverse() && deduplicationEnabled) {
151+
(*newRange)->SetFakeSort(true);
152+
}
150153
readMetadataRange = TValidator::CheckNotNull(newRange.DetachResult());
151154
} else {
152155
return SendError("cannot build metadata", newRange.GetErrorMessage(), ctx);

0 commit comments

Comments
 (0)