aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-01-17 20:04:10 +0300
committervvvv <vvvv@ydb.tech>2023-01-17 20:04:10 +0300
commitc245cd52f603893965b9fc05414d5164b0c90d6a (patch)
tree9b9cdf8f1e0b05257f3a33543c7e3793aceb1a0c
parentde2d8cecd95fea59200d342c690dce4b0357176e (diff)
downloadydb-c245cd52f603893965b9fc05414d5164b0c90d6a.tar.gz
simplify
-rw-r--r--ydb/library/yql/core/type_ann/type_ann_core.cpp35
-rw-r--r--ydb/library/yql/core/yql_type_annotation.h12
2 files changed, 24 insertions, 23 deletions
diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp
index 23a412fc2db..370d4fb6335 100644
--- a/ydb/library/yql/core/type_ann/type_ann_core.cpp
+++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp
@@ -7085,13 +7085,8 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
if (input->ChildrenSize() != 8) {
YQL_PROFILE_SCOPE(DEBUG, "ResolveUdfs");
- auto& cacheItem = ctx.Types.UdfTypeCache[std::make_tuple(TString(name), TString(typeConfig), userType)];
- auto& cachedFuncType = std::get<0>(cacheItem);
- auto& cachedRunConfigType = std::get<1>(cacheItem);
- auto& cachedNormalizedUserType = std::get<2>(cacheItem);
- auto& cachedSupportsBlocks = std::get<3>(cacheItem);
- auto& cachedIsStrict = std::get<4>(cacheItem);
- if (!cachedFuncType) {
+ auto& cached = ctx.Types.UdfTypeCache[std::make_tuple(TString(name), TString(typeConfig), userType)];
+ if (!cached.FunctionType) {
IUdfResolver::TFunction description;
description.Pos = ctx.Expr.GetPosition(input->Pos());
description.Name = TString(name);
@@ -7132,11 +7127,11 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
return IGraphTransformer::TStatus::Error;
}
- cachedFuncType = description.CallableType;
- cachedRunConfigType = description.RunConfigType ? description.RunConfigType : ctx.Expr.MakeType<TVoidExprType>();
- cachedNormalizedUserType = description.UserType ? description.NormalizedUserType : ctx.Expr.MakeType<TVoidExprType>();
- cachedSupportsBlocks = description.SupportsBlocks;
- cachedIsStrict = description.IsStrict;
+ cached.FunctionType = description.CallableType;
+ cached.RunConfigType = description.RunConfigType ? description.RunConfigType : ctx.Expr.MakeType<TVoidExprType>();
+ cached.NormalizedUserType = description.UserType ? description.NormalizedUserType : ctx.Expr.MakeType<TVoidExprType>();
+ cached.SupportsBlocks = description.SupportsBlocks;
+ cached.IsStrict = description.IsStrict;
}
TStringBuf typeConfig = "";
@@ -7144,19 +7139,19 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
typeConfig = input->Child(3)->Content();
}
- const auto callableTypeNode = ExpandType(input->Pos(), *cachedFuncType, ctx.Expr);
- const auto runConfigTypeNode = ExpandType(input->Pos(), *cachedRunConfigType, ctx.Expr);
+ const auto callableTypeNode = ExpandType(input->Pos(), *cached.FunctionType, ctx.Expr);
+ const auto runConfigTypeNode = ExpandType(input->Pos(), *cached.RunConfigType, ctx.Expr);
TExprNode::TPtr runConfigValue;
if (input->ChildrenSize() > 1 && !input->Child(1)->IsCallable("Void")) {
runConfigValue = input->ChildPtr(1);
} else {
- if (cachedRunConfigType->GetKind() == ETypeAnnotationKind::Void) {
+ if (cached.RunConfigType->GetKind() == ETypeAnnotationKind::Void) {
runConfigValue = ctx.Expr.NewCallable(input->Pos(), "Void", {});
- } else if (cachedRunConfigType->GetKind() == ETypeAnnotationKind::Optional) {
+ } else if (cached.RunConfigType->GetKind() == ETypeAnnotationKind::Optional) {
runConfigValue = ctx.Expr.NewCallable(input->Pos(), "Nothing", { runConfigTypeNode });
} else {
ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Pos()), TStringBuilder() << "Missing run config value for type: "
- << *cachedRunConfigType << " in function " << name));
+ << *cached.RunConfigType << " in function " << name));
return IGraphTransformer::TStatus::Error;
}
}
@@ -7167,7 +7162,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
.Callable("Udf")
.Add(0, input->HeadPtr())
.Add(1, runConfigValue)
- .Add(2, ExpandType(input->Pos(), *cachedNormalizedUserType, ctx.Expr))
+ .Add(2, ExpandType(input->Pos(), *cached.NormalizedUserType, ctx.Expr))
.Atom(3, typeConfig)
.Add(4, callableTypeNode)
.Add(5, runConfigTypeNode)
@@ -7175,13 +7170,13 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
.List(7)
.Do([&](TExprNodeBuilder& parent) -> TExprNodeBuilder& {
ui32 settingIndex = 0;
- if (cachedSupportsBlocks) {
+ if (cached.SupportsBlocks) {
parent.List(settingIndex++)
.Atom(0, "blocks")
.Seal();
}
- if (cachedIsStrict) {
+ if (cached.IsStrict) {
parent.List(settingIndex++)
.Atom(0, "strict")
.Seal();
diff --git a/ydb/library/yql/core/yql_type_annotation.h b/ydb/library/yql/core/yql_type_annotation.h
index ce3ab9de267..d52837bd4da 100644
--- a/ydb/library/yql/core/yql_type_annotation.h
+++ b/ydb/library/yql/core/yql_type_annotation.h
@@ -168,6 +168,14 @@ enum class EHiddenMode {
Auto /* "auto" */
};
+struct TUdfCachedInfo {
+ const TTypeAnnotationNode* FunctionType = nullptr;
+ const TTypeAnnotationNode* RunConfigType = nullptr;
+ const TTypeAnnotationNode* NormalizedUserType = nullptr;
+ bool SupportsBlocks = false;
+ bool IsStrict = false;
+};
+
struct TTypeAnnotationContext: public TThrRefBase {
TIntrusivePtr<ITimeProvider> TimeProvider;
TIntrusivePtr<IRandomProvider> RandomProvider;
@@ -206,9 +214,7 @@ struct TTypeAnnotationContext: public TThrRefBase {
ui32 EvaluateOrderByColumnLimit = 100;
bool PullUpFlatMapOverJoin = true;
bool DeprecatedSQL = false;
- THashMap<std::tuple<TString, TString, const TTypeAnnotationNode*>,
- std::tuple<const TTypeAnnotationNode*, const TTypeAnnotationNode*, const TTypeAnnotationNode*, bool, bool>>
- UdfTypeCache; // (name,typecfg,type)->(type,run config type,new user type, blocks, strict)
+ THashMap<std::tuple<TString, TString, const TTypeAnnotationNode*>, TUdfCachedInfo> UdfTypeCache; // (name,typecfg,type)->info
bool UseTableMetaFromGraph = false;
bool DiscoveryMode = false;
bool ForceDq = false;