aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqrort <31865255+qrort@users.noreply.github.com>2024-01-03 17:01:27 +0300
committerGitHub <noreply@github.com>2024-01-03 17:01:27 +0300
commit3c0bb781afe9473bb694a7e64f5066d128329744 (patch)
tree50bf21799355bab00780d61878d58d4c71fcc022
parent8d36ec874b0adf7988b281c5d62e53c89ed9ed67 (diff)
downloadydb-3c0bb781afe9473bb694a7e64f5066d128329744.tar.gz
add pg types to TQueryPlan (#828)
-rw-r--r--ydb/core/kqp/opt/kqp_query_plan.cpp26
-rw-r--r--ydb/core/kqp/ut/opt/kqp_not_null_ut.cpp4
-rw-r--r--ydb/public/lib/value/value.cpp15
-rw-r--r--ydb/public/lib/value/value.h2
-rw-r--r--ydb/public/lib/value/ya.make1
5 files changed, 35 insertions, 13 deletions
diff --git a/ydb/core/kqp/opt/kqp_query_plan.cpp b/ydb/core/kqp/opt/kqp_query_plan.cpp
index fbebd4bca6..c875a02248 100644
--- a/ydb/core/kqp/opt/kqp_query_plan.cpp
+++ b/ydb/core/kqp/opt/kqp_query_plan.cpp
@@ -515,17 +515,23 @@ private:
}
TString DescribeValue(const NKikimr::NClient::TValue& value) {
- auto str = value.GetDataText();
- switch (value.GetType().GetData().GetScheme()) {
- case NScheme::NTypeIds::Utf8:
- case NScheme::NTypeIds::Json:
- case NScheme::NTypeIds::String:
- case NScheme::NTypeIds::String4k:
- case NScheme::NTypeIds::String2m:
- return "«" + str + "»";
- default:
- return str;
+ if (value.GetType().GetKind() == NKikimrMiniKQL::ETypeKind::Data) {
+ auto str = value.GetDataText();
+ switch (value.GetType().GetData().GetScheme()) {
+ case NScheme::NTypeIds::Utf8:
+ case NScheme::NTypeIds::Json:
+ case NScheme::NTypeIds::String:
+ case NScheme::NTypeIds::String4k:
+ case NScheme::NTypeIds::String2m:
+ return "«" + str + "»";
+ default:
+ return str;
+ }
+ }
+ if (value.GetType().GetKind() == NKikimrMiniKQL::ETypeKind::Pg) {
+ return value.GetPgText();
}
+ Y_ENSURE(false, TStringBuilder() << "unexpected NKikimrMiniKQL::ETypeKind: " << ETypeKind_Name(value.GetType().GetKind()));
}
void Visit(const TKqpReadRangesSourceSettings& sourceSettings, TQueryPlanNode& planNode) {
diff --git a/ydb/core/kqp/ut/opt/kqp_not_null_ut.cpp b/ydb/core/kqp/ut/opt/kqp_not_null_ut.cpp
index bcb5ad28a0..80adbdfc08 100644
--- a/ydb/core/kqp/ut/opt/kqp_not_null_ut.cpp
+++ b/ydb/core/kqp/ut/opt/kqp_not_null_ut.cpp
@@ -1653,8 +1653,6 @@ Y_UNIT_TEST_SUITE(KqpNotNullColumns) {
}
}
-#if 0
- // TODO: fix TxPlanSerializer with PG keys
Y_UNIT_TEST(SecondaryIndexWithNotNullDataColumnPg) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false)
@@ -1759,7 +1757,7 @@ Y_UNIT_TEST_SUITE(KqpNotNullColumns) {
result.GetIssues().ToString());
}
}
-#endif
+
Y_UNIT_TEST_TWIN(JoinBothTablesWithNotNullPk, StreamLookup) {
NKikimrConfig::TAppConfig appConfig;
diff --git a/ydb/public/lib/value/value.cpp b/ydb/public/lib/value/value.cpp
index 7edde8c7a5..a728604b6b 100644
--- a/ydb/public/lib/value/value.cpp
+++ b/ydb/public/lib/value/value.cpp
@@ -1,6 +1,7 @@
#include "value.h"
#include <ydb/library/yql/public/decimal/yql_decimal.h>
+#include <ydb/library/yql/parser/pg_wrapper/interface/type_desc.h>
#include <library/cpp/string_utils/base64/base64.h>
@@ -432,6 +433,20 @@ TString TValue::GetDataText() const {
return TStringBuilder() << "\"<unknown type " << Type.GetData().GetScheme() << ">\"";
}
+TString TValue::GetPgText() const {
+ Y_ASSERT(Type.GetKind() == NKikimrMiniKQL::ETypeKind::Pg);
+ if (Value.HasNullFlagValue()) {
+ return TString("null");
+ }
+ if (Value.HasText()) {
+ return Value.GetText();
+ }
+ auto pgType = Type.GetPg();
+ auto convertResult = NPg::PgNativeTextFromNativeBinary(Value.GetBytes(), NPg::TypeDescFromPgTypeId(pgType.Getoid()));
+ Y_ENSURE(!convertResult.Error, convertResult.Error);
+ return convertResult.Str;
+}
+
template <> TString TValue::GetTypeText<TFormatCxx>(const TFormatCxx& format) const {
switch(Type.GetKind()) {
case NKikimrMiniKQL::ETypeKind::Void:
diff --git a/ydb/public/lib/value/value.h b/ydb/public/lib/value/value.h
index 8ae368ac02..c0b668ffe0 100644
--- a/ydb/public/lib/value/value.h
+++ b/ydb/public/lib/value/value.h
@@ -89,6 +89,8 @@ public:
NScheme::TTypeId GetDataType() const;
// gets text representation of simple 'Data' types
TString GetDataText() const;
+ // gets text representation of 'Pg' types
+ TString GetPgText() const;
// returns text representation of value's type
template <typename Format> TString GetTypeText(const Format& format = Format()) const;
// returns text representation of value itself
diff --git a/ydb/public/lib/value/ya.make b/ydb/public/lib/value/ya.make
index c87b3d4710..55e49f1b27 100644
--- a/ydb/public/lib/value/ya.make
+++ b/ydb/public/lib/value/ya.make
@@ -9,6 +9,7 @@ PEERDIR(
library/cpp/string_utils/base64
ydb/core/protos
ydb/library/mkql_proto/protos
+ ydb/library/yql/parser/pg_wrapper/interface
ydb/public/lib/scheme_types
ydb/public/sdk/cpp/client/ydb_value
)