EDIT: This was downstream of other issues, like adding the HasOutput to my functions SQLX file. This $ref code is fine
In my Dataform repo I define a function BusinessDays_ufn.sqlx, which is an Operations file for a SQL UDF called by another view in the sam repo, Metrics_uvw.sqlx. It calls it like:
${ref(dataform.projectConfig.vars.TARGET_PROJECT, dataform.projectConfig.vars.TARGET_SCHEMA, "BusinessDays_ufn")}
This gives the following error:
Compilation errors:
definitions\outputs\Loan\Metrics_uvw.sqlx: Error: Actions cannot resolve operations which do not produce output.
at t.Session.resolve (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:17:87750)
at p.resolve (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:15:317171)
at p.ref (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:15:317037)
at Object.sqlContextable (C:\Users\...\source\repos\dataform-prp-1\definitions\outputs\Loan\Metrics_uvw.sqlx:73:13)
at C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:17:86749
at p.apply (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:15:317893)
at u.compile (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:15:315771)
at C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:17:91987
at Array.forEach (<anonymous>)
at t.Session.compileGraphChunk (C:\Users\...\source\repos\dataform-prp-1\node_modules\@dataform\core\bundle.js:17:91961)
However, this works fine when I create the function separately and then call it directly, e.g. with schema.Business_Days_ufn(). Is this intended behavior?
Solved! Go to Solution.
Hi @AKatoch,
Welcome to Google Cloud Community!
Based on the error “Actions cannot resolve operations which do not produce output” that you’re getting, it seems like you don’t have a tangible output within your Metrics_uvw.sqlx
file. To make a table available to other scripts, you need to declare that the operation has an output.
config {
type: "operations",
hasOutput: true
}
The following code sample shows a custom SQL operation in a custom_SQL_operation_table.sqlx
file that creates a referenceable table called custom_SQL_operation_table
:
// filename is custom_SQL_operation_table.sqlx
config {
type: "operations",
hasOutput: true
}
CREATE OR REPLACE VIEW ${self()} AS (SELECT 1 AS TEST)
I hope the above information is helpful.