diff options
| author | vitya-smirnov <[email protected]> | 2025-09-03 16:23:37 +0300 |
|---|---|---|
| committer | vitya-smirnov <[email protected]> | 2025-09-03 16:53:40 +0300 |
| commit | 1a6fddffd17953f4ed4d20de9fdd5c010166acd1 (patch) | |
| tree | 1f90d4097dccbfa041bc9ef3ce695e75f51a3ed3 /yql/essentials/sql/v1/sql_query.cpp | |
| parent | db0b30ed142b14352bba1fb6e67768928da20d49 (diff) | |
YQL-20189: Track warnings as errors
There was an issue that a query with warnings
as errors passed translation.
commit_hash:890d18853380b5ad669e9684553cdb6991827cff
Diffstat (limited to 'yql/essentials/sql/v1/sql_query.cpp')
| -rw-r--r-- | yql/essentials/sql/v1/sql_query.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/yql/essentials/sql/v1/sql_query.cpp b/yql/essentials/sql/v1/sql_query.cpp index b84e2df0add..5f29be58d4d 100644 --- a/yql/essentials/sql/v1/sql_query.cpp +++ b/yql/essentials/sql/v1/sql_query.cpp @@ -2157,7 +2157,11 @@ bool TSqlQuery::DeclareStatement(const TRule_declare_stmt& stmt) { } if (Ctx_.IsAlreadyDeclared(varName)) { - Ctx_.Warning(varPos, TIssuesIds::YQL_DUPLICATE_DECLARE) << "Duplicate declaration of '" << varName << "' will be ignored"; + if (!Ctx_.Warning(varPos, TIssuesIds::YQL_DUPLICATE_DECLARE, [&](auto& out) { + out << "Duplicate declaration of '" << varName << "' will be ignored"; + })) { + return false; + } } else { PushNamedAtom(varPos, varName); Ctx_.DeclareVariable(varName, varPos, typeNode); @@ -3111,7 +3115,11 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ query.Error() << "Expected string literal as a single argument for: " << pragma; return {}; } - ctx.Warning(ctx.Pos(), TIssuesIds::YQL_PRAGMA_WARNING_MSG) << *values[0].GetLiteral(); + if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_PRAGMA_WARNING_MSG, [&](auto& out) { + out << *values[0].GetLiteral(); + })) { + return {}; + } return TNodePtr{}; }), TableElemExt("ErrorMsg", [](CB_SIG) -> TMaybe<TNodePtr> { @@ -3141,8 +3149,11 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ }), TableElemExt("DisableUnordered", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); - ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA) - << "Use of deprecated DisableUnordered pragma. It will be dropped soon"; + if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { + out << "Use of deprecated DisableUnordered pragma. It will be dropped soon"; + })) { + return {}; + } return TNodePtr{}; }), TableElemExt("RotateJoinTree", [](CB_SIG) -> TMaybe<TNodePtr> { @@ -3253,9 +3264,12 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ }), TableElemExt("DisableFlexibleTypes", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); - ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA) - << "Deprecated pragma DisableFlexibleTypes - it will be removed soon. " - "Consider submitting bug report if FlexibleTypes doesn't work for you"; + if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { + out << "Deprecated pragma DisableFlexibleTypes - it will be removed soon. " + << "Consider submitting bug report if FlexibleTypes doesn't work for you"; + })) { + return {}; + } ctx.FlexibleTypes = false; return TNodePtr{}; }), @@ -3287,9 +3301,12 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ }), TableElemExt("DisableCompactNamedExprs", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); - ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA) - << "Deprecated pragma DisableCompactNamedExprs - it will be removed soon. " - "Consider submitting bug report if CompactNamedExprs doesn't work for you"; + if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { + out << "Deprecated pragma DisableCompactNamedExprs - it will be removed soon. " + << "Consider submitting bug report if CompactNamedExprs doesn't work for you"; + })) { + return {}; + } ctx.CompactNamedExprs = false; return TNodePtr{}; }), @@ -3536,8 +3553,11 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { return {}; } if (normalizedPragma == "fast") { - Ctx_.Warning(Ctx_.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA) - << "Use of deprecated yson.Fast pragma. It will be dropped soon"; + if (!Ctx_.Warning(Ctx_.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { + out << "Use of deprecated yson.Fast pragma. It will be dropped soon"; + })) { + return {}; + } return TNodePtr{}; } else if (normalizedPragma == "autoconvert") { Ctx_.PragmaYsonAutoConvert = true; @@ -3899,7 +3919,9 @@ TNodePtr TSqlQuery::Build(const TSQLv1ParserAST& ast) { } auto result = BuildQuery(Ctx_.Pos(), blocks, true, Ctx_.Scoped, Ctx_.SeqMode); - WarnUnusedNodes(); + if (!WarnUnusedNodes()) { + return nullptr; + } return result; } |
