Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a flag to indicate that the result order of a test is not important #1265

Open
igofunke opened this issue Sep 8, 2021 · 3 comments

Comments

@igofunke
Copy link

igofunke commented Sep 8, 2021

In some occasions the order of rows of the result of a test is nondeterministic in BigQuery. This makes it very hard to come up with the expected order of rows. There should be some sort of flag in the config block of a test to indicate that the order of expected rows does not matter.

@Ekrekr
Copy link
Contributor

Ekrekr commented Mar 27, 2024

Could you give an example of when the expected order matters, so that I can add it as a test?

Example using inline assertions from https://cloud.google.com/dataform/docs/assertions#built-in

config {
  type: "table",
  assertions: {
    uniqueKey: ["user_id"],
    nonNull: ["user_id", "customer_id"],
    rowConditions: [
      'row like A',
      'row like B'
    ]
  }
}
SELECT 1

Becomes the execution SQL of:

create or replace view `cloud-dataform-testing.dataform_core_testing.dataform_core_testing_tmp_assertions_rowConditions` as
SELECT
  'row like A' AS failing_row_condition,
  *
FROM `cloud-dataform-testing.dataform_core_testing.tmp`
WHERE NOT (row like A)
UNION ALL
SELECT
  'row like B' AS failing_row_condition,
  *
FROM `cloud-dataform-testing.dataform_core_testing.tmp`
WHERE NOT (row like B)
UNION ALL
SELECT
  'user_id IS NOT NULL' AS failing_row_condition,
  *
FROM `cloud-dataform-testing.dataform_core_testing.tmp`
WHERE NOT (user_id IS NOT NULL)
UNION ALL
SELECT
  'customer_id IS NOT NULL' AS failing_row_condition,
  *
FROM `cloud-dataform-testing.dataform_core_testing.tmp`
WHERE NOT (customer_id IS NOT NULL)

(using bazel run //packages/@dataform/cli:bin run <dir> -- --dry-run --json)

@ttogola
Copy link

ttogola commented Apr 11, 2024

I believe @igofunke is talking about dataform unit tests, not assertions.

There used to be docs about unit tests available at dataform.co, but they are gone now and I can't find the equivalent in GCP docs. I looked quickly and this looks like where unit tests are run.

@lucasespinos
Copy link

Any progress on this so far? Its a really important feature...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants