@@ -91,7 +91,10 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
91
91
for query in config .get ("custom_queries" , []):
92
92
query = query .get ("query" )
93
93
if customer .is_manager_account and self .is_metrics_in_custom_query (query ):
94
- return False , f"Metrics are not available for manager account. Check fields in your custom query: { query } "
94
+ logger .warning (
95
+ f"Metrics are not available for manager account { customer .id } . "
96
+ f"Please remove metrics fields in your custom query: { query } ."
97
+ )
95
98
if CustomQuery .cursor_field in query :
96
99
return False , f"Custom query should not contain { CustomQuery .cursor_field } "
97
100
req_q = CustomQuery .insert_segments_date_expr (query , "1980-01-01" , "1980-01-01" )
@@ -109,37 +112,38 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
109
112
google_api = GoogleAds (credentials = self .get_credentials (config ))
110
113
accounts = self .get_account_info (google_api , config )
111
114
customers = Customer .from_accounts (accounts )
112
- incremental_stream_config = self .get_incremental_stream_config (google_api , config , customers )
115
+ non_manager_accounts = [customer for customer in customers if not customer .is_manager_account ]
116
+ incremental_config = self .get_incremental_stream_config (google_api , config , customers )
117
+ non_manager_incremental_config = self .get_incremental_stream_config (google_api , config , non_manager_accounts )
113
118
streams = [
114
- AdGroupAds (** incremental_stream_config ),
119
+ AdGroupAds (** incremental_config ),
115
120
AdGroupAdLabels (google_api , customers = customers ),
116
- AdGroups (** incremental_stream_config ),
121
+ AdGroups (** incremental_config ),
117
122
AdGroupLabels (google_api , customers = customers ),
118
- Accounts (** incremental_stream_config ),
119
- Campaigns (** incremental_stream_config ),
123
+ Accounts (** incremental_config ),
124
+ Campaigns (** incremental_config ),
120
125
CampaignLabels (google_api , customers = customers ),
121
- ClickView (** incremental_stream_config ),
122
- ]
123
- custom_query_streams = [
124
- CustomQuery (custom_query_config = single_query_config , ** incremental_stream_config )
125
- for single_query_config in config .get ("custom_queries" , [])
126
+ ClickView (** incremental_config ),
126
127
]
127
- streams .extend (custom_query_streams )
128
-
129
128
# Metrics streams cannot be requested for a manager account.
130
- non_manager_accounts = [customer for customer in customers if not customer .is_manager_account ]
131
129
if non_manager_accounts :
132
- incremental_stream_config ["customers" ] = non_manager_accounts
133
130
streams .extend (
134
131
[
135
- UserLocationReport (** incremental_stream_config ),
136
- AccountPerformanceReport (** incremental_stream_config ),
137
- DisplayTopicsPerformanceReport (** incremental_stream_config ),
138
- DisplayKeywordPerformanceReport (** incremental_stream_config ),
139
- ShoppingPerformanceReport (** incremental_stream_config ),
140
- AdGroupAdReport (** incremental_stream_config ),
141
- GeographicReport (** incremental_stream_config ),
142
- KeywordReport (** incremental_stream_config ),
132
+ UserLocationReport (** non_manager_incremental_config ),
133
+ AccountPerformanceReport (** non_manager_incremental_config ),
134
+ DisplayTopicsPerformanceReport (** non_manager_incremental_config ),
135
+ DisplayKeywordPerformanceReport (** non_manager_incremental_config ),
136
+ ShoppingPerformanceReport (** non_manager_incremental_config ),
137
+ AdGroupAdReport (** non_manager_incremental_config ),
138
+ GeographicReport (** non_manager_incremental_config ),
139
+ KeywordReport (** non_manager_incremental_config ),
143
140
]
144
141
)
142
+ for single_query_config in config .get ("custom_queries" , []):
143
+ query = single_query_config .get ("query" )
144
+ if self .is_metrics_in_custom_query (query ):
145
+ if non_manager_accounts :
146
+ streams .append (CustomQuery (custom_query_config = single_query_config , ** non_manager_incremental_config ))
147
+ continue
148
+ streams .append (CustomQuery (custom_query_config = single_query_config , ** incremental_config ))
145
149
return streams
0 commit comments