@@ -144,6 +144,11 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
144
144
TParserInputType InputType;
145
145
};
146
146
147
+ struct TFieldDescription {
148
+ ui64 IndexInParserSchema = 0 ;
149
+ TString Type;
150
+ };
151
+
147
152
bool InflightReconnect = false ;
148
153
TDuration ReconnectPeriod;
149
154
const TString TopicPath;
@@ -153,7 +158,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
153
158
ui32 PartitionId;
154
159
NYdb::TDriver Driver;
155
160
std::shared_ptr<NYdb::ICredentialsProviderFactory> CredentialsProviderFactory;
156
- NYql::NPureCalc::IProgramFactoryPtr PureCalcProgramFactory;
161
+ IPureCalcProgramFactory::TPtr PureCalcProgramFactory;
157
162
NYql::ITopicClient::TPtr TopicClient;
158
163
std::shared_ptr<NYdb::NTopic::IReadSession> ReadSession;
159
164
const i64 BufferSize;
@@ -170,7 +175,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
170
175
const ::NMonitoring::TDynamicCounterPtr Counters;
171
176
TTopicSessionMetrics Metrics;
172
177
TParserSchema ParserSchema;
173
- THashMap<TString, ui64 > FieldsIndexes;
178
+ THashMap<TString, TFieldDescription > FieldsIndexes;
174
179
NYql::IPqGateway::TPtr PqGateway;
175
180
TMaybe<TString> ConsumerName;
176
181
ui64 RestartSessionByOffsets = 0 ;
@@ -185,7 +190,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
185
190
ui32 partitionId,
186
191
NYdb::TDriver driver,
187
192
std::shared_ptr<NYdb::ICredentialsProviderFactory> credentialsProviderFactory,
188
- NYql::NPureCalc::IProgramFactoryPtr pureCalcProgramFactory,
193
+ IPureCalcProgramFactory::TPtr pureCalcProgramFactory,
189
194
const ::NMonitoring::TDynamicCounterPtr& counters,
190
195
const NYql::IPqGateway::TPtr& pqGateway);
191
196
@@ -276,7 +281,7 @@ TTopicSession::TTopicSession(
276
281
ui32 partitionId,
277
282
NYdb::TDriver driver,
278
283
std::shared_ptr<NYdb::ICredentialsProviderFactory> credentialsProviderFactory,
279
- NYql::NPureCalc::IProgramFactoryPtr pureCalcProgramFactory,
284
+ IPureCalcProgramFactory::TPtr pureCalcProgramFactory,
280
285
const ::NMonitoring::TDynamicCounterPtr& counters,
281
286
const NYql::IPqGateway::TPtr& pqGateway)
282
287
: TopicPath(topicPath)
@@ -686,14 +691,16 @@ void TTopicSession::SendData(TClientsInfo& info) {
686
691
}
687
692
688
693
void TTopicSession::UpdateFieldsIds (TClientsInfo& info) {
689
- for (auto name : info.Settings .GetSource ().GetColumns ()) {
694
+ const auto & source = info.Settings .GetSource ();
695
+ for (size_t i = 0 ; i < source.ColumnsSize (); ++i) {
696
+ const auto & name = source.GetColumns ().Get (i);
690
697
auto it = FieldsIndexes.find (name);
691
698
if (it == FieldsIndexes.end ()) {
692
699
auto nextIndex = FieldsIndexes.size ();
693
700
info.FieldsIds .push_back (nextIndex);
694
- FieldsIndexes[name] = nextIndex;
701
+ FieldsIndexes[name] = { nextIndex, source. GetColumnTypes (). Get (i)} ;
695
702
} else {
696
- info.FieldsIds .push_back (it->second );
703
+ info.FieldsIds .push_back (it->second . IndexInParserSchema );
697
704
}
698
705
}
699
706
}
@@ -730,10 +737,11 @@ void TTopicSession::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
730
737
std::forward_as_tuple (ev)).first ->second ;
731
738
UpdateFieldsIds (clientInfo);
732
739
733
- TString predicate = clientInfo.Settings .GetSource ().GetPredicate ();
740
+ const auto & source = clientInfo.Settings .GetSource ();
741
+ TString predicate = source.GetPredicate ();
734
742
735
743
// TODO: remove this when the re-parsing is removed from pq read actor
736
- if (predicate.empty () && HasJsonColumns (clientInfo. Settings . GetSource () )) {
744
+ if (predicate.empty () && HasJsonColumns (source )) {
737
745
predicate = " WHERE TRUE" ;
738
746
}
739
747
@@ -745,7 +753,9 @@ void TTopicSession::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
745
753
[&, actorId = clientInfo.ReadActorId ](ui64 offset, const TString& json){
746
754
Send (SelfId (), new NFq::TEvPrivate::TEvDataAfterFilteration (offset, json, actorId));
747
755
},
748
- PureCalcProgramFactory);
756
+ PureCalcProgramFactory,
757
+ {.EnabledLLVM = source.GetEnabledLLVM ()}
758
+ );
749
759
} else {
750
760
ClientsWithoutPredicate.insert (ev->Sender );
751
761
}
@@ -821,7 +831,7 @@ void TTopicSession::UpdateParserSchema(const TParserInputType& inputType) {
821
831
ui64 offset = 0 ;
822
832
for (const auto & [name, type]: inputType) {
823
833
Y_ENSURE (FieldsIndexes.contains (name));
824
- ui64 index = FieldsIndexes[name];
834
+ ui64 index = FieldsIndexes[name]. IndexInParserSchema ;
825
835
ParserSchema.FieldsMap [index] = offset++;
826
836
}
827
837
ParserSchema.InputType = inputType;
@@ -950,13 +960,26 @@ bool TTopicSession::CheckNewClient(NFq::TEvRowDispatcher::TEvStartSession::TPtr&
950
960
SendSessionError (ev->Sender , " Internal error: such a client already exists" );
951
961
return false ;
952
962
}
953
- if (!Config. GetWithoutConsumer ()
954
- && ConsumerName
955
- && ConsumerName != ev-> Get ()-> Record . GetSource () .GetConsumerName ()) {
956
- LOG_ROW_DISPATCHER_INFO (" Different consumer, expected " << ConsumerName << " , actual " << ev-> Get ()-> Record . GetSource () .GetConsumerName () << " , send error" );
963
+
964
+ const auto & source = ev-> Get ()-> Record . GetSource ();
965
+ if (!Config. GetWithoutConsumer () && ConsumerName && ConsumerName != source .GetConsumerName ()) {
966
+ LOG_ROW_DISPATCHER_INFO (" Different consumer, expected " << ConsumerName << " , actual " << source .GetConsumerName () << " , send error" );
957
967
SendSessionError (ev->Sender , TStringBuilder () << " Use the same consumer in all queries via RD (current consumer " << ConsumerName << " )" );
958
968
return false ;
959
969
}
970
+
971
+ Y_ENSURE (source.ColumnsSize () == source.ColumnTypesSize ());
972
+ for (size_t i = 0 ; i < source.ColumnsSize (); ++i) {
973
+ const auto & name = source.GetColumns ().Get (i);
974
+ const auto & type = source.GetColumnTypes ().Get (i);
975
+ const auto it = FieldsIndexes.find (name);
976
+ if (it != FieldsIndexes.end () && it->second .Type != type) {
977
+ LOG_ROW_DISPATCHER_INFO (" Different column `" << name << " ` type, expected " << it->second .Type << " , actual " << type << " , send error" );
978
+ SendSessionError (ev->Sender , TStringBuilder () << " Use the same column type in all queries via RD, current type for column `" << name << " ` is " << it->second .Type << " (requested type is " << type <<" )" );
979
+ return false ;
980
+ }
981
+ }
982
+
960
983
return true ;
961
984
}
962
985
@@ -973,7 +996,7 @@ std::unique_ptr<NActors::IActor> NewTopicSession(
973
996
ui32 partitionId,
974
997
NYdb::TDriver driver,
975
998
std::shared_ptr<NYdb::ICredentialsProviderFactory> credentialsProviderFactory,
976
- NYql::NPureCalc::IProgramFactoryPtr pureCalcProgramFactory,
999
+ IPureCalcProgramFactory::TPtr pureCalcProgramFactory,
977
1000
const ::NMonitoring::TDynamicCounterPtr& counters,
978
1001
const NYql::IPqGateway::TPtr& pqGateway) {
979
1002
return std::unique_ptr<NActors::IActor>(new TTopicSession (topicPath, endpoint, database, config, rowDispatcherActorId, partitionId, std::move (driver), credentialsProviderFactory, pureCalcProgramFactory, counters, pqGateway));
0 commit comments