diff options
author | udovichenko-r <rvu@ydb.tech> | 2023-01-13 18:24:55 +0300 |
---|---|---|
committer | udovichenko-r <rvu@ydb.tech> | 2023-01-13 18:24:55 +0300 |
commit | 8282110d4614b266f126a483959c2369ded6d738 (patch) | |
tree | 8ce91b9b406333e7a935339dbf1238674dfbe916 | |
parent | 657681dd6711ffd594a272b9bd92208250f4a7be (diff) | |
download | ydb-8282110d4614b266f126a483959c2369ded6d738.tar.gz |
[yql] Provider specific validation of execution
5 files changed, 31 insertions, 0 deletions
diff --git a/ydb/library/yql/core/yql_data_provider.h b/ydb/library/yql/core/yql_data_provider.h index 42d87d691f..ac606ffcb5 100644 --- a/ydb/library/yql/core/yql_data_provider.h +++ b/ydb/library/yql/core/yql_data_provider.h @@ -150,6 +150,7 @@ public: //-- execution virtual bool CanExecute(const TExprNode& node) = 0; + virtual bool ValidateExecution(const TExprNode& node, TExprContext& ctx) = 0; virtual void GetRequiredChildren(const TExprNode& node, TExprNode::TListType& children) = 0; virtual IGraphTransformer& GetCallableExecutionTransformer() = 0; diff --git a/ydb/library/yql/core/yql_execution.cpp b/ydb/library/yql/core/yql_execution.cpp index af607a7527..1c4fe1b60d 100644 --- a/ydb/library/yql/core/yql_execution.cpp +++ b/ydb/library/yql/core/yql_execution.cpp @@ -762,6 +762,10 @@ IGraphTransformer::TStatus ValidateCallable(const TExprNode::TPtr& node, TExprCo return TStatus::Error; } + if (!dataProvider->ValidateExecution(*node, ctx)) { + return TStatus::Error; + } + TExprNode::TListType childrenToCheck; dataProvider->GetRequiredChildren(*node, childrenToCheck); IGraphTransformer::TStatus combinedStatus = IGraphTransformer::TStatus::Ok; diff --git a/ydb/library/yql/providers/common/provider/yql_data_provider_impl.cpp b/ydb/library/yql/providers/common/provider/yql_data_provider_impl.cpp index c8187623fe..279d11ad51 100644 --- a/ydb/library/yql/providers/common/provider/yql_data_provider_impl.cpp +++ b/ydb/library/yql/providers/common/provider/yql_data_provider_impl.cpp @@ -244,6 +244,12 @@ bool TDataProviderBase::CanExecute(const TExprNode& node) { return false; } +bool TDataProviderBase::ValidateExecution(const TExprNode& node, TExprContext& ctx) { + Y_UNUSED(node); + Y_UNUSED(ctx); + return true; +} + void TDataProviderBase::GetRequiredChildren(const TExprNode& node, TExprNode::TListType& children) { TPlanFormatterBase::GetDependencies(node, children, false); } diff --git a/ydb/library/yql/providers/common/provider/yql_data_provider_impl.h b/ydb/library/yql/providers/common/provider/yql_data_provider_impl.h index a102d0a423..afdaa46509 100644 --- a/ydb/library/yql/providers/common/provider/yql_data_provider_impl.h +++ b/ydb/library/yql/providers/common/provider/yql_data_provider_impl.h @@ -72,6 +72,7 @@ public: TExprNode::TPtr OptimizePull(const TExprNode::TPtr& source, const TFillSettings& fillSettings, TExprContext& ctx, IOptimizationContext& optCtx) override; bool CanExecute(const TExprNode& node) override; + bool ValidateExecution(const TExprNode& node, TExprContext& ctx) override; void GetRequiredChildren(const TExprNode& node, TExprNode::TListType& children) override; IGraphTransformer& GetCallableExecutionTransformer() override; IGraphTransformer& GetFinalizingTransformer() override; diff --git a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp index 3074c37559..4a73bffcfa 100644 --- a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp +++ b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp @@ -1385,6 +1385,25 @@ namespace { return false; } + bool ValidateExecution(const TExprNode& node, TExprContext& ctx) override { + auto getDataProvider = [&]() { + auto provider = Config->Types.DataSourceMap.FindPtr(node.Child(5)->Content()); + Y_ENSURE(provider, "DataSource doesn't exist: " << node.Child(5)->Content()); + return *provider; + }; + + if (TResTransientBase::Match(&node)) { + return getDataProvider()->ValidateExecution(TResTransientBase(&node).Data().Ref(), ctx); + } + if (TResIf::Match(&node)) { + return getDataProvider()->ValidateExecution(TResIf(&node).Condition().Ref(), ctx); + } + if (TResFor::Match(&node)) { + return getDataProvider()->ValidateExecution(TResFor(&node).Items().Ref(), ctx); + } + return true; + } + IGraphTransformer& GetCallableExecutionTransformer() override { if (!CallableExecutionTransformer) { CallableExecutionTransformer = new TResultCallableExecutionTransformer(Config); |