Well, I remembered in SQLX there are pre_operations { ... }
so I experimented with this:
config {
type: "table",
schema: "debug",
name: "test"
}
pre_operations {
CREATE TEMP FUNCTION addition(a INT64, b INT64)
RETURNS INT64
AS (
a + b
);
---
CREATE TEMP FUNCTION multiply(a INT64, b INT64)
RETURNS INT64
AS (
a * b
);
}
WITH numbers AS
(SELECT 1 AS x, 5 as y
UNION ALL
SELECT 2 AS x, 10 as y
UNION ALL
SELECT 3 as x, 15 as y)
SELECT
x,
y,
addition(x, y) AS added,
multiply(x, y) as multiplied
FROM numbers
This works well when the job is executed, however it doesn't work when pressing "Run":