aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-08-24 21:17:29 +0300
committervvvv <vvvv@ydb.tech>2023-08-24 21:40:03 +0300
commitbe0a7d490e3d42e247c032da80dd03a4f9a1e86c (patch)
tree4fe68f5d4c7f0b91597579d493bbd91b4d5a6d13
parente952891ca11362042404965378d76b1b579aa424 (diff)
downloadydb-be0a7d490e3d42e247c032da80dd03a4f9a1e86c.tar.gz
Moved astdiff
-rw-r--r--build/conf/project_specific/yql_udf.conf2
-rw-r--r--ydb/library/yql/tools/CMakeLists.txt1
-rw-r--r--ydb/library/yql/tools/astdiff/CMakeLists.darwin-x86_64.txt32
-rw-r--r--ydb/library/yql/tools/astdiff/CMakeLists.linux-aarch64.txt35
-rw-r--r--ydb/library/yql/tools/astdiff/CMakeLists.linux-x86_64.txt37
-rw-r--r--ydb/library/yql/tools/astdiff/CMakeLists.txt17
-rw-r--r--ydb/library/yql/tools/astdiff/CMakeLists.windows-x86_64.txt25
-rw-r--r--ydb/library/yql/tools/astdiff/astdiff.cpp88
-rw-r--r--ydb/library/yql/tools/astdiff/ya.make13
-rw-r--r--ydb/library/yql/tools/ya.make1
10 files changed, 250 insertions, 1 deletions
diff --git a/build/conf/project_specific/yql_udf.conf b/build/conf/project_specific/yql_udf.conf
index f2b575e2729..7c1256da477 100644
--- a/build/conf/project_specific/yql_udf.conf
+++ b/build/conf/project_specific/yql_udf.conf
@@ -36,7 +36,7 @@ macro UDF_NO_PROBE() {
module YQL_UDF_TEST: PY3TEST_BIN {
PEERDIR(yql/library/udf_test)
- DEPENDS(yql/tools/astdiff)
+ DEPENDS(ydb/library/yql/tools/astdiff)
DEPENDS(yql/tools/yqlrun)
DATA(arcadia/ydb/library/yql/mount)
DATA(arcadia/ydb/library/yql/cfg/udf_test)
diff --git a/ydb/library/yql/tools/CMakeLists.txt b/ydb/library/yql/tools/CMakeLists.txt
index 4c2a3daa2ea..1bb9aec0d0d 100644
--- a/ydb/library/yql/tools/CMakeLists.txt
+++ b/ydb/library/yql/tools/CMakeLists.txt
@@ -6,4 +6,5 @@
# original buildsystem will not be accepted.
+add_subdirectory(astdiff)
add_subdirectory(mrjob)
diff --git a/ydb/library/yql/tools/astdiff/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/tools/astdiff/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 00000000000..09fe7f98db7
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,32 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(astdiff)
+target_link_libraries(astdiff PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ library-cpp-getopt
+ library-yql-ast
+ yql-utils-backtrace
+)
+target_link_options(astdiff PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(astdiff PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/tools/astdiff/astdiff.cpp
+)
+target_allocator(astdiff
+ system_allocator
+)
+vcs_info(astdiff)
diff --git a/ydb/library/yql/tools/astdiff/CMakeLists.linux-aarch64.txt b/ydb/library/yql/tools/astdiff/CMakeLists.linux-aarch64.txt
new file mode 100644
index 00000000000..d40d22a6667
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,35 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(astdiff)
+target_link_libraries(astdiff PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-getopt
+ library-yql-ast
+ yql-utils-backtrace
+)
+target_link_options(astdiff PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(astdiff PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/tools/astdiff/astdiff.cpp
+)
+target_allocator(astdiff
+ cpp-malloc-jemalloc
+)
+vcs_info(astdiff)
diff --git a/ydb/library/yql/tools/astdiff/CMakeLists.linux-x86_64.txt b/ydb/library/yql/tools/astdiff/CMakeLists.linux-x86_64.txt
new file mode 100644
index 00000000000..95dcdef6905
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,37 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(astdiff)
+target_link_libraries(astdiff PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ library-cpp-getopt
+ library-yql-ast
+ yql-utils-backtrace
+)
+target_link_options(astdiff PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(astdiff PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/tools/astdiff/astdiff.cpp
+)
+target_allocator(astdiff
+ cpp-malloc-tcmalloc
+ libs-tcmalloc-no_percpu_cache
+)
+vcs_info(astdiff)
diff --git a/ydb/library/yql/tools/astdiff/CMakeLists.txt b/ydb/library/yql/tools/astdiff/CMakeLists.txt
new file mode 100644
index 00000000000..f8b31df0c11
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/library/yql/tools/astdiff/CMakeLists.windows-x86_64.txt b/ydb/library/yql/tools/astdiff/CMakeLists.windows-x86_64.txt
new file mode 100644
index 00000000000..1e43832a4d8
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,25 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(astdiff)
+target_link_libraries(astdiff PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ library-cpp-getopt
+ library-yql-ast
+ yql-utils-backtrace
+)
+target_sources(astdiff PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/tools/astdiff/astdiff.cpp
+)
+target_allocator(astdiff
+ system_allocator
+)
+vcs_info(astdiff)
diff --git a/ydb/library/yql/tools/astdiff/astdiff.cpp b/ydb/library/yql/tools/astdiff/astdiff.cpp
new file mode 100644
index 00000000000..6d2b6baf024
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/astdiff.cpp
@@ -0,0 +1,88 @@
+
+#include <ydb/library/yql/utils/backtrace/backtrace.h>
+
+#include <ydb/library/yql/ast/yql_expr.h>
+
+#include <library/cpp/svnversion/svnversion.h>
+
+#include <util/stream/file.h>
+#include <util/generic/yexception.h>
+
+using namespace NYql;
+
+int Main(int argc, const char *argv[])
+{
+ if (argc != 3) {
+ PrintProgramSvnVersion();
+ Cout << Endl << "Usage: " << argv[0] << " <fileone> <filetwo>" << Endl;
+ return 2;
+ }
+
+ const TString fileOne(argv[1]), fileTwo(argv[2]);
+ const auto progOne(ParseAst(TFileInput(fileOne).ReadAll())), progTwo(ParseAst(TFileInput(fileTwo).ReadAll()));
+
+ if (!(progOne.IsOk() && progTwo.IsOk())) {
+ if (!progOne.IsOk()) {
+ Cerr << "Errors in " << fileOne << Endl;
+ progOne.Issues.PrintTo(Cerr);
+ }
+ if (!progTwo.IsOk()) {
+ Cerr << "Errors in " << fileTwo << Endl;
+ progTwo.Issues.PrintTo(Cerr);
+ }
+ return 3;
+ }
+
+ TExprContext ctxOne, ctxTwo;
+ TExprNode::TPtr exprOne, exprTwo;
+
+ const bool okOne = CompileExpr(*progOne.Root, exprOne, ctxOne, nullptr, nullptr);
+ const bool okTwo = CompileExpr(*progTwo.Root, exprTwo, ctxTwo, nullptr, nullptr);
+
+ if (!(okOne && okTwo)) {
+ if (!okOne) {
+ Cerr << "Errors on compile " << fileOne << Endl;
+ ctxOne.IssueManager.GetIssues().PrintTo(Cerr);
+ }
+ if (!okTwo) {
+ Cerr << "Errors on compile " << fileTwo << Endl;
+ ctxTwo.IssueManager.GetIssues().PrintTo(Cerr);
+ }
+ return 4;
+ }
+
+ const TExprNode* rootOne = exprOne.Get();
+ const TExprNode* rootTwo = exprTwo.Get();
+
+ auto rootOnePos = ctxOne.GetPosition(rootOne->Pos());
+ auto rootTwoPos = ctxTwo.GetPosition(rootTwo->Pos());
+ if (!CompareExprTrees(rootOne, rootTwo)) {
+ Cerr << "Programs are not equal!" << Endl;
+ if (rootOne->Type() != rootTwo->Type()) {
+ Cerr << "Node in " << fileOne << " at [" << rootOnePos.Row << ":" << rootOnePos.Column << "] type is " << rootOne->Type() << Endl;
+ Cerr << "Node in " << fileTwo << " at [" << rootTwoPos.Row << ":" << rootTwoPos.Column << "] type is " << rootTwo->Type() << Endl;
+ } else if (rootOne->ChildrenSize() != rootTwo->ChildrenSize()) {
+ Cerr << "Node '" << rootOne->Content() << "' in " << fileOne << " at [" << rootOnePos.Row << ":" << rootOnePos.Column << "] has " << rootOne->ChildrenSize() << " children." << Endl;
+ Cerr << "Node '" << rootTwo->Content() << "' in " << fileTwo << " at [" << rootTwoPos.Row << ":" << rootTwoPos.Column << "] has " << rootTwo->ChildrenSize() << " children." << Endl;
+ } else {
+ Cerr << "Node in " << fileOne << " at [" << rootOnePos.Row << ":" << rootOnePos.Column << "]:" << Endl << rootOne->Dump() << Endl;
+ Cerr << "Node in " << fileTwo << " at [" << rootTwoPos.Row << ":" << rootTwoPos.Column << "]:" << Endl << rootTwo->Dump() << Endl;
+ }
+ return 5;
+ }
+
+ 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/ydb/library/yql/tools/astdiff/ya.make b/ydb/library/yql/tools/astdiff/ya.make
new file mode 100644
index 00000000000..4f49b8d1c06
--- /dev/null
+++ b/ydb/library/yql/tools/astdiff/ya.make
@@ -0,0 +1,13 @@
+PROGRAM(astdiff)
+
+SRCS(
+ astdiff.cpp
+)
+
+PEERDIR(
+ library/cpp/getopt
+ ydb/library/yql/ast
+ ydb/library/yql/utils/backtrace
+)
+
+END()
diff --git a/ydb/library/yql/tools/ya.make b/ydb/library/yql/tools/ya.make
index abaf4d8a13a..afc6bc7b1fd 100644
--- a/ydb/library/yql/tools/ya.make
+++ b/ydb/library/yql/tools/ya.make
@@ -1,4 +1,5 @@
RECURSE(
+ astdiff
mrjob
mrjob/test
)