Skip to content

Commit 62f20bc

Browse files
committed
don't remove DESC sorting for sys view reads
1 parent fe21f71 commit 62f20bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ydb/core/kqp/opt/physical/kqp_opt_phy_sort.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ TExprBase KqpRemoveRedundantSortOverReadTable(TExprBase node, TExprContext& ctx,
9393
}
9494

9595
if (direction == ESortDirection::Reverse) {
96+
// For sys views, we need to set reverse flag even if UseSource returns false
97+
// because sys view actors can handle reverse direction
98+
bool isSysView = tableDesc.Metadata->Kind == EKikimrTableKind::SysView;
99+
if (isSysView) {
100+
return node;
101+
}
102+
96103
if (!UseSource(kqpCtx, tableDesc) && kqpCtx.IsScanQuery()) {
97104
return node;
98105
}
@@ -206,6 +213,13 @@ TExprBase KqpRemoveRedundantSortOverReadTableFSM(
206213
}
207214

208215
if (isReversed) {
216+
// For sys views, we need to set reverse flag even if UseSource returns false
217+
// because sys view actors can handle reverse direction
218+
bool isSysView = tableDesc.Metadata->Kind == EKikimrTableKind::SysView;
219+
if (isSysView) {
220+
return node;
221+
}
222+
209223
if (!UseSource(kqpCtx, tableDesc) && kqpCtx.IsScanQuery()) {
210224
return node;
211225
}

0 commit comments

Comments
 (0)