Fix SQL syntax error in extract-sample-data.sql preventing view extraction#8358
Merged
Fix SQL syntax error in extract-sample-data.sql preventing view extraction#8358
Conversation
…ws section Co-authored-by: pethers <[email protected]>
|
Copilot
AI
changed the title
[WIP] Fix SQL syntax error in extract-sample-data.sql Phase 2
Fix SQL syntax error in extract-sample-data.sql preventing view extraction
Feb 7, 2026
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a SQL syntax error in extract-sample-data.sql that prevented Phase 2 dynamic command generation from completing, which in turn blocked Phase 3 from extracting any view sample CSVs.
Changes:
- Corrected malformed multi-line string concatenation in the WEEKLY temporal view extraction command by replacing
|| E''with|| E'\n' ||to match the pattern used in other temporal sections.
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
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.



Description
SQL syntax error in Phase 2 (line 1477) caused all view extraction to fail. The WEEKLY views section had malformed string concatenation (
|| E''split across lines) in the dynamic SQL generation, preventing Phase 2 from completing and Phase 3 from executing any view extractions (0 of 109 views extracted).Fix: Line 1477 changed from
|| E''to|| E'\n' ||, matching the pattern used in DAILY, MONTHLY, and other temporal view sections.Result: Phase 2 extraction command generation now completes successfully, enabling Phase 3 to extract all 109 views.
Type of Change
Primary Changes
Technical Changes
Impact Analysis
Political Analysis Impact
Technical Impact
Testing
Documentation
Screenshots
N/A - Backend SQL fix
Checklist
Additional Notes
All INSERT INTO cia_extraction_tracking statements in temporal view sections verified to use consistent
|| E'\n' ||pattern. No other instances of this error pattern found in the file.Security Considerations
Release Notes
Fixed SQL syntax error in extract-sample-data.sql that prevented extraction of all 109 database views. View sample data extraction now completes successfully.
Original prompt
This section details on the original issue you should resolve
<issue_title>Fix SQL syntax error in extract-sample-data.sql Phase 2 preventing view extraction</issue_title>
<issue_description>## 🎯 Objective
Fix SQL syntax error in extract-sample-data.sql Phase 2 that prevents ANY view extraction from occurring.
📋 Background
PR #8348 extraction log shows that 0 views were extracted despite 28 materialized views being refreshed successfully. The root cause is a SQL syntax error at line ~1487 in the extraction command generation SQL.
Error from log (line 2243-2246):
This error occurs during Phase 2 ("Generating extraction commands") which builds the dynamic SQL commands to extract each view. Because this phase fails, Phase 3 executes zero extraction commands.
📊 Current State (Measured from Log)
Misleading File: The
problematic_views.csvfile showing "materialized view not populated" errors is from a PREVIOUS validation run, not from this extraction attempt. This caused initial misanalysis.✅ Acceptance Criteria
psql -f extract-sample-data.sql --dry-run🛠️ Implementation Guidance
Files to Modify:
service.data.impl/src/main/resources/extract-sample-data.sql- Fix syntax error around line 1487Root Cause:
Line 1487 in the WEEKLY views section is missing the
E'\n'string continuation:Fix:
Testing Strategy:
🔍 Verification Steps
🤖 Recommended Agent
Agent: @stack-specialist
Rationale: This issue requires PostgreSQL SQL expertise, understanding of dynamic SQL generation with format() functions, and knowledge of the CIA database schema. The Stack Specialist has the SQL and database skills to fix this syntax error correctly.
📚 Related Resources
service.data.impl/sample-data/extract-sample-data.log- Full extraction log (2843 lines)📊 Impact
Critical - Without this fix, zero views are extracted, making sample data incomplete for:
📊 Metadata
**Prio...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.