diff options
| author | Pavel Velikhov <[email protected]> | 2024-03-12 13:35:00 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-12 11:35:00 +0100 |
| commit | 196eab23300e1c293a748efb74e3cbcf95e3c83a (patch) | |
| tree | de7ade0612ebe0e985813de9bdc54af1ed39d951 | |
| parent | 1d0b69a84f76331a252d7690f8f50b8bcb0f5a36 (diff) | |
Added statistics calculation for AsList structure (#2646)
| -rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_stat.cpp | 10 | ||||
| -rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_stat.h | 1 | ||||
| -rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_stat_transformer_base.cpp | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/ydb/library/yql/dq/opt/dq_opt_stat.cpp b/ydb/library/yql/dq/opt/dq_opt_stat.cpp index f16a3af75fc..464def94be6 100644 --- a/ydb/library/yql/dq/opt/dq_opt_stat.cpp +++ b/ydb/library/yql/dq/opt/dq_opt_stat.cpp @@ -359,6 +359,16 @@ void InferStatisticsForAggregateMergeFinalize(const TExprNode::TPtr& input, TTyp typeCtx->SetStats( input.Get(), inputStats ); } +void InferStatisticsForAsList(const TExprNode::TPtr& input, TTypeAnnotationContext* typeCtx) { + double nRows = input->ChildrenSize(); + int nAttrs = 5; + if (input->ChildrenSize() && input->Child(0)->IsCallable("AsStruct")) { + nAttrs = input->Child(0)->ChildrenSize(); + } + auto outputStats = TOptimizerStatistics(EStatisticsType::BaseTable, nRows, nAttrs, nRows*nAttrs, 0.0); + typeCtx->SetStats(input.Get(), std::make_shared<TOptimizerStatistics>(outputStats)); +} + /*** * For callables that include lambdas, we want to propagate the statistics from lambda's input to its argument, so * that the operators inside lambda receive the correct statistics diff --git a/ydb/library/yql/dq/opt/dq_opt_stat.h b/ydb/library/yql/dq/opt/dq_opt_stat.h index 4f3497da4fc..31013988c3f 100644 --- a/ydb/library/yql/dq/opt/dq_opt_stat.h +++ b/ydb/library/yql/dq/opt/dq_opt_stat.h @@ -17,6 +17,7 @@ void InferStatisticsForStage(const TExprNode::TPtr& input, TTypeAnnotationContex void InferStatisticsForDqSource(const TExprNode::TPtr& input, TTypeAnnotationContext* typeCtx); void InferStatisticsForGraceJoin(const TExprNode::TPtr& input, TTypeAnnotationContext* typeCtx, const IProviderContext& ctx); void InferStatisticsForMapJoin(const TExprNode::TPtr& input, TTypeAnnotationContext* typeCtx, const IProviderContext& ctx); +void InferStatisticsForAsList(const TExprNode::TPtr& input, TTypeAnnotationContext* typeCtx); double ComputePredicateSelectivity(const NNodes::TExprBase& input, const std::shared_ptr<TOptimizerStatistics>& stats); bool NeedCalc(NNodes::TExprBase node); bool IsConstantExpr(const TExprNode::TPtr& input); diff --git a/ydb/library/yql/dq/opt/dq_opt_stat_transformer_base.cpp b/ydb/library/yql/dq/opt/dq_opt_stat_transformer_base.cpp index f29e814444c..ee0e7d67730 100644 --- a/ydb/library/yql/dq/opt/dq_opt_stat_transformer_base.cpp +++ b/ydb/library/yql/dq/opt/dq_opt_stat_transformer_base.cpp @@ -52,6 +52,9 @@ bool TDqStatisticsTransformerBase::BeforeLambdas(const TExprNode::TPtr& input, T else if(TCoAggregateMergeFinalize::Match(input.Get())){ InferStatisticsForAggregateMergeFinalize(input, TypeCtx); } + else if (TCoAsList::Match(input.Get())){ + InferStatisticsForAsList(input, TypeCtx); + } // Join matchers else if(TCoMapJoinCore::Match(input.Get())) { |
