|
9 | 9 | #include <ydb/library/yql/core/yql_opt_utils.h> |
10 | 10 | #include <ydb/library/yql/dq/opt/dq_opt_join.h> |
11 | 11 | #include <ydb/library/yql/dq/opt/dq_opt_log.h> |
| 12 | +#include <ydb/library/yql/dq/opt/dq_opt_hopping.h> |
12 | 13 | #include <ydb/library/yql/providers/common/transform/yql_optimize.h> |
13 | 14 | #include <ydb/library/yql/providers/dq/common/yql_dq_settings.h> |
14 | 15 |
|
@@ -111,8 +112,28 @@ class TKqpLogicalOptTransformer : public TOptimizeTransformerBase { |
111 | 112 | } |
112 | 113 |
|
113 | 114 | TMaybeNode<TExprBase> RewriteAggregate(TExprBase node, TExprContext& ctx) { |
114 | | - TExprBase output = DqRewriteAggregate(node, ctx, TypesCtx, false, KqpCtx.Config->HasOptEnableOlapPushdown() || KqpCtx.Config->HasOptUseFinalizeByKey(), KqpCtx.Config->HasOptUseFinalizeByKey()); |
115 | | - DumpAppliedRule("RewriteAggregate", node.Ptr(), output.Ptr(), ctx); |
| 115 | + TMaybeNode<TExprBase> output; |
| 116 | + auto aggregate = node.Cast<TCoAggregateBase>(); |
| 117 | + auto hopSetting = GetSetting(aggregate.Settings().Ref(), "hopping"); |
| 118 | + if (hopSetting) { |
| 119 | + auto input = aggregate.Input().Maybe<TDqConnection>(); |
| 120 | + if (!input) { |
| 121 | + return node; |
| 122 | + } |
| 123 | + output = NHopping::RewriteAsHoppingWindow( |
| 124 | + node, |
| 125 | + ctx, |
| 126 | + input.Cast(), |
| 127 | + false, |
| 128 | + TDuration::MilliSeconds(TDqSettings::TDefault::WatermarksLateArrivalDelayMs), |
| 129 | + true, |
| 130 | + false); |
| 131 | + } else { |
| 132 | + output = DqRewriteAggregate(node, ctx, TypesCtx, false, KqpCtx.Config->HasOptEnableOlapPushdown() || KqpCtx.Config->HasOptUseFinalizeByKey(), KqpCtx.Config->HasOptUseFinalizeByKey()); |
| 133 | + } |
| 134 | + if (output) { |
| 135 | + DumpAppliedRule("RewriteAggregate", node.Ptr(), output.Cast().Ptr(), ctx); |
| 136 | + } |
116 | 137 | return output; |
117 | 138 | } |
118 | 139 |
|
|
0 commit comments