@@ -29,6 +29,7 @@ extern "C" {
29
29
#include " utils.h"
30
30
#include < yql/essentials/ast/yql_expr.h>
31
31
#include < yql/essentials/sql/settings/partitioning.h>
32
+ #include < yql/essentials/sql/settings/translator.h>
32
33
#include < yql/essentials/parser/pg_wrapper/interface/config.h>
33
34
#include < yql/essentials/parser/pg_wrapper/interface/parser.h>
34
35
#include < yql/essentials/parser/pg_wrapper/interface/utils.h>
@@ -1665,7 +1666,7 @@ class TConverter : public IPGParseEvents {
1665
1666
const auto select = ParseSelectStmt (
1666
1667
&selectStmt,
1667
1668
{
1668
- .Inner = true ,
1669
+ .Inner = true ,
1669
1670
.AllowEmptyResSet = true ,
1670
1671
.EmitPgStar = true ,
1671
1672
.FillTargetColumns = false ,
@@ -2971,7 +2972,7 @@ class TConverter : public IPGParseEvents {
2971
2972
return State.Statements .back ();
2972
2973
}
2973
2974
2974
- [[nodiscard]]
2975
+ [[nodiscard]]
2975
2976
TAstNode* ParseAlterTableStmt (const AlterTableStmt* value) {
2976
2977
std::vector<TAstNode*> options;
2977
2978
TString mode = (value->missing_ok ) ? " alter_if_exists" : " alter" ;
@@ -3015,7 +3016,7 @@ class TConverter : public IPGParseEvents {
3015
3016
return nullptr ;
3016
3017
}
3017
3018
const A_Const* localConst = nullptr ;
3018
- if (NodeTag (rawArg) == T_TypeCast) {
3019
+ if (NodeTag (rawArg) == T_TypeCast) {
3019
3020
auto localCast = CAST_NODE (TypeCast, rawArg)->arg ;
3020
3021
if (NodeTag (localCast) != T_A_Const) {
3021
3022
AddError (TStringBuilder () << " Expected a_const in cast, but got something wrong: " << NodeTag (localCast));
@@ -3043,7 +3044,7 @@ class TConverter : public IPGParseEvents {
3043
3044
NodeNotImplemented (def);
3044
3045
return nullptr ;
3045
3046
}
3046
- break ;
3047
+ break ;
3047
3048
}
3048
3049
default :
3049
3050
NodeNotImplemented (rawNode);
@@ -3054,7 +3055,7 @@ class TConverter : public IPGParseEvents {
3054
3055
std::vector<TAstNode*> actions { QL (QA (" alterColumns" ), QVL (alterColumns.data (), alterColumns.size ())) };
3055
3056
3056
3057
options.push_back (
3057
- QL (QA (" actions" ),
3058
+ QL (QA (" actions" ),
3058
3059
QVL (actions.data (), actions.size ())
3059
3060
)
3060
3061
);
@@ -4037,7 +4038,7 @@ class TConverter : public IPGParseEvents {
4037
4038
for (const auto & s : argStrs) {
4038
4039
concatArgs.push_back (L (A (" Key" ), QL (QA (" table" ),L (A (" String" ), QAX (s)))));
4039
4040
}
4040
-
4041
+
4041
4042
key = VL (concatArgs);
4042
4043
} else if (lowerName == " concat_view" ) {
4043
4044
if (argStrs.size () % 2 != 0 ) {
@@ -4048,11 +4049,11 @@ class TConverter : public IPGParseEvents {
4048
4049
TVector<TAstNode*> concatArgs;
4049
4050
concatArgs.push_back (A (" MrTableConcat" ));
4050
4051
for (ui32 i = 0 ; i < argStrs.size (); i += 2 ) {
4051
- concatArgs.push_back (L (A (" Key" ),
4052
+ concatArgs.push_back (L (A (" Key" ),
4052
4053
QL (QA (" table" ),L (A (" String" ), QAX (argStrs[i]))),
4053
4054
QL (QA (" view" ),L (A (" String" ), QAX (argStrs[i + 1 ])))));
4054
4055
}
4055
-
4056
+
4056
4057
key = VL (concatArgs);
4057
4058
} else if (lowerName == " range" ) {
4058
4059
if (argStrs.size () > 5 ) {
@@ -4094,8 +4095,8 @@ class TConverter : public IPGParseEvents {
4094
4095
A (" item" ));
4095
4096
} else {
4096
4097
expr = L (A (" Apply" ),L (A (" Udf" ),QA (" Re2.Match" ),
4097
- QL (L (A (" Apply" ),
4098
- L (A (" Udf" ), QA (" Re2.PatternFromLike" )),
4098
+ QL (L (A (" Apply" ),
4099
+ L (A (" Udf" ), QA (" Re2.PatternFromLike" )),
4099
4100
L (A (" String" ),QAX (argStrs[1 ]))),L (A (" Null" )))),
4100
4101
A (" item" ));
4101
4102
}
@@ -5806,8 +5807,8 @@ class TExtensionHandler : public IPGParseEvents {
5806
5807
5807
5808
if (!leftType) {
5808
5809
return false ;
5809
- }
5810
-
5810
+ }
5811
+
5811
5812
if (procedureName.empty ()) {
5812
5813
return false ;
5813
5814
}
@@ -6194,13 +6195,13 @@ class TExtensionHandler : public IPGParseEvents {
6194
6195
desc.Family = familyName;
6195
6196
TVector<NPg::TAmOpDesc> ops;
6196
6197
TVector<NPg::TAmProcDesc> procs;
6197
-
6198
+
6198
6199
for (int i = 0 ; i < ListLength (value->items ); ++i) {
6199
6200
auto node = LIST_CAST_NTH (CreateOpClassItem, value->items , i);
6200
6201
if (node->itemtype != OPCLASS_ITEM_OPERATOR && node->itemtype != OPCLASS_ITEM_FUNCTION) {
6201
6202
continue ;
6202
6203
}
6203
-
6204
+
6204
6205
if (ListLength (node->name ->objname ) != 1 ) {
6205
6206
return false ;
6206
6207
}
@@ -6422,4 +6423,47 @@ std::unique_ptr<NYql::NPg::ISqlLanguageParser> CreateSqlLanguageParser() {
6422
6423
return std::make_unique<TSqlLanguageParser>();
6423
6424
}
6424
6425
6426
+ class TTranslator : public NSQLTranslation ::ITranslator {
6427
+ public:
6428
+ NSQLTranslation::ILexer::TPtr MakeLexer (const NSQLTranslation::TTranslationSettings& settings) final {
6429
+ Y_UNUSED (settings);
6430
+ ythrow yexception () << " Unsupported method" ;
6431
+ }
6432
+
6433
+ NYql::TAstParseResult TextToAst (const TString& query, const NSQLTranslation::TTranslationSettings& settings,
6434
+ NYql::TWarningRules* warningRules, NYql::TStmtParseInfo* stmtParseInfo) final {
6435
+ Y_UNUSED (warningRules);
6436
+ return PGToYql (query, settings, stmtParseInfo);
6437
+ }
6438
+
6439
+ google::protobuf::Message* TextToMessage (const TString& query, const TString& queryName,
6440
+ NYql::TIssues& issues, size_t maxErrors, const NSQLTranslation::TTranslationSettings& settings) final {
6441
+ Y_UNUSED (query);
6442
+ Y_UNUSED (queryName);
6443
+ Y_UNUSED (issues);
6444
+ Y_UNUSED (maxErrors);
6445
+ Y_UNUSED (settings);
6446
+ ythrow yexception () << " Unsupported method" ;
6447
+ }
6448
+
6449
+ NYql::TAstParseResult TextAndMessageToAst (const TString& query, const google::protobuf::Message& protoAst,
6450
+ const NSQLTranslation::TSQLHints& hints, const NSQLTranslation::TTranslationSettings& settings) final {
6451
+ Y_UNUSED (query);
6452
+ Y_UNUSED (protoAst);
6453
+ Y_UNUSED (hints);
6454
+ Y_UNUSED (settings);
6455
+ ythrow yexception () << " Unsupported method" ;
6456
+ }
6457
+
6458
+ TVector<NYql::TAstParseResult> TextToManyAst (const TString& query, const NSQLTranslation::TTranslationSettings& settings,
6459
+ NYql::TWarningRules* warningRules, TVector<NYql::TStmtParseInfo>* stmtParseInfo) final {
6460
+ Y_UNUSED (warningRules);
6461
+ return PGToYqlStatements (query, settings, stmtParseInfo);
6462
+ }
6463
+ };
6464
+
6465
+ NSQLTranslation::TTranslatorPtr MakeTranslator () {
6466
+ return MakeIntrusive<TTranslator>();
6467
+ }
6468
+
6425
6469
} // NSQLTranslationPG
0 commit comments