Hi Community folks,
I've got some complex logic in definitions/javascript file that iterates through a list of tables in includes/constants.js and merges into a certain table. It's also got a postOps step that does a DELETE operation on that table (after the merge happens).
I'd like to add another postOps action/step (added in code snippet below) that INSERTS INTO another table by running a SELECT on the merged table. However I get the error Actions cannot resolve operations which do not produce output. I've read that a hasOutput option does exist, but I can only find it as an option to pass in a config block in a .sqlx file. I'm not sure how to apply it in a .postOp in a JS file. Could some please help?
Also, I used resolve as ctx.ref was giving a circular dependency error and I read somewhere that resolve could help with that. Would appreciate if someone could lso let me know if such usage is reasonable.
const tbl = "*SOME STRING*";
const tbl_ts = "*SOME STRING*";
publish(tbl,
{
* Some config details *
}
)
.preOps(
ctx=> `*SOME SQL*`
);
.postOps(
ctx => `DELETE from ${ctx.self()} where ${*SOME PRIMARY KEY*} in
(
*SOME SQL*
`)
.postOps( ctx => `
INSERT INTO ${ctx.resolve(`${project_name}`,`${dataset}`,
tbl_ts)}
SELECT * from ${ctx.resolve(`${project_name}`,`${dataset}`,
tbl)}`)
.query(
ctx =>`*SOME SQL*`
)