diff options
author | vvvv <[email protected]> | 2022-04-16 02:07:08 +0300 |
---|---|---|
committer | vvvv <[email protected]> | 2022-04-16 02:07:08 +0300 |
commit | e80376842a0113f2772c067a0195c4429d30ec35 (patch) | |
tree | f2373419cf08e693e27bd14bfc98ba9877e76959 | |
parent | 3fb8db1bb8f357ec7c35ac9cd17bd9a5c6d22274 (diff) |
YQL-12683 less deps for formatter
ref:a551bdffd5063fb0dfbe9f76affb9926b43925c3
-rw-r--r-- | CMakeLists.darwin.txt | 1 | ||||
-rw-r--r-- | CMakeLists.linux.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/sql/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/sql/sql.cpp | 1 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/proto_parser/CMakeLists.txt | 23 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp | 58 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/proto_parser/proto_parser.h | 20 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/sql.cpp | 35 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/sql.h | 1 |
10 files changed, 108 insertions, 34 deletions
diff --git a/CMakeLists.darwin.txt b/CMakeLists.darwin.txt index fb70403c04e..40f5c20757e 100644 --- a/CMakeLists.darwin.txt +++ b/CMakeLists.darwin.txt @@ -474,6 +474,7 @@ add_subdirectory(ydb/library/yql/sql/v1) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1_proto) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1_ansi) +add_subdirectory(ydb/library/yql/sql/v1/proto_parser) add_subdirectory(ydb/library/yql/sql/v1/lexer) add_subdirectory(ydb/library/yql/core/common_opt) add_subdirectory(ydb/library/yql/core/peephole_opt) diff --git a/CMakeLists.linux.txt b/CMakeLists.linux.txt index efdbd5fb980..314468b7c2a 100644 --- a/CMakeLists.linux.txt +++ b/CMakeLists.linux.txt @@ -554,6 +554,7 @@ add_subdirectory(ydb/library/yql/sql/v1) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1_proto) add_subdirectory(ydb/library/yql/parser/proto_ast/gen/v1_ansi) +add_subdirectory(ydb/library/yql/sql/v1/proto_parser) add_subdirectory(ydb/library/yql/sql/v1/lexer) add_subdirectory(ydb/library/yql/core/common_opt) add_subdirectory(ydb/library/yql/core/peephole_opt) diff --git a/ydb/library/yql/sql/CMakeLists.txt b/ydb/library/yql/sql/CMakeLists.txt index 56605d2d226..24b0c63d407 100644 --- a/ydb/library/yql/sql/CMakeLists.txt +++ b/ydb/library/yql/sql/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(library-yql-sql PUBLIC sql-v0-lexer yql-sql-v1 sql-v1-lexer + sql-v1-proto_parser library-yql-utils ) target_sources(library-yql-sql PRIVATE diff --git a/ydb/library/yql/sql/sql.cpp b/ydb/library/yql/sql/sql.cpp index edbc7779884..00adc841177 100644 --- a/ydb/library/yql/sql/sql.cpp +++ b/ydb/library/yql/sql/sql.cpp @@ -5,6 +5,7 @@ #include <ydb/library/yql/sql/v0/lexer/lexer.h> #include <ydb/library/yql/sql/v1/sql.h> #include <ydb/library/yql/sql/v1/lexer/lexer.h> +#include <ydb/library/yql/sql/v1/proto_parser/proto_parser.h> #include "pg_sql.h" #include <google/protobuf/arena.h> diff --git a/ydb/library/yql/sql/v1/CMakeLists.txt b/ydb/library/yql/sql/v1/CMakeLists.txt index 66e7f9cbf3a..7794fc4b730 100644 --- a/ydb/library/yql/sql/v1/CMakeLists.txt +++ b/ydb/library/yql/sql/v1/CMakeLists.txt @@ -30,6 +30,7 @@ target_link_libraries(yql-sql-v1 PUBLIC proto_ast-gen-v1_ansi proto_ast-gen-v1_proto yql-parser-pg_catalog + sql-v1-proto_parser tools-enum_parser-enum_serialization_runtime ) target_sources(yql-sql-v1 PRIVATE diff --git a/ydb/library/yql/sql/v1/proto_parser/CMakeLists.txt b/ydb/library/yql/sql/v1/proto_parser/CMakeLists.txt new file mode 100644 index 00000000000..6e916d607b8 --- /dev/null +++ b/ydb/library/yql/sql/v1/proto_parser/CMakeLists.txt @@ -0,0 +1,23 @@ + +# This file was gererated 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_library(sql-v1-proto_parser) +target_link_libraries(sql-v1-proto_parser PUBLIC + contrib-libs-cxxsupp + yutil + library-yql-utils + yql-parser-proto_ast + parser-proto_ast-collect_issues + proto_ast-gen-v1 + proto_ast-gen-v1_ansi + proto_ast-gen-v1_proto +) +target_sources(sql-v1-proto_parser PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp +) diff --git a/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp b/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp new file mode 100644 index 00000000000..a26da0c62e0 --- /dev/null +++ b/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp @@ -0,0 +1,58 @@ +#include "proto_parser.h" + +#include <ydb/library/yql/utils/yql_panic.h> + +#include <ydb/library/yql/parser/proto_ast/collect_issues/collect_issues.h> +#include <ydb/library/yql/parser/proto_ast/gen/v1/SQLv1Lexer.h> +#include <ydb/library/yql/parser/proto_ast/gen/v1/SQLv1Parser.h> +#include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Lexer.h> +#include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Parser.h> + +#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h> + +#if defined(_tsan_enabled_) +#include <util/system/mutex.h> +#endif + +using namespace NYql; + +namespace NSQLTranslationV1 { + +using NALPDefault::SQLv1LexerTokens; + +#if defined(_tsan_enabled_) + TMutex SanitizerSQLTranslationMutex; +#endif + +using namespace NSQLv1Generated; + +google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, TIssues& err, size_t maxErrors, bool ansiLexer, google::protobuf::Arena* arena) { + YQL_ENSURE(arena); +#if defined(_tsan_enabled_) + TGuard<TMutex> grd(SanitizerSQLTranslationMutex); +#endif + NSQLTranslation::TErrorCollectorOverIssues collector(err, maxErrors, ""); + if (ansiLexer) { + NProtoAST::TProtoASTBuilder<NALPAnsi::SQLv1Parser, NALPAnsi::SQLv1Lexer> builder(query, queryName, arena); + return builder.BuildAST(collector); + } else { + NProtoAST::TProtoASTBuilder<NALPDefault::SQLv1Parser, NALPDefault::SQLv1Lexer> builder(query, queryName, arena); + return builder.BuildAST(collector); + } +} + +google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err, bool ansiLexer, google::protobuf::Arena* arena) { + YQL_ENSURE(arena); +#if defined(_tsan_enabled_) + TGuard<TMutex> grd(SanitizerSQLTranslationMutex); +#endif + if (ansiLexer) { + NProtoAST::TProtoASTBuilder<NALPAnsi::SQLv1Parser, NALPAnsi::SQLv1Lexer> builder(query, queryName, arena); + return builder.BuildAST(err); + } else { + NProtoAST::TProtoASTBuilder<NALPDefault::SQLv1Parser, NALPDefault::SQLv1Lexer> builder(query, queryName, arena); + return builder.BuildAST(err); + } +} + +} // namespace NSQLTranslationV1 diff --git a/ydb/library/yql/sql/v1/proto_parser/proto_parser.h b/ydb/library/yql/sql/v1/proto_parser/proto_parser.h new file mode 100644 index 00000000000..64ea34b0060 --- /dev/null +++ b/ydb/library/yql/sql/v1/proto_parser/proto_parser.h @@ -0,0 +1,20 @@ +#pragma once + +#include <ydb/library/yql/ast/yql_ast.h> +#include <ydb/library/yql/parser/proto_ast/proto_ast.h> +#include <ydb/library/yql/public/issue/yql_warning.h> +#include <ydb/library/yql/public/issue/yql_issue_manager.h> +#include <ydb/library/yql/sql/settings/translation_settings.h> + +#include <google/protobuf/message.h> + +namespace NSQLTranslation { + struct TTranslationSettings; +} + +namespace NSQLTranslationV1 { + + google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, NYql::TIssues& err, size_t maxErrors, bool ansiLexer, google::protobuf::Arena* arena = nullptr); + google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err, bool ansiLexer, google::protobuf::Arena* arena); + +} // namespace NSQLTranslationV1 diff --git a/ydb/library/yql/sql/v1/sql.cpp b/ydb/library/yql/sql/v1/sql.cpp index 891665d1ea8..9b96d0e2889 100644 --- a/ydb/library/yql/sql/v1/sql.cpp +++ b/ydb/library/yql/sql/v1/sql.cpp @@ -10,6 +10,8 @@ #include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Lexer.h> #include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Parser.h> +#include <ydb/library/yql/sql/v1/proto_parser/proto_parser.h> + #include <ydb/library/yql/ast/yql_expr.h> #include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h> #include <ydb/library/yql/minikql/mkql_program_builder.h> @@ -43,10 +45,6 @@ namespace NSQLTranslationV1 { using NALPDefault::SQLv1LexerTokens; -#if defined(_tsan_enabled_) - TMutex SanitizerSQLTranslationMutex; -#endif - using namespace NSQLv1Generated; static TPosition GetPos(const TToken& token) { @@ -10125,35 +10123,6 @@ TNodePtr TSqlTranslation::ForStatement(const TRule_for_stmt& stmt) { return BuildWorldForNode(Ctx.Pos(), exprNode, bodyNode, elseNode, isEvaluate); } -google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, TIssues& err, size_t maxErrors, bool ansiLexer, google::protobuf::Arena* arena) { - YQL_ENSURE(arena); -#if defined(_tsan_enabled_) - TGuard<TMutex> grd(SanitizerSQLTranslationMutex); -#endif - NSQLTranslation::TErrorCollectorOverIssues collector(err, maxErrors, ""); - if (ansiLexer) { - NProtoAST::TProtoASTBuilder<NALPAnsi::SQLv1Parser, NALPAnsi::SQLv1Lexer> builder(query, queryName, arena); - return builder.BuildAST(collector); - } else { - NProtoAST::TProtoASTBuilder<NALPDefault::SQLv1Parser, NALPDefault::SQLv1Lexer> builder(query, queryName, arena); - return builder.BuildAST(collector); - } -} - -google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err, bool ansiLexer, google::protobuf::Arena* arena) { - YQL_ENSURE(arena); -#if defined(_tsan_enabled_) - TGuard<TMutex> grd(SanitizerSQLTranslationMutex); -#endif - if (ansiLexer) { - NProtoAST::TProtoASTBuilder<NALPAnsi::SQLv1Parser, NALPAnsi::SQLv1Lexer> builder(query, queryName, arena); - return builder.BuildAST(err); - } else { - NProtoAST::TProtoASTBuilder<NALPDefault::SQLv1Parser, NALPDefault::SQLv1Lexer> builder(query, queryName, arena); - return builder.BuildAST(err); - } -} - TAstNode* SqlASTToYql(const google::protobuf::Message& protoAst, TContext& ctx) { const google::protobuf::Descriptor* d = protoAst.GetDescriptor(); if (d && d->name() != "TSQLv1ParserAST") { diff --git a/ydb/library/yql/sql/v1/sql.h b/ydb/library/yql/sql/v1/sql.h index 9c7dc676c63..a59f0f3c23c 100644 --- a/ydb/library/yql/sql/v1/sql.h +++ b/ydb/library/yql/sql/v1/sql.h @@ -15,7 +15,6 @@ namespace NSQLTranslation { namespace NSQLTranslationV1 { NYql::TAstParseResult SqlToYql(const TString& query, const NSQLTranslation::TTranslationSettings& settings, NYql::TWarningRules* warningRules = nullptr); - google::protobuf::Message* SqlAST(const TString& query, const TString& queryName, NYql::TIssues& err, size_t maxErrors, bool ansiLexer, google::protobuf::Arena* arena = nullptr); NYql::TAstParseResult SqlASTToYql(const google::protobuf::Message& protoAst, const NSQLTranslation::TTranslationSettings& settings); } // namespace NSQLTranslationV1 |