@@ -138,6 +138,40 @@ struct TMetadataInfoHolder {
138
138
}
139
139
};
140
140
141
+ THashMap<TString, NYql::TKikimrTableMetadataPtr> ExtractStaticMetadata (const NJson::TJsonValue& data) {
142
+ EMetaSerializationType metaType = EMetaSerializationType::EncodedProto;
143
+ if (data.Has (" table_meta_serialization_type" )) {
144
+ metaType = static_cast <EMetaSerializationType>(data[" table_meta_serialization_type" ].GetUIntegerSafe ());
145
+ }
146
+ THashMap<TString, NYql::TKikimrTableMetadataPtr> meta;
147
+
148
+ if (metaType == EMetaSerializationType::EncodedProto) {
149
+ static NJson::TJsonReaderConfig readerConfig;
150
+ NJson::TJsonValue tablemetajson;
151
+ TStringInput in (data[" table_metadata" ].GetStringSafe ());
152
+ NJson::ReadJsonTree (&in, &readerConfig, &tablemetajson, false );
153
+ Y_ENSURE (tablemetajson.IsArray ());
154
+ for (auto & node : tablemetajson.GetArray ()) {
155
+ NKikimrKqp::TKqpTableMetadataProto proto;
156
+
157
+ TString decoded = Base64Decode (node.GetStringRobust ());
158
+ Y_ENSURE (proto.ParseFromString (decoded));
159
+
160
+ NYql::TKikimrTableMetadataPtr ptr = MakeIntrusive<NYql::TKikimrTableMetadata>(&proto);
161
+ meta.emplace (proto.GetName (), ptr);
162
+ }
163
+ } else {
164
+ Y_ENSURE (data[" table_metadata" ].IsArray ());
165
+ for (auto & node : data[" table_metadata" ].GetArray ()) {
166
+ NKikimrKqp::TKqpTableMetadataProto proto;
167
+ NProtobufJson::Json2Proto (node.GetStringRobust (), proto);
168
+ NYql::TKikimrTableMetadataPtr ptr = MakeIntrusive<NYql::TKikimrTableMetadata>(&proto);
169
+ meta.emplace (proto.GetName (), ptr);
170
+ }
171
+ }
172
+ return meta;
173
+ }
174
+
141
175
142
176
class TStaticTableMetadataLoader : public NYql ::IKikimrGateway::IKqpTableMetadataLoader, public NYql::IDbSchemeResolver {
143
177
TActorSystem* ActorSystem;
@@ -534,46 +568,12 @@ class TReplayCompileActor: public TActorBootstrapped<TReplayCompileActor> {
534
568
PassAway ();
535
569
}
536
570
537
- static THashMap<TString, NYql::TKikimrTableMetadataPtr> ExtractStaticMetadata (const NJson::TJsonValue& data, EMetaSerializationType metaType) {
538
- THashMap<TString, NYql::TKikimrTableMetadataPtr> meta;
539
-
540
- if (metaType == EMetaSerializationType::EncodedProto) {
541
- static NJson::TJsonReaderConfig readerConfig;
542
- NJson::TJsonValue tablemetajson;
543
- TStringInput in (data.GetStringSafe ());
544
- NJson::ReadJsonTree (&in, &readerConfig, &tablemetajson, false );
545
- Y_ENSURE (tablemetajson.IsArray ());
546
- for (auto & node : tablemetajson.GetArray ()) {
547
- NKikimrKqp::TKqpTableMetadataProto proto;
548
-
549
- TString decoded = Base64Decode (node.GetStringRobust ());
550
- Y_ENSURE (proto.ParseFromString (decoded));
551
-
552
- NYql::TKikimrTableMetadataPtr ptr = MakeIntrusive<NYql::TKikimrTableMetadata>(&proto);
553
- meta.emplace (proto.GetName (), ptr);
554
- }
555
- } else {
556
- Y_ENSURE (data.IsArray ());
557
- for (auto & node : data.GetArray ()) {
558
- NKikimrKqp::TKqpTableMetadataProto proto;
559
- NProtobufJson::Json2Proto (node.GetStringRobust (), proto);
560
- NYql::TKikimrTableMetadataPtr ptr = MakeIntrusive<NYql::TKikimrTableMetadata>(&proto);
561
- meta.emplace (proto.GetName (), ptr);
562
- }
563
- }
564
- return meta;
565
- }
566
-
567
571
void Handle (TQueryReplayEvents::TEvCompileRequest::TPtr& ev) {
568
572
Owner = ev->Sender ;
569
573
570
574
ReplayDetails = std::move (ev->Get ()->ReplayDetails );
571
575
572
- EMetaSerializationType metaType = EMetaSerializationType::EncodedProto;
573
- if (ReplayDetails.Has (" table_meta_serialization_type" )) {
574
- metaType = static_cast <EMetaSerializationType>(ReplayDetails[" table_meta_serialization_type" ].GetUIntegerSafe ());
575
- }
576
- TableMetadata = std::make_shared<TMetadataInfoHolder>(std::move (ExtractStaticMetadata (ReplayDetails[" table_metadata" ], metaType)));
576
+ TableMetadata = std::make_shared<TMetadataInfoHolder>(std::move (ExtractStaticMetadata (ReplayDetails)));
577
577
TString queryText = UnescapeC (ReplayDetails[" query_text" ].GetStringSafe ());
578
578
579
579
std::map<TString, Ydb::Type> queryParameterTypes;
0 commit comments