Skip to content

Commit 33b9933

Browse files
authored
Add EnablePgSyntax (#8796)
1 parent fcf9368 commit 33b9933

File tree

14 files changed

+33
-4
lines changed

14 files changed

+33
-4
lines changed

ydb/core/kqp/compile_service/kqp_compile_actor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
146146
.SetIsEnableExternalDataSources(AppData(ctx)->FeatureFlags.GetEnableExternalDataSources())
147147
.SetIsEnablePgConstsToParams(Config->EnablePgConstsToParams)
148148
.SetApplicationName(ApplicationName)
149-
.SetQueryParameters(QueryId.QueryParameterTypes);
149+
.SetQueryParameters(QueryId.QueryParameterTypes)
150+
.SetIsEnablePgSyntax(AppData(ctx)->FeatureFlags.GetEnablePgSyntax());
150151

151152
return ParseStatements(QueryId.Text, QueryId.Settings.Syntax, QueryId.IsSql(), settingsBuilder, PerStatementResult);
152153
}

ydb/core/kqp/host/kqp_host.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,8 @@ class TKqpHost : public IKqpHost {
12261226
.SetIsEnableExternalDataSources(SessionCtx->Config().FeatureFlags.GetEnableExternalDataSources())
12271227
.SetIsEnablePgConstsToParams(SessionCtx->Config().EnablePgConstsToParams)
12281228
.SetQueryParameters(query.ParameterTypes)
1229-
.SetApplicationName(ApplicationName);
1229+
.SetApplicationName(ApplicationName)
1230+
.SetIsEnablePgSyntax(SessionCtx->Config().FeatureFlags.GetEnablePgSyntax());
12301231
auto astRes = ParseQuery(query.Text, isSql, sqlVersion, TypesCtx->DeprecatedSQL, ctx, settingsBuilder, result.KeepInCache, result.CommandTagName);
12311232
if (astRes.ActualSyntaxType == NYql::ESyntaxType::Pg) {
12321233
SessionCtx->Config().IndexAutoChooserMode = NKikimrConfig::TTableServiceConfig_EIndexAutoChooseMode::TTableServiceConfig_EIndexAutoChooseMode_MAX_USED_PREFIX;

ydb/core/kqp/host/kqp_translate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ NSQLTranslation::TTranslationSettings TKqpTranslationSettingsBuilder::Build(NYql
8686
settings.SaveWorldDependencies = true;
8787
}
8888

89+
settings.PGDisable = !IsEnablePgSyntax;
8990
settings.InferSyntaxVersion = true;
9091
settings.V0ForceDisable = false;
9192
settings.WarnOnV0 = false;

ydb/core/kqp/host/kqp_translate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class TKqpTranslationSettingsBuilder {
6262
return *this;
6363
}
6464

65+
TKqpTranslationSettingsBuilder& SetIsEnablePgSyntax(bool value) {
66+
IsEnablePgSyntax = value;
67+
return *this;
68+
}
69+
6570
private:
6671
const NYql::EKikimrQueryType QueryType;
6772
const ui16 KqpYqlSyntaxVersion;
@@ -73,6 +78,7 @@ class TKqpTranslationSettingsBuilder {
7378
TString KqpTablePathPrefix = {};
7479
bool IsEnableExternalDataSources = false;
7580
bool IsEnablePgConstsToParams = false;
81+
bool IsEnablePgSyntax = false;
7682
TMaybe<bool> SqlAutoCommit = {};
7783
TGUCSettings::TPtr GUCSettings;
7884
TMaybe<TString> ApplicationName = {};

ydb/core/kqp/ut/common/kqp_ut_common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ TKikimrRunner::TKikimrRunner(const TKikimrSettings& settings) {
132132
ServerSettings->SetEnableUniqConstraint(true);
133133
ServerSettings->SetUseRealThreads(settings.UseRealThreads);
134134
ServerSettings->SetEnableTablePgTypes(true);
135+
ServerSettings->SetEnablePgSyntax(true);
135136
ServerSettings->S3ActorsFactory = settings.S3ActorsFactory;
136137

137138
if (settings.Storage) {

ydb/core/kqp/ut/pg/kqp_pg_ut.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4685,7 +4685,8 @@ Y_UNIT_TEST_SUITE(KqpPg) {
46854685
ui16 mbusport = tp.GetPort(2134);
46864686
auto settings = Tests::TServerSettings(mbusport)
46874687
.SetDomainName("Root")
4688-
.SetUseRealThreads(false);
4688+
.SetUseRealThreads(false)
4689+
.SetEnablePgSyntax(true);
46894690

46904691
Tests::TServer::TPtr server = new Tests::TServer(settings);
46914692

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,5 @@ message TFeatureFlags {
148148
optional bool EnableChangefeedsOnIndexTables = 134 [default = false];
149149
optional bool EnableResourcePoolsCounters = 135 [default = false];
150150
optional bool EnableOptionalColumnsInColumnShard = 136 [default = false];
151+
optional bool EnablePgSyntax = 139 [default = true];
151152
}

ydb/core/testlib/basics/feature_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class TTestFeatureFlagsHolder {
6262
FEATURE_FLAG_SETTER(EnableTableDatetime64)
6363
FEATURE_FLAG_SETTER(EnableResourcePools)
6464
FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables)
65+
FEATURE_FLAG_SETTER(EnablePgSyntax)
6566

6667
#undef FEATURE_FLAG_SETTER
6768
};

ydb/library/yql/sql/settings/translation_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace NSQLTranslation {
5757
, InferSyntaxVersion(false)
5858
, V0Behavior(EV0Behavior::Disable)
5959
, V0ForceDisable(InTestEnvironment())
60+
, PGDisable(false)
6061
, WarnOnV0(true)
6162
, V0WarnAsError(ISqlFeaturePolicy::MakeAlwaysDisallow())
6263
, DqDefaultAuto(ISqlFeaturePolicy::MakeAlwaysDisallow())

ydb/library/yql/sql/settings/translation_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ namespace NSQLTranslation {
105105
bool InferSyntaxVersion;
106106
EV0Behavior V0Behavior;
107107
bool V0ForceDisable;
108+
bool PGDisable;
108109
bool WarnOnV0;
109110
ISqlFeaturePolicy::TPtr V0WarnAsError;
110111
ISqlFeaturePolicy::TPtr DqDefaultAuto;

ydb/library/yql/sql/sql.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ namespace NSQLTranslation {
3434
return result;
3535
}
3636

37+
if (parsedSettings.PgParser && parsedSettings.PGDisable) {
38+
result.Issues.AddIssue(NYql::YqlIssue(NYql::TPosition(), NYql::TIssuesIds::DEFAULT_ERROR,
39+
"PG syntax is disabled"));
40+
return result;
41+
}
42+
3743
if (parsedSettings.PgParser) {
3844
return NSQLTranslationPG::PGToYql(query, parsedSettings, stmtParseInfo);
3945
}
@@ -184,6 +190,12 @@ namespace NSQLTranslation {
184190
return {};
185191
}
186192

193+
if (parsedSettings.PgParser && parsedSettings.PGDisable) {
194+
issues.AddIssue(NYql::YqlIssue(NYql::TPosition(), NYql::TIssuesIds::DEFAULT_ERROR,
195+
"PG syntax is disabled"));
196+
return result;
197+
}
198+
187199
if (parsedSettings.PgParser) {
188200
return NSQLTranslationPG::PGToYqlStatements(query, parsedSettings, stmtParseInfo);
189201
}

ydb/tests/fq/yt/cfg/kqprun_config.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FeatureFlags {
22
EnableExternalDataSources: true
33
EnableScriptExecutionOperations: true
4+
EnablePgSyntax: true
45
}
56

67
QueryServiceConfig {

ydb/tests/functional/postgresql/test_postgres.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setup_class(cls):
6969
'KQP_COMPILE_REQUEST': LogLevels.DEBUG,
7070
'KQP_PROXY': LogLevels.DEBUG
7171
},
72-
extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables'],
72+
extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables', 'enable_pg_syntax'],
7373
pgwire_port=cls.pgport
7474
))
7575
cls.cluster.start()

ydb/tests/library/harness/kikimr_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ def __init__(
395395
self.yaml_config["table_service_config"]["index_auto_choose_mode"] = 'max_used_prefix'
396396
self.yaml_config["feature_flags"]['enable_temp_tables'] = True
397397
self.yaml_config["feature_flags"]['enable_table_pg_types'] = True
398+
self.yaml_config['feature_flags']['enable_pg_syntax'] = True
398399
self.yaml_config['feature_flags']['enable_uniq_constraint'] = True
399400

400401
# https://github.com/ydb-platform/ydb/issues/5152

0 commit comments

Comments
 (0)