Skip to content

Commit b453b4a

Browse files
Don't include facts from ended resources.
1 parent 2f9000e commit b453b4a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

digital_land/package/datasetparquet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ def load_entities(self):
190190
# If there are still matches then pick the first resource (and fact, just to make sure)
191191
query = f"""
192192
SELECT {fields_str} FROM (
193-
SELECT {fields_str}, CASE WHEN resource_csv."end-date" IS NULL THEN '2999-12-31' ELSE resource_csv."end-date" END AS resource_end_date
193+
SELECT {fields_str}, resource_csv."end-date" AS resource_end_date
194194
FROM temp_table
195195
LEFT JOIN read_csv_auto('collection/resource.csv') resource_csv
196196
ON temp_table.resource = resource_csv.resource
197+
WHERE resource_end_date IS NULL OR resource_end_date > current_date
197198
QUALIFY ROW_NUMBER() OVER (
198199
PARTITION BY entity, field
199200
ORDER BY priority, "entry-date" DESC, "entry-number" DESC, resource_end_date DESC, temp_table.resource, fact

0 commit comments

Comments
 (0)