99#include < ydb/core/fq/libs/control_plane_proxy/events/events.h>
1010#include < ydb/core/fq/libs/control_plane_storage/control_plane_storage.h>
1111#include < ydb/public/api/protos/draft/fq.pb.h>
12+ #include < ydb/public/lib/fq/scope.h>
1213#include < ydb/public/sdk/cpp/client/ydb_table/table.h>
1314
1415namespace NFq ::NPrivate {
@@ -418,7 +419,7 @@ class TGenerateRecoverySQLIfExternalDataSourceAlreadyExistsActor :
418419
419420 event->IsExactNameMatch = true ;
420421
421- TBase::Send (NFq::ControlPlaneStorageServiceActorId (), event);
422+ TBase::Send (:: NFq::ControlPlaneStorageServiceActorId (), event);
422423 }
423424
424425 STRICT_STFUNC (StateFunc, cFunc(NActors::TEvents::TSystem::Wakeup, TBase::HandleTimeout);
@@ -493,7 +494,7 @@ class TGenerateRecoverySQLIfExternalDataTableAlreadyExistsActor :
493494
494495 event->IsExactNameMatch = true ;
495496
496- TBase::Send (NFq::ControlPlaneStorageServiceActorId (), event);
497+ TBase::Send (:: NFq::ControlPlaneStorageServiceActorId (), event);
497498 }
498499
499500 STRICT_STFUNC (StateFunc, cFunc(NActors::TEvents::TSystem::Wakeup, TBase::HandleTimeout);
@@ -543,7 +544,7 @@ IActor* MakeCreateConnectionActor(
543544 TCounters& counters,
544545 TPermissions permissions,
545546 const TCommonConfig& commonConfig,
546- const NFq::TComputeConfig& computeConfig,
547+ const :: NFq::TComputeConfig& computeConfig,
547548 TSigner::TPtr signer,
548549 bool withoutRollback,
549550 TMaybe<TString> connectionId) {
@@ -557,10 +558,13 @@ IActor* MakeCreateConnectionActor(
557558 computeConfig](const TEvControlPlaneProxy::TEvCreateConnectionRequest::TPtr& req)
558559 -> std::vector<TSchemaQueryTask> {
559560 auto & connectionContent = req->Get ()->Request .content ();
561+ const auto & scope = req->Get ()->Scope ;
562+ const TString folderId = NYdb::NFq::TScope{scope}.ParseFolder ();
560563
561564 auto createSecretStatement = CreateSecretObjectQuery (connectionContent.setting (),
562565 connectionContent.name (),
563- signer);
566+ signer,
567+ folderId);
564568
565569 std::vector<TSchemaQueryTask> statements;
566570 if (createSecretStatement) {
@@ -603,7 +607,7 @@ IActor* MakeCreateConnectionActor(
603607 statements.push_back (TSchemaQueryTask{
604608 .SQL = MakeCreateExternalDataSourceQuery (
605609 connectionContent, signer, commonConfig,
606- computeConfig.IsReplaceIfExistsSyntaxSupported ()),
610+ computeConfig.IsReplaceIfExistsSyntaxSupported (), folderId ),
607611 .ScheduleErrorRecoverySQLGeneration =
608612 withoutRollback
609613 ? NoRecoverySQLGeneration ()
@@ -647,7 +651,7 @@ IActor* MakeModifyConnectionActor(
647651 TDuration requestTimeout,
648652 TCounters& counters,
649653 const TCommonConfig& commonConfig,
650- const NFq::TComputeConfig& computeConfig,
654+ const :: NFq::TComputeConfig& computeConfig,
651655 TSigner::TPtr signer) {
652656 auto queryFactoryMethod =
653657 [signer = std::move (signer),
@@ -659,21 +663,24 @@ IActor* MakeModifyConnectionActor(
659663 auto & oldConnectionContent = (*request->Get ()->OldConnectionContent );
660664 auto & oldBindings = request->Get ()->OldBindingContents ;
661665 auto & newConnectionContent = request->Get ()->Request .content ();
666+ const auto & scope = request->Get ()->Scope ;
667+ const TString folderId = NYdb::NFq::TScope{scope}.ParseFolder ();
662668
663669 auto dropOldSecret =
664- DropSecretObjectQuery (oldConnectionContent.name ());
670+ DropSecretObjectQuery (oldConnectionContent.name (), folderId );
665671 auto createNewSecret =
666672 CreateSecretObjectQuery (newConnectionContent.setting (),
667673 newConnectionContent.name (),
668- signer);
674+ signer,
675+ folderId);
669676
670677 bool replaceSupported = computeConfig.IsReplaceIfExistsSyntaxSupported ();
671678 if (replaceSupported &&
672679 oldConnectionContent.name () == newConnectionContent.name ()) {
673680 // CREATE OR REPLACE
674681 auto createSecretStatement =
675682 CreateSecretObjectQuery (newConnectionContent.setting (),
676- newConnectionContent.name (), signer);
683+ newConnectionContent.name (), signer, folderId );
677684
678685 std::vector<TSchemaQueryTask> statements;
679686 if (createSecretStatement) {
@@ -683,7 +690,7 @@ IActor* MakeModifyConnectionActor(
683690
684691 statements.push_back (TSchemaQueryTask{
685692 .SQL = MakeCreateExternalDataSourceQuery (
686- newConnectionContent, signer, commonConfig, replaceSupported)});
693+ newConnectionContent, signer, commonConfig, replaceSupported, folderId )});
687694 return statements;
688695 }
689696
@@ -712,26 +719,26 @@ IActor* MakeModifyConnectionActor(
712719 statements.push_back (TSchemaQueryTask{
713720 .SQL = TString{MakeDeleteExternalDataSourceQuery (oldConnectionContent.name ())},
714721 .RollbackSQL = TString{MakeCreateExternalDataSourceQuery (
715- oldConnectionContent, signer, commonConfig, false )},
722+ oldConnectionContent, signer, commonConfig, false , folderId )},
716723 .ShouldSkipStepOnError = IsPathDoesNotExistIssue});
717724
718725 if (dropOldSecret) {
719726 statements.push_back (TSchemaQueryTask{
720727 .SQL = *dropOldSecret,
721728 .RollbackSQL = CreateSecretObjectQuery (oldConnectionContent.setting (),
722729 oldConnectionContent.name (),
723- signer),
730+ signer, folderId ),
724731 .ShouldSkipStepOnError = IsPathDoesNotExistIssue});
725732 }
726733 if (createNewSecret) {
727734 statements.push_back (TSchemaQueryTask{.SQL = *createNewSecret,
728735 .RollbackSQL = DropSecretObjectQuery (
729- newConnectionContent.name ())});
736+ newConnectionContent.name (), folderId )});
730737 }
731738
732739 statements.push_back (
733740 TSchemaQueryTask{.SQL = TString{MakeCreateExternalDataSourceQuery (
734- newConnectionContent, signer, commonConfig, false )},
741+ newConnectionContent, signer, commonConfig, false , folderId )},
735742 .RollbackSQL = TString{MakeDeleteExternalDataSourceQuery (
736743 newConnectionContent.name ())}});
737744
@@ -787,23 +794,25 @@ IActor* MakeDeleteConnectionActor(
787794 const TEvControlPlaneProxy::TEvDeleteConnectionRequest::TPtr& request)
788795 -> std::vector<TSchemaQueryTask> {
789796 auto & connectionContent = *request->Get ()->ConnectionContent ;
797+ const auto & scope = request->Get ()->Scope ;
798+ const TString folderId = NYdb::NFq::TScope{scope}.ParseFolder ();
790799
791800 auto dropSecret =
792- DropSecretObjectQuery (connectionContent.name ());
801+ DropSecretObjectQuery (connectionContent.name (), folderId );
793802
794803 std::vector statements = {
795804 TSchemaQueryTask{.SQL = TString{MakeDeleteExternalDataSourceQuery (
796805 connectionContent.name ())},
797806 .RollbackSQL = MakeCreateExternalDataSourceQuery (
798- connectionContent, signer, commonConfig, false ),
807+ connectionContent, signer, commonConfig, false , folderId ),
799808 .ShouldSkipStepOnError = IsPathDoesNotExistIssue}};
800809 if (dropSecret) {
801810 statements.push_back (
802811 TSchemaQueryTask{.SQL = *dropSecret,
803812 .RollbackSQL =
804813 CreateSecretObjectQuery (connectionContent.setting (),
805814 connectionContent.name (),
806- signer),
815+ signer, folderId ),
807816 .ShouldSkipStepOnError = IsPathDoesNotExistIssue});
808817 }
809818 return statements;
@@ -832,7 +841,7 @@ IActor* MakeCreateBindingActor(const TActorId& proxyActorId,
832841 TDuration requestTimeout,
833842 TCounters& counters,
834843 TPermissions permissions,
835- const NFq::TComputeConfig& computeConfig,bool withoutRollback,
844+ const :: NFq::TComputeConfig& computeConfig,bool withoutRollback,
836845 TMaybe<TString> bindingId) {
837846 auto queryFactoryMethod =
838847 [requestTimeout, &counters, permissions, withoutRollback, computeConfig](
@@ -916,7 +925,7 @@ IActor* MakeModifyBindingActor(const TActorId& proxyActorId,
916925 TEvControlPlaneProxy::TEvModifyBindingRequest::TPtr request,
917926 TDuration requestTimeout,
918927 TCounters& counters,
919- const NFq::TComputeConfig& computeConfig) {
928+ const :: NFq::TComputeConfig& computeConfig) {
920929 auto queryFactoryMethod =
921930 [computeConfig](const TEvControlPlaneProxy::TEvModifyBindingRequest::TPtr& request)
922931 -> std::vector<TSchemaQueryTask> {
0 commit comments