how to get all compiled queries in dataform using cli?

90 Views Asked by At

I want to get all compiled dataform sql queries via cli. when I execute

dataform compile

it returns:

    datasetname.tablename1 [table]
    .
    .

but I want to get all sql queries of my project.

Thank you.

1

There are 1 best solutions below

0
On

There's a flag for the compile to get the json: dataform compile --json

You can then output this into a json file and then query it further using the jq tool.

dataform compile --json > result.json


For example, if you want to list all the queries, you could do this:

jq .tables | .[] | .query' result.json


If you want to query a specific table, then assuming the table name is "tbl1":

jq '.tables | .[] | select(.target.name == "tbl1") | .query' result.json.


Hope that helps!