@@ -24,14 +24,16 @@ class TCMSEval : public IColumnStatisticEval {
2424 static std::optional<TCMSEval> MaybeCreate (
2525 const NKikimrStat::TSimpleColumnStatistics& simpleStats,
2626 const NScheme::TTypeInfo&) {
27- if (simpleStats.GetCountDistinct () >= 0.8 * simpleStats.GetCount ()) {
27+ if (simpleStats.GetCount () == 0 || simpleStats.GetCountDistinct () == 0 ) {
28+ // Empty table
2829 return std::nullopt ;
2930 }
3031
3132 const double n = simpleStats.GetCount ();
3233 const double ndv = simpleStats.GetCountDistinct ();
33- if (ndv == 0 ) {
34- return TCMSEval (MIN_WIDTH);
34+
35+ if (ndv >= 0.8 * n) {
36+ return std::nullopt ;
3537 }
3638
3739 const double c = 10 ;
@@ -208,7 +210,7 @@ void TAnalyzeActor::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr&
208210 for (const auto & colTag : RequestedColumnTags) {
209211 auto colIt = tag2Column.find (colTag);
210212 if (colIt == tag2Column.end ()) {
211- // Column probably already deleted , skip it.
213+ // Column probably already dropped , skip it.
212214 continue ;
213215 }
214216 addColumn (colIt->second );
@@ -219,6 +221,14 @@ void TAnalyzeActor::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr&
219221 }
220222 }
221223
224+ if (Columns.empty ()) {
225+ // All requested columns were already dropped. Send empty response right away.
226+ auto response = std::make_unique<TEvStatistics::TEvFinishTraversal>(std::move (Results));
227+ Send (Parent, response.release ());
228+ PassAway ();
229+ return ;
230+ }
231+
222232 Become (&TThis::StateQueryStage1);
223233 auto actor = std::make_unique<TScanActor>(
224234 SelfId (), DatabaseName, stage1Builder.Build (TableName), stage1Builder.ColumnCount ());
@@ -263,7 +273,6 @@ void TAnalyzeActor::HandleStage1(TEvPrivate::TEvAnalyzeScanResult::TPtr& ev) {
263273 continue ;
264274 }
265275 if (statEval->EstimateSize () >= 4_MB) {
266- // To avoid: Error: ydb/library/yql/dq/runtime/dq_output_channel.cpp:405: Row data size is too big: 53839241 bytes, exceeds limit of 50331648 bytes
267276 continue ;
268277 }
269278 statEval->AddAggregations (col.Name , stage2Builder);
0 commit comments