fix(bakery): fix demographics table column shift and define dataset description#52
Closed
n-issei-777 wants to merge 1 commit into
Closed
fix(bakery): fix demographics table column shift and define dataset description#52n-issei-777 wants to merge 1 commit into
n-issei-777 wants to merge 1 commit into
Conversation
…me to demographics table
Contributor
Author
|
Resolved by #53, so this PR is no longer needed. |
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
This PR fixes a data alignment bug and a missing environment/script variable definition in the
launchmybakeryBigQuery setup script.1. Fix Demographics Table Column Shift (Data Corruption)
The Issue:
The source CSV file
data/demographics.csvcontains 8 columns in the following order:zip_code,city,neighborhood,median_household_income,total_population,median_age,bachelors_degree_pct,foot_traffic_indexHowever, the
CREATE TABLEschema insetup_bigquery.shonly defined 7 columns, completely omitting the 4th columnmedian_household_income.Because
bq loadperforms a positional mapping for CSV imports, and--ignore_unknown_values=truewas specified, the data was shifted left sequentially:median_household_income(4th CSV column) was loaded intototal_population(4th schema column).total_populationwas loaded intomedian_age(causing values like33626to be stored as the age).median_agewas loaded intobachelors_degree_pct.bachelors_degree_pctwas loaded intofoot_traffic_index.The actual
foot_traffic_index(8th CSV column) was entirely ignored and lost.The Fix:
Added
median_household_income INT64in the 4th position of theCREATE TABLEquery insidesetup_bigquery.shto perfectly align with the CSV columns and restore data integrity.2. Define Dataset Description Variable
The
bq mkcommand uses--description "$DATASET_DESCRIPTION", but the variable$DATASET_DESCRIPTIONwas never initialized anywhere in the script, resulting in an empty dataset description.Defined
DATASET_DESCRIPTION="Dataset for MCP Bakery Demo"at the top of the script.