aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgalaxycrab <UgnineSirdis@ydb.tech>2022-10-06 13:27:00 +0300
committergalaxycrab <UgnineSirdis@ydb.tech>2022-10-06 13:27:00 +0300
commit2fe2ca32ad3db605707d9dd760b3a2482ba1c3cf (patch)
tree121fa84b70fabb79315a6baf69115f209fafaa6f
parenta9fdd4fb908d14a055b3a536c523d679391a70b3 (diff)
downloadydb-2fe2ca32ad3db605707d9dd760b3a2482ba1c3cf.tar.gz
Fix COUNT(*) for tables with pg types
-rw-r--r--ydb/library/yql/core/yql_opt_utils.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/ydb/library/yql/core/yql_opt_utils.cpp b/ydb/library/yql/core/yql_opt_utils.cpp
index f1d7a068f6..069d223976 100644
--- a/ydb/library/yql/core/yql_opt_utils.cpp
+++ b/ydb/library/yql/core/yql_opt_utils.cpp
@@ -5,6 +5,7 @@
#include "yql_type_helpers.h"
#include <ydb/library/yql/ast/yql_constraint.h>
+#include <ydb/library/yql/parser/pg_catalog/catalog.h>
#include <ydb/library/yql/utils/log/log.h>
#include <util/generic/set.h>
@@ -1473,8 +1474,12 @@ ui8 GetTypeWeight(const TTypeAnnotationNode& type) {
default: return 32;
}
- case ETypeAnnotationKind::Optional: return 1 + GetTypeWeight(*type.Cast<TOptionalExprType>()->GetItemType());
- default: return 255;
+ case ETypeAnnotationKind::Optional:
+ return 1 + GetTypeWeight(*type.Cast<TOptionalExprType>()->GetItemType());
+ case ETypeAnnotationKind::Pg:
+ return ui8(ClampVal(NPg::LookupType(type.Cast<TPgExprType>()->GetId()).TypeLen, 1, 255));
+ default:
+ return 255;
}
}
@@ -1484,12 +1489,14 @@ const TItemExprType* GetLightColumn(const TStructExprType& type) {
ui8 weight = 255;
const TItemExprType* field = nullptr;
for (const auto& item : type.GetItems()) {
-
if (const auto w = GetTypeWeight(*item->GetItemType()); w < weight) {
weight = w;
field = item;
}
}
+ if (const auto& items = type.GetItems(); !items.empty() && !field) {
+ field = items[0];
+ }
return field;
}