summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_translation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'yql/essentials/sql/v1/sql_translation.cpp')
-rw-r--r--yql/essentials/sql/v1/sql_translation.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/sql_translation.cpp b/yql/essentials/sql/v1/sql_translation.cpp
index b95e1c61b56..17596ab4d9c 100644
--- a/yql/essentials/sql/v1/sql_translation.cpp
+++ b/yql/essentials/sql/v1/sql_translation.cpp
@@ -790,6 +790,28 @@ bool TSqlTranslation::CreateTableIndex(const TRule_table_index& node, TVector<TI
return true;
}
+bool TSqlTranslation::CreateTableStatistics(const TRule_table_statistics& node, TVector<TStatisticsDescription>& statistics) {
+ statistics.emplace_back(IdEx(node.GetRule_an_id2(), *this));
+ auto& stat = statistics.back();
+
+ // ON (columns)
+ stat.Columns.emplace_back(IdEx(node.GetRule_an_id_schema5(), *this));
+ for (const auto& block : node.GetBlock6()) {
+ stat.Columns.emplace_back(IdEx(block.GetRule_an_id_schema2(), *this));
+ }
+
+ // WITH (types) — optional; omission means "all supported statistic types"
+ if (node.HasBlock8()) {
+ const auto& withTypes = node.GetBlock8().GetRule_with_statistics_types1();
+ stat.Types.emplace_back(IdEx(withTypes.GetRule_an_id_or_type3(), *this));
+ for (const auto& block : withTypes.GetBlock4()) {
+ stat.Types.emplace_back(IdEx(block.GetRule_an_id_or_type2(), *this));
+ }
+ }
+
+ return true;
+}
+
bool TSqlTranslation::ParseDatabaseSettings(const TRule_database_settings& in, THashMap<TString, TNodePtr>& out) {
if (!ParseDatabaseSetting(in.GetRule_database_setting1(), out)) {
return false;
@@ -2156,6 +2178,14 @@ bool TSqlTranslation::CreateTableEntry(const TRule_create_table_entry& node, TCr
params.Columns.push_back({.Pos = pos, .Name = name, .Nullable = true});
break;
}
+ case TRule_create_table_entry::kAltCreateTableEntry7: {
+ // table_statistics
+ auto& table_statistics = node.GetAlt_create_table_entry7().GetRule_table_statistics1();
+ if (!CreateTableStatistics(table_statistics, params.Statistics)) {
+ return false;
+ }
+ break;
+ }
case NSQLv1Generated::TRule_create_table_entry::ALT_NOT_SET:
YQL_ENSURE(false, "Unreachable");
}