summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <[email protected]>2022-07-28 14:07:52 +0300
committervvvv <[email protected]>2022-07-28 14:07:52 +0300
commitceb7e240f642d3a6c3ba7cd26e9e31a79b289741 (patch)
treeeafc840c5927b472a30723859240fc65e2db1b68
parent3b661e725941d7b18f905f2b6f5c8c7adc0995ae (diff)
all statements should have visitors
-rw-r--r--ydb/library/yql/sql/v1/format/sql_format.cpp19
-rw-r--r--ydb/library/yql/sql/v1/format/sql_format.h5
2 files changed, 19 insertions, 5 deletions
diff --git a/ydb/library/yql/sql/v1/format/sql_format.cpp b/ydb/library/yql/sql/v1/format/sql_format.cpp
index 7083c153885..6a23be764f8 100644
--- a/ydb/library/yql/sql/v1/format/sql_format.cpp
+++ b/ydb/library/yql/sql/v1/format/sql_format.cpp
@@ -1746,6 +1746,25 @@ TStaticData::TStaticData()
{TRule_drop_role_stmt::GetDescriptor(), MakeFunctor(&TVisitor::VisitDropRole)},
})
{
+ // ensure that all statements has a visitor
+ auto coreDescr = TRule_sql_stmt_core::GetDescriptor();
+ for (int i = 0; i < coreDescr->field_count(); ++i) {
+ const NProtoBuf::FieldDescriptor* fd = coreDescr->field(i);
+ if (fd->cpp_type() != NProtoBuf::FieldDescriptor::CPPTYPE_MESSAGE) {
+ continue;
+ }
+
+ auto altDescr = fd->message_type();
+ for (int j = 0; j < altDescr->field_count(); ++j) {
+ auto fd2 = altDescr->field(j);
+ if (fd2->cpp_type() != NProtoBuf::FieldDescriptor::CPPTYPE_MESSAGE) {
+ continue;
+ }
+
+ auto stmtMessage = fd2->message_type();
+ Y_ENSURE(VisitDispatch.contains(stmtMessage), TStringBuilder() << "Missing visitor for " << stmtMessage->name());
+ }
+ }
}
class TSqlFormatter : public NSQLFormat::ISqlFormatter {
diff --git a/ydb/library/yql/sql/v1/format/sql_format.h b/ydb/library/yql/sql/v1/format/sql_format.h
index 80fc78fcddb..5c6f3d23b8a 100644
--- a/ydb/library/yql/sql/v1/format/sql_format.h
+++ b/ydb/library/yql/sql/v1/format/sql_format.h
@@ -13,11 +13,6 @@ class ISqlFormatter {
public:
using TPtr = THolder<ISqlFormatter>;
- struct TSettings {
- bool TabToSpacesOnly = false;
- size_t TabSize = OneIndent;
- };
-
virtual bool Format(const TString& query, TString& formattedQuery, NYql::TIssues& issues) = 0;
virtual ~ISqlFormatter() = default;
};