diff --git a/download.py b/download.py index 5c0d49b..ed09b61 100644 --- a/download.py +++ b/download.py @@ -75,8 +75,9 @@ def validate_file(source): # are expected columns present? columns = [x.lower() for x in df.columns] - if source["primary_key"]: - if source["primary_key"] not in columns: + # is primary key present and not null? + if "primary_key" in source and source["primary_key"]: + if source["primary_key"].lower() not in columns: raise ValueError( f"Validation error: {source['alias']} - primary key is not present - {source['primary_key']}" ) @@ -110,8 +111,8 @@ def validate_bcgw(source): table_def = bcdata.get_table_definition(table) columns = [c["column_name"] for c in table_def["schema"]] - # is primary key present? - if source["primary_key"]: + # is primary key present and not null? + if "primary_key" in source and source["primary_key"]: if source["primary_key"] not in columns: raise ValueError( f"Validation error: {source['alias']} - Primary key - {source['primary_key']} is not present in {table}" diff --git a/sources.json b/sources.json index 18f70aa..f9b8455 100644 --- a/sources.json +++ b/sources.json @@ -429,9 +429,7 @@ "source_type": "FILE", "layer": "GBRSchD_GB_20151105", "query": "GB_CLASS = 2", - "field_mapper": { - "name": "GB_CLASS" - }, + "field_mapper": {"name": "GB_CLASS"}, "data": {"harvest_restriction": 5} }, { @@ -441,9 +439,7 @@ "source_type": "FILE", "layer": "BC_Boundary_Terrestrial_Singlepart", "query": null, - "field_mapper": { - "name": null - }, + "field_mapper": {"name": null}, "data": {"harvest_restriction": 6} } ] \ No newline at end of file