This commit is contained in:
+1
-1
@@ -3418,7 +3418,7 @@ SELECT
|
||||
"IsTemplate",
|
||||
MAX("PoweredOn") AS "PoweredOn",
|
||||
"SrmPlaceholder", "VmUuid",
|
||||
SUM("SamplesPresent") AS "SamplesPresent",
|
||||
CAST(SUM("SamplesPresent") AS BIGINT) AS "SamplesPresent",
|
||||
CASE WHEN totals.total_samples > 0
|
||||
THEN SUM(CASE WHEN "AvgVcpuCount" IS NOT NULL THEN "AvgVcpuCount" * total_samples_day ELSE 0 END) / totals.total_samples
|
||||
ELSE NULL END AS "AvgVcpuCount",
|
||||
|
||||
@@ -22,3 +22,13 @@ GROUP BY`) {
|
||||
t.Fatalf("unexpected final GROUP BY after agg/totals join; this breaks Postgres SQLSTATE 42803")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildMonthlySummaryInsertCastsSampleSumToBigInt(t *testing.T) {
|
||||
query, err := BuildMonthlySummaryInsert("inventory_monthly_summary_202601", "SELECT 1")
|
||||
if err != nil {
|
||||
t.Fatalf("BuildMonthlySummaryInsert failed: %v", err)
|
||||
}
|
||||
if !strings.Contains(query, `CAST(SUM("SamplesPresent") AS BIGINT) AS "SamplesPresent"`) {
|
||||
t.Fatalf("expected monthly sample sum cast to BIGINT to avoid Postgres numeric assignment issues")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user