From c4f1f00ab009182894e4c44b83595605841356f0 Mon Sep 17 00:00:00 2001 From: Ana Mileva Date: Mon, 23 Sep 2024 14:17:51 -0700 Subject: [PATCH] Fix duplicate timepoint inputs with spinup/lookahead (#1157) --- .../project/operations/operational_types/common_functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gridpath/project/operations/operational_types/common_functions.py b/gridpath/project/operations/operational_types/common_functions.py index 65769a87b..21763f07b 100644 --- a/gridpath/project/operations/operational_types/common_functions.py +++ b/gridpath/project/operations/operational_types/common_functions.py @@ -589,7 +589,9 @@ def get_prj_tmp_opr_inputs_from_db( sql = f""" SELECT project, prj_tbl.timepoint, {data_column} FROM - (SELECT project, stage_id, timepoint + -- Use DISTINCT in case there are spinup/lookahead timepoints, + -- which will show up more than once otherwise + (SELECT DISTINCT project, stage_id, timepoint FROM project_operational_timepoints WHERE project_portfolio_scenario_id = {subscenarios.PROJECT_PORTFOLIO_SCENARIO_ID} AND project_operational_chars_scenario_id = {subscenarios.PROJECT_OPERATIONAL_CHARS_SCENARIO_ID}