{"record":{"id":"03790ab38e948203","repo":"dbt-labs/dbt-core","slug":"wrapped-vs-bare-create-view-body-should-compare-as","errorCode":null,"errorMessage":"wrapped vs bare CREATE VIEW body should compare as equal","messagePattern":"wrapped vs bare CREATE VIEW body should compare as equal","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/sql/diff.rs","lineNumber":3447,"sourceCode":"        FROM users u\"#;\n\n        let result = compare_sql(sql1, sql2, AdapterType::Snowflake);\n        assert!(\n            result.is_err(),\n            \"Should detect content differences even with newlines\"\n        );\n    }\n\n    #[test]\n    fn test_create_view_as_tolerates_asymmetric_wrapping_parens() {\n        // `AS (<subquery>)` and `AS <subquery>` are always semantically identical. Some code\n        // paths (e.g. dbt-core's hand-rolled `latest_version` pointer-view SQL) emit the bare\n        // form while others always wrap the body in parens -- see fs#13705.\n        let wrapped = \"create or replace view db.sch.v as (\\n    select * from db.sch.t\\n  );\";\n        let bare = \"create or replace view db.sch.v as select * from db.sch.t\";\n\n        compare_sql(wrapped, bare, AdapterType::Snowflake)\n            .expect(\"wrapped vs bare CREATE VIEW body should compare as equal\");\n        compare_sql(bare, wrapped, AdapterType::Snowflake)\n            .expect(\"bare vs wrapped CREATE VIEW body should compare as equal (order-independent)\");\n    }\n\n    #[test]\n    fn test_create_view_as_bare_form_still_detects_real_mismatches() {\n        // Guard against over-relaxing: two bare (unwrapped) bodies that are actually different\n        // must still be reported as a mismatch.\n        let actual = \"create or replace view db.sch.v as select * from db.sch.t1\";\n        let expected = \"create or replace view db.sch.v as select * from db.sch.t2\";\n\n        assert!(\n            compare_sql(actual, expected, AdapterType::Snowflake).is_err(),\n            \"genuinely different bare CREATE VIEW bodies must not compare as equal\"\n        );\n    }\n\n    #[test]","sourceCodeStart":3429,"sourceCodeEnd":3465,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/sql/diff.rs#L3429-L3465","documentation":"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.","triggerScenarios":"Thrown at crates/dbt-adapter/src/sql/diff.rs:3447 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the CREATE VIEW body normalization in compare_sql to strip symmetric wrapping parens","Re-run the sql diff test suite to confirm both directions are tolerated","Treat failure as a diff-engine regression producing false positives"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}