fix(SUPPORT-14107): fix sync and async extraction for action breakdown queries #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix(SUPPORT-14107): fix sync and async extraction for action breakdown queries
Summary
Fixes two bugs in the Facebook Ads V2 extractor that caused sync and async extraction to fail for action breakdown queries:
Bug 1 - Sync Extraction: DSL-style queries like
insights.level(ad).action_breakdowns(action_type).date_preset(last_3d)...{fields}were not being parsed correctly. The_build_paramsmethod only extractedmetric,period,since,untilbut missedlevel,action_breakdowns,date_preset,time_increment,breakdowns, and the fields list from curly braces. This caused the API request to be sent without critical parameters, returning minimal/incorrect data.Bug 2 - Async Extraction: Action breakdown queries returned correct row counts but empty metric columns (
ad_name,clicks,impressions,spend,reach). The_copy_common_fieldsmethod only copied ID fields to action rows, not the metric fields from the original row.Bug 3 - Detection Logic: Action breakdown detection only checked
query.parametersbut DSL-style queries haveaction_breakdownsin thefieldsstring, causing incorrect parsing behavior.Updates since last revision
Backwards compatibility fix #1: Initial testing revealed that adding too many new columns to
_copy_common_fieldscaused "column mismatch" errors with existing customer tables. The field list has been reduced to only include columns that already existed in V2 async tables:ad_name,impressions,clicks,spend,reach.Backwards compatibility fix #2: Testing on job 151760765 revealed a "missing columns: account_id" error. The issue was that when parsing the DSL
{fields}list, we now explicitly setparams["fields"], but the old behavior relied on Facebook API defaults which includedaccount_id. Fixed by automatically appendingaccount_idto the fields list when parsing DSL syntax, ensuring existing tables continue to receive this structural field.Review & Testing Checklist for Human
account_id.split(".level(")[1].split(")")[0]) could break with malformed input or nested parenthesesRecommended Test Plan
insights.level(ad).action_breakdowns(action_type).date_preset(last_3d).time_increment(1){ad_id,ad_name,campaign_id,campaign_name,cost_per_action_type,actions,impressions,reach,clicks,spend}parent_id, campaign_id, date_start, date_stop, ads_action_name, action_type, ad_idad_name,clicks,impressions,spend,reach) are populatedaccount_idcolumn should now be presentNotes