Skip to content

fix(etl): add missing table insertions - #2

Open
shprink wants to merge 1 commit into
open-ev-data:mainfrom
shprink:main
Open

fix(etl): add missing table insertions#2
shprink wants to merge 1 commit into
open-ev-data:mainfrom
shprink:main

Conversation

@shprink

@shprink shprink commented Jul 28, 2026

Copy link
Copy Markdown

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:

  • charge_ports — from vehicle.charge_ports (1,275 rows)
  • range_ratings — from vehicle.range.rated (1,590 rows)
  • sources — from vehicle.sources (1,406 rows)

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant