@@ -603,8 +603,15 @@ TExprNode::TPtr THorizontalJoinOptimizer::HandleList(const TExprNode::TPtr& node
603
603
size_t outNdx = JoinedMaps.size ();
604
604
const TExprNode* columns = nullptr ;
605
605
const TExprNode* ranges = nullptr ;
606
+ bool incompleteSectionSettings = false ;
606
607
if (sectionList) {
607
- auto path = TYtSection (node->Child (sectionNum)).Paths ().Item (pathNum);
608
+ const auto section = TYtSection (node->Child (sectionNum));
609
+ const auto path = section.Paths ().Item (pathNum);
610
+
611
+ // Section cannot be changed right now. Keep all section inputs as is (add to ExclusiveOuts)
612
+ incompleteSectionSettings = NYql::HasAnySetting (section.Settings ().Ref (), EYtSettingType::Take | EYtSettingType::Skip)
613
+ || HasNonEmptyKeyFilter (section);
614
+
608
615
columns = path.Columns ().Raw ();
609
616
ranges = path.Ranges ().Raw ();
610
617
}
@@ -642,7 +649,7 @@ TExprNode::TPtr THorizontalJoinOptimizer::HandleList(const TExprNode::TPtr& node
642
649
auto outRowSpec = TYtTableBaseInfo::GetRowSpec (map.Output ().Item (0 ));
643
650
const bool sortedOut = outRowSpec && outRowSpec->IsSorted ();
644
651
645
- if (sortedOut) {
652
+ if (sortedOut || incompleteSectionSettings ) {
646
653
if (ExclusiveOuts.find (outNdx) == ExclusiveOuts.end ()) {
647
654
// Sorted output cannot be joined with others
648
655
outputCountIncrement = 1 ;
@@ -694,7 +701,7 @@ TExprNode::TPtr THorizontalJoinOptimizer::HandleList(const TExprNode::TPtr& node
694
701
Worlds.emplace (map.World ().Ptr (), Worlds.size ());
695
702
}
696
703
697
- if (sortedOut) {
704
+ if (sortedOut || incompleteSectionSettings ) {
698
705
ExclusiveOuts[outNdx].emplace_back (sectionNum, pathNum);
699
706
} else {
700
707
GroupedOuts[std::make_tuple (sectionNum, columns, ranges)][outNdx] = pathNum;
0 commit comments