dataform icon indicating copy to clipboard operation
dataform copied to clipboard

Provide `--json` option for `run` command

Open michicodes opened this issue 5 years ago • 6 comments

We are using dataform inside gcp and want to emit pubsub events based on the outcome of dataform run.

Which *.sqlx files are run is based on some tagging. The only way to figure out which of them were affected would be to parse the text output. It looks something like that:

Dataset created:  some_database.some_view [view]
Dataset created:  some_database.some_table [incremental]
Dataset created:  some_database.some_table [incremental]

Having the possibility to get the json representation here as well would help tremendously. Right now --json is not respected for the run command.

Cheers, Michi

michicodes avatar Apr 30 '21 15:04 michicodes

As I was looking a little closer it seems the --json command is only used to display the compiled graph before actually running it, but not the executed graph of the run result. Do you have plans on adding that?

michicodes avatar Apr 30 '21 18:04 michicodes

To save it to a JSON you can pipe the output, e.g. dataform compile --json >> file.json. An output file would be a more elegant solution though!

Ekrekr avatar Feb 10 '23 18:02 Ekrekr

being able to get the execution graph form the cli would be really useful

andres-lowrie avatar Feb 10 '23 22:02 andres-lowrie

in case anyone lands on this via search engine. The run command does respect the --json flag check it out over here https://github.com/dataform-co/dataform/blob/main/cli/index.ts#L636-L644

@michicodes not sure if this covers your point though

andres-lowrie avatar Sep 06 '23 16:09 andres-lowrie

You're right that the JSON option is allowed for the run command, but it doesn't actually do anything currently unless the dry run is used https://github.com/dataform-co/dataform/blob/c0d1a7400f4aed74f90e032149561a3027df0ea4/cli/index.ts#L513

This makes sense, because otherwise there would be no output about whether tables were created or not by the run. To prevent confusion, I'm instead throwing an error if json is specified without dryRun: https://github.com/dataform-co/dataform/pull/1697.

Ekrekr avatar Mar 26 '24 14:03 Ekrekr

You're right that the JSON option is allowed for the run command, but it doesn't actually do anything currently unless the dry run is used

https://github.com/dataform-co/dataform/blob/c0d1a7400f4aed74f90e032149561a3027df0ea4/cli/index.ts#L513

This makes sense, because otherwise there would be no output about whether tables were created or not by the run. To prevent confusion, I'm instead throwing an error if json is specified without dryRun: #1697.

sweet... that will make the ux a bit nicer 😊

andres-lowrie avatar Mar 26 '24 20:03 andres-lowrie