@@ -54,6 +54,7 @@ class TYtLogicalOptProposalTransformer : public TOptimizeTransformerBase {
54
54
AddHandler (0 , &TCoUnorderedBase::Match, HNDL (Unordered));
55
55
AddHandler (0 , &TCoAggregate::Match, HNDL (CountAggregate));
56
56
AddHandler (0 , &TYtReadTable::Match, HNDL (ZeroSampleToZeroLimit));
57
+ AddHandler (0 , &TCoMatchRecognize::Match, HNDL (MatchRecognize));
57
58
58
59
AddHandler (1 , &TCoFilterNullMembers::Match, HNDL (FilterNullMemebers<TCoFilterNullMembers>));
59
60
AddHandler (1 , &TCoSkipNullMembers::Match, HNDL (FilterNullMemebers<TCoSkipNullMembers>));
@@ -75,8 +76,6 @@ class TYtLogicalOptProposalTransformer : public TOptimizeTransformerBase {
75
76
76
77
AddHandler (2 , &TCoEquiJoin::Match, HNDL (ConvertToCommonTypeForForcedMergeJoin));
77
78
AddHandler (2 , &TCoShuffleByKeys::Match, HNDL (ShuffleByKeys));
78
-
79
- AddHandler (0 , &TCoMatchRecognize::Match, HNDL (MatchRecognize));
80
79
#undef HNDL
81
80
}
82
81
@@ -139,13 +138,20 @@ class TYtLogicalOptProposalTransformer : public TOptimizeTransformerBase {
139
138
effectiveColumns.insert (column.Name );
140
139
}
141
140
141
+ if (NYql::HasSetting (op.Settings ().Ref (), EYtSettingType::KeepSorted)) {
142
+ for (size_t i = 0 ; i < rowSpec->SortedBy .size (); ++i) {
143
+ const bool inserted = effectiveColumns.insert (rowSpec->SortedBy [i]).second ;
144
+ keepColumns = keepColumns || inserted;
145
+ }
146
+ }
147
+
142
148
if (!path.Ranges ().Maybe <TCoVoid>()) {
143
149
// add columns which are implicitly used by path.Ranges(), but not included in path.Columns();
144
150
const auto ranges = TYtRangesInfo (path.Ranges ());
145
151
const size_t usedKeyPrefix = ranges.GetUsedKeyPrefixLength ();
146
152
YQL_ENSURE (usedKeyPrefix <= rowSpec->SortedBy .size ());
147
153
for (size_t i = 0 ; i < usedKeyPrefix; ++i) {
148
- bool inserted = effectiveColumns.insert (rowSpec->SortedBy [i]).second ;
154
+ const bool inserted = effectiveColumns.insert (rowSpec->SortedBy [i]).second ;
149
155
keepColumns = keepColumns || inserted;
150
156
}
151
157
}
0 commit comments