From 19c7f84188738b48f55f3647c537aa39f374fde8 Mon Sep 17 00:00:00 2001
From: Riccardo Boero <ribo@nilu.no>
Date: Thu, 4 Apr 2024 10:08:52 +0200
Subject: [PATCH] Added check on results form

---
 src/FACT_jobs.jl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/FACT_jobs.jl b/src/FACT_jobs.jl
index 5baeb2f..54f00e9 100644
--- a/src/FACT_jobs.jl
+++ b/src/FACT_jobs.jl
@@ -138,6 +138,11 @@ function eu_lfs(conn::MySQL.Connection, selection::Dict)
         query = "SELECT Nace as industry, ((EmpTh_Q1+EmpTh_Q2+EmpTh_Q3+EmpTh_Q4)/4)*1000 as jobs FROM LFS WHERE Year = $year AND GeoID = '$id';"
         # execute
         result = query_connection(conn, query)
+        if !("industry" in names(result))
+            println("No data returned for query with GeoID = $full_id and Year = $year and AND Agglvl_code = $agglvl_code.")
+           # Initialize `result` with the expected columns but no rows
+           #result = DataFrame(industry = String[], jobs = Float64[], geo_id = String[], agg_level = Int[])
+        end
         # add geo_id col
         result[!, :geo_id] = fill(id, nrow(result))
         # add agg level
-- 
GitLab