79402910

Date: 2025-01-31 13:48:52
Score: 0.5
Natty:
Report link

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":

b0rk3d results saying "Function not found: addition at 15:5"

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
Posted by: Matt Scheurich