fix(etl): add missing table insertions - #2
Open
shprink wants to merge 1 commit into
Open
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
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
ETL PostgreSQL
the write_data() function only generated INSERT INTO vehicles but never generated inserts for the child tables, even though the data was available on the Vehicle struct.
What changed:
After each vehicle INSERT, the ETL now generates INSERT statements for:
BEFORE:
INSERT INTO vehicles (unique_code, make_slug, make_name, model_slug, model_name, year, trim_slug, trim_name, variant_slug, variant_name, vehicle_type, drivetrain, system_power_kw, system_torque_nm, battery_capacity_gross_kwh, battery_capacity_net_kwh, battery_chemistry, dc_max_power_kw, ac_max_power_kw, range_wltp_km, range_epa_km, acceleration_0_100_s, top_speed_kmh, json_data) VALUES ('audi:a6_e_tron:2024:a6_e_tron', 'audi', 'Audi', 'a6_e_tron', 'A6 e-tron', 2024, 'base', 'Base', 'sportback', 'Sportback', 'PassengerCar', 'Rwd', 350, 550, 100, 94.9, 'li-ion', 270, 11, 700, NULL, 4.5, 209, '{"$schema":"../../../../schema.json","schema_version":"1.0.0","make":{"slug":"audi","name":"Audi"},"model":{"slug":"a6_e_tron","name":"A6 e-tron"},"year":2024,"trim":{"slug":"base","name":"Base"},"vehicle_type":"passenger_car","powertrain":{"drivetrain":"rwd","system_power_kw":350.0,"system_torque_nm":550.0,"motors":[{"position":"rear","type":"pmsm","power_kw":350.0,"torque_nm":550.0}]},"battery":{"chemistry":"li-ion","pack_capacity_kwh_gross":100.0,"pack_capacity_kwh_net":94.9,"thermal_management":"liquid","heat_pump":true},"charge_ports":[{"kind":"combo","connector":"ccs2","location":{"side":"right","position":"rear"}}],"charging":{"ac":{"max_power_kw":11.0,"phases":3},"dc":{"max_power_kw":270.0,"architecture_voltage_class":"800v"}},"range":{"rated":[{"cycle":"wltp","range_km":700.0}]},"sources":[{"type":"oem","title":"Audi A6 e-tron Sportback 2024 Official Specifications","url":"https://www.audi.com","accessed_at":"2025-01-15T00:00:00Z"}],"unique_code":"audi:a6_e_tron:2024:a6_e_tron","variant":{"slug":"sportback","name":"Sportback","kind":"body_style"},"markets":["US","BR","DE","GB","FR","PT","IT","CN","JP"],"availability":{"status":"production","start_year":2024},"body":{"style":"sedan","doors":4,"seats":5,"platform":"PPE","drag_coefficient_cd":0.22},"dimensions":{"length_mm":4960.0,"width_mm":1960.0,"height_mm":1440.0,"wheelbase_mm":2960.0},"weights":{"curb_weight_kg":2200.0},"performance":{"acceleration_0_100_kmh_s":4.5,"top_speed_kmh":209.0}}');
AFTER:
INSERT INTO vehicles (unique_code, make_slug, make_name, model_slug, model_name, year, trim_slug, trim_name, variant_slug, variant_name, vehicle_type, drivetrain, system_power_kw, system_torque_nm, battery_capacity_gross_kwh, battery_capacity_net_kwh, battery_chemistry, dc_max_power_kw, ac_max_power_kw, range_wltp_km, range_epa_km, acceleration_0_100_s, top_speed_kmh, json_data) VALUES ('audi:a6_e_tron:2024:a6_e_tron', 'audi', 'Audi', 'a6_e_tron', 'A6 e-tron', 2024, 'base', 'Base', 'sportback', 'Sportback', 'PassengerCar', 'Rwd', 350, 550, 100, 94.9, 'li-ion', 270, 11, 700, NULL, 4.5, 209, '{"$schema":"../../../../schema.json","schema_version":"1.0.0","make":{"slug":"audi","name":"Audi"},"model":{"slug":"a6_e_tron","name":"A6 e-tron"},"year":2024,"trim":{"slug":"base","name":"Base"},"vehicle_type":"passenger_car","powertrain":{"drivetrain":"rwd","system_power_kw":350.0,"system_torque_nm":550.0,"motors":[{"position":"rear","type":"pmsm","power_kw":350.0,"torque_nm":550.0}]},"battery":{"chemistry":"li-ion","pack_capacity_kwh_gross":100.0,"pack_capacity_kwh_net":94.9,"thermal_management":"liquid","heat_pump":true},"charge_ports":[{"kind":"combo","connector":"ccs2","location":{"side":"right","position":"rear"}}],"charging":{"ac":{"max_power_kw":11.0,"phases":3},"dc":{"max_power_kw":270.0,"architecture_voltage_class":"800v"}},"range":{"rated":[{"cycle":"wltp","range_km":700.0}]},"sources":[{"type":"oem","title":"Audi A6 e-tron Sportback 2024 Official Specifications","url":"https://www.audi.com","accessed_at":"2025-01-15T00:00:00Z"}],"unique_code":"audi:a6_e_tron:2024:a6_e_tron","variant":{"slug":"sportback","name":"Sportback","kind":"body_style"},"markets":["US","BR","DE","GB","FR","PT","IT","CN","JP"],"availability":{"status":"production","start_year":2024},"body":{"style":"sedan","doors":4,"seats":5,"platform":"PPE","drag_coefficient_cd":0.22},"dimensions":{"length_mm":4960.0,"width_mm":1960.0,"height_mm":1440.0,"wheelbase_mm":2960.0},"weights":{"curb_weight_kg":2200.0},"performance":{"acceleration_0_100_kmh_s":4.5,"top_speed_kmh":209.0}}');
INSERT INTO charge_ports (vehicle_id, kind, connector, location_side, location_position) VALUES (currval('vehicles_id_seq'), 'Combo', 'Ccs2', 'Right', 'Rear');
INSERT INTO range_ratings (vehicle_id, cycle, range_km, notes) VALUES (currval('vehicles_id_seq'), 'Wltp', 700, NULL);
INSERT INTO sources (vehicle_id, source_type, title, url, accessed_at, publisher) VALUES (currval('vehicles_id_seq'), 'Oem', 'Audi A6 e-tron Sportback 2024 Official Specifications', 'https://www.audi.com', '2025-01-15T00:00:00Z', NULL);