Skip to content

Commit a6248d0

Browse files
authored
Allow to specify PG syntax in dqrun/yqlrun (#4893)
1 parent 2f366dc commit a6248d0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ydb/library/yql/tools/dqrun/dqrun.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ using namespace NYql;
108108

109109
struct TRunOptions {
110110
bool Sql = false;
111+
bool Pg = false;
111112
TString User;
112113
TMaybe<TString> BindingsFile;
113114
NYson::EYsonFormat ResultsFormat;
@@ -339,9 +340,10 @@ std::tuple<std::unique_ptr<TActorSystemManager>, TActorIds> RunActorSystem(
339340
int RunProgram(TProgramPtr program, const TRunOptions& options, const THashMap<TString, TString>& clusters, const THashSet<TString>& sqlFlags) {
340341
program->SetUseTableMetaFromGraph(options.UseMetaFromGraph);
341342
bool fail = true;
342-
if (options.Sql) {
343+
if (options.Sql || options.Pg) {
343344
Cout << "Parse SQL..." << Endl;
344345
NSQLTranslation::TTranslationSettings sqlSettings;
346+
sqlSettings.PgParser = options.Pg;
345347
sqlSettings.ClusterMapping = clusters;
346348
sqlSettings.SyntaxVersion = 1;
347349
sqlSettings.Flags = sqlFlags;
@@ -507,6 +509,7 @@ int RunMain(int argc, const char* argv[])
507509
.Optional()
508510
.NoArgument()
509511
.SetFlag(&runOptions.Sql);
512+
opts.AddLongOption("pg", "Program has PG syntax").NoArgument().SetFlag(&runOptions.Pg);
510513
opts.AddLongOption('t', "table", "table@file").AppendTo(&tablesMappingList);
511514
opts.AddLongOption('C', "cluster", "set cluster to service mapping").RequiredArgument("name@service").Handler(new TStoreMappingFunctor(&clusterMapping));
512515
opts.AddLongOption('u', "user", "MR user")

ydb/library/yql/tools/yqlrun/yqlrun.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ int Main(int argc, const char *argv[])
411411
opts.AddHelpOption();
412412
opts.AddLongOption('p', "program", "program file").StoreResult<TString>(&programFile);
413413
opts.AddLongOption('s', "sql", "program is SQL query").NoArgument();
414+
opts.AddLongOption("pg", "program has PG syntax").NoArgument();
414415
opts.AddLongOption('t', "table", "table@file").AppendTo(&tablesMappingList);
415416
opts.AddLongOption('C', "cluster", "set cluster to service mapping").RequiredArgument("name@service").Handler(new TStoreMappingFunctor(&clusterMapping));
416417
opts.AddLongOption("ndebug", "should be at first argument, do not show debug info in error output").NoArgument();
@@ -677,10 +678,11 @@ int Main(int argc, const char *argv[])
677678
program->SetParametersYson(parameters);
678679
}
679680

680-
if (res.Has("sql")) {
681+
if (res.Has("sql") || res.Has("pg")) {
681682
google::protobuf::Arena arena;
682683
NSQLTranslation::TTranslationSettings settings;
683684
settings.Arena = &arena;
685+
settings.PgParser = res.Has("pg");
684686
settings.ClusterMapping = clusterMapping;
685687
settings.Flags = sqlFlags;
686688
settings.SyntaxVersion = syntaxVersion;

0 commit comments

Comments
 (0)