dbt-labs/dbt-core · error

wrapped vs bare CREATE VIEW body should compare as equal

Error message

wrapped vs bare CREATE VIEW body should compare as equal

What it means

Test-only assertion in test_create_view_as_tolerates_asymmetric_wrapping_parens: comparing a CREATE VIEW whose body is wrapped in parentheses against the bare form must succeed (they are semantically identical; see fs#13705). Fires only if SQL diff comparison regresses to treating the two forms as different.

Solutions

  1. Fix the CREATE VIEW body normalization in compare_sql to strip symmetric wrapping parens
  2. Re-run the sql diff test suite to confirm both directions are tolerated
  3. Treat failure as a diff-engine regression producing false positives
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/dbt-adapter/src/sql/diff.rs:3447 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/03790ab38e948203. Report an issue: GitHub.

Appendix: source

Thrown at crates/dbt-adapter/src/sql/diff.rs:3447

        FROM users u"#;

        let result = compare_sql(sql1, sql2, AdapterType::Snowflake);
        assert!(
            result.is_err(),
            "Should detect content differences even with newlines"
        );
    }

    #[test]
    fn test_create_view_as_tolerates_asymmetric_wrapping_parens() {
        // `AS (<subquery>)` and `AS <subquery>` are always semantically identical. Some code
        // paths (e.g. dbt-core's hand-rolled `latest_version` pointer-view SQL) emit the bare
        // form while others always wrap the body in parens -- see fs#13705.
        let wrapped = "create or replace view db.sch.v as (\n    select * from db.sch.t\n  );";
        let bare = "create or replace view db.sch.v as select * from db.sch.t";

        compare_sql(wrapped, bare, AdapterType::Snowflake)
            .expect("wrapped vs bare CREATE VIEW body should compare as equal");
        compare_sql(bare, wrapped, AdapterType::Snowflake)
            .expect("bare vs wrapped CREATE VIEW body should compare as equal (order-independent)");
    }

    #[test]
    fn test_create_view_as_bare_form_still_detects_real_mismatches() {
        // Guard against over-relaxing: two bare (unwrapped) bodies that are actually different
        // must still be reported as a mismatch.
        let actual = "create or replace view db.sch.v as select * from db.sch.t1";
        let expected = "create or replace view db.sch.v as select * from db.sch.t2";

        assert!(
            compare_sql(actual, expected, AdapterType::Snowflake).is_err(),
            "genuinely different bare CREATE VIEW bodies must not compare as equal"
        );
    }

    #[test]

View on GitHub (pinned to 0267ce9170)