aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_query.cpp
diff options
context:
space:
mode:
authoraneporada <aneporada@yandex-team.com>2024-11-12 20:02:10 +0300
committeraneporada <aneporada@yandex-team.com>2024-11-12 20:12:34 +0300
commit10eb11dab8afe0eae39e5d587d57d4f123f3fa9d (patch)
tree118f7e40deb9422875a557dab721dfda74450d72 /yql/essentials/sql/v1/sql_query.cpp
parent1620cea68d4380267df949c1a62270c7e961ba89 (diff)
downloadydb-10eb11dab8afe0eae39e5d587d57d4f123f3fa9d.tar.gz
Merge PR #10831, #11068, #11075, #11152
#11152 - Allow to choose normal or aggreation PG function #11075 - Handle invalid base #11068 - Allow more postgis functions #10831 - Views: if exists / if not exists for DDL commit_hash:0ebf35e45ac6de147c9000440ca25237db061d2e
Diffstat (limited to 'yql/essentials/sql/v1/sql_query.cpp')
-rw-r--r--yql/essentials/sql/v1/sql_query.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/yql/essentials/sql/v1/sql_query.cpp b/yql/essentials/sql/v1/sql_query.cpp
index d0fb8737e1..f3755bf6f0 100644
--- a/yql/essentials/sql/v1/sql_query.cpp
+++ b/yql/essentials/sql/v1/sql_query.cpp
@@ -1228,11 +1228,11 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
break;
}
case TRule_sql_stmt_core::kAltSqlStmtCore42: {
- // create_view_stmt: CREATE VIEW name WITH (k = v, ...) AS select_stmt;
+ // create_view_stmt: CREATE VIEW (IF NOT EXISTS)? name (WITH (k = v, ...))? AS select_stmt;
auto& node = core.GetAlt_sql_stmt_core42().GetRule_create_view_stmt1();
TObjectOperatorContext context(Ctx.Scoped);
- if (node.GetRule_object_ref3().HasBlock1()) {
- if (!ClusterExpr(node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(),
+ if (node.GetRule_object_ref4().HasBlock1()) {
+ if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(),
false,
context.ServiceId,
context.Cluster)) {
@@ -1240,34 +1240,36 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
}
}
+ const bool existingOk = node.HasBlock3();
+
std::map<TString, TDeferredAtom> features;
- if (node.HasBlock4()) {
- if (!ParseObjectFeatures(features, node.GetBlock4().GetRule_create_object_features1().GetRule_object_features2())) {
+ if (node.HasBlock5()) {
+ if (!ParseObjectFeatures(features, node.GetBlock5().GetRule_create_object_features1().GetRule_object_features2())) {
return false;
}
}
- if (!ParseViewQuery(features, node.GetRule_select_stmt6())) {
+ if (!ParseViewQuery(features, node.GetRule_select_stmt7())) {
return false;
}
- const TString objectId = Id(node.GetRule_object_ref3().GetRule_id_or_at2(), *this).second;
+ const TString objectId = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second;
constexpr const char* TypeId = "VIEW";
AddStatementToBlocks(blocks,
BuildCreateObjectOperation(Ctx.Pos(),
BuildTablePath(Ctx.GetPrefixPath(context.ServiceId, context.Cluster), objectId),
TypeId,
- false,
+ existingOk,
false,
std::move(features),
context));
break;
}
case TRule_sql_stmt_core::kAltSqlStmtCore43: {
- // drop_view_stmt: DROP VIEW name;
+ // drop_view_stmt: DROP VIEW (IF EXISTS)? name;
auto& node = core.GetAlt_sql_stmt_core43().GetRule_drop_view_stmt1();
TObjectOperatorContext context(Ctx.Scoped);
- if (node.GetRule_object_ref3().HasBlock1()) {
- if (!ClusterExpr(node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(),
+ if (node.GetRule_object_ref4().HasBlock1()) {
+ if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(),
false,
context.ServiceId,
context.Cluster)) {
@@ -1275,13 +1277,15 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
}
}
- const TString objectId = Id(node.GetRule_object_ref3().GetRule_id_or_at2(), *this).second;
+ const bool missingOk = node.HasBlock3();
+
+ const TString objectId = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second;
constexpr const char* TypeId = "VIEW";
AddStatementToBlocks(blocks,
BuildDropObjectOperation(Ctx.Pos(),
BuildTablePath(Ctx.GetPrefixPath(context.ServiceId, context.Cluster), objectId),
TypeId,
- false,
+ missingOk,
{},
context));
break;