diff options
author | galaxycrab <UgnineSirdis@ydb.tech> | 2022-10-06 13:27:00 +0300 |
---|---|---|
committer | galaxycrab <UgnineSirdis@ydb.tech> | 2022-10-06 13:27:00 +0300 |
commit | 2fe2ca32ad3db605707d9dd760b3a2482ba1c3cf (patch) | |
tree | 121fa84b70fabb79315a6baf69115f209fafaa6f | |
parent | a9fdd4fb908d14a055b3a536c523d679391a70b3 (diff) | |
download | ydb-2fe2ca32ad3db605707d9dd760b3a2482ba1c3cf.tar.gz |
Fix COUNT(*) for tables with pg types
-rw-r--r-- | ydb/library/yql/core/yql_opt_utils.cpp | 13 |
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; } |