@@ -79,140 +79,92 @@ class TQueryBase : public NKikimr::TQueryBase {
79
79
};
80
80
81
81
82
- class TScriptExecutionsTablesCreator : public TActorBootstrapped <TScriptExecutionsTablesCreator> {
83
- public:
84
- explicit TScriptExecutionsTablesCreator (THolder<NActors::IEventBase> resultEvent)
85
- : ResultEvent(std::move(resultEvent))
86
- {
87
- }
88
-
89
- void Registered (NActors::TActorSystem* sys, const NActors::TActorId& owner) override {
90
- NActors::TActorBootstrapped<TScriptExecutionsTablesCreator>::Registered (sys, owner);
91
- Owner = owner;
92
- }
82
+ class TScriptExecutionsTablesCreator : public NTableCreator ::TMultiTableCreator {
83
+ using TBase = NTableCreator::TMultiTableCreator;
93
84
94
- void Bootstrap () {
95
- Become (&TScriptExecutionsTablesCreator::StateFunc);
96
- RunCreateScriptExecutions ();
97
- RunCreateScriptExecutionLeases ();
98
- RunCreateScriptResultSets ();
99
- }
85
+ public:
86
+ explicit TScriptExecutionsTablesCreator ()
87
+ : TBase({
88
+ GetScriptExecutionsCreator (),
89
+ GetScriptExecutionLeasesCreator (),
90
+ GetScriptResultSetsCreator ()
91
+ })
92
+ {}
100
93
101
94
private:
102
- static NKikimrSchemeOp::TColumnDescription Col (const TString& columnName, const char * columnType) {
103
- NKikimrSchemeOp::TColumnDescription desc;
104
- desc.SetName (columnName);
105
- desc.SetType (columnType);
106
- return desc;
107
- }
108
-
109
- static NKikimrSchemeOp::TColumnDescription Col (const TString& columnName, NScheme::TTypeId columnType) {
110
- return Col (columnName, NScheme::TypeName (columnType));
111
- }
112
-
113
- static NKikimrSchemeOp::TTTLSettings TtlCol (const TString& columnName) {
114
- NKikimrSchemeOp::TTTLSettings settings;
115
- settings.MutableEnabled ()->SetExpireAfterSeconds (DEADLINE_OFFSET.Seconds ());
116
- settings.MutableEnabled ()->SetColumnName (columnName);
117
- settings.MutableEnabled ()->MutableSysSettings ()->SetRunInterval (BRO_RUN_INTERVAL.MicroSeconds ());
118
- return settings;
119
- }
120
-
121
- void RunCreateScriptExecutions () {
122
- TablesCreating++;
123
- Register (
124
- CreateTableCreator (
125
- { " .metadata" , " script_executions" },
126
- {
127
- Col (" database" , NScheme::NTypeIds::Text),
128
- Col (" execution_id" , NScheme::NTypeIds::Text),
129
- Col (" run_script_actor_id" , NScheme::NTypeIds::Text),
130
- Col (" operation_status" , NScheme::NTypeIds::Int32),
131
- Col (" execution_status" , NScheme::NTypeIds::Int32),
132
- Col (" finalization_status" , NScheme::NTypeIds::Int32),
133
- Col (" execution_mode" , NScheme::NTypeIds::Int32),
134
- Col (" start_ts" , NScheme::NTypeIds::Timestamp),
135
- Col (" end_ts" , NScheme::NTypeIds::Timestamp),
136
- Col (" query_text" , NScheme::NTypeIds::Text),
137
- Col (" syntax" , NScheme::NTypeIds::Int32),
138
- Col (" ast" , NScheme::NTypeIds::Text),
139
- Col (" ast_compressed" , NScheme::NTypeIds::String),
140
- Col (" ast_compression_method" , NScheme::NTypeIds::Text),
141
- Col (" issues" , NScheme::NTypeIds::JsonDocument),
142
- Col (" plan" , NScheme::NTypeIds::JsonDocument),
143
- Col (" meta" , NScheme::NTypeIds::JsonDocument),
144
- Col (" parameters" , NScheme::NTypeIds::String), // TODO: store aparameters separately to support bigger storage.
145
- Col (" result_set_metas" , NScheme::NTypeIds::JsonDocument),
146
- Col (" stats" , NScheme::NTypeIds::JsonDocument),
147
- Col (" expire_at" , NScheme::NTypeIds::Timestamp), // Will be deleted from database after this deadline.
148
- Col (" customer_supplied_id" , NScheme::NTypeIds::Text),
149
- Col (" user_token" , NScheme::NTypeIds::Text),
150
- Col (" script_sinks" , NScheme::NTypeIds::JsonDocument),
151
- Col (" script_secret_names" , NScheme::NTypeIds::JsonDocument),
152
- },
153
- { " database" , " execution_id" },
154
- NKikimrServices::KQP_PROXY,
155
- TtlCol (" expire_at" )
156
- )
95
+ static IActor* GetScriptExecutionsCreator () {
96
+ return CreateTableCreator (
97
+ { " .metadata" , " script_executions" },
98
+ {
99
+ Col (" database" , NScheme::NTypeIds::Text),
100
+ Col (" execution_id" , NScheme::NTypeIds::Text),
101
+ Col (" run_script_actor_id" , NScheme::NTypeIds::Text),
102
+ Col (" operation_status" , NScheme::NTypeIds::Int32),
103
+ Col (" execution_status" , NScheme::NTypeIds::Int32),
104
+ Col (" finalization_status" , NScheme::NTypeIds::Int32),
105
+ Col (" execution_mode" , NScheme::NTypeIds::Int32),
106
+ Col (" start_ts" , NScheme::NTypeIds::Timestamp),
107
+ Col (" end_ts" , NScheme::NTypeIds::Timestamp),
108
+ Col (" query_text" , NScheme::NTypeIds::Text),
109
+ Col (" syntax" , NScheme::NTypeIds::Int32),
110
+ Col (" ast" , NScheme::NTypeIds::Text),
111
+ Col (" ast_compressed" , NScheme::NTypeIds::String),
112
+ Col (" ast_compression_method" , NScheme::NTypeIds::Text),
113
+ Col (" issues" , NScheme::NTypeIds::JsonDocument),
114
+ Col (" plan" , NScheme::NTypeIds::JsonDocument),
115
+ Col (" meta" , NScheme::NTypeIds::JsonDocument),
116
+ Col (" parameters" , NScheme::NTypeIds::String), // TODO: store aparameters separately to support bigger storage.
117
+ Col (" result_set_metas" , NScheme::NTypeIds::JsonDocument),
118
+ Col (" stats" , NScheme::NTypeIds::JsonDocument),
119
+ Col (" expire_at" , NScheme::NTypeIds::Timestamp), // Will be deleted from database after this deadline.
120
+ Col (" customer_supplied_id" , NScheme::NTypeIds::Text),
121
+ Col (" user_token" , NScheme::NTypeIds::Text),
122
+ Col (" script_sinks" , NScheme::NTypeIds::JsonDocument),
123
+ Col (" script_secret_names" , NScheme::NTypeIds::JsonDocument),
124
+ },
125
+ { " database" , " execution_id" },
126
+ NKikimrServices::KQP_PROXY,
127
+ TtlCol (" expire_at" , DEADLINE_OFFSET, BRO_RUN_INTERVAL)
157
128
);
158
129
}
159
130
160
- void RunCreateScriptExecutionLeases () {
161
- TablesCreating++;
162
- Register (
163
- CreateTableCreator (
164
- { " .metadata" , " script_execution_leases" },
165
- {
166
- Col (" database" , NScheme::NTypeIds::Text),
167
- Col (" execution_id" , NScheme::NTypeIds::Text),
168
- Col (" lease_deadline" , NScheme::NTypeIds::Timestamp),
169
- Col (" lease_generation" , NScheme::NTypeIds::Int64),
170
- Col (" expire_at" , NScheme::NTypeIds::Timestamp), // Will be deleted from database after this deadline.
171
- },
172
- { " database" , " execution_id" },
173
- NKikimrServices::KQP_PROXY,
174
- TtlCol (" expire_at" )
175
- )
131
+ static IActor* GetScriptExecutionLeasesCreator () {
132
+ return CreateTableCreator (
133
+ { " .metadata" , " script_execution_leases" },
134
+ {
135
+ Col (" database" , NScheme::NTypeIds::Text),
136
+ Col (" execution_id" , NScheme::NTypeIds::Text),
137
+ Col (" lease_deadline" , NScheme::NTypeIds::Timestamp),
138
+ Col (" lease_generation" , NScheme::NTypeIds::Int64),
139
+ Col (" expire_at" , NScheme::NTypeIds::Timestamp), // Will be deleted from database after this deadline.
140
+ },
141
+ { " database" , " execution_id" },
142
+ NKikimrServices::KQP_PROXY,
143
+ TtlCol (" expire_at" , DEADLINE_OFFSET, BRO_RUN_INTERVAL)
176
144
);
177
145
}
178
146
179
- void RunCreateScriptResultSets () {
180
- TablesCreating++;
181
- Register (
182
- CreateTableCreator (
183
- { " .metadata" , " result_sets" },
184
- {
185
- Col (" database" , NScheme::NTypeIds::Text),
186
- Col (" execution_id" , NScheme::NTypeIds::Text),
187
- Col (" result_set_id" , NScheme::NTypeIds::Int32),
188
- Col (" row_id" , NScheme::NTypeIds::Int64),
189
- Col (" expire_at" , NScheme::NTypeIds::Timestamp),
190
- Col (" result_set" , NScheme::NTypeIds::String),
191
- Col (" accumulated_size" , NScheme::NTypeIds::Int64),
192
- },
193
- { " database" , " execution_id" , " result_set_id" , " row_id" },
194
- NKikimrServices::KQP_PROXY,
195
- TtlCol (" expire_at" )
196
- )
147
+ static IActor* GetScriptResultSetsCreator () {
148
+ return CreateTableCreator (
149
+ { " .metadata" , " result_sets" },
150
+ {
151
+ Col (" database" , NScheme::NTypeIds::Text),
152
+ Col (" execution_id" , NScheme::NTypeIds::Text),
153
+ Col (" result_set_id" , NScheme::NTypeIds::Int32),
154
+ Col (" row_id" , NScheme::NTypeIds::Int64),
155
+ Col (" expire_at" , NScheme::NTypeIds::Timestamp),
156
+ Col (" result_set" , NScheme::NTypeIds::String),
157
+ Col (" accumulated_size" , NScheme::NTypeIds::Int64),
158
+ },
159
+ { " database" , " execution_id" , " result_set_id" , " row_id" },
160
+ NKikimrServices::KQP_PROXY,
161
+ TtlCol (" expire_at" , DEADLINE_OFFSET, BRO_RUN_INTERVAL)
197
162
);
198
163
}
199
164
200
- void Handle (TEvTableCreator::TEvCreateTableResponse::TPtr&) {
201
- Y_ABORT_UNLESS (TablesCreating > 0 );
202
- if (--TablesCreating == 0 ) {
203
- Send (Owner, std::move (ResultEvent));
204
- PassAway ();
205
- }
165
+ void OnTablesCreated (bool success, NYql::TIssues issues) override {
166
+ Send (Owner, new TEvScriptExecutionsTablesCreationFinished (success, std::move (issues)));
206
167
}
207
-
208
- STRICT_STFUNC (StateFunc,
209
- hFunc (TEvTableCreator::TEvCreateTableResponse, Handle );
210
- )
211
-
212
- private:
213
- THolder<NActors::IEventBase> ResultEvent;
214
- NActors::TActorId Owner;
215
- size_t TablesCreating = 0 ;
216
168
};
217
169
218
170
Ydb::Query::ExecMode GetExecModeFromAction (NKikimrKqp::EQueryAction action) {
@@ -2867,8 +2819,8 @@ NActors::IActor* CreateScriptExecutionCreatorActor(TEvKqp::TEvScriptRequest::TPt
2867
2819
return new TCreateScriptExecutionActor (std::move (ev), queryServiceConfig, counters, maxRunTime);
2868
2820
}
2869
2821
2870
- NActors::IActor* CreateScriptExecutionsTablesCreator (THolder<NActors::IEventBase> resultEvent ) {
2871
- return new TScriptExecutionsTablesCreator (std::move (resultEvent) );
2822
+ NActors::IActor* CreateScriptExecutionsTablesCreator () {
2823
+ return new TScriptExecutionsTablesCreator ();
2872
2824
}
2873
2825
2874
2826
NActors::IActor* CreateForgetScriptExecutionOperationActor (TEvForgetScriptExecutionOperation::TPtr ev) {
0 commit comments