Create simple test case for failure to load PUDL into Postgresql
See original GitHub issueAs @briannacote noted in #413, there’s some issue which prevents the loading of even an already flattened / simple PUDL data package into a postgres database. @roll thinks this is something which should actually work, but needs a test case to debug it and fix it in the data package libraries.
We need to come up with a simple test case that demonstrates the “non-unique foreign key” issue.
The error which gets thrown:
psycopg2.errors.InvalidForeignKey: there is no unique constraint matching given keys for referenced table "generators_entity_eia"
Resulting from this SQL:
CREATE TABLE ownership_eia860 (
id SERIAL NOT NULL,
report_date DATE,
utility_id_eia INTEGER,
plant_id_eia INTEGER,
generator_id TEXT,
operational_status_code TEXT,
owner_utility_id_eia INTEGER,
owner_name TEXT,
owner_state TEXT,
owner_city TEXT,
owner_street_address TEXT,
owner_zip_code TEXT,
fraction_owned NUMERIC,
PRIMARY KEY (id),
FOREIGN KEY(utility_id_eia) REFERENCES utilities_entity_eia (utility_id_eia),
FOREIGN KEY(plant_id_eia) REFERENCES generators_entity_eia (plant_id_eia),
FOREIGN KEY(generator_id) REFERENCES generators_entity_eia (generator_id)
)
]
(Background on this error at: http://sqlalche.me/e/f405)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Loading Test Data into PostgreSQL - Tangram Vision
The simplest way to get test data into PostgreSQL is to make a static dataset, which you can save as CSV files or...
Read more >Documentation: 15: 33.1. Running the Tests - PostgreSQL
(In case of failure, the stderr messages are usually enough to determine where to look closer.) Alternatively, you can run individual test suites...
Read more >The Public Utility Data Liberation Project - PUDL documentation
PUDL takes these spreadsheets, CSV files, and databases and turns them into easy to parse, well-documented tabular data packages that can be ...
Read more >Database (Data) Testing Tutorial with Sample Test Cases
It may involve creating complex queries to load/stress test the ... and information received and stored into database are valid or not.
Read more >The database abstraction layer - Web2py
If it does not exist, it is created. This file is locked every time it is accessed. In the case of MySQL, PostgreSQL,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update
probably should be a composite FK
This is awesome! I’ll give it a go soon. I’ve also connected to the SQLite database as well. So we have options now over here. I’ll let you know if I run into any issues again trying it with Postgres.
Also, forgive my delay in getting back. I was out of the office the last two weeks.