aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_translation.cpp
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.com>2024-11-12 22:07:02 +0300
committerudovichenko-r <udovichenko-r@yandex-team.com>2024-11-12 22:21:07 +0300
commitfa5655229271d7a09cce8033d1097f1b03daf94e (patch)
tree5922c2db17789e411b6cc46069c66188e834f28b /yql/essentials/sql/v1/sql_translation.cpp
parent77c13da33ae29c033359e516ac2eb55a6c3d5e9e (diff)
downloadydb-fa5655229271d7a09cce8033d1097f1b03daf94e.tar.gz
Apply GH commits
Apply GH: Extract prefix and entries in backup-related sql (#10807) Apply GH: Fix syntax for Column Family (#10781) Apply GH: Case-insensitive mode for searching modules and functions (#10842) Apply GH: Fixed i/o for pg_proc (#10914) Apply GH: An option to render SQL transalation with Seq! (#11015) commit_hash:d2d2fcdef2bbd0434236aef325aa071c7e39c526
Diffstat (limited to 'yql/essentials/sql/v1/sql_translation.cpp')
-rw-r--r--yql/essentials/sql/v1/sql_translation.cpp56
1 files changed, 49 insertions, 7 deletions
diff --git a/yql/essentials/sql/v1/sql_translation.cpp b/yql/essentials/sql/v1/sql_translation.cpp
index 4bcfb7de84..b298eb8abb 100644
--- a/yql/essentials/sql/v1/sql_translation.cpp
+++ b/yql/essentials/sql/v1/sql_translation.cpp
@@ -1567,17 +1567,59 @@ TNodePtr TSqlTranslation::SerialTypeNode(const TRule_type_name_or_bind& node) {
return nullptr;
}
+bool StoreString(const TRule_family_setting_value& from, TNodePtr& to, TContext& ctx) {
+ switch (from.Alt_case()) {
+ case TRule_family_setting_value::kAltFamilySettingValue1: {
+ // STRING_VALUE
+ const TString stringValue(ctx.Token(from.GetAlt_family_setting_value1().GetToken1()));
+ TNodePtr literal = BuildLiteralSmartString(ctx, stringValue);
+ if (!literal) {
+ return false;
+ }
+ to = literal;
+ break;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
+bool StoreInt(const TRule_family_setting_value& from, TNodePtr& to, TContext& ctx) {
+ switch (from.Alt_case()) {
+ case TRule_family_setting_value::kAltFamilySettingValue2: {
+ // integer
+ TNodePtr literal = LiteralNumber(ctx, from.GetAlt_family_setting_value2().GetRule_integer1());
+ if (!literal) {
+ return false;
+ }
+ to = literal;
+ break;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
bool TSqlTranslation::FillFamilySettingsEntry(const TRule_family_settings_entry& settingNode, TFamilyEntry& family) {
TIdentifier id = IdEx(settingNode.GetRule_an_id1(), *this);
const TRule_family_setting_value& value = settingNode.GetRule_family_setting_value3();
if (to_lower(id.Name) == "data") {
- const TString stringValue(Ctx.Token(value.GetAlt_family_setting_value1().GetToken1()));
- family.Data = BuildLiteralSmartString(Ctx, stringValue);
+ if (!StoreString(value, family.Data, Ctx)) {
+ Ctx.Error() << to_upper(id.Name) << " value should be a string literal";
+ return false;
+ }
} else if (to_lower(id.Name) == "compression") {
- const TString stringValue(Ctx.Token(value.GetAlt_family_setting_value1().GetToken1()));
- family.Compression = BuildLiteralSmartString(Ctx, stringValue);
+ if (!StoreString(value, family.Compression, Ctx)) {
+ Ctx.Error() << to_upper(id.Name) << " value should be a string literal";
+ return false;
+ }
} else if (to_lower(id.Name) == "compression_level") {
- family.CompressionLevel = LiteralNumber(Ctx, value.GetAlt_family_setting_value2().GetRule_integer1());
+ if (!StoreInt(value, family.CompressionLevel, Ctx)) {
+ Ctx.Error() << to_upper(id.Name) << " value should be an integer";
+ return false;
+ }
} else {
Ctx.Error() << "Unknown table setting: " << id.Name;
return false;
@@ -4466,7 +4508,7 @@ TNodePtr TSqlTranslation::DoStatement(const TRule_do_stmt& stmt, bool makeLambda
TBlocks innerBlocks;
const bool hasValidBody = DefineActionOrSubqueryBody(query, innerBlocks, body);
- auto ret = hasValidBody ? BuildQuery(Ctx.Pos(), innerBlocks, false, Ctx.Scoped) : nullptr;
+ auto ret = hasValidBody ? BuildQuery(Ctx.Pos(), innerBlocks, false, Ctx.Scoped, Ctx.SeqMode) : nullptr;
WarnUnusedNodes();
Ctx.ScopeLevel--;
Ctx.Scoped = saveScoped;
@@ -4579,7 +4621,7 @@ bool TSqlTranslation::DefineActionOrSubqueryStatement(const TRule_define_action_
return false;
}
- auto ret = hasValidBody ? BuildQuery(Ctx.Pos(), innerBlocks, false, Ctx.Scoped) : nullptr;
+ auto ret = hasValidBody ? BuildQuery(Ctx.Pos(), innerBlocks, false, Ctx.Scoped, Ctx.SeqMode) : nullptr;
WarnUnusedNodes();
Ctx.Scoped = saveScoped;
Ctx.ScopeLevel--;