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

uniqueKey assertions generate invalid SQL for incremental tables in v3.0.2 #1804

Open
stevenleggdfe opened this issue Aug 12, 2024 · 2 comments
Labels

Comments

@stevenleggdfe
Copy link

stevenleggdfe commented Aug 12, 2024

To reproduce, put the .sqlx file below in a Dataform repo with dataform-core v3.0.2 installed:

config {
  type: "incremental",
  assertions: {
    uniqueKey: ["foo"]
  }
}

SELECT 1 as foo, 2 AS bar

This generates the SQL below for the assertion (view):

SELECT
  *
FROM (
  SELECT
    TableAssertionsConfig,
    COUNT(1) AS index_row_count
  FROM `project-name.dataform.uniquekey_bug_test`
  GROUP BY TableAssertionsConfig
  ) AS data
WHERE index_row_count > 1

This in turn generates the compilation error "Unrecognized name: TableAssertionsConfig at [6:5]."

This bug does not occur when:

  • An earlier version of dataform-core is used - function is as expected in v3.0.0 and not visible because of a different bug (now fixed) in v3.0.1.
  • The uniqueKey assertion is applied to a non-incremental table
  • uniqueKeys: [["foo"]] is used instead of uniqueKey: ["foo"] - this is a possible workaround if others are experiencing this, but not a fix I feel as uniqueKey is supported and documented here: https://cloud.google.com/dataform/docs/assertions#built-in .
@stevenleggdfe stevenleggdfe changed the title uniqueKey assertions generate invalid SQL for incremental table in v3.0.1/2 uniqueKey assertions generate invalid SQL for incremental table in v3.0.2 Aug 12, 2024
@stevenleggdfe stevenleggdfe changed the title uniqueKey assertions generate invalid SQL for incremental table in v3.0.2 uniqueKey assertions generate invalid SQL for incremental tables in v3.0.2 Aug 12, 2024
@Ekrekr Ekrekr added the bug label Aug 16, 2024
@mattimoller
Copy link

The same issue seems to be present for models of type view

@blundin
Copy link

blundin commented Aug 23, 2024

I'm seeing this on models of type view as well.

Updated: This error occurs in v3.0.2 and v3.0.1. v3.0.0 does not throw this error.

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

No branches or pull requests

4 participants