diff options
author | uzhas <uzhas@ydb.tech> | 2023-08-21 13:39:42 +0300 |
---|---|---|
committer | uzhas <uzhas@ydb.tech> | 2023-08-21 15:26:01 +0300 |
commit | 69809b16c83fab8124e9dd87c284b57c694e1f49 (patch) | |
tree | 4744edbabba8f3810f4c50cda745fa4f66d6ec87 | |
parent | 41317102c917880a58599ea258ac0cf7392c3b04 (diff) | |
download | ydb-69809b16c83fab8124e9dd87c284b57c694e1f49.tar.gz |
,support reading from bindings in v2, pg syntax
-rw-r--r-- | ydb/library/yql/sql/pg/pg_sql.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/ydb/library/yql/sql/pg/pg_sql.cpp b/ydb/library/yql/sql/pg/pg_sql.cpp index e1b90fdcbf1..1bea59055b8 100644 --- a/ydb/library/yql/sql/pg/pg_sql.cpp +++ b/ydb/library/yql/sql/pg/pg_sql.cpp @@ -8,6 +8,7 @@ #include <ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/catalog/pg_type_d.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> #include <ydb/library/yql/providers/common/provider/yql_provider_names.h> +#include <ydb/library/yql/core/issue/yql_issue.h> #include <ydb/library/yql/core/yql_callable_names.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> #include <util/string/builder.h> @@ -1976,17 +1977,36 @@ public: return { view->Source, alias, colnames.empty() ? view->ColNames : colnames, false }; } + TString schemaname = value->schemaname; if (!StrCompare(value->schemaname, "bindings")) { - auto s = BuildBindingSource(value); - if (!s) { + bool isBinding = false; + switch (Settings.BindingsMode) { + case NSQLTranslation::EBindingsMode::DISABLED: + AddError("Please remove 'bindings.' from your query, the support for this syntax has ended"); return {}; + case NSQLTranslation::EBindingsMode::ENABLED: + isBinding = true; + break; + case NSQLTranslation::EBindingsMode::DROP_WITH_WARNING: + AddWarning(TIssuesIds::YQL_DEPRECATED_BINDINGS, "Please remove 'bindings.' from your query, the support for this syntax will be dropped soon"); + [[fallthrough]]; + case NSQLTranslation::EBindingsMode::DROP: + schemaname = Settings.DefaultCluster; + break; + } + + if (isBinding) { + auto s = BuildBindingSource(value); + if (!s) { + return {}; + } + return { s, alias, colnames, true }; } - return { s, alias, colnames, true }; } const auto [source, key] = ParseQualifiedRelationName( - value->catalogname, value->schemaname, value->relname, + value->catalogname, schemaname, value->relname, /* isSink */ false, /* isScheme */ false); if (source == nullptr || key == nullptr) { @@ -3485,6 +3505,10 @@ private: AstParseResult.Issues.AddIssue(TIssue(Positions.back(), value)); } + void AddWarning(int code, const TString& value) { + AstParseResult.Issues.AddIssue(TIssue(Positions.back(), value).SetCode(code, ESeverity::TSeverityIds_ESeverityId_S_WARNING)); + } + struct TLState { TPosition Position; TVector<TAstNode*> Nodes; |