aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@yandex-team.ru>2022-04-07 06:56:20 +0300
committervvvv <vvvv@yandex-team.ru>2022-04-07 06:56:20 +0300
commit2d9b61d661f97eb64fc680983b2d3580cc2d302d (patch)
treef9a9b22d8020f6f7503f799b7d1b231c4900e610
parentfb12d151cadf2e1ad39b0b6a7d8baa5d31ab663a (diff)
downloadydb-2d9b61d661f97eb64fc680983b2d3580cc2d302d.tar.gz
YQL-13710 expose prockind from catalog
ref:3953c1b96b091572d5e7bff63d85ded376133ca5
-rw-r--r--ydb/library/yql/parser/pg_catalog/catalog.cpp10
-rw-r--r--ydb/library/yql/parser/pg_catalog/catalog.h7
-rw-r--r--ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp7
3 files changed, 24 insertions, 0 deletions
diff --git a/ydb/library/yql/parser/pg_catalog/catalog.cpp b/ydb/library/yql/parser/pg_catalog/catalog.cpp
index 8ff7952fd8..ed377ed59e 100644
--- a/ydb/library/yql/parser/pg_catalog/catalog.cpp
+++ b/ydb/library/yql/parser/pg_catalog/catalog.cpp
@@ -259,6 +259,16 @@ public:
LastProc.ProcId = FromString<ui32>(value);
} else if (key == "provariadic") {
IsSupported = false;
+ } else if (key == "prokind") {
+ if (value == "f") {
+ LastProc.Kind = EProcKind::Function;
+ } else if (value == "a") {
+ LastProc.Kind = EProcKind::Aggregate;
+ } else if (value == "w") {
+ LastProc.Kind = EProcKind::Window;
+ } else {
+ IsSupported = false;
+ }
} else if (key == "prorettype") {
auto idPtr = TypeByName.FindPtr(value);
Y_ENSURE(idPtr);
diff --git a/ydb/library/yql/parser/pg_catalog/catalog.h b/ydb/library/yql/parser/pg_catalog/catalog.h
index c241f54b01..2c9f4e729f 100644
--- a/ydb/library/yql/parser/pg_catalog/catalog.h
+++ b/ydb/library/yql/parser/pg_catalog/catalog.h
@@ -21,6 +21,12 @@ struct TOperDesc {
ui32 ProcId = 0;
};
+enum EProcKind {
+ Function,
+ Aggregate,
+ Window
+};
+
struct TProcDesc {
ui32 ProcId = 0;
TString Name;
@@ -28,6 +34,7 @@ struct TProcDesc {
TVector<ui32> ArgTypes;
ui32 ResultType = 0;
bool IsStrict = true;
+ EProcKind Kind = EProcKind::Function;
};
struct TTypeDesc {
diff --git a/ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp b/ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp
index 66e5d6b2d4..52dceecbd9 100644
--- a/ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp
+++ b/ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp
@@ -65,6 +65,7 @@ Y_UNIT_TEST_SUITE(TFunctionsTests) {
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[0], LookupType("int4").TypeId);
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[1], LookupType("int4").TypeId);
UNIT_ASSERT_VALUES_EQUAL(ret.Src, "int4pl");
+ UNIT_ASSERT(ret.Kind == EProcKind::Function);
ret = LookupProcByStrArgTypes("substring", {"text", "int4", "int4"});
UNIT_ASSERT_VALUES_EQUAL(ret.ResultType, LookupType("text").TypeId);
@@ -80,6 +81,12 @@ Y_UNIT_TEST_SUITE(TFunctionsTests) {
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[0], LookupType("text").TypeId);
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[1], LookupType("int4").TypeId);
UNIT_ASSERT_VALUES_EQUAL(ret.Src, "text_substr_no_len");
+
+ ret = LookupProcByStrArgTypes("sum", {"int4"});
+ UNIT_ASSERT(ret.Kind == EProcKind::Aggregate);
+
+ ret = LookupProcByStrArgTypes("row_number", {});
+ UNIT_ASSERT(ret.Kind == EProcKind::Window);
}
}