diff options
author | vvvv <vvvv@yandex-team.com> | 2024-12-09 14:29:21 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.com> | 2024-12-09 14:45:05 +0300 |
commit | cd83d367ca7edd078dd5eb9a97fda32212b5f3e8 (patch) | |
tree | 23e739e9fe607edf8858aaa6c786e66a947e1977 | |
parent | d4510c40056498c21c4185bc678c4eed3ab89cea (diff) | |
download | ydb-cd83d367ca7edd078dd5eb9a97fda32212b5f3e8.tar.gz |
Introduced two stages mode for type annotation, a FailMe callable to simulate optimization failures
В обычном select 1 \|\| 2 теперь выдается ошибка в InitialTypeAnnotation stage
А ошибка на RepeatTypeAnnotation stage эскалируется до Severity=Fatal
commit_hash:fb09693b4baf9e14bfe7dae9a8a9cd4b9e0e0142
41 files changed, 358 insertions, 61 deletions
diff --git a/yql/essentials/core/common_opt/yql_co_simple1.cpp b/yql/essentials/core/common_opt/yql_co_simple1.cpp index 76c39f5f82..06107c3bfd 100644 --- a/yql/essentials/core/common_opt/yql_co_simple1.cpp +++ b/yql/essentials/core/common_opt/yql_co_simple1.cpp @@ -6786,6 +6786,39 @@ void RegisterCoSimpleCallables1(TCallableOptimizerMap& map) { return node; }; + map["FailMe"] = [](const TExprNode::TPtr& node, TExprContext& ctx, TOptimizeContext& /*optCtx*/) { + YQL_CLOG(DEBUG, Core) << "Expand FailMe"; + auto failureKind = node->Child(0)->Content(); + if (failureKind == "expr") { + return ctx.Builder(node->Pos()) + .Callable("String") + .Atom(0, "foo") + .Atom(1, "bar") + .Seal() + .Build(); + } + + if (failureKind == "type") { + return ctx.Builder(node->Pos()) + .Callable("Int32") + .Atom(0, "1") + .Seal() + .Build(); + } + + if (failureKind == "constraint") { + return ctx.Builder(node->Pos()) + .Callable("AsList") + .Callable(0, "String") + .Atom(0, "foo") + .Seal() + .Seal() + .Build(); + } + + throw yexception() << "Unknown failure kind: " << failureKind; + }; + // will be applied to any callable after all above map[""] = [](const TExprNode::TPtr& node, TExprContext& ctx, TOptimizeContext& optCtx) { YQL_ENSURE(node->IsCallable()); diff --git a/yql/essentials/core/facade/yql_facade.cpp b/yql/essentials/core/facade/yql_facade.cpp index 94309e2148..3b342a60e8 100644 --- a/yql/essentials/core/facade/yql_facade.cpp +++ b/yql/essentials/core/facade/yql_facade.cpp @@ -874,7 +874,7 @@ TProgram::TFutureStatus TProgram::LineageAsync(const TString& username, IOutputS .AddPreTypeAnnotation() .AddExpressionEvaluation(*FunctionRegistry_) .AddIOAnnotation() - .AddTypeAnnotation() + .AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true) .AddPostTypeAnnotation() .Add(TExprOutputTransformer::Sync(ExprRoot_, traceOut), "ExprOutput") .AddCheckExecution(false) @@ -937,7 +937,7 @@ TProgram::TFutureStatus TProgram::ValidateAsync(const TString& username, IOutput .AddPreTypeAnnotation() .AddExpressionEvaluation(*FunctionRegistry_) .AddIOAnnotation() - .AddTypeAnnotation() + .AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true) .Add(TExprOutputTransformer::Sync(ExprRoot_, exprOut, withTypes), "AstOutput") .Build(); @@ -1012,7 +1012,7 @@ TProgram::TFutureStatus TProgram::OptimizeAsync( .AddPreTypeAnnotation() .AddExpressionEvaluation(*FunctionRegistry_) .AddIOAnnotation() - .AddTypeAnnotation() + .AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true) .AddPostTypeAnnotation() .Add(TExprOutputTransformer::Sync(ExprRoot_, traceOut), "ExprOutput") .AddOptimization() @@ -1080,7 +1080,7 @@ TProgram::TFutureStatus TProgram::OptimizeAsyncWithConfig( pipeline.AddPreTypeAnnotation(); pipeline.AddExpressionEvaluation(*FunctionRegistry_); pipeline.AddIOAnnotation(); - pipeline.AddTypeAnnotation(); + pipeline.AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true); pipeline.AddPostTypeAnnotation(); pipelineConf.AfterTypeAnnotation(&pipeline); @@ -1139,7 +1139,7 @@ TProgram::TFutureStatus TProgram::LineageAsyncWithConfig( pipeline.AddPreTypeAnnotation(); pipeline.AddExpressionEvaluation(*FunctionRegistry_); pipeline.AddIOAnnotation(); - pipeline.AddTypeAnnotation(); + pipeline.AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true); pipeline.AddPostTypeAnnotation(); pipelineConf.AfterTypeAnnotation(&pipeline); @@ -1220,7 +1220,7 @@ TProgram::TFutureStatus TProgram::RunAsync( pipeline.AddPreTypeAnnotation(); pipeline.AddExpressionEvaluation(*FunctionRegistry_); pipeline.AddIOAnnotation(); - pipeline.AddTypeAnnotation(); + pipeline.AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true); pipeline.AddPostTypeAnnotation(); pipeline.Add(TExprOutputTransformer::Sync(ExprRoot_, traceOut), "ExprOutput"); pipeline.AddOptimization(); @@ -1297,7 +1297,7 @@ TProgram::TFutureStatus TProgram::RunAsyncWithConfig( pipeline.AddPreTypeAnnotation(); pipeline.AddExpressionEvaluation(*FunctionRegistry_); pipeline.AddIOAnnotation(); - pipeline.AddTypeAnnotation(); + pipeline.AddTypeAnnotation(TIssuesIds::CORE_TYPE_ANN, true); pipeline.AddPostTypeAnnotation(); pipelineConf.AfterTypeAnnotation(&pipeline); @@ -1711,6 +1711,7 @@ TIssues TProgram::Issues() const { result.AddIssues(ExprCtx_->IssueManager.GetIssues()); } result.AddIssues(FinalIssues_); + CheckFatalIssues(result); return result; } @@ -1720,9 +1721,53 @@ TIssues TProgram::CompletedIssues() const { result.AddIssues(ExprCtx_->IssueManager.GetCompletedIssues()); } result.AddIssues(FinalIssues_); + CheckFatalIssues(result); return result; } +void TProgram::CheckFatalIssues(TIssues& issues) const { + bool isFatal = false; + auto checkIssue = [&](const TIssue& issue) { + if (issue.GetSeverity() == TSeverityIds::S_FATAL) { + isFatal = true; + } + }; + + std::function<void(const TIssuePtr& issue)> recursiveCheck = [&](const TIssuePtr& issue) { + if (isFatal) { + return; + } + + checkIssue(*issue); + for (const auto& subissue : issue->GetSubIssues()) { + recursiveCheck(subissue); + } + }; + + for (const auto& issue : issues) { + if (isFatal) { + break; + } + + checkIssue(issue); + // check subissues + for (const auto& subissue : issue.GetSubIssues()) { + recursiveCheck(subissue); + } + } + + if (isFatal) { + TIssue result; + result.SetMessage( + TStringBuilder() + << "An abnormal situation found, so consider opening a bug report to YQL (st/YQLSUPPORT)," + << " because more detailed information is only available in server side logs and/or " + << "coredumps."); + result.SetCode(TIssuesIds::UNEXPECTED, TSeverityIds::S_FATAL); + issues.AddIssue(result); + } +} + TIssue MakeNoBlocksInfoIssue(const TVector<TString>& names, bool isTypes) { TIssue result; TString msg = TStringBuilder() << "Most frequent " << (isTypes ? "types " : "callables ") diff --git a/yql/essentials/core/facade/yql_facade.h b/yql/essentials/core/facade/yql_facade.h index 23aa2bd2b4..eacbe1aa44 100644 --- a/yql/essentials/core/facade/yql_facade.h +++ b/yql/essentials/core/facade/yql_facade.h @@ -375,6 +375,7 @@ private: private: std::optional<bool> CheckFallbackIssues(const TIssues& issues); + void CheckFatalIssues(TIssues& issues) const; void HandleSourceCode(TString& sourceCode); void HandleTranslationSettings(NSQLTranslation::TTranslationSettings& loadedSettings, const NSQLTranslation::TTranslationSettings*& currentSettings); diff --git a/yql/essentials/core/issue/protos/issue_id.proto b/yql/essentials/core/issue/protos/issue_id.proto index 688a471afb..b8ae30b8f4 100644 --- a/yql/essentials/core/issue/protos/issue_id.proto +++ b/yql/essentials/core/issue/protos/issue_id.proto @@ -46,6 +46,7 @@ message TIssuesIds { // core errors CORE_GC_NODES_LIMIT_EXCEEDED = 1500; CORE_GC_STRINGS_LIMIT_EXCEEDED = 1501; + CORE_RUNTIME_ERROR = 1502; // kikimr KIKIMR_LOCKS_INVALIDATED = 2001; diff --git a/yql/essentials/core/issue/yql_issue.txt b/yql/essentials/core/issue/yql_issue.txt index 148363532c..c5be249510 100644 --- a/yql/essentials/core/issue/yql_issue.txt +++ b/yql/essentials/core/issue/yql_issue.txt @@ -128,6 +128,10 @@ ids { severity: S_ERROR } ids { + code: CORE_RUNTIME_ERROR + severity: S_ERROR +} +ids { code: KIKIMR_LOCKS_INVALIDATED severity: S_ERROR format: "Transaction locks invalidated." diff --git a/yql/essentials/core/services/yql_transform_pipeline.cpp b/yql/essentials/core/services/yql_transform_pipeline.cpp index 9a52515b0e..427801fc6b 100644 --- a/yql/essentials/core/services/yql_transform_pipeline.cpp +++ b/yql/essentials/core/services/yql_transform_pipeline.cpp @@ -106,8 +106,8 @@ TTransformationPipeline& TTransformationPipeline::AddIOAnnotation(bool withEpoch return *this; } -TTransformationPipeline& TTransformationPipeline::AddTypeAnnotation(EYqlIssueCode issueCode) { - AddTypeAnnotationTransformer(); +TTransformationPipeline& TTransformationPipeline::AddTypeAnnotation(EYqlIssueCode issueCode, bool twoStages) { + AddTypeAnnotationTransformer(issueCode, twoStages); Transformers_.push_back(TTransformStage( CreateFunctorTransformer(&CheckWholeProgramType), "CheckWholeProgramType", issueCode)); @@ -235,19 +235,42 @@ TTransformationPipeline& TTransformationPipeline::AddTableMetadataLoaderTransfor } TTransformationPipeline& TTransformationPipeline::AddTypeAnnotationTransformer( - TAutoPtr<IGraphTransformer> callableTransformer, EYqlIssueCode issueCode) + TAutoPtr<IGraphTransformer> callableTransformer, EYqlIssueCode issueCode, ETypeCheckMode mode) { + TString stageName; + TString issue; + switch (mode) { + case ETypeCheckMode::Single: + stageName = "TypeAnnotation"; + issue = "Type annotation"; + break; + case ETypeCheckMode::Initial: + stageName = "InitialTypeAnnotation"; + issue = "Type annotation"; + break; + case ETypeCheckMode::Repeat: + stageName = "RepeatTypeAnnotation"; + issue = "Type annotation (repeat)"; + break; + } + Transformers_.push_back(TTransformStage( - CreateTypeAnnotationTransformer(callableTransformer, *TypeAnnotationContext_), - "TypeAnnotation", - issueCode)); + CreateTypeAnnotationTransformer(callableTransformer, *TypeAnnotationContext_, mode), stageName, issueCode, issue)); return *this; } -TTransformationPipeline& TTransformationPipeline::AddTypeAnnotationTransformer(EYqlIssueCode issueCode) +TTransformationPipeline& TTransformationPipeline::AddTypeAnnotationTransformer(EYqlIssueCode issueCode, bool twoStages) { - auto callableTransformer = CreateExtCallableTypeAnnotationTransformer(*TypeAnnotationContext_); - return AddTypeAnnotationTransformer(callableTransformer, issueCode); + if (twoStages) { + std::shared_ptr<IGraphTransformer> callableTransformer(CreateExtCallableTypeAnnotationTransformer(*TypeAnnotationContext_).Release()); + AddTypeAnnotationTransformer(MakeSharedTransformerProxy(callableTransformer), issueCode, ETypeCheckMode::Initial); + AddTypeAnnotationTransformer(MakeSharedTransformerProxy(callableTransformer), issueCode, ETypeCheckMode::Repeat); + } else { + auto callableTransformer = CreateExtCallableTypeAnnotationTransformer(*TypeAnnotationContext_); + AddTypeAnnotationTransformer(callableTransformer, issueCode, ETypeCheckMode::Single); + } + + return *this; } TAutoPtr<IGraphTransformer> TTransformationPipeline::Build(bool useIssueScopes) { diff --git a/yql/essentials/core/services/yql_transform_pipeline.h b/yql/essentials/core/services/yql_transform_pipeline.h index 928e56a236..d21290e2a5 100644 --- a/yql/essentials/core/services/yql_transform_pipeline.h +++ b/yql/essentials/core/services/yql_transform_pipeline.h @@ -4,6 +4,7 @@ #include <yql/essentials/core/yql_type_annotation.h> #include <yql/essentials/core/yql_execution.h> #include <yql/essentials/core/issue/yql_issue.h> +#include <yql/essentials/core/type_ann/type_ann_expr.h> #include <util/generic/ptr.h> @@ -29,7 +30,7 @@ public: IGraphTransformer* calcTransfomer = nullptr, EYqlIssueCode issueCode = TIssuesIds::CORE_EXPR_EVALUATION); TTransformationPipeline& AddPreIOAnnotation(bool withEpochsTransformer = true, EYqlIssueCode issueCode = TIssuesIds::CORE_PRE_TYPE_ANN); TTransformationPipeline& AddIOAnnotation(bool withEpochsTransformer = true, EYqlIssueCode issueCode = TIssuesIds::CORE_PRE_TYPE_ANN); - TTransformationPipeline& AddTypeAnnotation(EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN); + TTransformationPipeline& AddTypeAnnotation(EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN, bool twoStages = false); TTransformationPipeline& AddPostTypeAnnotation(bool forSubGraph = false, bool disableConstraintCheck = false, EYqlIssueCode issueCode = TIssuesIds::CORE_POST_TYPE_ANN); TTransformationPipeline& AddCommonOptimization(EYqlIssueCode issueCode = TIssuesIds::CORE_OPTIMIZATION); TTransformationPipeline& AddFinalCommonOptimization(EYqlIssueCode issueCode = TIssuesIds::CORE_OPTIMIZATION); @@ -40,8 +41,9 @@ public: TTransformationPipeline& AddIntentDeterminationTransformer(EYqlIssueCode issueCode = TIssuesIds::CORE_INTENT); TTransformationPipeline& AddTableMetadataLoaderTransformer(EYqlIssueCode issueCode = TIssuesIds::CORE_TABLE_METADATA_LOADER); - TTransformationPipeline& AddTypeAnnotationTransformer(TAutoPtr<IGraphTransformer> callableTransformer, EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN); - TTransformationPipeline& AddTypeAnnotationTransformer(EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN); + TTransformationPipeline& AddTypeAnnotationTransformer(TAutoPtr<IGraphTransformer> callableTransformer, EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN, + ETypeCheckMode mode = ETypeCheckMode::Single); + TTransformationPipeline& AddTypeAnnotationTransformer(EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN, bool twoStages = false); TTransformationPipeline& Add(TAutoPtr<IGraphTransformer> transformer, const TString& stageName, EYqlIssueCode issueCode = TIssuesIds::DEFAULT_ERROR, const TString& issueMessage = {}); diff --git a/yql/essentials/core/type_ann/type_ann_core.cpp b/yql/essentials/core/type_ann/type_ann_core.cpp index 8dd928d4aa..4b8f9c63b9 100644 --- a/yql/essentials/core/type_ann/type_ann_core.cpp +++ b/yql/essentials/core/type_ann/type_ann_core.cpp @@ -579,6 +579,30 @@ namespace NTypeAnnImpl { return IGraphTransformer::TStatus::Ok; } + IGraphTransformer::TStatus FailMeWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx) { + if (!EnsureArgsCount(*input, 1, ctx.Expr)) { + return IGraphTransformer::TStatus::Error; + } + + if (!EnsureAtom(*input->Child(0), ctx.Expr)) { + return IGraphTransformer::TStatus::Error; + } + + auto failureKind = input->Child(0)->Content(); + if (failureKind == "expr") { + input->SetTypeAnn(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String)); + } else if (failureKind == "type") { + input->SetTypeAnn(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String)); + } else if (failureKind == "constraint") { + input->SetTypeAnn(ctx.Expr.MakeType<TListExprType>(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String))); + } else { + ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Child(0)->Pos()), TStringBuilder() << "Unknown failure kind: " << failureKind)); + return IGraphTransformer::TStatus::Error; + } + + return IGraphTransformer::TStatus::Ok; + } + IGraphTransformer::TStatus DataWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx) { if (!EnsureArgsCount(*input, 2, ctx.Expr)) { return IGraphTransformer::TStatus::Error; @@ -12197,6 +12221,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot> } TSyncFunctionsMap::TSyncFunctionsMap() { + Functions["FailMe"] = &FailMeWrapper; Functions["Data"] = &DataWrapper; Functions["DataOrOptionalData"] = &DataWrapper; Functions["DataSource"] = &DataSourceWrapper; diff --git a/yql/essentials/core/type_ann/type_ann_core.h b/yql/essentials/core/type_ann/type_ann_core.h index 4a0199d9a8..c97577e2f2 100644 --- a/yql/essentials/core/type_ann/type_ann_core.h +++ b/yql/essentials/core/type_ann/type_ann_core.h @@ -12,7 +12,9 @@ IGraphTransformer::TStatus ValidateDataSink(const TExprNode::TPtr& node, TExprCo IGraphTransformer::TStatus ValidateProviders(const TExprNode::TPtr& node, TExprNode::TPtr& output, TExprContext& ctx, const TTypeAnnotationContext& types); TAutoPtr<IGraphTransformer> CreateIntentDeterminationTransformer(const TTypeAnnotationContext& types); -TAutoPtr<IGraphTransformer> CreateExtCallableTypeAnnotationTransformer(TTypeAnnotationContext& types, bool instantOnly = false); + +TAutoPtr<IGraphTransformer> CreateExtCallableTypeAnnotationTransformer(TTypeAnnotationContext& types, + bool instantOnly = false); const THashSet<TString>& GetBuiltinFunctions(); diff --git a/yql/essentials/core/type_ann/type_ann_expr.cpp b/yql/essentials/core/type_ann/type_ann_expr.cpp index 2c19236af6..8b213a0431 100644 --- a/yql/essentials/core/type_ann/type_ann_expr.cpp +++ b/yql/essentials/core/type_ann/type_ann_expr.cpp @@ -17,9 +17,11 @@ constexpr bool PrintCallableTimes = false; class TTypeAnnotationTransformer : public TGraphTransformerBase { public: - TTypeAnnotationTransformer(TAutoPtr<IGraphTransformer> callableTransformer, TTypeAnnotationContext& types) + TTypeAnnotationTransformer(TAutoPtr<IGraphTransformer> callableTransformer, TTypeAnnotationContext& types, + ETypeCheckMode mode) : CallableTransformer(callableTransformer) , Types(types) + , Mode(mode) { } @@ -43,6 +45,10 @@ public: TStatus DoTransform(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) final { YQL_PROFILE_SCOPE(DEBUG, "TypeAnnotationTransformer::DoTransform"); output = input; + if (Mode == ETypeCheckMode::Initial && IsComplete) { + return TStatus::Ok; + } + auto status = TransformNode(input, output, ctx); UpdateStatusIfChanged(status, input, output); if (status.Level != TStatus::Ok) { @@ -60,6 +66,14 @@ public: } HasRenames = false; + if (Mode == ETypeCheckMode::Initial && status == TStatus::Ok) { + IsComplete = true; + } + + if (Mode == ETypeCheckMode::Repeat && status == TStatus::Error) { + throw yexception() << "Detected a type error after initial validation"; + } + return status; } @@ -107,6 +121,7 @@ public: RepeatCallableCount.clear(); CurrentFunctions = {}; CallableTimes.clear(); + IsComplete = false; } @@ -547,6 +562,8 @@ private: private: TAutoPtr<IGraphTransformer> CallableTransformer; TTypeAnnotationContext& Types; + const ETypeCheckMode Mode; + bool IsComplete = false; TDeque<TExprNode::TPtr> CallableInputs; TNodeOnNodeOwnedMap Processed; bool HasRenames = false; @@ -569,8 +586,8 @@ IGraphTransformer::TStatus CheckWholeProgramType(const TExprNode::TPtr& input, T } TAutoPtr<IGraphTransformer> CreateTypeAnnotationTransformer(TAutoPtr<IGraphTransformer> callableTransformer, - TTypeAnnotationContext& types) { - return new TTypeAnnotationTransformer(callableTransformer, types); + TTypeAnnotationContext& types, ETypeCheckMode mode) { + return new TTypeAnnotationTransformer(callableTransformer, types, mode); } TAutoPtr<IGraphTransformer> CreateFullTypeAnnotationTransformer( @@ -637,11 +654,12 @@ TAutoPtr<IGraphTransformer> CreateFullTypeAnnotationTransformer( issueCode = TIssuesIds::CORE_TYPE_ANN; auto callableTransformer = CreateExtCallableTypeAnnotationTransformer(typeAnnotationContext); - auto typeTransformer = CreateTypeAnnotationTransformer(callableTransformer, typeAnnotationContext); + auto typeTransformer = CreateTypeAnnotationTransformer(callableTransformer, typeAnnotationContext, ETypeCheckMode::Single); transformers.push_back(TTransformStage( typeTransformer, "TypeAnnotation", issueCode)); + if (wholeProgram) { transformers.push_back(TTransformStage( CreateFunctorTransformer(&CheckWholeProgramType), @@ -685,8 +703,8 @@ TExprNode::TPtr ParseAndAnnotate( } const bool annotated = instant - ? InstantAnnotateTypes(exprRoot, exprCtx, wholeProgram, typeAnnotationContext) - : SyncAnnotateTypes(exprRoot, exprCtx, wholeProgram, typeAnnotationContext); + ? InstantAnnotateTypes(exprRoot, exprCtx, wholeProgram, typeAnnotationContext) + : SyncAnnotateTypes(exprRoot, exprCtx, wholeProgram, typeAnnotationContext); if (!annotated) { return nullptr; } diff --git a/yql/essentials/core/type_ann/type_ann_expr.h b/yql/essentials/core/type_ann/type_ann_expr.h index 88581d9dde..5b9c072a61 100644 --- a/yql/essentials/core/type_ann/type_ann_expr.h +++ b/yql/essentials/core/type_ann/type_ann_expr.h @@ -8,8 +8,15 @@ namespace NYql { +enum class ETypeCheckMode { + Single, + Initial, + Repeat +}; + TAutoPtr<IGraphTransformer> CreateTypeAnnotationTransformer( - TAutoPtr<IGraphTransformer> callableTransformer, TTypeAnnotationContext& types); + TAutoPtr<IGraphTransformer> callableTransformer, TTypeAnnotationContext& types, + ETypeCheckMode mode = ETypeCheckMode::Single); TAutoPtr<IGraphTransformer> CreateFullTypeAnnotationTransformer(bool instant, bool wholeProgram, TTypeAnnotationContext& types); diff --git a/yql/essentials/core/yql_expr_constraint.cpp b/yql/essentials/core/yql_expr_constraint.cpp index aa57aecb71..3782544df1 100644 --- a/yql/essentials/core/yql_expr_constraint.cpp +++ b/yql/essentials/core/yql_expr_constraint.cpp @@ -79,6 +79,7 @@ public: : TCallableTransformerBase<TCallableConstraintTransformer>(types, instantOnly) , SubGraph(subGraph) { + Functions["FailMe"] = &TCallableConstraintTransformer::FailMe; Functions["Unordered"] = &TCallableConstraintTransformer::FromFirst<TEmptyConstraintNode, TUniqueConstraintNode, TDistinctConstraintNode, TVarIndexConstraintNode, TMultiConstraintNode>; Functions["UnorderedSubquery"] = &TCallableConstraintTransformer::FromFirst<TEmptyConstraintNode, TUniqueConstraintNode, TDistinctConstraintNode, TVarIndexConstraintNode, TMultiConstraintNode>; Functions["Sort"] = &TCallableConstraintTransformer::SortWrap; @@ -327,6 +328,14 @@ private: return TStatus::Ok; } + TStatus FailMe(const TExprNode::TPtr& input, TExprNode::TPtr& /*output*/, TExprContext& ctx) const { + if (input->Child(0)->Content() == "constraint") { + input->AddConstraint(ctx.MakeConstraint<TEmptyConstraintNode>()); + } + + return TStatus::Ok; + } + TStatus EmptyFromWrap(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx) const { auto set = input->Head().GetConstraintSet(); set.RemoveConstraint(TEmptyConstraintNode::Name()); diff --git a/yql/essentials/core/yql_graph_transformer.cpp b/yql/essentials/core/yql_graph_transformer.cpp index 5248ee1597..139f8b15b8 100644 --- a/yql/essentials/core/yql_graph_transformer.cpp +++ b/yql/essentials/core/yql_graph_transformer.cpp @@ -7,6 +7,36 @@ namespace NYql { namespace { +class TSharedTransformerProxy : public IGraphTransformer { +public: + TSharedTransformerProxy(const std::shared_ptr<IGraphTransformer>& inner) + : Inner_(inner) + {} + + TStatus Transform(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) { + return Inner_->Transform(input, output, ctx); + } + + NThreading::TFuture<void> GetAsyncFuture(const TExprNode& input) { + return Inner_->GetAsyncFuture(input); + } + + TStatus ApplyAsyncChanges(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) { + return Inner_->ApplyAsyncChanges(input, output, ctx); + } + + void Rewind() final { + return Inner_->Rewind(); + } + + TStatistics GetStatistics() const final { + return Inner_->GetStatistics(); + } + +private: + const std::shared_ptr<IGraphTransformer> Inner_; +}; + class TCompositeGraphTransformer : public TGraphTransformerBase { public: TCompositeGraphTransformer(const TVector<TTransformStage>& stages, bool useIssueScopes, bool doCheckArguments) @@ -219,6 +249,10 @@ private: } // namespace +TAutoPtr<IGraphTransformer> MakeSharedTransformerProxy(const std::shared_ptr<IGraphTransformer>& inner) { + return new TSharedTransformerProxy(inner); +} + TAutoPtr<IGraphTransformer> CreateChoiceGraphTransformer( const std::function<bool(const TExprNode::TPtr& input, TExprContext& ctx)>& condition, const TTransformStage& left, const TTransformStage& right) diff --git a/yql/essentials/core/yql_graph_transformer.h b/yql/essentials/core/yql_graph_transformer.h index d216761589..a86187e79d 100644 --- a/yql/essentials/core/yql_graph_transformer.h +++ b/yql/essentials/core/yql_graph_transformer.h @@ -188,6 +188,8 @@ private: TInstant AsyncStart_; }; +TAutoPtr<IGraphTransformer> MakeSharedTransformerProxy(const std::shared_ptr<IGraphTransformer>& inner); + struct TTransformStage { TString Name; EYqlIssueCode IssueCode; diff --git a/yql/essentials/minikql/computation/mkql_value_builder.cpp b/yql/essentials/minikql/computation/mkql_value_builder.cpp index db44ce4066..e0bda9dd04 100644 --- a/yql/essentials/minikql/computation/mkql_value_builder.cpp +++ b/yql/essentials/minikql/computation/mkql_value_builder.cpp @@ -49,7 +49,7 @@ void TDefaultValueBuilder::Terminate(const char* message) const { } Rethrow_ = true; - ythrow yexception() << fullMessage; + throw TTerminateException() << fullMessage; } Cerr << fullMessage << Flush; @@ -239,7 +239,7 @@ void TDefaultValueBuilder::ExportArrowBlock(NUdf::TUnboxedValuePod value, ui32 c } NUdf::TUnboxedValue TDefaultValueBuilder::ImportArrowBlock(ArrowArray* arrays, ui32 chunkCount, bool isScalar, const NUdf::IArrowType& type) const { - const auto dataType = static_cast<const TArrowType&>(type).GetType(); + const auto dataType = static_cast<const TArrowType&>(type).GetType(); if (isScalar) { if (chunkCount != 1) { UdfTerminate("Bad chunkCount value"); diff --git a/yql/essentials/minikql/mkql_terminator.cpp b/yql/essentials/minikql/mkql_terminator.cpp index b2f9e0ca7f..a889d76d0a 100644 --- a/yql/essentials/minikql/mkql_terminator.cpp +++ b/yql/essentials/minikql/mkql_terminator.cpp @@ -1,12 +1,18 @@ #include "defs.h" #include "mkql_terminator.h" +#include <yql/essentials/core/issue/yql_issue.h> + #include <util/string/builder.h> namespace NKikimr { namespace NMiniKQL { +TTerminateException::TTerminateException() + : TErrorException(NYql::EYqlIssueCode::TIssuesIds_EIssueCode_CORE_RUNTIME_ERROR) +{} + thread_local ITerminator* TBindTerminator::Terminator = nullptr; TBindTerminator::TBindTerminator(ITerminator* terminator) @@ -29,7 +35,7 @@ void TThrowingBindTerminator::Terminate(const char* message) const { TStringBuf reason = (message ? TStringBuf(message) : TStringBuf("(unknown)")); TString fullMessage = TStringBuilder() << "Terminate was called, reason(" << reason.size() << "): " << reason << Endl; - ythrow yexception() << fullMessage; + ythrow TTerminateException() << fullMessage; } TOnlyThrowingBindTerminator::TOnlyThrowingBindTerminator() @@ -38,7 +44,7 @@ TOnlyThrowingBindTerminator::TOnlyThrowingBindTerminator() } void TOnlyThrowingBindTerminator::Terminate(const char* message) const { - ythrow yexception() << message; + ythrow TTerminateException() << message; } diff --git a/yql/essentials/minikql/mkql_terminator.h b/yql/essentials/minikql/mkql_terminator.h index a3655e3b57..3bfaa3f20b 100644 --- a/yql/essentials/minikql/mkql_terminator.h +++ b/yql/essentials/minikql/mkql_terminator.h @@ -3,10 +3,18 @@ #include <util/generic/noncopyable.h> #include <util/system/compiler.h> +#include <yql/essentials/public/issue/yql_issue.h> namespace NKikimr { namespace NMiniKQL { + +class TTerminateException : public NYql::TErrorException +{ +public: + TTerminateException(); +}; + /////////////////////////////////////////////////////////////////////////////// // ITerminator /////////////////////////////////////////////////////////////////////////////// diff --git a/yql/essentials/minikql/ya.make b/yql/essentials/minikql/ya.make index 5976632607..b308132cb9 100644 --- a/yql/essentials/minikql/ya.make +++ b/yql/essentials/minikql/ya.make @@ -63,9 +63,11 @@ PEERDIR( library/cpp/yson yql/essentials/core/pg_settings yql/essentials/core/sql_types + yql/essentials/core/issue yql/essentials/minikql/dom yql/essentials/parser/pg_catalog yql/essentials/parser/pg_wrapper/interface + yql/essentials/public/issue yql/essentials/public/udf yql/essentials/public/udf/tz yql/essentials/types/binary_json diff --git a/yql/essentials/tests/sql/sql2yql/canondata/result.json b/yql/essentials/tests/sql/sql2yql/canondata/result.json index ee6df683bf..597f7ccdd4 100644 --- a/yql/essentials/tests/sql/sql2yql/canondata/result.json +++ b/yql/essentials/tests/sql/sql2yql/canondata/result.json @@ -6215,6 +6215,27 @@ "uri": "https://{canondata_backend}/1936273/4a1b39013e1bae40e722cff8ccef8829784964e2/resource.tar.gz#test_sql2yql.test_expr-extra_opt_try_member_/sql.yql" } ], + "test_sql2yql.test[expr-fail_constraint]": [ + { + "checksum": "f20af754fea0c44771384857ad6957f2", + "size": 1087, + "uri": "https://{canondata_backend}/1817427/9071fa74025d031d4df7af90be1dad5cebd18046/resource.tar.gz#test_sql2yql.test_expr-fail_constraint_/sql.yql" + } + ], + "test_sql2yql.test[expr-fail_expr]": [ + { + "checksum": "ff0f789bbd6c7a0d1a7b1461da7c8aec", + "size": 1081, + "uri": "https://{canondata_backend}/1817427/9071fa74025d031d4df7af90be1dad5cebd18046/resource.tar.gz#test_sql2yql.test_expr-fail_expr_/sql.yql" + } + ], + "test_sql2yql.test[expr-fail_type]": [ + { + "checksum": "bbfc80a4e0a08d8282c1e1832238f9c6", + "size": 1081, + "uri": "https://{canondata_backend}/1817427/9071fa74025d031d4df7af90be1dad5cebd18046/resource.tar.gz#test_sql2yql.test_expr-fail_type_/sql.yql" + } + ], "test_sql2yql.test[expr-fallback_filternullelements]": [ { "checksum": "09b44cf52176a1186cb0c7a81b4bbb99", @@ -24347,6 +24368,21 @@ "uri": "file://test_sql_format.test_expr-extra_opt_try_member_/formatted.sql" } ], + "test_sql_format.test[expr-fail_constraint]": [ + { + "uri": "file://test_sql_format.test_expr-fail_constraint_/formatted.sql" + } + ], + "test_sql_format.test[expr-fail_expr]": [ + { + "uri": "file://test_sql_format.test_expr-fail_expr_/formatted.sql" + } + ], + "test_sql_format.test[expr-fail_type]": [ + { + "uri": "file://test_sql_format.test_expr-fail_type_/formatted.sql" + } + ], "test_sql_format.test[expr-fallback_filternullelements]": [ { "uri": "file://test_sql_format.test_expr-fallback_filternullelements_/formatted.sql" diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_constraint_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_constraint_/formatted.sql new file mode 100644 index 0000000000..b835c26c0a --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_constraint_/formatted.sql @@ -0,0 +1,6 @@ +/* custom error:missing Empty constraint in node AsList*/ +PRAGMA warning("disable", "4510"); + +SELECT + Yql::FailMe(AsAtom('constraint')) +; diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_expr_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_expr_/formatted.sql new file mode 100644 index 0000000000..8bd146d7c7 --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_expr_/formatted.sql @@ -0,0 +1,6 @@ +/* custom error:Detected a type error after initial validation*/ +PRAGMA warning("disable", "4510"); + +SELECT + Yql::FailMe(AsAtom('expr')) +; diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_type_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_type_/formatted.sql new file mode 100644 index 0000000000..8b1b217f24 --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-fail_type_/formatted.sql @@ -0,0 +1,6 @@ +/* custom error:Rewrite error, type should be : String, but it is: Int32 for node Int32*/ +PRAGMA warning("disable", "4510"); + +SELECT + Yql::FailMe(AsAtom('type')) +; diff --git a/yql/essentials/tests/sql/suites/expr/fail_constraint.cfg b/yql/essentials/tests/sql/suites/expr/fail_constraint.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_constraint.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/sql/suites/expr/fail_constraint.sql b/yql/essentials/tests/sql/suites/expr/fail_constraint.sql new file mode 100644 index 0000000000..ac1a7a47b8 --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_constraint.sql @@ -0,0 +1,4 @@ +/* custom error:missing Empty constraint in node AsList*/ +pragma warning("disable","4510"); +select Yql::FailMe(AsAtom('constraint')); + diff --git a/yql/essentials/tests/sql/suites/expr/fail_expr.cfg b/yql/essentials/tests/sql/suites/expr/fail_expr.cfg new file mode 100644 index 0000000000..5dae597903 --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_expr.cfg @@ -0,0 +1 @@ +xfail diff --git a/yql/essentials/tests/sql/suites/expr/fail_expr.sql b/yql/essentials/tests/sql/suites/expr/fail_expr.sql new file mode 100644 index 0000000000..3ace8ea83c --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_expr.sql @@ -0,0 +1,4 @@ +/* custom error:Detected a type error after initial validation*/ +pragma warning("disable","4510"); +select Yql::FailMe(AsAtom('expr')); + diff --git a/yql/essentials/tests/sql/suites/expr/fail_type.cfg b/yql/essentials/tests/sql/suites/expr/fail_type.cfg new file mode 100644 index 0000000000..5dae597903 --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_type.cfg @@ -0,0 +1 @@ +xfail diff --git a/yql/essentials/tests/sql/suites/expr/fail_type.sql b/yql/essentials/tests/sql/suites/expr/fail_type.sql new file mode 100644 index 0000000000..9a4ce9720c --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/fail_type.sql @@ -0,0 +1,4 @@ +/* custom error:Rewrite error, type should be : String, but it is: Int32 for node Int32*/ +pragma warning("disable","4510"); +select Yql::FailMe(AsAtom('type')); + diff --git a/yql/essentials/udfs/common/hyperscan/test/canondata/test.test_Error_/extracted b/yql/essentials/udfs/common/hyperscan/test/canondata/test.test_Error_/extracted index 4d090620be..d3707ae88c 100644 --- a/yql/essentials/udfs/common/hyperscan/test/canondata/test.test_Error_/extracted +++ b/yql/essentials/udfs/common/hyperscan/test/canondata/test.test_Error_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:8:1: Fatal: Execution of node: YtMap! + <tmp_path>/program.sql:<main>:8:1: Error: Execution of node: YtMap! SELECT $match(value) AS match FROM Input; ^ - <tmp_path>/program.sql:<main>:6:21: Fatal: library/cpp/regex/hyperscan/hyperscan.cpp:102: Failed to compile regex: ^*$. Error message (hyperscan): Invalid repeat at index 1. + <tmp_path>/program.sql:<main>:6:21: Error: library/cpp/regex/hyperscan/hyperscan.cpp:102: Failed to compile regex: ^*$. Error message (hyperscan): Invalid repeat at index 1. $match = Hyperscan::Match("*"); ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlQueryError_/extracted b/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlQueryError_/extracted index 12f3e1927d..7ddd685906 100644 --- a/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlQueryError_/extracted +++ b/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlQueryError_/extracted @@ -1,9 +1,9 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:12:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:12:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:14:12: Fatal: yql/essentials/udfs/common/json2/sql_query.h:xxx: Error executing jsonpath: + <tmp_path>/program.sql:<main>:14:12: Error: yql/essentials/udfs/common/json2/sql_query.h:xxx: Error executing jsonpath: jsonpath:1:8: Error: Member not found, code: 4702 Json2::SqlQuery($jsonpath_error, $path, AsDict(), false, NULL, true, NULL); diff --git a/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlTryExistsError_/extracted b/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlTryExistsError_/extracted index 7761bc9a04..3dad6f1e53 100644 --- a/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlTryExistsError_/extracted +++ b/yql/essentials/udfs/common/json2/test/canondata/test.test_SqlTryExistsError_/extracted @@ -1,9 +1,9 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:12:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:12:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:14:12: Fatal: yql/essentials/udfs/common/json2/sql_exists.h:xxx: Error executing jsonpath: + <tmp_path>/program.sql:<main>:14:12: Error: yql/essentials/udfs/common/json2/sql_exists.h:xxx: Error executing jsonpath: jsonpath:1:8: Error: Expected object, code: 4701 Json2::SqlTryExists($json, $path, AsDict()); diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted index d03cedfb32..7e9db6c109 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:2:1: Fatal: Input string is not a number + <tmp_path>/program.sql:<main>:2:1: Error: Input string is not a number SELECT ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted index 3ed803548b..dbf4721670 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:2:1: Fatal: Input string contains junk after the number + <tmp_path>/program.sql:<main>:2:1: Error: Input string contains junk after the number SELECT ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted index c441fbf4e1..f6b225d561 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:2:1: Fatal: Converted value falls out of Uint64 range + <tmp_path>/program.sql:<main>:2:1: Error: Converted value falls out of Uint64 range SELECT ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted index 23c6342305..5b73d97b40 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:2:1: Fatal: Incorrect base + <tmp_path>/program.sql:<main>:2:1: Error: Incorrect base SELECT ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryMaxFieldsErr_/extracted b/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryMaxFieldsErr_/extracted index e80a93b299..f4c852d0f2 100644 --- a/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryMaxFieldsErr_/extracted +++ b/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryMaxFieldsErr_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:4:10: Fatal: Max number of fields (2) exceeded: got 3 + <tmp_path>/program.sql:<main>:4:10: Error: Max number of fields (2) exceeded: got 3 Url::QueryStringToList("glfilter=78318%3A79492&glfilter=561%3A121037&hid=904", 2 AS MaxFields) ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryStrictErr_/extracted b/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryStrictErr_/extracted index 6326332de1..1b43f17791 100644 --- a/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryStrictErr_/extracted +++ b/yql/essentials/udfs/common/url_base/test/canondata/test.test_UrlQueryStrictErr_/extracted @@ -1,8 +1,8 @@ -<tmp_path>/program.sql:<main>: Fatal: Execution +<tmp_path>/program.sql:<main>: Error: Execution - <tmp_path>/program.sql:<main>:2:1: Fatal: Execution of node: Result + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result SELECT ^ - <tmp_path>/program.sql:<main>:4:10: Fatal: Bad query field: "mistaken" + <tmp_path>/program.sql:<main>:4:10: Error: Bad query field: "mistaken" Url::QueryStringToList("glfilter=78318%3A79492&mistaken&glfilter=1&hid=904") ^
\ No newline at end of file diff --git a/yt/yql/providers/yt/gateway/file/ya.make b/yt/yql/providers/yt/gateway/file/ya.make index 2957d7703b..454419e0fd 100644 --- a/yt/yql/providers/yt/gateway/file/ya.make +++ b/yt/yql/providers/yt/gateway/file/ya.make @@ -16,6 +16,7 @@ PEERDIR( yql/essentials/core/file_storage yql/essentials/core/file_storage/proto yql/essentials/core/file_storage/http_download + yql/essentials/core/issue yql/essentials/minikql/comp_nodes yql/essentials/public/udf yql/essentials/utils diff --git a/yt/yql/providers/yt/gateway/file/yql_yt_file.cpp b/yt/yql/providers/yt/gateway/file/yql_yt_file.cpp index 5eff2bc247..c742d4f06b 100644 --- a/yt/yql/providers/yt/gateway/file/yql_yt_file.cpp +++ b/yt/yql/providers/yt/gateway/file/yql_yt_file.cpp @@ -438,6 +438,8 @@ public: if (exists) { try { LoadTableMetaInfo(req, path, *metaData); + } catch (const TErrorException& e) { + throw TErrorException(e.GetCode()) << "Error loading " << req.Cluster() << '.' << req.Table() << " table metadata: " << e.what(); } catch (const yexception& e) { throw yexception() << "Error loading " << req.Cluster() << '.' << req.Table() << " table metadata: " << e.what(); } @@ -450,6 +452,8 @@ public: if (metaData->SqlView.empty()) { try { LoadTableStatInfo(path, *statData); + } catch (const TErrorException& e) { + throw TErrorException(e.GetCode()) << "Error loading " << req.Cluster() << '.' << req.Table() << " table stat: " << e.what(); } catch (const yexception& e) { throw yexception() << "Error loading " << req.Cluster() << '.' << req.Table() << " table stat: " << e.what(); } diff --git a/yt/yql/providers/yt/gateway/file/yql_yt_file_services.cpp b/yt/yql/providers/yt/gateway/file/yql_yt_file_services.cpp index cc8458ce0d..30f3792c33 100644 --- a/yt/yql/providers/yt/gateway/file/yql_yt_file_services.cpp +++ b/yt/yql/providers/yt/gateway/file/yql_yt_file_services.cpp @@ -1,6 +1,7 @@ #include "yql_yt_file_services.h" #include <yql/essentials/providers/common/provider/yql_provider_names.h> +#include <yql/essentials/core/issue/yql_issue.h> #include <util/system/guard.h> #include <util/system/fs.h> @@ -45,7 +46,7 @@ TString TYtFileServices::GetTablePath(TStringBuf cluster, TStringBuf table, bool if (auto dirPtr = TablesDirMapping.FindPtr(tablePrefix)) { return TFsPath(*dirPtr) / TString(table).append(".txt"); } - ythrow yexception() << "Table \"" << table << "\" does not exist"; + throw TErrorException(TIssuesIds::YT_TABLE_NOT_FOUND) << "Table \"" << table << "\" does not exist"; } void TYtFileServices::LockPath(const TString& path, const TString& fullTableName) { diff --git a/yt/yql/providers/yt/gateway/lib/yt_helpers.cpp b/yt/yql/providers/yt/gateway/lib/yt_helpers.cpp index 1f20fc7dae..494bce164e 100644 --- a/yt/yql/providers/yt/gateway/lib/yt_helpers.cpp +++ b/yt/yql/providers/yt/gateway/lib/yt_helpers.cpp @@ -629,7 +629,7 @@ void FillResultFromOperationError(NCommon::TOperationResult& result, const NYT:: } else { TString errorDescription = failedJob.Error.ShortDescription(); if (uniqueErrors.insert(errorDescription).second) { - rootIssue.AddSubIssue(MakeIntrusive<TIssue>(YqlIssue(pos, TIssuesIds::UNEXPECTED, errorDescription))); + rootIssue.AddSubIssue(MakeIntrusive<TIssue>(YqlIssue(pos, TIssuesIds::DEFAULT_ERROR, errorDescription))); } } } @@ -658,7 +658,7 @@ void FillResultFromCurrentException(NCommon::TOperationResult& result, TPosition } catch (const std::exception& e) { result.SetException(e, pos); } catch (const NKikimr::TMemoryLimitExceededException&) { - result.SetStatus(TIssuesIds::UNEXPECTED); + result.SetStatus(TIssuesIds::DEFAULT_ERROR); result.AddIssue(TIssue(pos, "Memory limit exceeded in MKQL runtime")); } catch (...) { result.SetStatus(TIssuesIds::UNEXPECTED); |