Skip to content

feat: support for dataform test #97

Open
@ashish10alex

Description

@ashish10alex

Yes, that solved it, thank you very much for this excellent extension!

I had hated using the GCP Dataform web UI for development. I prefer VScode and the dataform CLI. I had built some makefile rules around the dataform cli (e.g. to generate a dependency graph, view the schema of a source). Your extension greatly improves my workflow!

Can I suggest a feature? Dataform unit tests are not supported in GCP and even the cli dataform test command can be a bit tricky to debug errors in your test. It does not allow you to execute a single test and show the compiled query, the output and the expected output.

My makefile rule for the above (example usage make df-test-file name=TRANSFERS):

format_flag := $(if $(format),--format=$(format),)
df-test-file: # Run a single dataform test query with 'name=' [format=prettyjson]
	@echo "Running test query:"
	@dataform compile --json  | jq -r '.tests[] | select(.name == "$(name)") | .testQuery' | nl -ba
	@echo "Actual output:"
	@dataform compile --json  | jq -r '.tests[] | select(.name == "$(name)") | .testQuery' | bq query --nouse_legacy_sql $(format_flag)
	@echo "Expecting output:"
	@dataform compile --json  | jq -r '.tests[] | select(.name == "$(name)") | .expectedOutputQuery' | bq query --nouse_legacy_sql $(format_flag)

Originally posted by @IzakMaraisTAL in #94

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions