Dataform Does Not Allow ${self()} in Function Names

Ideally I would have my devs use ${self()} when referring to the names of Operations in the SQL body and be strict on the config block, however, that throws a compilation error (Actions cannot resolve operations which do not produce output.).

This is strange, as hardcoding the fully qualified name DOES work, and I can see in the side bar that they resolve to the same thing. Fails:

config {
    type: "operations",
    schema: dataform.projectConfig.vars.TARGET_SCHEMA,
    name: "BusinessDays_ufn",
    description: "Calculates the number of business days between two dates",
}

CREATE SCHEMA IF NOT EXISTS `${database()}.${schema()}`;

CREATE OR REPLACE FUNCTION
  `ActualProject.ActualSchema.BusinessDays_ufn` (pvStartDate DATE, pvEndDate DATE) AS (

Works:

config {
    type: "operations",
    schema: dataform.projectConfig.vars.TARGET_SCHEMA,
    name: "BusinessDays_ufn",
    description: "Calculates the number of business days between two dates",
}

CREATE SCHEMA IF NOT EXISTS `${database()}.${schema()}`;

CREATE OR REPLACE FUNCTION
  ${schema()} (pvStartDate DATE, pvEndDate DATE) AS ( 
  ...

Is this a bug?

Additionally, Dataform does not automatically create datasets for Operations, so I throw `

CREATE SCHEMA IF NOT EXISTS ${schema()};` before every Operation. If anyone has a better method please let me know

2 Likes

Try adding

hasOutput: true

to your config block.

3 Likes

Omg thank you

1 Like