@@ -182,7 +182,7 @@ class TYtPhysicalFinalizingTransformer : public TSyncTransformerBase {
182
182
}
183
183
184
184
if (!disableOptimizers.contains (" BypassMergeBeforeLength" )) {
185
- status = BypassMergeBeforeLength (input, output, opDeps, lefts, ctx);
185
+ status = BypassMergeOrCopyBeforeLength (input, output, opDeps, lefts, ctx);
186
186
if (status.Level != TStatus::Ok) {
187
187
return status;
188
188
}
@@ -1610,33 +1610,35 @@ class TYtPhysicalFinalizingTransformer : public TSyncTransformerBase {
1610
1610
return lambda;
1611
1611
}
1612
1612
1613
- TStatus BypassMergeBeforeLength (TExprNode::TPtr input, TExprNode::TPtr& output, const TOpDeps& opDeps, const TNodeSet& lefts, TExprContext& ctx) {
1613
+ TStatus BypassMergeOrCopyBeforeLength (TExprNode::TPtr input, TExprNode::TPtr& output, const TOpDeps& opDeps, const TNodeSet& lefts, TExprContext& ctx) {
1614
1614
TNodeOnNodeOwnedMap replaces;
1615
1615
for (auto & x: opDeps) {
1616
- if (TYtMerge::Match (x.first ) && x.second .size () > 0 && AllOf (x.second , [](const auto & item) { return TYtLength::Match (std::get<0 >(item)); } )) {
1617
- auto merge = TYtMerge (x.first );
1618
- if (merge .Ref ().HasResult ()) {
1616
+ if (( TYtMerge::Match (x.first ) || TYtCopy::Match (x. first ) ) && x.second .size () > 0 && AllOf (x.second , [](const auto & item) { return TYtLength::Match (std::get<0 >(item)); } )) {
1617
+ auto op = TYtTransientOpBase (x.first );
1618
+ if (op .Ref ().HasResult ()) {
1619
1619
continue ;
1620
1620
}
1621
1621
1622
- if (NYql::HasSetting (merge.Settings ().Ref (), EYtSettingType::Limit)) {
1623
- continue ;
1624
- }
1622
+ auto section = op.Input ().Item (0 );
1623
+ if (op.Maybe <TYtMerge>()) {
1624
+ if (NYql::HasSetting (op.Settings ().Ref (), EYtSettingType::Limit)) {
1625
+ continue ;
1626
+ }
1625
1627
1626
- auto section = merge.Input ().Item (0 );
1627
- if (NYql::HasAnySetting (section.Settings ().Ref (), EYtSettingType::Take | EYtSettingType::Skip | EYtSettingType::Sample)) {
1628
- continue ;
1629
- }
1630
- if (NYql::HasNonEmptyKeyFilter (section)) {
1631
- continue ;
1632
- }
1628
+ if (NYql::HasAnySetting (section.Settings ().Ref (), EYtSettingType::Take | EYtSettingType::Skip | EYtSettingType::Sample)) {
1629
+ continue ;
1630
+ }
1631
+ if (NYql::HasNonEmptyKeyFilter (section)) {
1632
+ continue ;
1633
+ }
1633
1634
1634
- if (AnyOf (section.Paths (), [](const TYtPath& path) { return !path.Ranges ().Maybe <TCoVoid>() || TYtTableBaseInfo::GetMeta (path.Table ())->IsDynamic ; })) {
1635
- continue ;
1636
- }
1637
- // Dependency on more than 1 operation
1638
- if (1 < Accumulate (section.Paths (), 0ull , [](ui64 val, const TYtPath& path) { return val + path.Table ().Maybe <TYtOutput>().IsValid (); })) {
1639
- continue ;
1635
+ if (AnyOf (section.Paths (), [](const TYtPath& path) { return !path.Ranges ().Maybe <TCoVoid>() || TYtTableBaseInfo::GetMeta (path.Table ())->IsDynamic ; })) {
1636
+ continue ;
1637
+ }
1638
+ // Dependency on more than 1 operation
1639
+ if (1 < Accumulate (section.Paths (), 0ull , [](ui64 val, const TYtPath& path) { return val + path.Table ().Maybe <TYtOutput>().IsValid (); })) {
1640
+ continue ;
1641
+ }
1640
1642
}
1641
1643
1642
1644
TSyncMap syncList;
@@ -1645,10 +1647,10 @@ class TYtPhysicalFinalizingTransformer : public TSyncTransformerBase {
1645
1647
syncList.emplace (GetOutputOp (out.Cast ()).Ptr (), syncList.size ());
1646
1648
}
1647
1649
}
1648
- auto newWorld = ApplySyncListToWorld (merge .World ().Ptr (), syncList, ctx);
1650
+ auto newWorld = ApplySyncListToWorld (op .World ().Ptr (), syncList, ctx);
1649
1651
for (auto node: lefts) {
1650
1652
TCoLeft left (node);
1651
- if (left.Input ().Raw () == merge .Raw ()) {
1653
+ if (left.Input ().Raw () == op .Raw ()) {
1652
1654
replaces[node] = newWorld;
1653
1655
}
1654
1656
}
@@ -1695,7 +1697,7 @@ class TYtPhysicalFinalizingTransformer : public TSyncTransformerBase {
1695
1697
}
1696
1698
1697
1699
if (!replaces.empty ()) {
1698
- YQL_CLOG (INFO, ProviderYt) << " PhysicalFinalizing-BypassMergeBeforeLength " ;
1700
+ YQL_CLOG (INFO, ProviderYt) << " PhysicalFinalizing-BypassMergeOrCopyBeforeLength " ;
1699
1701
return RemapExpr (input, output, replaces, ctx, TOptimizeExprSettings (State_->Types ));
1700
1702
}
1701
1703
0 commit comments