From 6f180d1983e5fa9df5410c36d924af890b1f621f Mon Sep 17 00:00:00 2001 From: Geoffrey Yu Date: Sun, 3 Dec 2023 19:07:31 -0500 Subject: [PATCH] Handle empty slices --- src/brad/planner/scoring/performance/unified_aurora.py | 3 +++ src/brad/planner/scoring/performance/unified_redshift.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/brad/planner/scoring/performance/unified_aurora.py b/src/brad/planner/scoring/performance/unified_aurora.py index 1e9567a2..18d774d4 100644 --- a/src/brad/planner/scoring/performance/unified_aurora.py +++ b/src/brad/planner/scoring/performance/unified_aurora.py @@ -230,6 +230,9 @@ def predict_query_latency_load_resources( cpu_util: float, ctx: "ScoringContext", ) -> npt.NDArray: + if base_predicted_latency.shape[0] == 0: + return base_predicted_latency + # 1. Compute each query's expected run time on the given provisioning. resource_factor = _AURORA_BASE_RESOURCE_VALUE / aurora_num_cpus(to_prov) basis = np.array([resource_factor, 1.0]) diff --git a/src/brad/planner/scoring/performance/unified_redshift.py b/src/brad/planner/scoring/performance/unified_redshift.py index 0e57f26e..995da3e1 100644 --- a/src/brad/planner/scoring/performance/unified_redshift.py +++ b/src/brad/planner/scoring/performance/unified_redshift.py @@ -158,6 +158,9 @@ def predict_query_latency_load_resources( overall_cpu_denorm: float, ctx: "ScoringContext", ) -> npt.NDArray: + if base_predicted_latency.shape[0] == 0: + return base_predicted_latency + # 1. Compute each query's expected run time on the given provisioning. resource_factor = _REDSHIFT_BASE_RESOURCE_VALUE / ( redshift_num_cpus(to_prov) * to_prov.num_nodes()