-
Notifications
You must be signed in to change notification settings - Fork 0
fix(SUPPORT-14107): robust action breakdown detection and DSL parsing #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
- Add _is_action_breakdown_query() helper that handles both string and dict parameters - Add _has_action_reaction_breakdown() helper for action_reaction specific detection - Use urllib.parse.parse_qs for proper query string parsing with fallback - Support DSL-style fields string (.action_breakdowns() syntax) - Add missing fields to _copy_common_fields(extended=True): ad_name, adset_name, impressions, clicks, spend, reach This fixes the issue where action breakdown queries were not properly detected when parameters were in different formats, causing empty columns in output. Co-Authored-By: [email protected] <[email protected]>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…elds Instead of maintaining an explicit list of fields to copy, follow the Clojure V1 approach: when extended=True, copy ALL scalar fields from original_row to action rows. This is simpler, more flexible, and automatically includes any new fields that Facebook API returns without code changes. Co-Authored-By: [email protected] <[email protected]>
- Remove _has_action_reaction_breakdown() helper entirely - Remove DSL detection from _is_action_breakdown_query() - Simplify _populate_action_row() to copy all fields from action data - action_reaction is now included automatically if present in data Co-Authored-By: [email protected] <[email protected]>
Customer config uses DSL-style fields (e.g., insights.action_breakdowns(action_type)) which requires DSL detection to properly route output to action rows. Without this, output mapping fails with missing columns error. Co-Authored-By: [email protected] <[email protected]>
Add parsing for DSL patterns in sync insights queries:
- .level(X) -> level=X
- .action_breakdowns(X) -> action_breakdowns=X
- .date_preset(X) -> date_preset=X
- .time_increment(X) -> time_increment=X
- {field1,field2,...} -> fields=field1,field2,...
Without this, sync queries using DSL syntax don't send the
required parameters to Facebook API, resulting in missing columns.
Co-Authored-By: [email protected] <[email protected]>
Replace individual .X() handlers with generic regex extractor that automatically forwards any .X(Y) pattern as X=Y parameter. Only special handling for: - since/until: date conversion via get_past_date() - metric: comma-separated list normalization Any new DSL pattern (e.g. .filtering(), .breakdowns()) will be automatically forwarded without code changes. query.parameters still overrides DSL-derived values (existing behavior). Co-Authored-By: [email protected] <[email protected]>
Facebook API doesn't return account_id when explicit fields are specified in DSL. Following Clojure approach: derive account_id from the query context (page_id) instead of relying on API response. For Ads accounts (page_id starts with 'act_'), strip the prefix to get the numeric account_id that output mapping expects. Co-Authored-By: [email protected] <[email protected]>
Contributor
|
Merged into PR #23 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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): robust action breakdown detection and DSL parsing
Summary
Fixes Facebook Ads V2 action breakdown queries that were producing empty columns in output. The root cause was threefold:
account_idin output when explicit fields are specified in DSL (Facebook API doesn't return it automatically)Changes in output_parser.py:
_is_action_breakdown_query()helper that properly handles:action_breakdowns=action_type).action_breakdowns(action_type)syntax)urllib.parse.parse_qsfor proper query string parsing with fallback_copy_common_fields(extended=True)to follow Clojure V1 approach: copy ALL scalar fields from original_row instead of maintaining an explicit field list_populate_action_row()to copy all fields from action data (Clojure approach)_has_action_reaction_breakdown()helper -action_reactionis now included automatically if present in dataaccount_idderivation frompage_idin_create_base_row()for Ads accounts (stripsact_prefix)Changes in page_loader.py:
.X(Y)pattern asX=Yparametersince/until: date conversion viaget_past_date()metric: comma-separated list normalizationlevel,action_breakdowns,date_preset,period,time_increment, etc.) pass through directly{field1,field2,...}→fields=field1,field2,...via regexUpdates since last revision
Added
account_idfallback - Test job 152495554 failed with "Missing columns: account_id" because Facebook API doesn't returnaccount_idwhen explicit fields are specified in DSL. Following Clojure approach: deriveaccount_idfrom the query context (page_id) by stripping theact_prefix for Ads accounts.Review & Testing Checklist for Human
account_idaccount_idformat is correct - the fix stripsact_prefix (e.g.,act_123456→123456). Confirm this matches what the output mapping/schema expects[^)]+won't handle nested parentheses. Check for configs where DSL values might contain)charactersaccount_idderivation only triggers whenpage_idstarts withact__build_params()used by sync queriesRecommended test plan:
action_breakdowns=action_typeaccount_id, ad_name, clicks, impressions, spend, reachNotes
account_id- addressed in latest commitLink to Devin run: https://app.devin.ai/sessions/d820bdbb1686427f81b3777a37f3fc2d
Requested by: [email protected] (@ZdenekSrotyr)