From 68ab6071d5efc3b690ec9e1fc50ad8256733182a Mon Sep 17 00:00:00 2001 From: prql-bot <107324867+prql-bot@users.noreply.github.com> Date: Sun, 4 Oct 2026 08:36:19 +0000 Subject: [PATCH] test: cover a cast inside an aggregate's argument --- prqlc/prqlc/tests/integration/sql.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/prqlc/prqlc/tests/integration/sql.rs b/prqlc/prqlc/tests/integration/sql.rs index ac29b799885c..0ac22d157f24 100644 --- a/prqlc/prqlc/tests/integration/sql.rs +++ b/prqlc/prqlc/tests/integration/sql.rs @@ -6470,6 +6470,29 @@ fn test_aggregate_of_expression() { "); } +#[test] +fn test_aggregate_of_cast() { + // https://github.com/PRQL/prql/issues/3534 — a cast inside an aggregate + // compiles the same as one derived beforehand. + assert_snapshot!(compile( + r###" + from artists + derive {artist_int = (artist_id | as int)} + aggregate { + total_int = sum artist_int, + total_cast = sum (artist_id | as int), + } + "###, + ) + .unwrap(), @" + SELECT + COALESCE(SUM(CAST(artist_id AS int)), 0) AS total_int, + COALESCE(SUM(CAST(artist_id AS int)), 0) AS total_cast + FROM + artists + "); +} + #[test] fn test_table_declarations() { assert_snapshot!(compile(