summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tools/sql_functions_dump
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-03-28 21:08:12 +0300
committervvvv <[email protected]>2025-03-28 21:52:08 +0300
commit76a438f2d7f4c7cb366eff6974bb20378568a2c2 (patch)
tree835090e7e01160cad4117715a8d0df691b6226b6 /yql/essentials/tools/sql_functions_dump
parente7152a5d77d75887f1234792aafb9d672bb4838e (diff)
YQL-19747 sql functions
commit_hash:9f628fe1894ee7dcdcbdd161855b668ca6e7380f
Diffstat (limited to 'yql/essentials/tools/sql_functions_dump')
-rw-r--r--yql/essentials/tools/sql_functions_dump/sql_functions_dump.cpp39
-rw-r--r--yql/essentials/tools/sql_functions_dump/test/test.py20
-rw-r--r--yql/essentials/tools/sql_functions_dump/test/ya.make15
-rw-r--r--yql/essentials/tools/sql_functions_dump/ya.make20
4 files changed, 94 insertions, 0 deletions
diff --git a/yql/essentials/tools/sql_functions_dump/sql_functions_dump.cpp b/yql/essentials/tools/sql_functions_dump/sql_functions_dump.cpp
new file mode 100644
index 00000000000..14627a85aed
--- /dev/null
+++ b/yql/essentials/tools/sql_functions_dump/sql_functions_dump.cpp
@@ -0,0 +1,39 @@
+#include <yql/essentials/sql/v1/node.h>
+#include <yql/essentials/utils/backtrace/backtrace.h>
+#include <library/cpp/json/writer/json.h>
+#include <util/generic/yexception.h>
+
+using namespace NYql;
+
+int Main(int argc, const char *argv[])
+{
+ Y_UNUSED(argc);
+ Y_UNUSED(argv);
+ NJsonWriter::TBuf json;
+ json.BeginObject();
+ NSQLTranslationV1::EnumerateBuiltins([&](auto name, auto kind) {
+ json.WriteKey(name);
+ json.BeginObject();
+ json.WriteKey("kind");
+ json.WriteString(kind);
+ json.EndObject();
+ });
+
+ json.EndObject();
+ Cout << json.Str() << Endl;
+
+ return 0;
+}
+
+int main(int argc, const char *argv[]) {
+ NYql::NBacktrace::RegisterKikimrFatalActions();
+ NYql::NBacktrace::EnableKikimrSymbolize();
+
+ try {
+ return Main(argc, argv);
+ }
+ catch (...) {
+ Cerr << CurrentExceptionMessage() << Endl;
+ return 1;
+ }
+}
diff --git a/yql/essentials/tools/sql_functions_dump/test/test.py b/yql/essentials/tools/sql_functions_dump/test/test.py
new file mode 100644
index 00000000000..2595e4bc0b6
--- /dev/null
+++ b/yql/essentials/tools/sql_functions_dump/test/test.py
@@ -0,0 +1,20 @@
+import yatest.common
+import json
+import os
+
+DATA_PATH = yatest.common.source_path('yql/essentials/data/language')
+TOOL_PATH = yatest.common.binary_path('yql/essentials/tools/sql_functions_dump/sql_functions_dump')
+
+
+def test_functions_dump():
+ with open(os.path.join(DATA_PATH, "sql_functions.json")) as f:
+ types_from_file = json.load(f)
+ res = yatest.common.execute(
+ [TOOL_PATH],
+ check_exit_code=True,
+ wait=True
+ )
+ types_from_tool = json.loads(res.stdout)
+ assert types_from_tool == types_from_file, 'JSON_DIFFER\n' \
+ 'File:\n %(types_from_file)s\n\n' \
+ 'Tool:\n %(types_from_tool)s\n' % locals()
diff --git a/yql/essentials/tools/sql_functions_dump/test/ya.make b/yql/essentials/tools/sql_functions_dump/test/ya.make
new file mode 100644
index 00000000000..e9e5f0d6a45
--- /dev/null
+++ b/yql/essentials/tools/sql_functions_dump/test/ya.make
@@ -0,0 +1,15 @@
+PY3TEST()
+
+TEST_SRCS(
+ test.py
+)
+
+DEPENDS(
+ yql/essentials/tools/sql_functions_dump
+)
+
+DATA(
+ arcadia/yql/essentials/data/language
+)
+
+END()
diff --git a/yql/essentials/tools/sql_functions_dump/ya.make b/yql/essentials/tools/sql_functions_dump/ya.make
new file mode 100644
index 00000000000..73dda185476
--- /dev/null
+++ b/yql/essentials/tools/sql_functions_dump/ya.make
@@ -0,0 +1,20 @@
+PROGRAM()
+
+SRCS(
+ sql_functions_dump.cpp
+)
+
+PEERDIR(
+ yql/essentials/sql
+ yql/essentials/sql/v1
+ yql/essentials/utils/backtrace
+ yql/essentials/sql/pg_dummy
+ yql/essentials/public/udf/service/stub
+ library/cpp/json
+)
+
+END()
+
+RECURSE_FOR_TESTS(
+ test
+)