diff options
author | spuchin <spuchin@ydb.tech> | 2023-09-21 09:32:16 +0300 |
---|---|---|
committer | spuchin <spuchin@ydb.tech> | 2023-09-21 09:52:46 +0300 |
commit | ff79b3e9fcd5a59bed95feaa6ffb29691841c89d (patch) | |
tree | c3ffc415338d2cd47f4dd1de7b2883c0eb1f8250 | |
parent | f287b07175ebc7a20d4cca65ee18928866978790 (diff) | |
download | ydb-ff79b3e9fcd5a59bed95feaa6ffb29691841c89d.tar.gz |
Enable Ansi settings for generic query. (KIKIMR-16294)
-rw-r--r-- | ydb/core/grpc_services/query/rpc_execute_query.cpp | 2 | ||||
-rw-r--r-- | ydb/core/kqp/host/kqp_host.cpp | 14 | ||||
-rw-r--r-- | ydb/core/kqp/ut/yql/kqp_yql_ut.cpp | 19 | ||||
-rw-r--r-- | ydb/public/sdk/cpp/client/ydb_query/impl/exec_query.cpp | 2 |
4 files changed, 35 insertions, 2 deletions
diff --git a/ydb/core/grpc_services/query/rpc_execute_query.cpp b/ydb/core/grpc_services/query/rpc_execute_query.cpp index e38dc79e99..89c0577708 100644 --- a/ydb/core/grpc_services/query/rpc_execute_query.cpp +++ b/ydb/core/grpc_services/query/rpc_execute_query.cpp @@ -416,7 +416,7 @@ private: << Ydb::StatusIds::StatusCode_Name(status)); // Skip sending empty result in case of success status - simplify client logic - if (status != Ydb::StatusIds::SUCCESS) { + if (status != Ydb::StatusIds::SUCCESS || message.size() > 0) { TString out; Ydb::Query::ExecuteQueryResponsePart response; response.set_status(status); diff --git a/ydb/core/kqp/host/kqp_host.cpp b/ydb/core/kqp/host/kqp_host.cpp index af5c5d4262..0ddf0bce7d 100644 --- a/ydb/core/kqp/host/kqp_host.cpp +++ b/ydb/core/kqp/host/kqp_host.cpp @@ -1099,9 +1099,12 @@ private: settings.EndOfQueryCommit = sqlAutoCommit; settings.Flags.insert("FlexibleTypes"); settings.Flags.insert("AnsiLike"); + if (SessionCtx->Query().Type == EKikimrQueryType::Scan || SessionCtx->Query().Type == EKikimrQueryType::YqlScript - || SessionCtx->Query().Type == EKikimrQueryType::YqlScriptStreaming) + || SessionCtx->Query().Type == EKikimrQueryType::YqlScriptStreaming + || SessionCtx->Query().Type == EKikimrQueryType::Query + || SessionCtx->Query().Type == EKikimrQueryType::Script) { // We enable EmitAggApply for filter and aggregate pushdowns to Column Shards settings.Flags.insert("EmitAggApply"); @@ -1109,6 +1112,15 @@ private: settings.Flags.insert("DisableEmitStartsWith"); } + if (SessionCtx->Query().Type == EKikimrQueryType::Query + || SessionCtx->Query().Type == EKikimrQueryType::Script) + { + settings.Flags.insert("AnsiOptionalAs"); + settings.Flags.insert("WarnOnAnsiAliasShadowing"); + settings.Flags.insert("AnsiCurrentRow"); + settings.Flags.insert("AnsiInForEmptyOrNullableItemsCollections"); + } + if (query.ParameterTypes) { NSQLTranslation::TTranslationSettings versionSettings = settings; NYql::TIssues versionIssues; diff --git a/ydb/core/kqp/ut/yql/kqp_yql_ut.cpp b/ydb/core/kqp/ut/yql/kqp_yql_ut.cpp index d8ac2baf90..f2f398838f 100644 --- a/ydb/core/kqp/ut/yql/kqp_yql_ut.cpp +++ b/ydb/core/kqp/ut/yql/kqp_yql_ut.cpp @@ -472,6 +472,25 @@ Y_UNIT_TEST_SUITE(KqpYql) { UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString()); UNIT_ASSERT(HasIssue(result.GetIssues(), NYql::TIssuesIds::KIKIMR_BAD_OPERATION)); } + + Y_UNIT_TEST(AnsiIn) { + auto kikimr = DefaultKikimrRunner(); + auto db = kikimr.GetQueryClient(); + + auto result = db.ExecuteQuery(R"( + $list = AsList( + Just(1), + Just(2), + NULL + ); + + SELECT 1 in $list; + )", NYdb::NQuery::TTxControl::BeginTx().CommitTx()).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + UNIT_ASSERT_C(result.GetIssues().Size() == 0, result.GetIssues().ToString()); + + CompareYson(R"([[[%true]]])", FormatResultSetYson(result.GetResultSet(0))); + } } } // namespace NKqp diff --git a/ydb/public/sdk/cpp/client/ydb_query/impl/exec_query.cpp b/ydb/public/sdk/cpp/client/ydb_query/impl/exec_query.cpp index 6cf6344618..21bd9e2125 100644 --- a/ydb/public/sdk/cpp/client/ydb_query/impl/exec_query.cpp +++ b/ydb/public/sdk/cpp/client/ydb_query/impl/exec_query.cpp @@ -153,6 +153,8 @@ struct TExecuteQueryBuffer : public TThrRefBase, TNonCopyable { return; } + self->Issues_.insert(self->Issues_.end(), part.GetIssues().begin(), part.GetIssues().end()); + if (part.HasResultSet()) { auto inRs = part.ExtractResultSet(); auto& inRsProto = TProtoAccessor::GetProto(inRs); |