Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnablePgSyntax flag #8703

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ydb/core/kqp/compile_service/kqp_compile_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
.SetIsEnableExternalDataSources(AppData(ctx)->FeatureFlags.GetEnableExternalDataSources())
.SetIsEnablePgConstsToParams(Config->EnablePgConstsToParams)
.SetApplicationName(ApplicationName)
.SetQueryParameters(QueryId.QueryParameterTypes);
.SetQueryParameters(QueryId.QueryParameterTypes)
.SetIsEnablePgSyntax(AppData(ctx)->FeatureFlags.GetEnablePgSyntax());

return ParseStatements(QueryId.Text, QueryId.Settings.Syntax, QueryId.IsSql(), settingsBuilder, PerStatementResult);
}
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/kqp/host/kqp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,8 @@ class TKqpHost : public IKqpHost {
.SetIsEnableExternalDataSources(SessionCtx->Config().FeatureFlags.GetEnableExternalDataSources())
.SetIsEnablePgConstsToParams(SessionCtx->Config().EnablePgConstsToParams)
.SetQueryParameters(query.ParameterTypes)
.SetApplicationName(ApplicationName);
.SetApplicationName(ApplicationName)
.SetIsEnablePgSyntax(SessionCtx->Config().FeatureFlags.GetEnablePgSyntax());
auto astRes = ParseQuery(query.Text, isSql, sqlVersion, TypesCtx->DeprecatedSQL, ctx, settingsBuilder, result.KeepInCache, result.CommandTagName);
if (astRes.ActualSyntaxType == NYql::ESyntaxType::Pg) {
SessionCtx->Config().IndexAutoChooserMode = NKikimrConfig::TTableServiceConfig_EIndexAutoChooseMode::TTableServiceConfig_EIndexAutoChooseMode_MAX_USED_PREFIX;
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/host/kqp_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ NSQLTranslation::TTranslationSettings TKqpTranslationSettingsBuilder::Build(NYql
settings.SaveWorldDependencies = true;
}

settings.PGDisable = !IsEnablePgSyntax;
settings.InferSyntaxVersion = true;
settings.V0ForceDisable = false;
settings.WarnOnV0 = false;
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/kqp/host/kqp_translate.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class TKqpTranslationSettingsBuilder {
return *this;
}

TKqpTranslationSettingsBuilder& SetIsEnablePgSyntax(bool value) {
IsEnablePgSyntax = value;
return *this;
}

private:
const NYql::EKikimrQueryType QueryType;
const ui16 KqpYqlSyntaxVersion;
Expand All @@ -73,6 +78,7 @@ class TKqpTranslationSettingsBuilder {
TString KqpTablePathPrefix = {};
bool IsEnableExternalDataSources = false;
bool IsEnablePgConstsToParams = false;
bool IsEnablePgSyntax = false;
TMaybe<bool> SqlAutoCommit = {};
TGUCSettings::TPtr GUCSettings;
TMaybe<TString> ApplicationName = {};
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/ut/common/kqp_ut_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ TKikimrRunner::TKikimrRunner(const TKikimrSettings& settings) {
ServerSettings->SetEnableMoveIndex(true);
ServerSettings->SetUseRealThreads(settings.UseRealThreads);
ServerSettings->SetEnableTablePgTypes(true);
ServerSettings->SetEnablePgSyntax(true);
ServerSettings->S3ActorsFactory = settings.S3ActorsFactory;

if (settings.Storage) {
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/kqp/ut/pg/kqp_pg_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4801,7 +4801,8 @@ Y_UNIT_TEST_SUITE(KqpPg) {
ui16 mbusport = tp.GetPort(2134);
auto settings = Tests::TServerSettings(mbusport)
.SetDomainName("Root")
.SetUseRealThreads(false);
.SetUseRealThreads(false)
.SetEnablePgSyntax(true);

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

Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,5 @@ message TFeatureFlags {
optional bool EnableOptionalColumnsInColumnShard = 136 [default = false];
optional bool EnableGranularTimecast = 137 [default = true];
optional bool EnableAlterShardingInColumnShard = 138 [default = false];
optional bool EnablePgSyntax = 139 [default = true];
}
1 change: 1 addition & 0 deletions ydb/core/testlib/basics/feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TTestFeatureFlagsHolder {
FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables)
FEATURE_FLAG_SETTER(EnableBackupService)
FEATURE_FLAG_SETTER(EnableGranularTimecast)
FEATURE_FLAG_SETTER(EnablePgSyntax)

#undef FEATURE_FLAG_SETTER
};
Expand Down
1 change: 1 addition & 0 deletions ydb/library/yql/sql/settings/translation_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace NSQLTranslation {
, InferSyntaxVersion(false)
, V0Behavior(EV0Behavior::Disable)
, V0ForceDisable(InTestEnvironment())
, PGDisable(false)
, WarnOnV0(true)
, V0WarnAsError(ISqlFeaturePolicy::MakeAlwaysDisallow())
, DqDefaultAuto(ISqlFeaturePolicy::MakeAlwaysDisallow())
Expand Down
1 change: 1 addition & 0 deletions ydb/library/yql/sql/settings/translation_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace NSQLTranslation {
bool InferSyntaxVersion;
EV0Behavior V0Behavior;
bool V0ForceDisable;
bool PGDisable;
bool WarnOnV0;
ISqlFeaturePolicy::TPtr V0WarnAsError;
ISqlFeaturePolicy::TPtr DqDefaultAuto;
Expand Down
12 changes: 12 additions & 0 deletions ydb/library/yql/sql/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ namespace NSQLTranslation {
return result;
}

if (parsedSettings.PgParser && parsedSettings.PGDisable) {
result.Issues.AddIssue(NYql::YqlIssue(NYql::TPosition(), NYql::TIssuesIds::DEFAULT_ERROR,
"PG syntax is disabled"));
return result;
}

if (parsedSettings.PgParser) {
return NSQLTranslationPG::PGToYql(query, parsedSettings, stmtParseInfo);
}
Expand Down Expand Up @@ -184,6 +190,12 @@ namespace NSQLTranslation {
return {};
}

if (parsedSettings.PgParser && parsedSettings.PGDisable) {
issues.AddIssue(NYql::YqlIssue(NYql::TPosition(), NYql::TIssuesIds::DEFAULT_ERROR,
"PG syntax is disabled"));
return result;
}

if (parsedSettings.PgParser) {
return NSQLTranslationPG::PGToYqlStatements(query, parsedSettings, stmtParseInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/tests/functional/postgresql/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def setup_class(cls):
'KQP_COMPILE_REQUEST': LogLevels.DEBUG,
'KQP_PROXY': LogLevels.DEBUG
},
extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables'],
extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables', 'enable_pg_syntax'],
))
cls.cluster.start()

Expand Down
1 change: 1 addition & 0 deletions ydb/tests/library/harness/kikimr_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def __init__(
self.yaml_config["table_service_config"]["index_auto_choose_mode"] = 'max_used_prefix'
self.yaml_config["feature_flags"]['enable_temp_tables'] = True
self.yaml_config["feature_flags"]['enable_table_pg_types'] = True
self.yaml_config['feature_flags']['enable_pg_syntax'] = True
self.yaml_config['feature_flags']['enable_uniq_constraint'] = True
if "local_pg_wire_config" not in self.yaml_config:
self.yaml_config["local_pg_wire_config"] = {}
Expand Down
Loading