@@ -97,8 +97,8 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
97
97
private:
98
98
using TParserInputType = TSet<std::pair<TString, TString>>;
99
99
100
- struct ClientsInfo {
101
- ClientsInfo (const NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev)
100
+ struct TClientsInfo {
101
+ TClientsInfo (const NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev)
102
102
: Settings(ev->Get ()->Record)
103
103
, ReadActorId(ev->Sender)
104
104
{
@@ -151,7 +151,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
151
151
ui64 LastMessageOffset = 0 ;
152
152
bool IsWaitingEvents = false ;
153
153
bool IsStartParsingScheduled = false ;
154
- THashMap<NActors::TActorId, ClientsInfo > Clients;
154
+ THashMap<NActors::TActorId, TClientsInfo > Clients;
155
155
THashSet<NActors::TActorId> ClientsWithoutPredicate;
156
156
std::unique_ptr<TJsonParser> Parser;
157
157
NConfig::TRowDispatcherConfig Config;
@@ -190,15 +190,15 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
190
190
void SendToParsing (const TVector<NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent::TMessage>& messages);
191
191
void DoParsing (bool force = false );
192
192
void DoFiltering (const TVector<ui64>& offsets, const TVector<NKikimr::NMiniKQL::TUnboxedValueVector>& parsedValues);
193
- void SendData (ClientsInfo & info);
193
+ void SendData (TClientsInfo & info);
194
194
void UpdateParser ();
195
195
void FatalError (const TString& message, const std::unique_ptr<TJsonFilter>* filter = nullptr );
196
- void SendDataArrived (ClientsInfo & client);
196
+ void SendDataArrived (TClientsInfo & client);
197
197
void StopReadSession ();
198
198
TString GetSessionId () const ;
199
199
void HandleNewEvents ();
200
200
TInstant GetMinStartingMessageTimestamp () const ;
201
- void AddDataToClient (ClientsInfo & client, ui64 offset, const TString& json);
201
+ void AddDataToClient (TClientsInfo & client, ui64 offset, const TString& json);
202
202
203
203
std::pair<NYql::NUdf::TUnboxedValuePod, i64 > CreateItem (const NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent::TMessage& message);
204
204
@@ -215,9 +215,9 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
215
215
216
216
void SendStatistic ();
217
217
void SendSessionError (NActors::TActorId readActorId, const TString& message);
218
- TVector<const NKikimr::NMiniKQL::TUnboxedValueVector*> RebuildJson (const ClientsInfo & info, const TVector<NKikimr::NMiniKQL::TUnboxedValueVector>& parsedValues);
218
+ TVector<const NKikimr::NMiniKQL::TUnboxedValueVector*> RebuildJson (const TClientsInfo & info, const TVector<NKikimr::NMiniKQL::TUnboxedValueVector>& parsedValues);
219
219
void UpdateParserSchema (const TParserInputType& inputType);
220
- void UpdateFieldsIds (ClientsInfo & clientInfo);
220
+ void UpdateFieldsIds (TClientsInfo & clientInfo);
221
221
222
222
private:
223
223
@@ -387,7 +387,7 @@ void TTopicSession::Handle(NFq::TEvPrivate::TEvCreateSession::TPtr&) {
387
387
CreateTopicSession ();
388
388
}
389
389
390
- TVector<const NKikimr::NMiniKQL::TUnboxedValueVector*> TTopicSession::RebuildJson (const ClientsInfo & info, const TVector<NKikimr::NMiniKQL::TUnboxedValueVector>& parsedValues) {
390
+ TVector<const NKikimr::NMiniKQL::TUnboxedValueVector*> TTopicSession::RebuildJson (const TClientsInfo & info, const TVector<NKikimr::NMiniKQL::TUnboxedValueVector>& parsedValues) {
391
391
TVector<const NKikimr::NMiniKQL::TUnboxedValueVector*> result;
392
392
const auto & offsets = ParserSchema.FieldsMap ;
393
393
result.reserve (info.FieldsIds .size ());
@@ -601,7 +601,7 @@ void TTopicSession::DoFiltering(const TVector<ui64>& offsets, const TVector<NKik
601
601
Send (SelfId (), new TEvPrivate::TEvDataFiltered (offsets.back ()));
602
602
}
603
603
604
- void TTopicSession::SendData (ClientsInfo & info) {
604
+ void TTopicSession::SendData (TClientsInfo & info) {
605
605
info.DataArrivedSent = false ;
606
606
if (info.Buffer .empty ()) {
607
607
LOG_ROW_DISPATCHER_TRACE (" Buffer empty" );
@@ -639,7 +639,7 @@ void TTopicSession::SendData(ClientsInfo& info) {
639
639
info.LastSendedNextMessageOffset = *info.NextMessageOffset ;
640
640
}
641
641
642
- void TTopicSession::UpdateFieldsIds (ClientsInfo & info) {
642
+ void TTopicSession::UpdateFieldsIds (TClientsInfo & info) {
643
643
for (auto name : info.Settings .GetSource ().GetColumns ()) {
644
644
auto it = FieldsIndexes.find (name);
645
645
if (it == FieldsIndexes.end ()) {
@@ -652,6 +652,15 @@ void TTopicSession::UpdateFieldsIds(ClientsInfo& info) {
652
652
}
653
653
}
654
654
655
+ bool HasJsonColumns (const NYql::NPq::NProto::TDqPqTopicSource& sourceParams) {
656
+ for (const auto & type : sourceParams.GetColumnTypes ()) {
657
+ if (type.Contains (" Json" )) {
658
+ return true ;
659
+ }
660
+ }
661
+ return false ;
662
+ }
663
+
655
664
void TTopicSession::Handle (NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
656
665
auto it = Clients.find (ev->Sender );
657
666
if (it != Clients.end ()) {
@@ -678,6 +687,12 @@ void TTopicSession::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
678
687
UpdateFieldsIds (clientInfo);
679
688
680
689
TString predicate = clientInfo.Settings .GetSource ().GetPredicate ();
690
+
691
+ // TODO: remove this when the re-parsing is removed from pq read actor
692
+ if (predicate.empty () && HasJsonColumns (clientInfo.Settings .GetSource ())) {
693
+ predicate = " WHERE TRUE" ;
694
+ }
695
+
681
696
if (!predicate.empty ()) {
682
697
clientInfo.Filter = NewJsonFilter (
683
698
columns,
@@ -710,7 +725,7 @@ void TTopicSession::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
710
725
}
711
726
}
712
727
713
- void TTopicSession::AddDataToClient (ClientsInfo & info, ui64 offset, const TString& json) {
728
+ void TTopicSession::AddDataToClient (TClientsInfo & info, ui64 offset, const TString& json) {
714
729
if (info.NextMessageOffset && offset < info.NextMessageOffset ) {
715
730
return ;
716
731
}
@@ -836,7 +851,7 @@ void TTopicSession::StopReadSession() {
836
851
TopicClient.Reset ();
837
852
}
838
853
839
- void TTopicSession::SendDataArrived (ClientsInfo & info) {
854
+ void TTopicSession::SendDataArrived (TClientsInfo & info) {
840
855
if (info.Buffer .empty () || info.DataArrivedSent ) {
841
856
return ;
842
857
}
0 commit comments